Address comments

This commit is contained in:
Chris Garrity 2019-10-25 11:07:38 -04:00
parent 2c4520e9e1
commit c8f655447a
9 changed files with 24 additions and 25 deletions

View file

@ -617,14 +617,14 @@ public class JavaScriptDirectInterface {
// Analytics // Analytics
@JavascriptInterface @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); _activity.logAnalyticsEvent(category, action, label);
} }
@JavascriptInterface @JavascriptInterface
public void setAnalyticsUser(String place) { public void setAnalyticsPlacePref(String place) {
if (place != null) { if (place != null) {
_activity.setAnalyticsUser(place); _activity.setAnalyticsPlacePref(place);
} }
} }
} }

View file

@ -494,7 +494,7 @@ public class ScratchJrActivity
* Record the preferred place for the user: home, school, other, noanswer * Record the preferred place for the user: home, school, other, noanswer
* @param place * @param place
*/ */
public void setAnalyticsUser(String place) { public void setAnalyticsPlacePref(String place) {
_FirebaseAnalytics.setUserProperty("place_preference", place); _FirebaseAnalytics.setUserProperty("place_preference", place);
} }

View file

@ -126,8 +126,8 @@
:(int)shareType :(int)shareType
:(NSString *)b64data; :(NSString *)b64data;
- (NSString *) deviceName; - (NSString *) deviceName;
- (NSString *) analyticsEvent:(NSString *)category :(NSString *)action :(NSString *)label :(NSNumber*)value; - (NSString *) analyticsEvent:(NSString *)category :(NSString *)action :(NSString *)label;
- (void) setAnalyticsUser:(NSString *)place; - (void) setAnalyticsPlacePref:(NSString *)place;
@end @end
@interface ViewController : UIViewController <JSExports,UIWebViewDelegate,MFMailComposeViewControllerDelegate> @interface ViewController : UIViewController <JSExports,UIWebViewDelegate,MFMailComposeViewControllerDelegate>

View file

@ -131,7 +131,7 @@ JSContext *js;
// Track pageview in Firebase? // Track pageview in Firebase?
[FIRAnalytics setScreenName:page screenClass:NULL]; [FIRAnalytics setScreenName:page screenClass:NULL];
} }
// Disables iOS 9 webview touch tooltip by disabling the long-press gesture recognizer in subviews // 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]; 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 [FIRAnalytics logEventWithName:kFIREventViewItem
parameters:@{ parameters:@{
kFIRParameterItemID:action, kFIRParameterItemID:action,
@ -325,7 +325,7 @@ JSContext *js;
return @"1"; return @"1";
} }
-(void) setAnalyticsUser:(NSString*)place { -(void) setAnalyticsPlacePref:(NSString*)place {
[FIRAnalytics setUserPropertyString:place forName:@"place_preference"]; [FIRAnalytics setUserPropertyString:place forName:@"place_preference"];
} }

View file

@ -28,6 +28,9 @@ let info = null;
let okclicky = null; let okclicky = null;
let infoBoxOpen = false; let infoBoxOpen = false;
const EMAILSHARE = 0;
const AIRDROPSHARE = 1;
export default class UI { export default class UI {
static get infoBoxOpen () { static get infoBoxOpen () {
return infoBoxOpen; return infoBoxOpen;
@ -134,7 +137,7 @@ export default class UI {
shareEmail.id = 'infoboxShareButtonEmail'; shareEmail.id = 'infoboxShareButtonEmail';
shareEmail.textContent = Localization.localize('SHARING_BY_EMAIL'); shareEmail.textContent = Localization.localize('SHARING_BY_EMAIL');
shareEmail.ontouchstart = function (e) { shareEmail.ontouchstart = function (e) {
UI.infoDoShare(e, nameField, shareLoadingGif, 0); UI.infoDoShare(e, nameField, shareLoadingGif, EMAILSHARE);
}; };
if (isAndroid) { if (isAndroid) {
@ -149,7 +152,7 @@ export default class UI {
shareAirdrop.textContent = Localization.localize('SHARING_BY_AIRDROP'); shareAirdrop.textContent = Localization.localize('SHARING_BY_AIRDROP');
shareAirdrop.style.float = 'right'; shareAirdrop.style.float = 'right';
shareAirdrop.ontouchstart = function (e) { 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 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 () { function saveAndShare () {
// Save the project's new name // Save the project's new name

View file

@ -94,7 +94,7 @@ function indexLoadStart (afterUsage) {
gn('usageOther').className = 'usageOther hide'; gn('usageOther').className = 'usageOther hide';
gn('usageNoanswer').className = 'usageNoanswer hide'; gn('usageNoanswer').className = 'usageNoanswer hide';
} }
iOS.setAnalyticsUser(AppUsage.currentUsage); iOS.setAnalyticsPlacePref(AppUsage.currentUsage);
} }
gn('gettings').className = 'gettings show'; gn('gettings').className = 'gettings show';
gn('startcode').className = 'startcode show'; gn('startcode').className = 'startcode show';

View file

@ -351,15 +351,12 @@ export default class iOS {
fcn(tabletInterface.deviceName()); fcn(tabletInterface.deviceName());
} }
static analyticsEvent (category, action, label, value) { static analyticsEvent (category, action, label) {
if (!value) { tabletInterface.analyticsEvent(category, action, label);
value = 1;
}
tabletInterface.analyticsEvent(category, action, label, value);
} }
static setAnalyticsUser (preferredPlace) { static setAnalyticsPlacePref (preferredPlace) {
tabletInterface.setAnalyticsUser(preferredPlace); tabletInterface.setAnalyticsPlacePref(preferredPlace);
} }
// Web Wiew delegate call backs // Web Wiew delegate call backs

View file

@ -163,6 +163,9 @@ export default class Paint {
static open (bkg, md5, sname, cname, cscale, sw, sh) { static open (bkg, md5, sname, cname, cscale, sw, sh) {
let action = ''; let action = '';
let label = ''; 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) { if (bkg) {
action = 'edit_background'; action = 'edit_background';
label = (md5 in MediaLib.keys) ? md5 : 'user_background'; label = (md5 in MediaLib.keys) ? md5 : 'user_background';

View file

@ -31,11 +31,7 @@ export default class AppUsage {
* @param {string} kind answer from user to the usage survey (home, school, other, noanswer) * @param {string} kind answer from user to the usage survey (home, school, other, noanswer)
*/ */
static setUsage (kind) { static setUsage (kind) {
if (kind === '') {
Cookie.set('usage', 'noanswer');
} else {
Cookie.set('usage', kind);
}
currentUsage = (kind === '') ? 'noanswer' : kind; currentUsage = (kind === '') ? 'noanswer' : kind;
Cookie.set('usage', currentUsage);
} }
} }