-
Notifications
You must be signed in to change notification settings - Fork 483
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
fix: Anonymize safe address on gtm init #1041
Conversation
Deploying with
|
Latest commit: |
3b4a736
|
Status: | ✅ Deploy successful! |
Preview URL: | https://2d4c5f95.web-core.pages.dev |
Branch Preview URL: | https://anon-pathname.web-core.pages.dev |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
TagManager.initialize({ | ||
gtmId: GOOGLE_TAG_MANAGER_ID, | ||
...GTM_ENVIRONMENT, | ||
dataLayer: { | ||
pageLocation: `${location.origin}${pagePath}`, |
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.
In my tests, router.pathname
doesn't include our rewrites. We could pass it as an argument to gtmInit
and then not need anonymise the pathname
.
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.
Good idea! It works nicely although we have to exclude it from the dependency array but I think it should be fine since it is only needed on the initial load.
@@ -19,7 +19,8 @@ const useGtm = () => { | |||
|
|||
// Initialize GTM, or clear it if analytics is disabled | |||
useEffect(() => { | |||
isAnalyticsEnabled ? gtmInit() : gtmClear() | |||
isAnalyticsEnabled ? gtmInit(router.pathname) : gtmClear() | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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 add a comment why we need to do this please.
src/utils/url.ts
Outdated
@@ -5,7 +5,8 @@ const trimTrailingSlash = (url: string): string => { | |||
const isSameUrl = (url1: string, url2: string): boolean => { | |||
return trimTrailingSlash(url1) === trimTrailingSlash(url2) | |||
} | |||
|
|||
export const prefixedAddressRe = /[a-z0-9-]+\:0x[a-f0-9]{40}/i | |||
export const addressRe = /0x[a-f0-9]{40}/i |
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 being used anymore.
What it solves
Resolves #1034
How this PR fixes it
Sets anonymized path and location in dataLayer when initializing GTM
How to test it
user_engagement
event with anonymized path and location valuesScreenshots