-
Notifications
You must be signed in to change notification settings - Fork 510
feat: add cloud gtm injection #8311
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
Changes from 9 commits
65bc3b1
43f6251
ef1c55b
c43d4aa
c1cb37c
35d81c6
3d17edd
a0e840c
bb0abe7
b0b1f6f
8d1ff4e
51e7291
02a4d3e
cea03a5
7bdd527
cba42e2
523f1c4
62968f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,6 +36,17 @@ function getBasePath(): string { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const basePath = getBasePath() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| function pushPageView(): void { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!isCloud) return | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const dataLayer = window.dataLayer ?? (window.dataLayer = []) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dataLayer.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| event: 'page_view', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| page_location: window.location.href, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| page_title: document.title | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+48
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential timing issue with When Consider using 🔧 Suggested fix using nextTick+import { nextTick } from 'vue'
+
function pushPageView(): void {
if (!isCloud) return
- const dataLayer = window.dataLayer ?? (window.dataLayer = [])
- dataLayer.push({
- event: 'page_view',
- page_location: window.location.href,
- page_title: document.title
+ nextTick(() => {
+ const dataLayer = window.dataLayer ?? (window.dataLayer = [])
+ dataLayer.push({
+ event: 'page_view',
+ page_location: window.location.href,
+ page_title: document.title
+ })
})
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, we'll see what marketing/gtm wants. we pagetitle is practically only ever going to be ComfyUI because we only change it for workflow name, unsaved indicator, and node/progress status.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
✏️ Learnings added
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| const router = createRouter({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| history: isFileProtocol | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ? createWebHashHistory() | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -93,6 +104,10 @@ installPreservedQueryTracker(router, [ | |||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| router.afterEach(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| pushPageView() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isCloud) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const { flags } = useFeatureFlags() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const PUBLIC_ROUTE_NAMES = new Set([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -81,6 +81,31 @@ export const useFirebaseAuthStore = defineStore('firebaseAuth', () => { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const buildApiUrl = (path: string) => `${getComfyApiBaseUrl()}${path}` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const pushDataLayerEvent = (event: Record<string, unknown>) => { | ||||||||||||||||||||||||||||||
| if (!isCloud || typeof window === 'undefined') return | ||||||||||||||||||||||||||||||
| const dataLayer = window.dataLayer ?? (window.dataLayer = []) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| const pushDataLayerEvent = (event: Record<string, unknown>) => { | |
| if (!isCloud || typeof window === 'undefined') return | |
| const dataLayer = window.dataLayer ?? (window.dataLayer = []) | |
| const getDataLayer = (): unknown[] | undefined => { | |
| if (!isCloud || typeof window === 'undefined') return | |
| // Initialize dataLayer if it does not exist yet | |
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | |
| const dataLayer = (window as any).dataLayer ?? ((window as any).dataLayer = []) | |
| return dataLayer | |
| } | |
| const pushDataLayerEvent = (event: Record<string, unknown>) => { | |
| const dataLayer = getDataLayer() | |
| if (!dataLayer) return |
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 think it's fine for now just two callers
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.
Because
pushPageViewsendswindow.location.hrefaspage_location, any invite tokens in the query string are forwarded to GTM. The cloud invite flow explicitly accepts/?invite=TOKENand only removes it later inuseInviteUrlLoader(so the token is still present on the first navigation), which means the raw invite token will be sent to third‑party analytics on the initial page_view. To avoid leaking sensitive invite codes, consider sanitizingpage_location(e.g., removeinviteand other preserved query params) before pushing todataLayer.Useful? React with 👍 / 👎.