-
Notifications
You must be signed in to change notification settings - Fork 77
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
Updates GTM datalayer to include all documented details, includes consentMethod in all fides events where applicable #4847
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Passing run #7606 ↗︎Details:
Review all test suite changes for PR #4847 ↗︎ |
…sentMethod in all fides events where applicable
}, | ||
}); | ||
|
||
// TODO- right now we have to use a wait before our cy.waitUntilFidesInitialized() call which is flakey in CI |
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.
we saw a cy.wait working locally, but in CI this sometimes works and sometimes doesn't
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.
I don't really like lingering TODOs like this... I'd prefer you delete this commented out block entirely TBH, the GTM events are pretty well exercised elsewhere.
cy.get("@dataLayerPush") | ||
.its("secondCall.args.0") | ||
.its("Fides.fides_string") | ||
.should("contain", ",1~"); |
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.
partial match and not as part of the assertion on line 681 above, because the fides_string
generated is inconsistent
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 looks pretty solid, a few tweaks here and I think there might be a surprise bug in the FidesInitialized
event fired by the getInitialFides
part of the code...
interface FidesVariable { | ||
consent: NoticeConsent; | ||
} | ||
type FidesVariable = FidesEvent["detail"]; |
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.
✨ I'm glad this worked
@@ -174,6 +174,7 @@ export type FidesJSIdentity = Record<string, string>; | |||
* { | |||
* "version": "0.9.0", | |||
* "createdAt": "2023-01-01T12:00:00.000Z", | |||
* "consentMethod": "accept", |
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.
Nice 👍
@@ -79,6 +79,7 @@ const ConfigDrivenConsent = ({ | |||
}; | |||
}); | |||
const cookie: FidesCookie = getOrMakeFidesCookie(); | |||
cookie.fides_meta.consentMethod = ConsentMethod.SAVE; // include the consentMethod as extra metadata |
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.
Oh, interesting, yes this makes sense too... good eye.
@@ -325,9 +331,32 @@ describe("Consent settings", () => { | |||
analytics: true, | |||
gpc_test: true, | |||
}, | |||
extraDetails: undefined, |
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.
Hmm- why is this? Shouldn't the cookie include consentMethod: "save"
(your test above asserts that)
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.
hm weird. The 2nd init is being populated correctly with "save" but the 1st init is not, and currently trying to debug
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.
Logging it right before we 1st call FidesInitalized
is showing up fine with save
:
console.log(cookie.fides_meta.consentMethod)
dispatchFidesEvent("FidesInitialized", cookie, config.options.debug);
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.
the event log is even looking good, it's just not making it into the dataLayer:
Dispatching event type FidesInitialized with cookie {"consent":{"data_sales":false,"tracking":false,"analytics":true,"gpc_test":true},"identity":{"fides_user_device_id":"9ccb17a8-4104-4968-81a7-db5004350c97"},"fides_meta":{"version":"0.9.0","createdAt":"2024-05-02T10:52:43.981Z","updatedAt":"2024-05-02T10:52:44.367Z","consentMethod":"save"},"tcf_consent":{}} using consent method save
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.
Solved- turns out we have to keep window.Fides
in sync more often because Fides.gtm()
sometimes runs after the init events. In this case we fire a synthetic event that depends on props off of window.Fides. I've additionally updated our test sites to run Fides.gtm()
earlier.
}, | ||
}); | ||
|
||
// TODO- right now we have to use a wait before our cy.waitUntilFidesInitialized() call which is flakey in CI |
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.
I don't really like lingering TODOs like this... I'd prefer you delete this commented out block entirely TBH, the GTM events are pretty well exercised elsewhere.
…consistently, fix tests and CR cleanup
@@ -117,6 +123,7 @@ async function init(this: FidesGlobal, config: FidesConfig) { | |||
}); | |||
if (initialFides) { | |||
Object.assign(this, initialFides); | |||
updateWindowFides(this); |
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.
Our synthetic GTM event (https://github.com/ethyca/fides/pull/4847/files#diff-a04bb0647e72a17425850d5589eee0a2f72b4f239a0d721899cd15029555be6aR62) requires window.Fides to contain up-to-date properties
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 such a subtle footgun! Gah, the state mgmt in FidesJS has a lot of footguns
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.
agreed. This is the flakiest part of FidesJS
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.
Awesome, thanks!
@@ -117,6 +123,7 @@ async function init(this: FidesGlobal, config: FidesConfig) { | |||
}); | |||
if (initialFides) { | |||
Object.assign(this, initialFides); | |||
updateWindowFides(this); |
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 such a subtle footgun! Gah, the state mgmt in FidesJS has a lot of footguns
…sentMethod in all fides events where applicable (#4847)
Closes https://ethyca.atlassian.net/browse/PROD-2006
Description Of Changes
Updates GTM datalayer to include all details documented in our docs
Includes consentMethod in all fides events where applicable
Code Changes
Steps to Confirm
window.dataLayer
entries should include not only your consent vals, but also details likeconsentMethod
where applicablePre-Merge Checklist
CHANGELOG.md