Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,9 @@ public void run() {
*/
public void logAnalyticsEvent(String category, String action, String label) {
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_ID, action);
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, category);
params.putString(FirebaseAnalytics.Param.ITEM_NAME, label);
_FirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
_FirebaseAnalytics.logEvent(action, params);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions ios/ScratchJr/src/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,8 @@ - (NSString *) hideSplash :(NSString *)body {
}

-(NSString*) analyticsEvent:(NSString*) category :(NSString*) action :(NSString*) label {
[FIRAnalytics logEventWithName:kFIREventViewItem
[FIRAnalytics logEventWithName:action
parameters:@{
kFIRParameterItemID:action,
kFIRParameterItemName:label,
kFIRParameterItemCategory:category
}];
Expand Down
2 changes: 2 additions & 0 deletions src/editor/ScratchJr.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export default class ScratchJr {
ScratchJr.stopStripsFromTop(e);
ScratchJr.unfocus(e);
ScratchJr.saveProject(e, ScratchJr.flippage);
iOS.analyticsEvent('editor', 'project_editor_close');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this and it seems to only be called when you click the home button while within the project editor. The function name "flip" is a little confusing

}

static flippage () {
Expand Down Expand Up @@ -536,6 +537,7 @@ export default class ScratchJr {
inFullscreen = false;
UI.quitFullScreen();
onBackButtonCallback.pop();
iOS.analyticsEvent('editor', 'full_screen_exited');
document.body.style.background = 'white';
}

Expand Down
3 changes: 3 additions & 0 deletions src/editor/engine/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ export default class Sprite {
var sprites = JSON.parse(page.sprites);
sprites.push(this.id);
page.sprites = JSON.stringify(sprites);
iOS.analyticsEvent('editor', 'text_sprite_create');
if ((this.str == '') && !whenDone) {
this.setTextBox();
this.activateInput();
Expand Down Expand Up @@ -805,6 +806,7 @@ export default class Sprite {
document.body.scrollLeft = 0;
var form = document.forms.activetextbox;
var changed = (this.oldvalue != form.typing.value);
iOS.analyticsEvent('editor', 'text_sprite_close');
if (this.noChars(form.typing.value)) {
this.deleteText(this.oldvalue != '');
} else {
Expand Down Expand Up @@ -889,6 +891,7 @@ export default class Sprite {
var ti = document.forms.activetextbox.typing;
gn('textbox').style.visibility = 'visible';
var me = this;
iOS.analyticsEvent('editor', 'text_sprite_open');
ti.onblur = function () {
me.unfocusText();
};
Expand Down
4 changes: 4 additions & 0 deletions src/editor/ui/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default class Record {

// Dialog box hide/show
static appear () {
iOS.analyticsEvent('editor', 'record_dialog_open');
gn('backdrop').setAttribute('class', 'modal-backdrop fade in');
setProps(gn('backdrop').style, {
display: 'block'
Expand All @@ -71,6 +72,7 @@ export default class Record {
}

static disappear () {
iOS.analyticsEvent('editor', 'record_dialog_close');
setTimeout(function () {
gn('backdrop').setAttribute('class', 'modal-backdrop fade');
setProps(gn('backdrop').style, {
Expand Down Expand Up @@ -152,6 +154,7 @@ export default class Record {
}

static startRecording (filename) {
iOS.analyticsEvent('editor', 'start_recording');
if (parseInt(filename) < 0) {
// Error in getting record filename - go back to editor
recordedSound = undefined;
Expand Down Expand Up @@ -250,6 +253,7 @@ export default class Record {

// Stop the volume monitor and recording
static stopRecording (fcn) {
iOS.analyticsEvent('editor', 'stop_recording');
if (timeLimit != null) {
clearTimeout(timeLimit);
timeLimit = null;
Expand Down
3 changes: 3 additions & 0 deletions src/editor/ui/Thumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Page from '../engine/Page';
import ScriptsPane from './ScriptsPane';
import Undo from './Undo';
import UI from './UI';
import iOS from '../../iPad/iOS';
import Events from '../../utils/Events';
import ScratchAudio from '../../utils/ScratchAudio';
import {frame, gn, localx, newHTML, scaleMultiplier, getIdFor,
Expand Down Expand Up @@ -82,6 +83,7 @@ export default class Thumbs {
var tb = Thumbs.getType(Thumbs.t, 'pagethumb');
if (ScratchJr.shaking && (e.target.className == 'deletethumb')) {
ScratchJr.clearSelection();
iOS.analyticsEvent('editor', 'delete_scene');
ScratchJr.stage.deletePage(tb.owner);
return;
}
Expand Down Expand Up @@ -376,6 +378,7 @@ export default class Thumbs {
sc.owner.deactivate();
}
ScratchJr.unfocus(e);
iOS.analyticsEvent('editor', 'add_scene');
new Page(getIdFor('page'));
}

Expand Down
9 changes: 5 additions & 4 deletions src/editor/ui/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ export default class UI {
UI.creatTopBarClicky(div, 'go', 'go on', UI.toggleRun);
UI.creatTopBarClicky(div, 'resetall', 'resetall', UI.resetAllSprites);
UI.creatTopBarClicky(div, 'full', 'fullscreen', ScratchJr.fullScreen);
UI.toggleGrid(true);
UI.setShowGrid(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I changed this function to be more clear, and to better distinguish it from switchGrid()

}

static resetAllSprites (e) {
Expand All @@ -756,11 +756,12 @@ export default class UI {

static switchGrid () {
ScratchAudio.sndFX('tap.wav');
UI.toggleGrid(!Grid.hidden);
UI.setShowGrid(Grid.hidden);
iOS.analyticsEvent('editor', Grid.hidden ? 'hide_grid' : 'show_grid');
}

static toggleGrid (b) {
Grid.hide(b);
static setShowGrid (b) {
Grid.hide(!b);
gn('grid').className = Grid.hidden ? 'gridToggle off' : 'gridToggle on';
}

Expand Down
1 change: 1 addition & 0 deletions src/entry/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Record from '../editor/ui/Record';

export function editorMain () {
iOS.getsettings(doNext);
iOS.analyticsEvent('editor', 'project_editor_open');
function doNext (str) {
var list = str.split(',');
iOS.path = list[1] == '0' ? list[0] + '/' : undefined;
Expand Down
9 changes: 7 additions & 2 deletions src/painteditor/Paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ export default class Paint {
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)
// * 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)
// log two events:
// * paint editor is opened
// * type of edit (edit_background, edit_character, new_character)
iOS.analyticsEvent('paint_editor', 'paint_editor_open');
if (bkg) {
action = 'edit_background';
label = (md5 in MediaLib.keys) ? md5 : 'user_background';
Expand Down Expand Up @@ -352,6 +356,7 @@ export default class Paint {
}

static close () {
iOS.analyticsEvent('paint_editor', 'paint_editor_close');
saving = true;
paintFrame.className = 'paintframe disappear';
frame.style.display = 'block';
Expand Down