66
77#import " CountlyCommon.h"
88
9+ CLYConsent const CLYConsentMetrics = @" metrics" ;
910CLYConsent const CLYConsentSessions = @" sessions" ;
1011CLYConsent const CLYConsentEvents = @" events" ;
1112CLYConsent const CLYConsentUserDetails = @" users" ;
2122
2223@implementation CountlyConsentManager
2324
25+ @synthesize consentForMetrics = _consentForMetrics;
2426@synthesize consentForSessions = _consentForSessions;
2527@synthesize consentForEvents = _consentForEvents;
2628@synthesize consentForUserDetails = _consentForUserDetails;
@@ -83,6 +85,9 @@ - (void)giveConsentForFeatures:(NSArray *)features
8385 if ([features containsObject: CLYConsentUserDetails] && !self.consentForUserDetails )
8486 self.consentForUserDetails = YES ;
8587
88+ if ([features containsObject: CLYConsentMetrics] && !self.consentForMetrics )
89+ self.consentForMetrics = YES ;
90+
8691 if ([features containsObject: CLYConsentSessions] && !self.consentForSessions )
8792 self.consentForSessions = YES ;
8893
@@ -137,6 +142,9 @@ - (void)cancelConsentForFeatures:(NSArray *)features shouldSkipSendingConsentsRe
137142 if (!self.requiresConsent )
138143 return ;
139144
145+ if ([features containsObject: CLYConsentMetrics] && self.consentForMetrics )
146+ self.consentForMetrics = NO ;
147+
140148 if ([features containsObject: CLYConsentSessions] && self.consentForSessions )
141149 self.consentForSessions = NO ;
142150
@@ -179,6 +187,7 @@ - (void)sendConsents
179187{
180188 NSDictionary * consents =
181189 @{
190+ CLYConsentMetrics: @(self.consentForMetrics ),
182191 CLYConsentSessions: @(self.consentForSessions ),
183192 CLYConsentEvents: @(self.consentForEvents ),
184193 CLYConsentUserDetails: @(self.consentForUserDetails ),
@@ -199,6 +208,7 @@ - (NSArray *)allFeatures
199208{
200209 return
201210 @[
211+ CLYConsentMetrics,
202212 CLYConsentSessions,
203213 CLYConsentEvents,
204214 CLYConsentUserDetails,
@@ -216,6 +226,19 @@ - (NSArray *)allFeatures
216226
217227#pragma mark -
218228
229+ - (void )setConsentForMetrics : (BOOL )consentForMetrics
230+ {
231+ _consentForMetrics = consentForMetrics;
232+
233+ if (consentForMetrics)
234+ {
235+ CLY_LOG_D (@" Consent for Metrics is given." );
236+ }
237+ else
238+ {
239+ CLY_LOG_D (@" Consent for Metrics is cancelled." );
240+ }
241+ }
219242
220243- (void )setConsentForSessions : (BOOL )consentForSessions
221244{
@@ -425,6 +448,14 @@ - (void)setConsentForRemoteConfig:(BOOL)consentForRemoteConfig
425448
426449#pragma mark -
427450
451+ - (BOOL )consentForMetrics
452+ {
453+ if (!self.requiresConsent )
454+ return YES ;
455+
456+ return _consentForMetrics;
457+ }
458+
428459- (BOOL )consentForSessions
429460{
430461 if (!self.requiresConsent )
0 commit comments