Skip to content

Commit

Permalink
feat: as a dev I want control over using local storage to store the s…
Browse files Browse the repository at this point in the history
…ession id
  • Loading branch information
demetriusj committed Apr 14, 2015
1 parent afd29ac commit fde95a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/config/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//"filter": "^(statsd|warn|error|info|uncaught-exception)$", list of types sent back to the server from the client if not set return all
"debug": "^(statsd|warn|error|info|uncaught-exception)$", // list of type that should be sent to console.debug if not set do not debug
"cookie": "_sid",
"lstorage": true, // use local storage and a cookie
"url": "/__idat" // or //foobar.com/__idat
}
// "abnDashboardUrl": "/__abn"
Expand Down
10 changes: 8 additions & 2 deletions src/instrumentation/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ if(process.env.BROWSER_ENV) {

sessionId = pellet.cookie.get(sessionKey);
if (!sessionId || forceRegenerate) {
sessionId = localStorage.getItem(sessionKey);
if(pellet.config.instrumentation.lstorage) {
sessionId = localStorage.getItem(sessionKey);
}

if(!sessionId || forceRegenerate) {
sessionId = 'pID:' + s4() + s4() + s4() + '-' + s4();
}
Expand All @@ -44,7 +47,10 @@ if(process.env.BROWSER_ENV) {
}
}

localStorage.setItem(sessionKey, sessionId);
if(pellet.config.instrumentation.lstorage) {
localStorage.setItem(sessionKey, sessionId);
}

pellet.cookie.set(sessionKey, sessionId);

return true;
Expand Down

0 comments on commit fde95a0

Please sign in to comment.