Skip to content

Commit cda242b

Browse files
authored
Gps/aa bools (#489)
* Stringify context vals of type bool * Add tests * LINT
1 parent 6d64aa0 commit cda242b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

integrations/adobe-analytics/lib/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,14 @@ function updateContextData(facade, options) {
620620
return;
621621
}
622622

623+
// If context data values are booleans then stringify them.
624+
// Adobe's SDK seems to reject a false boolean value. Stringifying is
625+
// acceptable since these values are appended as query strings anyway.
626+
if (typeof value === 'boolean') {
627+
addContextDatum(key, value.toString());
628+
return;
629+
}
630+
623631
addContextDatum(key, value);
624632
}, contextProperties);
625633
}

integrations/adobe-analytics/test/index.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,30 @@ describe('Adobe Analytics', function() {
11751175
});
11761176
analytics.equal(window.s.events, 'prodView,event1,event38');
11771177
});
1178+
1179+
it('should stringify bool context data', function() {
1180+
adobeAnalytics.options.contextValues = {
1181+
'page.referrer': 'page.referrer',
1182+
'page.url': 'page.title',
1183+
'page.bickenBack': 'page.bickenBack'
1184+
};
1185+
analytics.track(
1186+
'Drank Some Milk',
1187+
{ foo: 'bar' },
1188+
{ page: { bickenBack: false } }
1189+
);
1190+
analytics.equal(
1191+
window.s.contextData['page.referrer'],
1192+
window.document.referrer
1193+
);
1194+
analytics.equal(
1195+
window.s.contextData['page.title'],
1196+
window.location.href
1197+
);
1198+
analytics.equal(window.s.contextData['page.bickenBack'], 'false');
1199+
analytics.equal(window.s.contextData.foo, 'bar');
1200+
analytics.called(window.s.tl);
1201+
});
11781202
});
11791203
});
11801204

0 commit comments

Comments
 (0)