Skip to content

[backport cloud/1.38] fix: route gtm through telemetry entrypoint#8714

Draft
benceruleanlu wants to merge 1 commit intocloud/1.38from
backport-8354-to-cloud-1.38
Draft

[backport cloud/1.38] fix: route gtm through telemetry entrypoint#8714
benceruleanlu wants to merge 1 commit intocloud/1.38from
backport-8354-to-cloud-1.38

Conversation

@benceruleanlu
Copy link
Member

@benceruleanlu benceruleanlu commented Feb 7, 2026

Backport of #8354 to cloud/1.38.

Conflict resolution:

  • src/platform/workflow/management/stores/workflowStore.ts: kept the PR-side ComfyWorkflow extraction to comfyWorkflow.ts and retained target-branch behavior for the rest of the store.

@benceruleanlu benceruleanlu requested a review from a team as a code owner February 7, 2026 10:23
Copilot AI review requested due to automatic review settings February 7, 2026 10:23
@benceruleanlu benceruleanlu added the backport Backporting a PR onto a release candidate label Feb 7, 2026
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 7, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • backport

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backport-8354-to-cloud-1.38

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🎭 Playwright Tests: ⚠️ Passed with flaky tests

Results: 497 passed, 0 failed, 5 flaky, 8 skipped (Total: 510)

❌ Failed Tests

📊 Browser Reports
  • chromium: View Report (✅ 485 / ❌ 0 / ⚠️ 5 / ⏭️ 8)
  • chromium-2x: View Report (✅ 2 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • chromium-0.5x: View Report (✅ 1 / ❌ 0 / ⚠️ 0 / ⏭️ 0)
  • mobile-chrome: View Report (✅ 9 / ❌ 0 / ⚠️ 0 / ⏭️ 0)

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

🎨 Storybook Build Status

Build completed successfully!

⏰ Completed at: 02/07/2026, 10:24:20 AM UTC

🔗 Links


🎉 Your Storybook is ready for review!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backport to cloud/1.38 that extends the cloud telemetry pipeline to route GTM through a centralized telemetry entrypoint, and enriches checkout/auth events with GA identity + attribution so backend can correlate events without frontend cookie parsing.

Changes:

  • Introduces a telemetry registry/dispatcher with cloud-only initialization, registering Mixpanel + new GTM provider.
  • Adds checkout attribution capture (GA identity + click IDs) and includes it in both begin_checkout telemetry and checkout POST bodies.
  • Refactors ComfyWorkflow into its own module and updates related imports.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/stores/subgraphStore.ts Updates workflow type/class imports after ComfyWorkflow extraction.
src/stores/firebaseAuthStore.ts Adds user_id to auth telemetry metadata for cloud builds.
src/router.ts Adds SPA page_view telemetry on route changes (cloud only).
src/platform/workflow/management/stores/workflowStore.ts Removes embedded ComfyWorkflow implementation; re-exports from new module.
src/platform/workflow/management/stores/comfyWorkflow.ts New ComfyWorkflow module (with lazy imports for some dependencies).
src/platform/telemetry/utils/checkoutAttribution.ts New utility to read/persist click IDs and read GA identity from window.__ga_identity__.
src/platform/telemetry/utils/tests/checkoutAttribution.test.ts Adds tests for checkout attribution behavior.
src/platform/telemetry/types.ts Extends telemetry types (page view + begin checkout + optional provider methods) and adds dispatcher type.
src/platform/telemetry/providers/cloud/GtmTelemetryProvider.ts New GTM provider pushing events to dataLayer and loading GTM script when configured.
src/platform/telemetry/initTelemetry.ts Cloud-only telemetry initialization (registry + providers).
src/platform/telemetry/index.ts Replaces singleton provider with registry setter/getter (useTelemetry).
src/platform/telemetry/TelemetryRegistry.ts New dispatcher that fans out telemetry calls to registered providers.
src/platform/remoteConfig/types.ts Adds gtm_container_id to runtime remote config typing.
src/platform/cloud/subscription/utils/subscriptionCheckoutUtil.ts Adds attribution JSON body to checkout POST + tracks begin_checkout.
src/platform/cloud/subscription/utils/subscriptionCheckoutUtil.test.ts Adds tests for attribution payload + begin_checkout tracking.
src/platform/cloud/subscription/composables/useSubscriptionCancellationWatcher.ts Updates telemetry typing to dispatcher.
src/platform/cloud/subscription/composables/useSubscriptionCancellationWatcher.test.ts Updates telemetry typing to dispatcher.
src/platform/cloud/subscription/composables/useSubscription.ts Minor refactors (store reference + function style).
src/platform/cloud/subscription/composables/useSubscription.test.ts Updates test harness to use effect scopes + updated mocks.
src/platform/cloud/subscription/components/PricingTable.vue Tracks begin_checkout for plan changes and routes new checkout through shared util.
src/platform/cloud/subscription/components/PricingTable.test.ts Adds expectation for begin_checkout tracking on plan change flow.
src/platform/cloud/onboarding/CloudSubscriptionRedirectView.test.ts Adjusts mocked subscription composable shape.
src/main.ts Cloud-only remote config load now also initializes telemetry before app mount.
global.d.ts Adds gtm_container_id, __ga_identity__, and dataLayer to Window typings.
.github/workflows/ci-dist-telemetry-scan.yaml Adds CI job to ensure dist artifacts don’t contain GTM references.

Comment on lines +87 to +89
if (userId) {
telemetry?.trackBeginCheckout({
user_id: userId,
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

userId from useFirebaseAuthStore() is a computed ref (ComputedRef<string | undefined>) in the real store, so this if (userId) check will always be truthy and user_id: userId will send the ref object instead of the UID string. Use userId.value (or storeToRefs) for both the guard and the user_id field.

Suggested change
if (userId) {
telemetry?.trackBeginCheckout({
user_id: userId,
if (userId?.value) {
telemetry?.trackBeginCheckout({
user_id: userId.value,

Copilot uses AI. Check for mistakes.
Comment on lines +419 to +421
if (userId) {
telemetry?.trackBeginCheckout({
user_id: userId,
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

userId from useFirebaseAuthStore() is a computed ref in the actual Pinia setup store. As written, if (userId) will always pass and user_id: userId will push a ref object to telemetry. Use userId.value (or storeToRefs(useFirebaseAuthStore())) when checking and when populating user_id.

Suggested change
if (userId) {
telemetry?.trackBeginCheckout({
user_id: userId,
if (userId?.value) {
telemetry?.trackBeginCheckout({
user_id: userId.value,

Copilot uses AI. Check for mistakes.
useFirebaseAuthStore: () => ({
getFirebaseAuthHeader: mockGetFirebaseAuthHeader
getFirebaseAuthHeader: mockGetFirebaseAuthHeader,
userId: 'user-123'
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

This test mocks userId as a plain string, but the real useFirebaseAuthStore().userId is a computed ref. That mismatch makes it easy for ref/value bugs to slip through; mock userId as a ref/computed and assert the implementation reads userId.value.

Suggested change
userId: 'user-123'
userId: computed(() => 'user-123')

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +40
vi.mock('@/stores/firebaseAuthStore', () => ({
useFirebaseAuthStore: vi.fn(() => ({
getFirebaseAuthHeader: mockGetAuthHeader,
get userId() {
return mockUserId.value
}
})),
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

This test's useFirebaseAuthStore() mock exposes userId as a getter returning a string, but the real store returns a computed ref. Mocking it as a ref/computed will better match runtime behavior and will catch ref/value issues in the checkout telemetry code.

Copilot uses AI. Check for mistakes.
const { useDialogService } = await import('@/services/dialogService')
return await useDialogService().prompt({
title: t('workflowService.saveWorkflow'),
message: t('workflowService.enterFilenamePrompt'),
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

workflowService.enterFilenamePrompt doesn't exist in the locale files (only workflowService.enterFilename is defined). This will render the raw i18n key in the prompt. Either switch back to t('workflowService.enterFilename') + ':' to match existing usage, or add the new enterFilenamePrompt key to all locales.

Suggested change
message: t('workflowService.enterFilenamePrompt'),
message: t('workflowService.enterFilename') + ':',

Copilot uses AI. Check for mistakes.
await import('@/platform/workflow/persistence/stores/workflowDraftStore')
const draftStore = useWorkflowDraftStore()
this.content = JSON.stringify(this.activeState)
// Force save to ensure the content is updated in remote storage incase
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

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

Typo in comment: "incase" should be "in case".

Suggested change
// Force save to ensure the content is updated in remote storage incase
// Force save to ensure the content is updated in remote storage in case

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d651214a31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const { useDialogService } = await import('@/services/dialogService')
return await useDialogService().prompt({
title: t('workflowService.saveWorkflow'),
message: t('workflowService.enterFilenamePrompt'),

Choose a reason for hiding this comment

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

P2 Badge Use existing workflow filename prompt translation key

promptSave() now calls t('workflowService.enterFilenamePrompt'), but this key is not defined in the locale bundle on this branch (src/locales/en/main.json only defines workflowService.enterFilename), so users will see the raw i18n key in the save dialog instead of a readable prompt whenever they save/rename workflows.

Useful? React with 👍 / 👎.

Comment on lines +46 to +47
-e '(?i)googletagmanager\.com/gtm\.js\\?id=' \
-e '(?i)googletagmanager\.com/ns\.html\\?id=' \

Choose a reason for hiding this comment

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

P2 Badge Fix GTM URL regex escaping in dist telemetry scan

The new scan patterns use \?id= (googletagmanager\.com/...\\?id=), which in ripgrep regex does not match a literal ?id= URL query; as a result, GTM URL references like .../ns.html?id=... can slip past CI undetected. This weakens the guardrail the workflow is intended to enforce for telemetry-free dist assets.

Useful? React with 👍 / 👎.

@benceruleanlu
Copy link
Member Author

Waiting on BE implementation

@benceruleanlu benceruleanlu marked this pull request as draft February 7, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Backporting a PR onto a release candidate size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants