diff --git a/platform-darwin/Source/MPConfig.h b/platform-darwin/Source/MPConfig.h index 844e993a..f40da91e 100644 --- a/platform-darwin/Source/MPConfig.h +++ b/platform-darwin/Source/MPConfig.h @@ -21,6 +21,7 @@ @interface MPConfig : PearlConfig @property(nonatomic, retain) NSNumber *sendInfo; +@property(nonatomic, retain) NSNumber *sendInfoDecided; @property(nonatomic, retain) NSNumber *rememberLogin; @property(nonatomic, retain) NSNumber *hidePasswords; diff --git a/platform-darwin/Source/MPConfig.m b/platform-darwin/Source/MPConfig.m index 0168abb3..24381e42 100644 --- a/platform-darwin/Source/MPConfig.m +++ b/platform-darwin/Source/MPConfig.m @@ -29,13 +29,15 @@ return nil; [self.defaults registerDefaults:@{ - NSStringFromSelector( @selector( askForReviews ) ) : @YES, - NSStringFromSelector( @selector( sendInfo ) ) : @YES, + NSStringFromSelector( @selector( sendInfoDecided ) ) : @NO, + NSStringFromSelector( @selector( rememberLogin ) ) : @NO, NSStringFromSelector( @selector( hidePasswords ) ) : @NO, - NSStringFromSelector( @selector( checkInconsistency ) ): @NO, NSStringFromSelector( @selector( siteAttacker ) ) : @(MPAttacker1), + + NSStringFromSelector( @selector( checkInconsistency ) ): @NO, + NSStringFromSelector( @selector( askForReviews ) ) : @YES, }]; self.delegate = [MPAppDelegate_Shared get]; diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.m b/platform-darwin/Source/Mac/MPMacAppDelegate.m index 0f2251c5..664bffd3 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.m +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.m @@ -86,7 +86,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven }]; [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { PearlLogLevel level = PearlLogLevelWarn; - if ([[MPConfig get].sendInfo boolValue]) + if ([[MPMacConfig get].sendInfo boolValue]) level = PearlLogLevelDebug; if (message.level >= level) { @@ -145,7 +145,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven } // Setup delegates and listeners. - [MPConfig get].delegate = self; + [MPMacConfig get].delegate = self; __weak id weakSelf = self; [self addObserverBlock:^(NSString *keyPath, id object, NSDictionary *change, void *context) { dispatch_async( dispatch_get_main_queue(), ^{ @@ -210,7 +210,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (void)applicationWillResignActive:(NSNotification *)notification { - if (![[MPConfig get].rememberLogin boolValue]) + if (![[MPMacConfig get].rememberLogin boolValue]) [self lock:nil]; } @@ -408,12 +408,18 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)togglePreference:(id)sender { - if (sender == self.diagnosticsItem) - [MPConfig get].sendInfo = @(self.diagnosticsItem.state != NSOnState); + if (sender == self.diagnosticsItem) { + BOOL sendInfo = self.diagnosticsItem.state != NSOnState; + [[Countly sharedInstance] recordEvent:@"sendInfoDecided" segmentation:@{ + @"from": @"preferences", + @"sendInfo": [@(sendInfo) description], + }]; + [MPMacConfig get].sendInfo = @(sendInfo); + } if (sender == self.hidePasswordsItem) - [MPConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState); + [MPMacConfig get].hidePasswords = @(self.hidePasswordsItem.state != NSOnState); if (sender == self.rememberPasswordItem) - [MPConfig get].rememberLogin = @(self.rememberPasswordItem.state != NSOnState); + [MPMacConfig get].rememberLogin = @(self.rememberPasswordItem.state != NSOnState); if (sender == self.openAtLoginItem) [self setLoginItemEnabled:self.openAtLoginItem.state != NSOnState]; if (sender == self.showFullScreenItem) { @@ -760,26 +766,26 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven PearlMainQueue( ^{ if (!key || [key isEqualToString:NSStringFromSelector( @selector( sendInfo ) )]) - self.diagnosticsItem.state = [[MPConfig get].sendInfo boolValue]? NSOnState: NSOffState; + self.diagnosticsItem.state = [[MPMacConfig get].sendInfo boolValue]? NSOnState: NSOffState; if (!key || [key isEqualToString:NSStringFromSelector( @selector( hidePasswords ) )]) - self.hidePasswordsItem.state = [[MPConfig get].hidePasswords boolValue]? NSOnState: NSOffState; + self.hidePasswordsItem.state = [[MPMacConfig get].hidePasswords boolValue]? NSOnState: NSOffState; if (!key || [key isEqualToString:NSStringFromSelector( @selector( rememberLogin ) )]) - self.rememberPasswordItem.state = [[MPConfig get].rememberLogin boolValue]? NSOnState: NSOffState; + self.rememberPasswordItem.state = [[MPMacConfig get].rememberLogin boolValue]? NSOnState: NSOffState; } ); // Send info NSArray *countlyFeatures = @[ CLYConsentSessions, CLYConsentEvents, CLYConsentUserDetails, CLYConsentCrashReporting, CLYConsentViewTracking, CLYConsentStarRating ]; - if ([[MPConfig get].sendInfo boolValue]) { + if ([[MPMacConfig get].sendInfo boolValue]) { [Countly.sharedInstance giveConsentForFeatures:countlyFeatures]; if ([PearlLogger get].printLevel > PearlLogLevelInfo) [PearlLogger get].printLevel = PearlLogLevelInfo; [SentrySDK.currentHub getClient].options.enabled = @YES; [SentrySDK configureScope:^(SentryScope *scope) { - [scope setExtraValue:[MPConfig get].rememberLogin forKey:@"rememberLogin"]; - [scope setExtraValue:[MPConfig get].sendInfo forKey:@"sendInfo"]; + [scope setExtraValue:[MPMacConfig get].rememberLogin forKey:@"rememberLogin"]; + [scope setExtraValue:[MPMacConfig get].sendInfo forKey:@"sendInfo"]; [scope setExtraValue:[MPMacConfig get].fullScreen forKey:@"fullScreen"]; [scope setExtraValue:[PearlConfig get].firstRun forKey:@"firstRun"]; [scope setExtraValue:[PearlConfig get].launchCount forKey:@"launchCount"]; diff --git a/platform-darwin/Source/Mac/MPSitesWindowController.m b/platform-darwin/Source/Mac/MPSitesWindowController.m index d4fb7857..abfa591d 100644 --- a/platform-darwin/Source/Mac/MPSitesWindowController.m +++ b/platform-darwin/Source/Mac/MPSitesWindowController.m @@ -17,6 +17,7 @@ //============================================================================== #import +#import #import "MPSitesWindowController.h" #import "MPMacAppDelegate.h" #import "MPAppDelegate_Store.h" @@ -42,13 +43,35 @@ prof_rewind( @"replaceFonts" ); PearlAddNotificationObserver( NSWindowDidBecomeKeyNotification, self.window, [NSOperationQueue mainQueue], - ^(id host, NSNotification *note) { + (^(id host, NSNotification *note) { prof_new( @"didBecomeKey" ); [self.window makeKeyAndOrderFront:nil]; prof_rewind( @"fadeIn" ); [self updateUser]; - prof_finish( @"updateUser" ); - } ); + prof_rewind( @"updateUser" ); + + if (![[MPMacConfig get].sendInfoDecided boolValue]) { + NSAlert *alert = [NSAlert new]; + alert.messageText = @"Welcome to Master Password!"; + alert.informativeText = @"We want you to have a top-notch experience.\n" + @"Using diagnostics, we ensure the application keeps working as designed for you.\n" + @"\n" + @"We look out for application bugs, runtime issues, sudden crashes & usage counters.\n" + @"Needless to say, diagnostics are always scrubbed and personal details will never leave your device."; + [alert addButtonWithTitle:@"Thanks!"]; + [alert addButtonWithTitle:@"Disable"]; + [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { + BOOL sendInfo = returnCode != NSAlertSecondButtonReturn; + [[Countly sharedInstance] recordEvent:@"sendInfoDecided" segmentation:@{ + @"from": @"initial", + @"sendInfo": [@(sendInfo) description], + }]; + [MPMacConfig get].sendInfo = @(sendInfo); + [MPMacConfig get].sendInfoDecided = @(YES); + }]; + } + prof_finish( @"sendInfoDecided" ); + }) ); PearlAddNotificationObserver( NSWindowWillCloseNotification, self.window, [NSOperationQueue mainQueue], ^(id host, NSNotification *note) { NSWindow *sheet = [self.window attachedSheet];