Skip to content

Conversation

@Niyibitanga
Copy link
Contributor

Update cookie consent to store ad storage as well

export const enum ConsentSource {
Implicit = 0,
API = 1,
GCM = 2
Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i

What is u.consent storing?

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t

Style nit: Put parenthesis around the ?: to make the precedence clear.

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,
Copy link
Member

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?

@toby-walker
Copy link
Member

let consentStatus: ConsentState = null;

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);
Copy link
Member

@toby-walker toby-walker Dec 12, 2025

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 {
Copy link
Member

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];
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants