2
0

Consent tweaks.

Don't conditional Countly events on sendInfo, it already turns Countly
on/off.

Keep Sentry enabled for longer while turning on/off for sendInfo to
cache more errors.

Use sendInfoDecided event only for initial sendInfo prompt, can use
Countly's censent tools to view overall opt-in/opt-outs.
This commit is contained in:
Maarten Billemont 2020-04-19 17:40:28 -04:00
parent c3568e4744
commit 61d1660560
7 changed files with 44 additions and 60 deletions

View File

@ -197,7 +197,6 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve
forKey:transaction.payment.productIdentifier]; forKey:transaction.payment.productIdentifier];
[queue finishTransaction:transaction]; [queue finishTransaction:transaction];
if ([[MPConfig get].sendInfo boolValue]) {
SKProduct *product = self.products[transaction.payment.productIdentifier]; SKProduct *product = self.products[transaction.payment.productIdentifier];
[attributes addEntriesFromDictionary:@{ [attributes addEntriesFromDictionary:@{
@"id": product.productIdentifier, @"id": product.productIdentifier,
@ -208,7 +207,6 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve
@"quantity": @(transaction.payment.quantity).description, @"quantity": @(transaction.payment.quantity).description,
}]; }];
[Countly.sharedInstance recordEvent:@"purchase" segmentation:attributes]; [Countly.sharedInstance recordEvent:@"purchase" segmentation:attributes];
}
break; break;
} }
case SKPaymentTransactionStateRestored: { case SKPaymentTransactionStateRestored: {
@ -224,7 +222,6 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve
MPError( transaction.error, @"Transaction failed: %@.", transaction.payment.productIdentifier ); MPError( transaction.error, @"Transaction failed: %@.", transaction.payment.productIdentifier );
[queue finishTransaction:transaction]; [queue finishTransaction:transaction];
if ([[MPConfig get].sendInfo boolValue]) {
SKProduct *product = self.products[transaction.payment.productIdentifier]; SKProduct *product = self.products[transaction.payment.productIdentifier];
[Countly.sharedInstance recordEvent:@"purchase" segmentation:@{ [Countly.sharedInstance recordEvent:@"purchase" segmentation:@{
@"id": product.productIdentifier, @"id": product.productIdentifier,
@ -235,7 +232,6 @@ PearlAssociatedObjectProperty( NSMutableArray*, ProductObservers, productObserve
@"quantity": @(transaction.payment.quantity).description, @"quantity": @(transaction.payment.quantity).description,
@"reason" : [transaction.error localizedFailureReason]?: [transaction.error localizedDescription], @"reason" : [transaction.error localizedFailureReason]?: [transaction.error localizedDescription],
}]; }];
}
break; break;
} }
} }

View File

@ -173,13 +173,11 @@
else else
dbg( @"Automatic login failed for user: %@", user.userID ); dbg( @"Automatic login failed for user: %@", user.userID );
if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance recordEvent:@"login" segmentation:@{ [Countly.sharedInstance recordEvent:@"login" segmentation:@{
@"method" : password? @"Password": @"Automatic", @"method" : password? @"Password": @"Automatic",
@"state" : @"failed", @"state" : @"failed",
@"algorithm": @(user.algorithm.version).description, @"algorithm": @(user.algorithm.version).description,
}]; }];
}
return NO; return NO;
} }
@ -203,7 +201,6 @@
} }
@try { @try {
if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance userLoggedIn:user.userID]; [Countly.sharedInstance userLoggedIn:user.userID];
[Countly.sharedInstance recordEvent:@"login" segmentation:@{ [Countly.sharedInstance recordEvent:@"login" segmentation:@{
@ -212,7 +209,6 @@
@"algorithm": @(user.algorithm.version).description, @"algorithm": @(user.algorithm.version).description,
}]; }];
} }
}
@catch (id exception) { @catch (id exception) {
err( @"While setting username: %@", exception ); err( @"While setting username: %@", exception );
} }

View File

@ -119,7 +119,6 @@ static MPAppDelegate_Shared *instance;
if (self.key) if (self.key)
self.key = nil; self.key = nil;
if ([[MPConfig get].sendInfo boolValue])
[Countly.sharedInstance userLoggedOut]; [Countly.sharedInstance userLoggedOut];
self.activeUserOID = activeUserOID; self.activeUserOID = activeUserOID;

View File

@ -408,14 +408,8 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
- (IBAction)togglePreference:(id)sender { - (IBAction)togglePreference:(id)sender {
if (sender == self.diagnosticsItem) { if (sender == self.diagnosticsItem)
BOOL sendInfo = self.diagnosticsItem.state != NSOnState; [MPMacConfig get].sendInfo = @(self.diagnosticsItem.state != NSOnState);
[[Countly sharedInstance] recordEvent:@"sendInfoDecided" segmentation:@{
@"from": @"preferences",
@"sendInfo": [@(sendInfo) description],
}];
[MPMacConfig get].sendInfo = @(sendInfo);
}
if (sender == self.hidePasswordsItem) if (sender == self.hidePasswordsItem)
[MPMacConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState); [MPMacConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState);
if (sender == self.rememberPasswordItem) if (sender == self.rememberPasswordItem)
@ -778,7 +772,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating
]; ];
if ([[MPMacConfig get].sendInfo boolValue]) { if ([[MPMacConfig get].sendInfo boolValue]) {
[Countly.sharedInstance giveConsentForFeatures:countlyFeatures];
if ([PearlLogger get].printLevel > PearlLogLevelInfo) if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo; [PearlLogger get].printLevel = PearlLogLevelInfo;
@ -796,10 +789,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
[scope setExtraValue:@([PearlDeviceUtils isAppEncrypted]) forKey:@"encrypted"]; [scope setExtraValue:@([PearlDeviceUtils isAppEncrypted]) forKey:@"encrypted"];
[scope setExtraValue:[PearlDeviceUtils platform] forKey:@"platform"]; [scope setExtraValue:[PearlDeviceUtils platform] forKey:@"platform"];
}]; }];
[Countly.sharedInstance giveConsentForFeatures:countlyFeatures];
} }
else { else {
[SentrySDK.currentHub getClient].options.enabled = @NO;
[Countly.sharedInstance cancelConsentForFeatures:countlyFeatures]; [Countly.sharedInstance cancelConsentForFeatures:countlyFeatures];
[SentrySDK.currentHub getClient].options.enabled = @NO;
} }
} }

View File

@ -63,7 +63,6 @@
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
BOOL sendInfo = returnCode != NSAlertSecondButtonReturn; BOOL sendInfo = returnCode != NSAlertSecondButtonReturn;
[[Countly sharedInstance] recordEvent:@"sendInfoDecided" segmentation:@{ [[Countly sharedInstance] recordEvent:@"sendInfoDecided" segmentation:@{
@"from": @"initial",
@"sendInfo": [@(sendInfo) description], @"sendInfo": [@(sendInfo) description],
}]; }];
[MPMacConfig get].sendInfo = @(sendInfo); [MPMacConfig get].sendInfo = @(sendInfo);

View File

@ -231,13 +231,11 @@ typedef NS_ENUM( NSUInteger, MPActiveUserState ) {
user.avatar = newUserAvatar; user.avatar = newUserAvatar;
user.name = newUserName; user.name = newUserName;
if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance recordEvent:@"new-user" segmentation:@{ [Countly.sharedInstance recordEvent:@"new-user" segmentation:@{
@"algorithm": @(user.algorithm.version).description, @"algorithm": @(user.algorithm.version).description,
@"avatar" : @(user.avatar).description, @"avatar" : @(user.avatar).description,
}]; }];
} }
}
BOOL signedIn = [[MPiOSAppDelegate get] signInAsUser:user saveInContext:context BOOL signedIn = [[MPiOSAppDelegate get] signInAsUser:user saveInContext:context
usingMasterPassword:masterPassword]; usingMasterPassword:masterPassword];

View File

@ -646,7 +646,6 @@
CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating
]; ];
if ([[MPConfig get].sendInfo boolValue]) { if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance giveConsentForFeatures:countlyFeatures];
if ([PearlLogger get].printLevel > PearlLogLevelInfo) if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo; [PearlLogger get].printLevel = PearlLogLevelInfo;
@ -670,11 +669,13 @@
#else #else
[scope setExtraValue:@(NO) forKey:@"reviewedVersion"]; [scope setExtraValue:@(NO) forKey:@"reviewedVersion"];
#endif #endif
[Countly.sharedInstance giveConsentForFeatures:countlyFeatures];
}]; }];
} }
else { else {
[SentrySDK.currentHub getClient].options.enabled = @NO;
[Countly.sharedInstance cancelConsentForFeatures:countlyFeatures]; [Countly.sharedInstance cancelConsentForFeatures:countlyFeatures];
[SentrySDK.currentHub getClient].options.enabled = @NO;
} }
} }