Skip to content

Commit

Permalink
WEB-1471:FIX: Bug introduced by compiler due to renaming of opts.cust…
Browse files Browse the repository at this point in the history
…omSession.uuid property name because it matched a top lvel import
  • Loading branch information
snipebin committed Apr 4, 2018
1 parent c98b83e commit 49f95ee
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ga-autotrack-ids.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ga-autotrack-ids.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/externs/session-id-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* customDimensionIndex: (number),
* customSession: (Object),
* customSession.customDimensionIndex: (number),
* customSession.uuid: (string),
* customSession.id: (string),
* }}
*/
var SessionIdTrackerOpts;
Expand Down
12 changes: 6 additions & 6 deletions lib/plugins/session-id-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SessionIdTracker {
throw new Error(`The SessionIdTracker plugin requires a
customDimensionIndex to store the auto generated uuid value in
or a customSession object with customDimensionIndex number and
uuid string. You can use both. Please provide the options when requiring
id string. You can use both. Please provide the options when requiring
the plugin.`);
}

Expand All @@ -37,19 +37,19 @@ class SessionIdTracker {
if (SessionIdTracker.validateCustomSessionOpts(opts)) {
tracker.set(
'dimension' + opts.customSession.customDimensionIndex,
opts.customSession.uuid
opts.customSession.id
);
}
}

/**
* Validates the type of the uuid property passed in opts.
* Validates the type of the id property passed in opts.
* @param {!SessionIdTrackerOpts} opts Passed by the require command.
* @return {boolean} Indicates if uuid property passed in is valid.
* @return {boolean} Indicates if id property passed in is valid.
*/
static validateCustomSessionOpts(opts) {
return typeof opts.customSession.customDimensionIndex === 'number'
&& typeof opts.customSession.uuid === 'string';
return (typeof opts.customSession === 'object' && typeof opts.customSession.customDimensionIndex === 'number'
&& typeof opts.customSession.id === 'string');
}

/**
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/fixtures/ga-autotrack-ids-sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@
ga('require', 'gaTaskManager');

// Add a function to customTask
ga('GaTaskManager:addFunctionToTask', 'customTask', 'logShinyString', function(model){
ga('gaTaskManager:addFunctionToTask', 'customTask', 'logShinyString', function(model){
console.log("Look at my shiny new random customTask");
});

ga('require', 'ClientIdTracker', {
ga('require', 'clientIdTracker', {
customDimensionIndex: 1
});
ga('require', 'SessionIdTracker', {
ga('require', 'sessionIdTracker', {
customDimensionIndex: 2,
customSession: {
customDimensionIndex: 5,
uuid: 'MY-UUID'
id: 'MY-UUID'
}
});
ga('require', 'HitIdTracker', {
ga('require', 'hitIdTracker', {
customDimensionIndex: 3
});
ga('require', 'HitTimestampTracker', {
ga('require', 'hitTimestampTracker', {
customDimensionIndex: 4
});

Expand Down

0 comments on commit 49f95ee

Please sign in to comment.