-
Notifications
You must be signed in to change notification settings - Fork 261
Update Cookie Storage #998
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
base: master
Are you sure you want to change the base?
Conversation
| export const enum ConsentSource { | ||
| Implicit = 0, | ||
| API = 1, | ||
| GCM = 2 |
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.
Could we add APIV1 vs. APIV2 at the same time or in a separate PR (if you prefer that).
| analytics_Storage: config.track ? Constant.Granted : Constant.Denied, | ||
| source: u.consent || u.ad_consent ? ConsentSource.Cookie : ConsentSource.Implicit, | ||
| ad_Storage: u.ad_consent || (config.track && consentStatus.source != ConsentSource.Cookie) ? Constant.Granted : Constant.Denied, | ||
| analytics_Storage: u.consent || config.track ? Constant.Granted : Constant.Denied, |
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.
| analytics_Storage: config.track ? Constant.Granted : Constant.Denied, | ||
| source: u.consent || u.ad_consent ? ConsentSource.Cookie : ConsentSource.Implicit, | ||
| ad_Storage: u.ad_consent || (config.track && consentStatus.source != ConsentSource.Cookie) ? Constant.Granted : Constant.Denied, | ||
| analytics_Storage: u.consent || config.track ? Constant.Granted : Constant.Denied, |
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.
| ad_Storage: config.track ? Constant.Granted : Constant.Denied, | ||
| analytics_Storage: config.track ? Constant.Granted : Constant.Denied, | ||
| source: u.consent || u.ad_consent ? ConsentSource.Cookie : ConsentSource.Implicit, | ||
| ad_Storage: u.ad_consent || (config.track && consentStatus.source != ConsentSource.Cookie) ? Constant.Granted : Constant.Denied, |
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.
Can you explain this logic?
Style nit: This name is a bit confusing. Better would be something like "currentCurreent' consent or similar. Unify everything to state not status as well in naming things. Refers to: packages/clarity-js/src/data/metadata.ts:18 in 46911be. [](commit_id = 46911be, deletion_comment = False) |
| if (core.active() && consentData.analytics_Storage) { | ||
| config.track = true; | ||
| track(user(), BooleanFlag.True); | ||
| track(user(), consentData.analytics_Storage, consentData.ad_Storage); |
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.
Minor: Might be clean to just pass the cseontnData as a single argument not splitting it up here into separate arg (enables us to add more permissions later). And lot of bool parameters are easy to get wrong (order, etc.).
| } | ||
| } | ||
|
|
||
| function track(u: User, consent: BooleanFlag = null): void { |
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.
Rename to analytics to make it unambiguous. Consent own its own is too ambiguous.
| if (u.expiry === null || Math.abs(end - u.expiry) >= Setting.CookieInterval || u.consent !== consent || u.dob !== dob) { | ||
| let cookieParts = [data.userId, Setting.CookieVersion, end.toString(36), consent, dob]; | ||
| if (u.expiry === null || Math.abs(end - u.expiry) >= Setting.CookieInterval || u.consent !== consent || u.ad_consent != ad_consent || u.dob !== dob) { | ||
| let cookieParts = [data.userId, Setting.CookieVersion, end.toString(36), consent, ad_consent, dob]; |
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.
This is not backwards/forwards compatible. Better to append to end. Think about how this work in current client (or older) and newer ones in all combination (older cookie, new client) and (new cookies, old client).
Update cookie consent to store ad storage as well