diff --git a/osx/installerplugins/common/mixpanel.h b/osx/installerplugins/common/mixpanel.h index f5e580d818..aa5cb4e02a 100644 --- a/osx/installerplugins/common/mixpanel.h +++ b/osx/installerplugins/common/mixpanel.h @@ -35,18 +35,25 @@ return uuid; } -+ (void) trackEvent:(NSString *)name forPane:(InstallerPane*)pane { ++ (void) trackEvent:(NSString *)name forPane:(InstallerPane*)pane withProperties:(NSDictionary *)properties { BOOL trackingDisabled = [[[[pane section] sharedDictionary] objectForKey:@"disableTracking"] boolValue]; NSString *uuid = [self uuid]; if (!uuid || trackingDisabled) { return; } + + NSString *props = @""; + for (NSString *key in properties) { + props = [props stringByAppendingFormat:@",\"%@\": \"%@\"", key, [properties objectForKey:key]]; + } NSBundle* bundle = [[pane section] bundle]; NSString* token = [bundle objectForInfoDictionaryKey:@"Mixpanel Token"]; NSString* installerVersion = [bundle objectForInfoDictionaryKey:@"Installer Version"]; - NSString* payload = [NSString stringWithFormat:@"{\"event\": \"%@\", \"properties\": {\"token\": \"%@\", \"distinct_id\": \"%@\", \"os\": \"darwin\", \"version\": \"%@\"}}", name, token, uuid, installerVersion]; + NSString* payload = [NSString stringWithFormat:@"{\"event\": \"%@\", \"properties\": {\"token\": \"%@\", \"distinct_id\": \"%@\", \"os\": \"darwin\", \"version\": \"%@\" %@}}", name, token, uuid, installerVersion, props]; + + NSLog(@"%@", payload); NSData * data = [payload dataUsingEncoding:NSUTF8StringEncoding]; NSString* base64Encoded = [data base64EncodedStringWithOptions:0]; @@ -54,6 +61,11 @@ NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {}]; + +} + ++ (void) trackEvent:(NSString *)name forPane:(InstallerPane*)pane { + [self trackEvent:name forPane:pane withProperties:nil]; } @end diff --git a/osx/installerplugins/overviewplugin/overviewpluginPane.m b/osx/installerplugins/overviewplugin/overviewpluginPane.m index 8080be47bd..1c130d272b 100644 --- a/osx/installerplugins/overviewplugin/overviewpluginPane.m +++ b/osx/installerplugins/overviewplugin/overviewpluginPane.m @@ -9,8 +9,18 @@ #import "overviewpluginPane.h" #import "mixpanel.h" +@interface overviewpluginPane() +@property BOOL firstTime; +@end + @implementation overviewpluginPane +- (id) init { + self.firstTime = YES; + self = [super init]; + return self; +} + - (NSString *)title { return [[NSBundle bundleForClass:[self class]] localizedStringForKey:@"PaneTitle" value:nil table:nil]; } @@ -21,8 +31,10 @@ [formattedHTML addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:13.0f] range:NSMakeRange(0, formattedHTML.length)]; [[self.textView textStorage] setAttributedString:formattedHTML]; - - [Mixpanel trackEvent:@"Installer Started" forPane:self]; + if (self.firstTime) { + [Mixpanel trackEvent:@"Installer Started" forPane:self]; + self.firstTime = YES; + } } - (void) willExitPane:(InstallerSectionDirection)dir { diff --git a/osx/installerplugins/quickstartplugin/quickstartpluginPane.m b/osx/installerplugins/quickstartplugin/quickstartpluginPane.m index 446021b7fe..6c7d47f194 100644 --- a/osx/installerplugins/quickstartplugin/quickstartpluginPane.m +++ b/osx/installerplugins/quickstartplugin/quickstartpluginPane.m @@ -41,12 +41,12 @@ - (void) willExitPane:(InstallerSectionDirection)dir { if (dir == InstallerDirectionForward) { - [Mixpanel trackEvent:@"Installer Finished" forPane:self]; + [Mixpanel trackEvent:@"Installer Finished" forPane:self withProperties:[[NSDictionary alloc] initWithObjectsAndKeys:@"Continue Button", @"action", nil]]; } } - (IBAction)quickstartTerminalClicked:(id)sender { - [Mixpanel trackEvent:@"Opened Docker Quickstart Terminal" forPane:self]; + [Mixpanel trackEvent:@"Installer Finished" forPane:self withProperties:[[NSDictionary alloc] initWithObjectsAndKeys:@"Quickstart Terminal", @"action", nil]]; NSTask *task = [[NSTask alloc] init]; task.launchPath = @"/usr/bin/open"; task.arguments = @[@"/Applications/Docker/Docker Quickstart Terminal.app"]; @@ -54,7 +54,7 @@ } - (IBAction)kitematicClicked:(id)sender { - [Mixpanel trackEvent:@"Opened Kitematic" forPane:self]; + [Mixpanel trackEvent:@"Installer Finished" forPane:self withProperties:[[NSDictionary alloc] initWithObjectsAndKeys:@"Kitematic", @"action", nil]]; [[NSWorkspace sharedWorkspace] launchApplication:@"Kitematic (Beta)"]; } diff --git a/osx/mpkg/Plugins/managevmplugin.bundle/Contents/MacOS/managevmplugin b/osx/mpkg/Plugins/managevmplugin.bundle/Contents/MacOS/managevmplugin index d0bb22528d..68591e8ac4 100755 Binary files a/osx/mpkg/Plugins/managevmplugin.bundle/Contents/MacOS/managevmplugin and b/osx/mpkg/Plugins/managevmplugin.bundle/Contents/MacOS/managevmplugin differ diff --git a/osx/mpkg/Plugins/overviewplugin.bundle/Contents/MacOS/overviewplugin b/osx/mpkg/Plugins/overviewplugin.bundle/Contents/MacOS/overviewplugin index 8af860b96e..052bd39a48 100755 Binary files a/osx/mpkg/Plugins/overviewplugin.bundle/Contents/MacOS/overviewplugin and b/osx/mpkg/Plugins/overviewplugin.bundle/Contents/MacOS/overviewplugin differ diff --git a/osx/mpkg/Plugins/quickstartplugin.bundle/Contents/MacOS/quickstartplugin b/osx/mpkg/Plugins/quickstartplugin.bundle/Contents/MacOS/quickstartplugin index 1eed5071ea..e84a326a99 100755 Binary files a/osx/mpkg/Plugins/quickstartplugin.bundle/Contents/MacOS/quickstartplugin and b/osx/mpkg/Plugins/quickstartplugin.bundle/Contents/MacOS/quickstartplugin differ