2
0

Toggle Sentry and Countly when sendInfo is enabled/disabled.

This commit is contained in:
Maarten Billemont 2020-04-07 16:04:17 -04:00
parent b010432796
commit 508abec94e

View File

@ -126,7 +126,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
countlyConfig.host = @"https://countly.lyndir.com"; countlyConfig.host = @"https://countly.lyndir.com";
countlyConfig.appKey = decrypt( countlyKey ); countlyConfig.appKey = decrypt( countlyKey );
countlyConfig.features = @[ CLYPushNotifications ]; countlyConfig.features = @[ CLYPushNotifications ];
//countlyConfig.requiresConsent = YES; // FIXME: https://support.count.ly/hc/en-us/community/posts/900000930423-Notifications-on-macOS countlyConfig.requiresConsent = YES;
countlyConfig.alwaysUsePOST = YES; countlyConfig.alwaysUsePOST = YES;
countlyConfig.deviceID = [PearlKeyChain deviceIdentifier]; countlyConfig.deviceID = [PearlKeyChain deviceIdentifier];
countlyConfig.secretSalt = decrypt( countlySalt ); countlyConfig.secretSalt = decrypt( countlySalt );
@ -138,9 +138,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
countlyConfig.enableDebug = NO; countlyConfig.enableDebug = NO;
#endif #endif
[Countly.sharedInstance startWithConfig:countlyConfig]; [Countly.sharedInstance startWithConfig:countlyConfig];
[Countly.sharedInstance giveConsentForFeature:CLYConsentPushNotifications];
[Countly.sharedInstance askForNotificationPermission];
} }
@catch (id exception) { @catch (id exception) {
err( @"During Analytics Setup: %@", exception ); err( @"During Analytics Setup: %@", exception );
@ -732,6 +729,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
// Send info // Send info
if ([[MPConfig get].sendInfo boolValue]) { if ([[MPConfig get].sendInfo boolValue]) {
[Countly.sharedInstance giveConsentForAllFeatures]; [Countly.sharedInstance giveConsentForAllFeatures];
[Countly.sharedInstance askForNotificationPermission];
if ([PearlLogger get].printLevel > PearlLogLevelInfo) if ([PearlLogger get].printLevel > PearlLogLevelInfo)
[PearlLogger get].printLevel = PearlLogLevelInfo; [PearlLogger get].printLevel = PearlLogLevelInfo;
@ -749,12 +747,14 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
prefs[@"encrypted"] = @([PearlDeviceUtils isAppEncrypted]); prefs[@"encrypted"] = @([PearlDeviceUtils isAppEncrypted]);
prefs[@"platform"] = [PearlDeviceUtils platform]; prefs[@"platform"] = [PearlDeviceUtils platform];
[SentrySDK.currentHub getClient].options.enabled = @YES;
[SentrySDK configureScope:^(SentryScope *scope) { [SentrySDK configureScope:^(SentryScope *scope) {
for (NSString *pref in prefs.allKeys) for (NSString *pref in prefs.allKeys)
[scope setExtraValue:prefs[pref] forKey:pref]; [scope setExtraValue:prefs[pref] forKey:pref];
}]; }];
} }
else { else {
[SentrySDK.currentHub getClient].options.enabled = @NO;
[Countly.sharedInstance cancelConsentForAllFeatures]; [Countly.sharedInstance cancelConsentForAllFeatures];
} }
} }