Skip to content

Instantly share code, notes, and snippets.

@pimeo
Created January 11, 2017 10:28
Show Gist options
  • Save pimeo/38c18bea7a817f52f01f10c171c02f69 to your computer and use it in GitHub Desktop.
Save pimeo/38c18bea7a817f52f01f10c171c02f69 to your computer and use it in GitHub Desktop.
Tracking UBI Class
'use strict'
import Store from 'stores/store'
const TRACKING = {
DEBUG: true,//"<%= global.environment %>".match(/development/gi),
PAGES: {
// heroes xp
AGE_GATE: { ss: 'Loader Pages', sss: '', p: 'Age Gate' },
HEROES_EXPERIENCE_READY: { ss: 'Loader Pages', sss: '', p: 'Experience Ready' },
// see outdated.html
// BROWSER_NOT_COMPATIBLE: { ss: 'Error Pages', sss: '', p: 'Browser not compatible' },
// PHONE_NOT_COMPATIBLE: { ss: 'Error Pages', sss: '', p: 'Phone not compatible' },
HEROES_EXPERIENCE_START: { ss: 'Scars', sss: '', p: 'Experience Start' },
// warrior: <The Warden / The Kensei / The Raider>
HEROES_PRESENTATION: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Heroes Presentation' } },
HEROES_LEARN_MORE: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Heroes - Learn More' } },
HEROES_SELECTED: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Heroes - Selected' } },
SCARS_1: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Scars 1' } },
SCARS_2: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Scars 2' } },
SWITCH_1: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Switch 1' } },
SCARS_3: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Scars 3' } },
SWITCH_2: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Switch 2' } },
SCARS_4: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Scars 4' } },
DEATH: function( warrior ) { return { ss: 'Scars', sss: warrior, p: 'Death' } },
// customization
WEAPON_HOMEPAGE: { ss: 'Loader Pages - Weapons', sss: '', p: 'Weapons Homepage' },
WEAPON_EXPERIENCE_READY: { ss: 'Loader Pages - Weapons', sss: '', p: 'Experience Ready' },
// weapon: <Nodachi / Axe / Sword>
WEAPON_EXPERIENCE_START: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Experience Start' } },
WEAPON_PRESENTATION: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Weapon - Presentation' } },
WEAPON_SELECTED: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Weapon - Selected' } },
WEAPON_VALIDATED: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Weapon - Validated' } },
WEAPON_OBTAIN_BETA_KEY: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Obtain Beta Key' } },
WEAPON_BETA_KEY_SUCCESSFULL: function( weapon ) { return { ss: 'Weapons', sss: weapon, p: 'Beta Key Successfull' } },
},
EVENTS: {
LOADER_25 : { c: 'Loader', a: 'Loading 25%' },
LOADER_50 : { c: 'Loader', a: 'Loading 50%' },
LOADER_75 : { c: 'Loader', a: 'Loading 75%' },
AGE_GATE_VALIDATION : { c: 'Navigation', a: 'Age Gate Validation' },
SKIP_INTRO : { c: 'Action', a: 'Skip Introduction' },
SOUND_ON : { c: 'Action', a: 'Sound - on' },
SOUND_OFF : { c: 'Action', a: 'Sound - off' },
CREDITS : { c: 'Navigation', a: 'Credits' },
MENU : { c: 'Navigation', a: 'Menu' },
VIEW_ALL_HEROES : { c: 'Navigation', a: 'View all heroes' },
VIEW_ALL_WEAPONS : { c: 'Navigation', a: 'View all weapons' },
BACK_TO_WARRIORS : { c: 'Navigation', a: 'Back to warriors' },
SHARE_WEAPON : function( social, weapon ) { return { c: 'Social', a: 'Share Weapon - ' + social + ' - ' + weapon } },
// handle
HILT_CHANGE : { c: 'Action', a: 'Hilt Change' },
// guard
CROSS_GUARD_CHANGE : { c: 'Action', a: 'Cross Guard Change' },
// blade
BLADE_CHANGE : { c: 'Action', a: 'Blade Change' }
},
/**
* Send tracking page event
* @param {Object} page PAGES key Object
*/
sendPage( page ) {
let tc_params = {
'ACTION': page.p,
'SITESECTION': page.ss,
'SUBSITESECTION': page.sss,
'XPCUSTOM': '', // Progression level
'COUNTRY': '<%= global.locale.split("-")[1] %>',
'LANGUAGE': '<%= global.locale.split("-")[0] %>',
'UPLAYID': Store.ubisoftProfile.userId || ''
}
if( this.DEBUG ) console.debug( '[TRACKING]', 'pagevent', tc_params )
if( window.tc_events_100 ) {
if( this.DEBUG ) console.debug( '[TRACKING]', 'event sent' )
tc_events_100( this, 'pageevent', tc_params )
}
},
/**
* Send tracking click event
* @param {Object} event EVENTS key Object
*/
sendEvent( event ) {
let tc_params = { 'ACTION': [ 'For Honor', 'SCARS', event.c, event.a ].join( ' - ' ) }
if( this.DEBUG ) console.debug( '[TRACKING]', 'clickevent', tc_params )
if( window.tc_events_100 ) {
if( this.DEBUG ) console.debug( '[TRACKING]', 'event sent' )
tc_events_100( this, 'clickevent', tc_params )
}
},
}
module.exports = TRACKING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment