mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-25 00:28:20 -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 () {
|
||||
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 () {
|
||||
var usageCookie = Cookie.get('usage');
|
||||
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) {
|
||||
if (kind === '') {
|
||||
Cookie.set('usage', 'noanswer');
|
||||
} else {
|
||||
Cookie.set('usage', kind);
|
||||
}
|
||||
currentUsage = kind === 'noanswer' ? '' : '_' + kind;
|
||||
currentUsage = (kind === '') ? 'noanswer::' : kind + '::';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue