Skip to content
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

Merged
merged 3 commits into from
Nov 3, 2022
Merged

fix: Anonymize safe address on gtm init #1041

merged 3 commits into from
Nov 3, 2022

Conversation

usame-algan
Copy link
Member

What it solves

Resolves #1034

How this PR fixes it

Sets anonymized path and location in dataLayer when initializing GTM

How to test it

  1. Open the Safe with DebugView
  2. Reload the page
  3. Scroll around
  4. Observe a user_engagement event with anonymized path and location values

Screenshots

Screenshot 2022-11-03 at 09 10 30

Screenshot 2022-11-03 at 09 10 33

@usame-algan usame-algan requested a review from iamacook November 3, 2022 08:37
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 3, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3b4a736
Status: ✅  Deploy successful!
Preview URL: https://2d4c5f95.web-core.pages.dev
Branch Preview URL: https://anon-pathname.web-core.pages.dev

View logs

@github-actions
Copy link

github-actions bot commented Nov 3, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

TagManager.initialize({
gtmId: GOOGLE_TAG_MANAGER_ID,
...GTM_ENVIRONMENT,
dataLayer: {
pageLocation: `${location.origin}${pagePath}`,
Copy link
Member

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.

Copy link
Member Author

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
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 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
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 being used anymore.

@usame-algan usame-algan merged commit 5b3b1dc into dev Nov 3, 2022
@usame-algan usame-algan deleted the anon-pathname branch November 3, 2022 10:09
@usame-algan usame-algan mentioned this pull request Nov 3, 2022
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.

GA is tracking user_engamenet
2 participants