-
Notifications
You must be signed in to change notification settings - Fork 28
save cross domain identifier cookies from the server as an option #56
Conversation
lib/index.js
Outdated
| var xhr = new XMLHttpRequest(); | ||
| xhr.open('GET', url, true); | ||
| xhr.withCredentials = true; | ||
| xhr.send(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle XHR errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think so - I'm going to update it so that the localStorage value is only set once the HTTP request completes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
lib/index.js
Outdated
|
|
||
| var cachedCrossDomainId = this.getCachedCrossDomainId(); | ||
| if (cachedCrossDomainId) { | ||
| callback(null, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do if(callback) here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated!
we've verified that the legacy cookies are not in use anymore, hence we can get rid of this migration logic to simplify the client side code. here's a link to the same change we made on the server (internal link) https://github.com/segmentio/xid/pull/12.
Previously xid metadata was stored as client side cookies. This change allows us to set the cookies from a server as httpOnly cookies. We also store the identifier in localStorage To allow the current domain to read it from javascript. This is only set if the request completes succesfully. This behaviour is behind a flag `saveCrossDomainIdInLocalStorage` that is off by default. This also removes some of the metadata that we don't use (such as the domain of the cookie and timestamp of the cookie)
Previously cross domain analytics metadata was stored as client side cookies. This change allows us to set the cookies from a server as httpOnly cookies. We also store the identifier in localStorage To allow the current domain to read it from javascript. This behaviour is behind a flag
saveCrossDomainIdInLocalStoragethat is off by default.This also removes some of the extraneous metadata that we don't use (such as the domain of the cookie and timestamp of the cookie), and also removes code to migrate legacy cookies.