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

Disable cookies option #235

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename variable
  • Loading branch information
Jeremy Garey committed Jul 25, 2023
commit 5072f401ae2fe88072deb95a4fcf4b5ef4c5f785
3 changes: 3 additions & 0 deletions docs/auto-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ client.initAutoTracking({

// allow cookies to be placed on user's browser
useSessionCookies: true // default

// prevent cookies from being added on the user's browser
disableCookies: false // default
});
```

Expand Down
11 changes: 6 additions & 5 deletions lib/browser-auto-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function initAutoTrackingCore(lib) {
collectUuid: true,
recordElementViews: true,
catchError: undefined, // optional, function(someError) - error handler
useSessionCookies: true,
disableCookies: false,
}, obj);

if (client.config.requestType === 'beaconAPI' && options.catchError) {
Expand Down Expand Up @@ -69,8 +69,9 @@ export function initAutoTrackingCore(lib) {
}
}

if (options.useSessionCookies) {
const cookie = new utils.cookie('keen');
let cookie;
if (!options.disableCookies) {
cookie = new utils.cookie('keen');
}

const domainName = helpers.getDomainName(window.location.hostname);
Expand All @@ -79,7 +80,7 @@ export function initAutoTrackingCore(lib) {
} : {};

let uuid;
if (options.collectUuid && options.useSessionCookies) {
if (options.collectUuid && !options.disableCookies) {
uuid = cookie.get('uuid');
if (!uuid) {
uuid = helpers.getUniqueId();
Expand All @@ -88,7 +89,7 @@ export function initAutoTrackingCore(lib) {
}

let initialReferrer;
if (options.useSessionCookies) {
if (!options.disableCookies) {
initialReferrer = cookie.get('initialReferrer');
if (!initialReferrer){
initialReferrer = document && document.referrer || undefined;
Expand Down