diff --git a/src/utils/AppUsage.js b/src/utils/AppUsage.js index 9131049..0818e10 100644 --- a/src/utils/AppUsage.js +++ b/src/utils/AppUsage.js @@ -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 + '::'; } }