Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdagioRtdProvider: add new property in adg_rtd.session object #12450

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/adagioRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ const _SESSION = (function() {

storage.getDataFromLocalStorage('adagio', (storageValue) => {
// session can be an empty object
const { rnd, new: isNew = false, vwSmplg, vwSmplgNxt, lastActivityTime, id, testName, testVersion, initiator } = _internal.getSessionFromLocalStorage(storageValue);
const { rnd, new: isNew = false, vwSmplg, vwSmplgNxt, lastActivityTime, id, testName, testVersion, initiator, pages } = _internal.getSessionFromLocalStorage(storageValue);

// isNew can be `true` if the session has been initialized by the A/B test snippet (external)
const isNewSess = (initiator === 'snippet') ? isNew : isNewSession(lastActivityTime);

data.session = {
rnd,
pages: pages || 1,
new: isNewSess, // legacy: `new` was used but the choosen name is not good.
// Don't use values if they are not defined.
...(vwSmplg !== undefined && { vwSmplg }),
Expand Down Expand Up @@ -685,6 +686,7 @@ function registerEventsForAdServers(config) {
* @property {number} vwSmplg - View sampling rate.
* @property {number} vwSmplgNxt - Next view sampling rate.
* @property {number} lastActivityTime - Last activity time.
* @property {number} pages - current number of pages seen.
*/

/**
Expand Down
15 changes: 10 additions & 5 deletions test/spec/modules/adagioRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ describe('Adagio Rtd Provider', function () {
id: 'uid-1234',
rnd: 0.5697,
vwSmplg: 0.1,
vwSmplgNxt: 0.1
vwSmplgNxt: 0.1,
pages: 1
};

it('store new session data for further usage', function () {
Expand All @@ -139,7 +140,8 @@ describe('Adagio Rtd Provider', function () {
session: {
new: true,
id: utils.generateUUID(),
rnd: Math.random()
rnd: Math.random(),
pages: 1,
}
}

Expand Down Expand Up @@ -211,7 +213,8 @@ describe('Adagio Rtd Provider', function () {
vwSmplgNxt: 0.1,
testName: 'adg-test',
testVersion: 'srv',
initiator: 'snippet'
initiator: 'snippet',
pages: 1
};

it('store new session data instancied by the AB Test snippet for further usage', function () {
Expand Down Expand Up @@ -591,7 +594,8 @@ describe('Adagio Rtd Provider', function () {
'new': true,
'rnd': 0.020644826280300954,
'vwSmplg': 0.1,
'vwSmplgNxt': 0.1
'vwSmplgNxt': 0.1,
'pages': 1
}
}
}
Expand All @@ -617,7 +621,8 @@ describe('Adagio Rtd Provider', function () {
'new': true,
'rnd': 0.020644826280300954,
'vwSmplg': 0.1,
'vwSmplgNxt': 0.1
'vwSmplgNxt': 0.1,
'pages': 1
}
}
}
Expand Down