@@ -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