Skip to content

Commit 9fd07ea

Browse files
authored
Merge pull request #413 from Countly/reserved_event
feat: added ability to record reserved events
2 parents d0f5541 + f202848 commit 9fd07ea

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## XX.XX.XX
2-
* Mitigated a networking health check recording issue.
2+
* Added the ability to record reserved events.
3+
4+
* Mitigated a possible Health Check network log recording issue.
35

46
## 25.4.5
57
* Added "requestTimeoutDuration" init config parameter to change request timeout duration in seconds.

Countly.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,8 @@ NS_ASSUME_NONNULL_BEGIN
843843
- (void)halt;
844844
- (void)halt:(BOOL) clearStorage;
845845

846-
/* Combine all events in event queue into a request and attempt to process stored requests on demand
846+
/**
847+
* Combine all events in event queue into a request and attempt to process stored requests on demand
847848
*/
848849
- (void)attemptToSendStoredRequests;
849850

Countly.m

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -864,22 +864,25 @@ - (void)recordEvent:(NSString *)key segmentation:(NSDictionary *)segmentation co
864864
{
865865
CLY_LOG_I(@"%s %@ %@ %lu %f %f", __FUNCTION__, key, segmentation, (unsigned long)count, sum, duration);
866866

867-
if (!CountlyConsentManager.sharedInstance.consentForEvents)
868-
{
869-
CLY_LOG_W(@"Consent for events not given! Event will not be recorded.");
870-
return;
871-
}
872-
873-
BOOL isReservedEvent = [self isReservedEvent:key];
867+
NSNumber* isReservedEvent = [self isReservedEvent:key];
874868

875869
if (isReservedEvent)
876870
{
877-
CLY_LOG_W(@"A reserved event detected for key: '%@', event will not be recorded.", key);
871+
CLY_LOG_V(@"%s, A reserved event detected: %@", __FUNCTION__, key);
872+
if (!isReservedEvent.boolValue)
873+
{
874+
CLY_LOG_W(@"%s, No consent given for the reserved event! Event will not be recorded.", __FUNCTION__);
875+
return;
876+
}
877+
CLY_LOG_V(@"%s, Specific consent given for the reserved event! So, it will be recorded.", __FUNCTION__);
878+
} else if (!CountlyConsentManager.sharedInstance.consentForEvents) {
879+
CLY_LOG_W(@"%s, Consent for events not given! Event will not be recorded.", __FUNCTION__);
878880
return;
879881
}
882+
880883
if (!CountlyServerConfig.sharedInstance.customEventTrackingEnabled)
881884
{
882-
CLY_LOG_D(@"'recordEvent' is aborted: Custom Event Tracking is disabled from server config!");
885+
CLY_LOG_D(@"%s, aborted: Custom Event Tracking is disabled from server config!", __FUNCTION__);
883886
return;
884887
}
885888

@@ -997,20 +1000,21 @@ - (BOOL)isAppInForeground {
9971000
#endif
9981001
}
9991002

1000-
1001-
- (BOOL)isReservedEvent:(NSString *)key
1003+
/// This checks that given key requires any extra consent
1004+
- (NSNumber *)isReservedEvent:(NSString *)key
10021005
{
1003-
NSArray<NSString *>* reservedEvents =
1004-
@[
1005-
kCountlyReservedEventOrientation,
1006-
kCountlyReservedEventStarRating,
1007-
kCountlyReservedEventSurvey,
1008-
kCountlyReservedEventNPS,
1009-
kCountlyReservedEventPushAction,
1010-
kCountlyReservedEventView,
1011-
];
1012-
1013-
return [reservedEvents containsObject:key];
1006+
NSDictionary <NSString *, NSNumber *>* reservedEvents =
1007+
@{
1008+
kCountlyReservedEventOrientation: @(CountlyConsentManager.sharedInstance.consentForUserDetails),
1009+
kCountlyReservedEventStarRating: @(CountlyConsentManager.sharedInstance.consentForFeedback),
1010+
kCountlyReservedEventSurvey: @(CountlyConsentManager.sharedInstance.consentForFeedback),
1011+
kCountlyReservedEventNPS: @(CountlyConsentManager.sharedInstance.consentForFeedback),
1012+
kCountlyReservedEventPushAction: @(CountlyConsentManager.sharedInstance.consentForPushNotifications),
1013+
kCountlyReservedEventView: @(CountlyConsentManager.sharedInstance.consentForViewTracking),
1014+
};
1015+
1016+
NSNumber* aReservedEvent = reservedEvents[key];
1017+
return aReservedEvent;
10141018
}
10151019

10161020
#pragma mark -

0 commit comments

Comments
 (0)