mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-02-17 17:01:12 -05:00
Add documentation for AppUsage
Also make ternary operators easier to read.
This commit is contained in:
parent
7a530be88b
commit
0f2c31bfc9
1 changed files with 15 additions and 2 deletions
|
@ -7,22 +7,35 @@ export default class AppUsage {
|
||||||
return currentUsage;
|
return currentUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize currentUsage for attaching to Analytics events from
|
||||||
|
* the usage cookie if it is set. currentUsage is blank if the cookie is
|
||||||
|
* not set.
|
||||||
|
*/
|
||||||
static initUsage () {
|
static initUsage () {
|
||||||
const usageCookie = Cookie.get('usage');
|
const usageCookie = Cookie.get('usage');
|
||||||
currentUsage = usageCookie ? usageCookie + '::' : '';
|
currentUsage = (usageCookie) ? usageCookie + '::' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the App should ask for the usage data (first time launched)
|
||||||
|
* @return {boolean} True if the usage cookie has never been set
|
||||||
|
*/
|
||||||
static askForUsage () {
|
static askForUsage () {
|
||||||
var usageCookie = Cookie.get('usage');
|
var usageCookie = Cookie.get('usage');
|
||||||
return usageCookie === null;
|
return usageCookie === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the usage cookie for tracking Analytics Events
|
||||||
|
* @param {string} kind answer from user to the usage survey (home, school, other, noanswer)
|
||||||
|
*/
|
||||||
static setUsage (kind) {
|
static setUsage (kind) {
|
||||||
if (kind === '') {
|
if (kind === '') {
|
||||||
Cookie.set('usage', 'noanswer');
|
Cookie.set('usage', 'noanswer');
|
||||||
} else {
|
} else {
|
||||||
Cookie.set('usage', kind);
|
Cookie.set('usage', kind);
|
||||||
}
|
}
|
||||||
currentUsage = kind === 'noanswer' ? '' : '_' + kind;
|
currentUsage = (kind === '') ? 'noanswer::' : kind + '::';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue