|
71 | 71 | * 8. userFingerprintSeed, 123412414
|
72 | 72 | * 9. pageUnloadTimer, 500
|
73 | 73 | * 10. forceSecureTracker, false
|
74 |
| - * 11. writeCookies, true |
| 74 | + * 11. useLocalStorage, true |
| 75 | + * 12. useCookies, true |
| 76 | + * 13. writeCookies, true |
75 | 77 | */
|
76 | 78 | object.Tracker = function Tracker(functionName, namespace, version, mutSnowplowState, argmap) {
|
77 | 79 |
|
|
165 | 167 | // This forces the tracker to be HTTPS even if the page is not secure
|
166 | 168 | forceSecureTracker = argmap.hasOwnProperty('forceSecureTracker') ? (argmap.forceSecureTracker === true) : false,
|
167 | 169 |
|
| 170 | + // Whether to use localStorage to store events between sessions while offline |
| 171 | + useLocalStorage = argmap.hasOwnProperty('useLocalStorage') ? argmap.useLocalStorage : true, |
| 172 | + |
| 173 | + // Whether to use cookies |
| 174 | + configUseCookies = argmap.hasOwnProperty('useCookies') ? argmap.useCookies : true, |
168 | 175 |
|
169 | 176 | // Browser language (or Windows language for IE). Imperfect but CloudFront doesn't log the Accept-Language header
|
170 | 177 | browserLanguage = navigatorAlias.userLanguage || navigatorAlias.language,
|
171 | 178 |
|
172 | 179 | // Browser features via client-side data collection
|
173 |
| - browserFeatures = detectors.detectBrowserFeatures(getSnowplowCookieName('testcookie')), |
| 180 | + browserFeatures = detectors.detectBrowserFeatures(configUseCookies, getSnowplowCookieName('testcookie')), |
174 | 181 |
|
175 | 182 | // Visitor fingerprint
|
176 | 183 | userFingerprint = (argmap.userFingerprint === false) ? '' : detectors.detectSignature(configUserFingerprintHashSeed),
|
|
213 | 220 | formTrackingManager = forms.getFormTrackingManager(core, trackerId),
|
214 | 221 |
|
215 | 222 | // Manager for local storage queue
|
216 |
| - outQueueManager = new requestQueue.OutQueueManager(functionName, namespace, mutSnowplowState); |
| 223 | + outQueueManager = new requestQueue.OutQueueManager(functionName, namespace, mutSnowplowState, useLocalStorage); |
217 | 224 |
|
218 | 225 |
|
219 | 226 | // Enable base 64 encoding for unstructured events and custom contexts
|
|
326 | 333 |
|
327 | 334 | for (var contextKey in lowPriorityKeys) {
|
328 | 335 | if (request.hasOwnProperty(contextKey) && lowPriorityKeys.hasOwnProperty(contextKey)) {
|
329 |
| - querystring += '&' + contextKey + '=' + request[contextKey]; |
| 336 | + querystring += '&' + contextKey + '=' + encodeURIComponent(request[contextKey]); |
330 | 337 | }
|
331 | 338 | }
|
332 | 339 |
|
|
442 | 449 | * Load visitor ID cookie
|
443 | 450 | */
|
444 | 451 | function loadDomainUserIdCookie() {
|
| 452 | + if (!configUseCookies) { |
| 453 | + return []; |
| 454 | + } |
445 | 455 | var now = new Date(),
|
446 | 456 | nowTs = Math.round(now.getTime() / 1000),
|
447 | 457 | id = getSnowplowCookieValue('id'),
|
|
497 | 507 | currentVisitTs = id[4],
|
498 | 508 | lastVisitTs = id[5];
|
499 | 509 |
|
500 |
| - if (configDoNotTrack && configWriteCookies) { |
| 510 | + if (configDoNotTrack && configUseCookies && configWriteCookies) { |
501 | 511 | cookie.cookie(idname, '', -1, configCookiePath, configCookieDomain);
|
502 | 512 | cookie.cookie(sesname, '', -1, configCookiePath, configCookieDomain);
|
503 | 513 | return;
|
504 | 514 | }
|
505 | 515 |
|
506 | 516 | // New session?
|
507 |
| - if (!ses) { |
| 517 | + if (!ses && configUseCookies) { |
508 | 518 | // New session (aka new visit)
|
509 | 519 | visitCount++;
|
510 | 520 | // Update the last visit timestamp
|
|
529 | 539 |
|
530 | 540 |
|
531 | 541 | // Update cookies
|
532 |
| - if (configWriteCookies) { |
| 542 | + if (configUseCookies && configWriteCookies) { |
533 | 543 | setDomainUserIdCookie(_domainUserId, createTs, visitCount, nowTs, lastVisitTs);
|
534 | 544 | cookie.cookie(sesname, '*', configSessionCookieTimeout, configCookiePath, configCookieDomain);
|
535 | 545 | }
|
|
650 | 660 | function logPagePing(pageTitle, context) {
|
651 | 661 | resetMaxScrolls();
|
652 | 662 | core.trackPagePing(purify(configCustomUrl || locationHrefAlias), pageTitle, purify(configReferrerUrl),
|
653 |
| - minXOffset, maxXOffset, minYOffset, maxYOffset, context); |
| 663 | + Math.round(minXOffset), Math.round(maxXOffset), Math.round(minYOffset), Math.round(maxYOffset), context); |
654 | 664 | }
|
655 | 665 |
|
656 | 666 | /**
|
|
785 | 795 | return loadDomainUserIdCookie();
|
786 | 796 | },
|
787 | 797 |
|
| 798 | + /** |
| 799 | + * Get the user fingerprint |
| 800 | + * |
| 801 | + * @return string The user fingerprint |
| 802 | + */ |
| 803 | + getUserFingerprint: function () { |
| 804 | + return userFingerprint; |
| 805 | + }, |
| 806 | + |
788 | 807 | /**
|
789 | 808 | * Specify the app ID
|
790 | 809 | *
|
|
0 commit comments