diff --git a/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java b/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java index 605a1e1..51defe2 100644 --- a/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java +++ b/android/ScratchJr/app/src/main/java/org/scratchjr/android/JavaScriptDirectInterface.java @@ -617,14 +617,14 @@ public class JavaScriptDirectInterface { // Analytics @JavascriptInterface - public void analyticsEvent(String category, String action, String label, long value) { + public void analyticsEvent(String category, String action, String label) { _activity.logAnalyticsEvent(category, action, label); } @JavascriptInterface - public void setAnalyticsUser(String place) { + public void setAnalyticsPlacePref(String place) { if (place != null) { - _activity.setAnalyticsUser(place); + _activity.setAnalyticsPlacePref(place); } } } diff --git a/android/ScratchJr/app/src/main/java/org/scratchjr/android/ScratchJrActivity.java b/android/ScratchJr/app/src/main/java/org/scratchjr/android/ScratchJrActivity.java index 768b6e0..283fd41 100644 --- a/android/ScratchJr/app/src/main/java/org/scratchjr/android/ScratchJrActivity.java +++ b/android/ScratchJr/app/src/main/java/org/scratchjr/android/ScratchJrActivity.java @@ -494,7 +494,7 @@ public class ScratchJrActivity * Record the preferred place for the user: home, school, other, noanswer * @param place */ - public void setAnalyticsUser(String place) { + public void setAnalyticsPlacePref(String place) { _FirebaseAnalytics.setUserProperty("place_preference", place); } diff --git a/ios/ScratchJr/src/ScratchJr.h b/ios/ScratchJr/src/ScratchJr.h index 01f9cde..873bf71 100644 --- a/ios/ScratchJr/src/ScratchJr.h +++ b/ios/ScratchJr/src/ScratchJr.h @@ -126,8 +126,8 @@ :(int)shareType :(NSString *)b64data; - (NSString *) deviceName; -- (NSString *) analyticsEvent:(NSString *)category :(NSString *)action :(NSString *)label :(NSNumber*)value; -- (void) setAnalyticsUser:(NSString *)place; +- (NSString *) analyticsEvent:(NSString *)category :(NSString *)action :(NSString *)label; +- (void) setAnalyticsPlacePref:(NSString *)place; @end @interface ViewController : UIViewController diff --git a/ios/ScratchJr/src/ViewController.m b/ios/ScratchJr/src/ViewController.m index 9ceb42a..721fd28 100644 --- a/ios/ScratchJr/src/ViewController.m +++ b/ios/ScratchJr/src/ViewController.m @@ -131,7 +131,7 @@ JSContext *js; // Track pageview in Firebase? [FIRAnalytics setScreenName:page screenClass:NULL]; - + } // Disables iOS 9 webview touch tooltip by disabling the long-press gesture recognizer in subviews @@ -315,7 +315,7 @@ JSContext *js; return [ScratchJr hideSplash:body]; } --(NSString*) analyticsEvent:(NSString*) category :(NSString*) action :(NSString*) label :(NSNumber*) value { +-(NSString*) analyticsEvent:(NSString*) category :(NSString*) action :(NSString*) label { [FIRAnalytics logEventWithName:kFIREventViewItem parameters:@{ kFIRParameterItemID:action, @@ -325,7 +325,7 @@ JSContext *js; return @"1"; } --(void) setAnalyticsUser:(NSString*)place { +-(void) setAnalyticsPlacePref:(NSString*)place { [FIRAnalytics setUserPropertyString:place forName:@"place_preference"]; } diff --git a/src/editor/ui/UI.js b/src/editor/ui/UI.js index 9cc3474..42f6a82 100644 --- a/src/editor/ui/UI.js +++ b/src/editor/ui/UI.js @@ -28,6 +28,9 @@ let info = null; let okclicky = null; let infoBoxOpen = false; +const EMAILSHARE = 0; +const AIRDROPSHARE = 1; + export default class UI { static get infoBoxOpen () { return infoBoxOpen; @@ -134,7 +137,7 @@ export default class UI { shareEmail.id = 'infoboxShareButtonEmail'; shareEmail.textContent = Localization.localize('SHARING_BY_EMAIL'); shareEmail.ontouchstart = function (e) { - UI.infoDoShare(e, nameField, shareLoadingGif, 0); + UI.infoDoShare(e, nameField, shareLoadingGif, EMAILSHARE); }; if (isAndroid) { @@ -149,7 +152,7 @@ export default class UI { shareAirdrop.textContent = Localization.localize('SHARING_BY_AIRDROP'); shareAirdrop.style.float = 'right'; shareAirdrop.ontouchstart = function (e) { - UI.infoDoShare(e, nameField, shareLoadingGif, 1); + UI.infoDoShare(e, nameField, shareLoadingGif, AIRDROPSHARE); }; } @@ -254,7 +257,7 @@ export default class UI { setTimeout(saveAndShare, 500); // 500ms delay to wait for loading GIF to show and keyboard to hide - iOS.analyticsEvent('editor', 'share_button', (shareType == 0) ? 'email' : 'airdrop'); + iOS.analyticsEvent('editor', 'share_button', (shareType == EMAILSHARE) ? 'email' : 'airdrop'); function saveAndShare () { // Save the project's new name diff --git a/src/entry/index.js b/src/entry/index.js index 7433aeb..27415d5 100644 --- a/src/entry/index.js +++ b/src/entry/index.js @@ -94,7 +94,7 @@ function indexLoadStart (afterUsage) { gn('usageOther').className = 'usageOther hide'; gn('usageNoanswer').className = 'usageNoanswer hide'; } - iOS.setAnalyticsUser(AppUsage.currentUsage); + iOS.setAnalyticsPlacePref(AppUsage.currentUsage); } gn('gettings').className = 'gettings show'; gn('startcode').className = 'startcode show'; diff --git a/src/iPad/iOS.js b/src/iPad/iOS.js index 4458ef0..8062bfe 100644 --- a/src/iPad/iOS.js +++ b/src/iPad/iOS.js @@ -351,15 +351,12 @@ export default class iOS { fcn(tabletInterface.deviceName()); } - static analyticsEvent (category, action, label, value) { - if (!value) { - value = 1; - } - tabletInterface.analyticsEvent(category, action, label, value); + static analyticsEvent (category, action, label) { + tabletInterface.analyticsEvent(category, action, label); } - static setAnalyticsUser (preferredPlace) { - tabletInterface.setAnalyticsUser(preferredPlace); + static setAnalyticsPlacePref (preferredPlace) { + tabletInterface.setAnalyticsPlacePref(preferredPlace); } // Web Wiew delegate call backs diff --git a/src/painteditor/Paint.js b/src/painteditor/Paint.js index 1cad130..7140b99 100644 --- a/src/painteditor/Paint.js +++ b/src/painteditor/Paint.js @@ -163,6 +163,9 @@ export default class Paint { static open (bkg, md5, sname, cname, cscale, sw, sh) { let action = ''; let label = ''; + // Analytics: + // md3: name of the asset, an md5 hash for user generated, filename for library items + // sname: is not set for a new character (ignored for backgrounds) if (bkg) { action = 'edit_background'; label = (md5 in MediaLib.keys) ? md5 : 'user_background'; diff --git a/src/utils/AppUsage.js b/src/utils/AppUsage.js index ce373b3..441e284 100644 --- a/src/utils/AppUsage.js +++ b/src/utils/AppUsage.js @@ -31,11 +31,7 @@ export default class AppUsage { * @param {string} kind answer from user to the usage survey (home, school, other, noanswer) */ static setUsage (kind) { - if (kind === '') { - Cookie.set('usage', 'noanswer'); - } else { - Cookie.set('usage', kind); - } currentUsage = (kind === '') ? 'noanswer' : kind; + Cookie.set('usage', currentUsage); } }