Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): send public analytics with consent-controlled cookies (#916)
Gener4b50547579ea
diff --git a/src/web/blog/src/instrumentation-client.dom.test.tsx b/src/web/blog/src/instrumentation-client.dom.test.tsxindex d1e5fadff..36a4892a3 100644--- a/src/web/blog/src/instrumentation-client.dom.test.tsx+++ b/src/web/blog/src/instrumentation-client.dom.test.tsx@@ -10,6 +10,8 @@ afterEach(async () => {document.cookie = "alook_analytics_consent=v1.denied; path=/";announceAnalyticsConsent("denied");});+ delete window.dataLayer;+ Reflect.deleteProperty(window, "ga-disable-G-STBCL8F4ZY");vi.useRealTimers(); vi.unstubAllEnvs(); vi.unstubAllGlobals();});@@ -33,12 +35,14 @@ it("boots the actual Blog entry with the native resumed session and exports itsconst sent: Array<{ meta: { sdk: { name: string; version: string }; session: { id: string } }; events?: Array<{ name: string; attributes?: Record<string, string> }> }> = [];vi.stubGlobal("fetch", vi.fn(async (_url: unknown, options?: RequestInit) => { if (options?.body) sent.push(JSON.parse(String(options.body))); return new Response(null, { status: 204 }); }));const { onRouterTransitionStart } = await import("./instrumentation-client");+ expect(Array.from(window.dataLayer![0] as IArguments)).toEqual(["consent", "default", { analytics_storage: "granted", ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied" }]);const { navigationForHref } = await import("@/lib/observability/context");const { ObservedStaticContent, ObservedRouteCommit } = await import("@/lib/observability/regions");await vi.waitFor(() => expect(sent.some(body => body.events?.some(event => event.name === "session_resume"))).toBe(true), { timeout: 5000 });const view = render(<ObservedStaticContent key="/blog" pathname="/blog" />);const route = render(<ObservedRouteCommit />);await act(async () => { onRouterTransitionStart("/blog/introducing-alook?private=article-title"); });+ expect(Array.from(window.dataLayer!.at(-1) as IArguments)).toEqual(["set", { page_location: `${window.location.origin}/blog/introducing-alook`, page_referrer: `${window.location.origin}/` }]);const navigation = navigationForHref("/blog/introducing-alook?private=article-title")!;expect(navigation).toBeDefined();expect(navigation.done).toBe(false);@@ -61,3 +65,25 @@ it("boots the actual Blog entry with the native resumed session and exports itsexpect(JSON.stringify(exported)).not.toContain("article-title");expect(JSON.stringify(exported)).not.toContain("introducing-alook");});+++it.each(["", "v1.denied", "v0.granted", "v1.granted"])("boots the actual Blog document from %s without adding an optional telemetry grant", async value => {+ vi.resetModules();+ vi.stubEnv("NEXT_PUBLIC_FARO_COLLECTOR_URL", "");+ window.history.replaceState(null, "", "/blog/public?secret=query#hash");+ document.cookie = `alook_analytics_consent=${value}; path=/`;+ window.dataLayer = [];+ const fetcher = vi.fn();+ vi.stubGlobal("fetch", fetcher);+ const { onRouterTransitionStart } = await import("./instrumentation-client");+ expect(window.dataLayer.map(command => Array.from(command as IArguments))).toEqual([+ ["consent", "default", { analytics_storage: value === "v1.granted" ? "granted" : "denied", ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied" }],+ ["set", { page_location: `${window.location.origin}/blog/public`, page_referrer: `${window.location.origin}/` }],+ ]);+ onRouterTransitionStart("/blog/other?secret=route#hash");+ onRouterTransitionStart("/c/me?secret=private");+ expect(window.dataLayer).toHaveLength(3);+ expect(Array.from(window.dataLayer.at(-1) as IArguments)).toEqual(["set", { page_location: `${window.location.origin}/blog/other`, page_referrer: `${window.location.origin}/` }]);+ expect(JSON.stringify(window.dataLayer)).not.toMatch(/secret|page_view/);+ expect(fetcher).not.toHaveBeenCalled();+});diff --git a/src/web/blog/src/instrumentation-client.ts b/src/web/blog/src/instrumentation-client.tsindex 069fa0381..397c14235 100644--- a/src/web/blog/src/instrumentation-client.ts+++ b/src/web/blog/src/instrumentation-client.ts@@ -1,4 +1,10 @@import { bootstrapObservability, onObservedRouterTransition } from "@/lib/observability/client"+import { isTauri } from "@alook/shared"+import { bootstrapGoogleAnalytics, updateGooglePageFields } from "@/lib/analytics-consent"+if (!isTauri()) bootstrapGoogleAnalytics()bootstrapObservability("blog")-export function onRouterTransitionStart(url: string) { onObservedRouterTransition(url) }+export function onRouterTransitionStart(url: string) {+ if (!isTauri()) updateGooglePageFields(url)+ onObservedRouterTransition(url)+}diff --git a/src/web/src/components/analytics-consent.dom.test.tsx b/src/web/src/components/analytics-consent.dom.test.tsxindex f3f892d5e..341c0c635 100644--- a/src/web/src/components/analytics-consent.dom.test.tsx+++ b/src/web/src/components/analytics-consent.dom.test.tsx@@ -1,4 +1,4 @@-import { fireEvent, render, screen, waitFor, within } from "@/test/react-dom-harness"+import { act, fireEvent, render, screen, waitFor, within } from "@/test/react-dom-harness"import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"const platform = vi.hoisted(() => ({@@ -22,6 +22,7 @@ vi.mock("@next/third-parties/google", () => ({}))import { AnalyticsConsent, AnalyticsPreferenceControl } from "./analytics-consent"+import { bootstrapGoogleAnalytics } from "@/lib/analytics-consent"import { tid } from "@/lib/community/testids"function clearCookies() {@@ -32,10 +33,28 @@ function clearCookies() {}function successfulFetch(decision: "granted" | "denied") {- return vi.fn(async () => new Response(- JSON.stringify({ decision }),- { status: 200, headers: { "Content-Type": "application/json" } },- ))+ return vi.fn(async () => {+ document.cookie = `alook_analytics_consent=v1.${decision}; Path=/`+ return new Response(JSON.stringify({ decision }), { status: 200, headers: { "Content-Type": "application/json" } })+ })+}+++function installCookieStore() {+ const store = new EventTarget()+ vi.stubGlobal("cookieStore", store)+ const added = vi.spyOn(store, "addEventListener")+ const removed = vi.spyOn(store, "removeEventListener")+ const change = (changed: Array<{ name: string; value?: string }> = [], deleted: Array<{ name: string }> = []) => {+ const event = new Event("change")+ Object.assign(event, { changed, deleted })+ act(() => { store.dispatchEvent(event) })+ }+ return { store, added, removed, change }+}++function consentCommands() {+ return window.dataLayer!.map(command => Array.from(command as IArguments)).filter(command => command[0] === "consent")}beforeEach(() => {@@ -45,6 +64,8 @@ beforeEach(() => {platform.isTauri.mockReset().mockReturnValue(false)platform.isMobile.mockReset().mockReturnValue(false)window.dataLayer = []+ vi.stubGlobal("cookieStore", undefined)+ bootstrapGoogleAnalytics()})afterEach(() => {@@ -90,18 +111,37 @@ describe("AnalyticsConsent", () => {}})- it("shows a first-visit banner without loading GTM", async () => {+ it("loads public GTM with denied cookies and retains the first-visit banner", async () => {render(<AnalyticsConsent />)const banner = await screen.findByTestId(tid.analyticsConsentBanner)- expect(within(banner).getByText("Analytics, only if you want")).toBeVisible()+ expect(within(banner).getByText("Cookies are your choice")).toBeVisible()+ expect(banner).toHaveTextContent("Google receives page and feature signals on our public website, even without analytics cookies. Allow analytics enables analytics cookies and other optional analytics. No ad tracking. Read our privacy details.")expect(within(banner).getByRole("button", { name: "Only necessary" })).toBeVisible()expect(within(banner).getByRole("button", { name: "Allow analytics" })).toBeVisible()expect(within(banner).getByTestId(tid.analyticsConsentAvatarCluster).querySelectorAll("svg")).toHaveLength(3)- expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(screen.getByTestId("google-tag-manager")).toBeInTheDocument()expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()})+ it.each(["/sign-in", "/pricing"])("retains the original Native desktop banner on %s without requiring a choice", async pathname => {+ platform.isTauri.mockReturnValue(true)+ route.pathname = pathname+ window.history.replaceState({}, "", pathname)+ const fetcher = vi.fn()+ vi.stubGlobal("fetch", fetcher)++ render(<AnalyticsConsent />)++ const banner = await screen.findByTestId(tid.analyticsConsentBanner)+ expect(within(banner).getByText("Analytics, only if you want")).toBeVisible()+ expect(banner).toHaveTextContent("Optional analytics help us understand which parts of Alook are useful. No ad tracking. Read our privacy details.")+ expect(banner).not.toHaveTextContent("Google receives page and feature signals")+ expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(document.cookie).toBe("")+ expect(fetcher).not.toHaveBeenCalled()+ })+it("hides the first-visit banner in native mobile clients", async () => {platform.isTauri.mockReturnValue(true)platform.isMobile.mockReturnValue(true)@@ -115,7 +155,7 @@ describe("AnalyticsConsent", () => {expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()})- it("loads GTM only after the API confirms a grant", async () => {+ it("keeps public GTM and enables Ahrefs after the API confirms a grant", async () => {const fetcher = successfulFetch("granted")vi.stubGlobal("fetch", fetcher)render(<AnalyticsConsent />)@@ -129,9 +169,9 @@ describe("AnalyticsConsent", () => {)expect(await screen.findByTestId(tid.ahrefsAnalyticsFrame)).toHaveAttribute("sandbox", "allow-scripts")expect(screen.queryByTestId(tid.analyticsConsentBanner)).not.toBeInTheDocument()- expect(window.dataLayer?.[0]).toEqual([+ expect(Array.from(window.dataLayer!.at(-1) as IArguments)).toEqual(["consent",- "default",+ "update",expect.objectContaining({ analytics_storage: "granted", ad_storage: "denied" }),])expect(fetcher).toHaveBeenCalledWith(@@ -144,7 +184,7 @@ describe("AnalyticsConsent", () => {)})- it("stores a denial without loading GTM", async () => {+ it("stores a denial while retaining public GTM and excluding Ahrefs", async () => {vi.stubGlobal("fetch", successfulFetch("denied"))render(<AnalyticsConsent />)const banner = await screen.findByTestId(tid.analyticsConsentBanner)@@ -154,7 +194,7 @@ describe("AnalyticsConsent", () => {await waitFor(() => {expect(screen.queryByTestId(tid.analyticsConsentBanner)).not.toBeInTheDocument()})- expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(screen.getByTestId("google-tag-manager")).toBeInTheDocument()expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()})@@ -175,6 +215,7 @@ describe("AnalyticsConsent", () => {expect(screen.getByTestId(tid.ahrefsAnalyticsFrame)).not.toBe(home)expect(screen.getByTestId(tid.ahrefsAnalyticsFrame).getAttribute("srcdoc")).toContain(`data-page-location="${window.location.origin}/pricing"`)+ document.cookie = "alook_analytics_consent=v1.denied; Path=/"fireEvent(window, new CustomEvent("alook:analytics-consent-change", { detail: "denied" }))await waitFor(() => expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument())granted.unmount()@@ -185,7 +226,7 @@ describe("AnalyticsConsent", () => {await waitFor(() => {expect(screen.queryByTestId(tid.analyticsConsentBanner)).not.toBeInTheDocument()})- expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(screen.getByTestId("google-tag-manager")).toBeInTheDocument()})it("keeps the banner open and explains a save failure", async () => {@@ -197,7 +238,7 @@ describe("AnalyticsConsent", () => {const banner = await screen.findByTestId(tid.analyticsConsentBanner)fireEvent.click(within(banner).getByRole("button", { name: "Allow analytics" }))expect(await within(banner).findByRole("alert")).toHaveTextContent("Couldn’t save this choice")- expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(screen.getByTestId("google-tag-manager")).toBeInTheDocument()expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()})@@ -211,13 +252,13 @@ describe("AnalyticsConsent", () => {</>,)const control = await screen.findByTestId(tid.analyticsPreferenceControl)- expect(within(control).getByText(/Only necessary cookies/u)).toBeVisible()+ expect(within(control).getByText(/Analytics cookies denied/u)).toBeVisible()fireEvent.click(within(control).getByRole("button", { name: "Allow analytics" }))- expect(await within(control).findByText(/Optional analytics allowed/u)).toBeVisible()+ expect(await within(control).findByText(/Analytics cookies allowed/u)).toBeVisible()expect(await screen.findByTestId("google-tag-manager")).toBeInTheDocument()- expect(window.dataLayer?.[0]).toEqual([+ expect(Array.from(window.dataLayer!.at(-1) as IArguments)).toEqual(["consent","update",expect.objectContaining({ analytics_storage: "granted", ad_storage: "denied" }),@@ -234,7 +275,7 @@ describe("AnalyticsConsent", () => {window.history.replaceState({}, "", "/pricing")expect(Reflect.get(window, "ga-disable-G-STBCL8F4ZY")).toBe(false)document.cookie = "alook_analytics_consent=v1.denied; Path=/"- expect(Reflect.get(window, "ga-disable-G-STBCL8F4ZY")).toBe(true)+ expect(Reflect.get(window, "ga-disable-G-STBCL8F4ZY")).toBe(false)view.unmount()window.history.replaceState({}, "", "/")})@@ -249,4 +290,117 @@ describe("AnalyticsConsent", () => {.toContain(`data-page-location="${window.location.origin}${pathname}"`)})+ it("registers the root CookieStore listener before the mount reread and keeps one Google update owner", async () => {+ document.cookie = "alook_analytics_consent=v1.denied; Path=/"+ const cookie = installCookieStore()+ cookie.added.mockImplementation((type, listener, options) => {+ document.cookie = "alook_analytics_consent=v1.granted; Path=/"+ EventTarget.prototype.addEventListener.call(cookie.store, type, listener, options)+ })+ render(<><AnalyticsConsent /><AnalyticsPreferenceControl /></>)+ expect(await screen.findByTestId(tid.ahrefsAnalyticsFrame)).toBeInTheDocument()+ expect(cookie.added).toHaveBeenCalledOnce()+ expect(consentCommands()).toEqual([+ ["consent", "default", expect.objectContaining({ analytics_storage: "denied" })],+ ["consent", "update", expect.objectContaining({ analytics_storage: "granted" })],+ ])+ })++ it("rereads changed and deleted Cookies, rejects late values and deduplicates the original API event", async () => {+ const cookie = installCookieStore()+ const wake = vi.fn()+ window.addEventListener("alook:analytics-consent-change", wake)+ const view = render(<><AnalyticsConsent /><AnalyticsPreferenceControl /></>)+ await screen.findByTestId(tid.analyticsConsentBanner)+ wake.mockClear()+ const initial = consentCommands().length+ cookie.change([{ name: "alook_analytics_consent_proof", value: "ignored" }])+ expect(consentCommands()).toHaveLength(initial)+ document.cookie = "alook_analytics_consent=v1.granted; Path=/"+ cookie.change([{ name: "alook_analytics_consent", value: "v1.denied" }])+ await screen.findByTestId(tid.ahrefsAnalyticsFrame)+ expect(screen.getByTestId(tid.analyticsPreferenceControl)).toHaveTextContent("Analytics cookies allowed")+ expect(wake).toHaveBeenCalledOnce()+ fireEvent(window, new CustomEvent("alook:analytics-consent-change", { detail: "granted" }))+ cookie.change([{ name: "alook_analytics_consent", value: "v1.granted" }])+ expect(consentCommands()).toHaveLength(initial + 1)+ document.cookie = "alook_analytics_consent=v1.denied; Path=/"+ cookie.change([{ name: "alook_analytics_consent", value: "v1.granted" }])+ expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()+ expect(screen.getByTestId("google-tag-manager")).toBeInTheDocument()+ document.cookie = "alook_analytics_consent=; Max-Age=0; Path=/"+ cookie.change([], [{ name: "alook_analytics_consent" }])+ expect(screen.getByTestId(tid.analyticsConsentBanner)).toBeInTheDocument()+ expect(screen.getByTestId(tid.analyticsPreferenceControl)).toHaveTextContent("No choice saved — analytics cookies denied")+ document.cookie = "alook_analytics_consent=v0.granted; Path=/"+ cookie.change([{ name: "alook_analytics_consent", value: "v1.granted" }])+ expect(consentCommands()).toHaveLength(initial + 3)+ expect(consentCommands().slice(initial).map(command => (command[2] as { analytics_storage: string }).analytics_storage)).toEqual(["granted", "denied", "denied"])+ view.unmount()+ expect(cookie.removed).toHaveBeenCalledWith("change", cookie.added.mock.calls[0][1])+ const prior = consentCommands().length+ cookie.change([{ name: "alook_analytics_consent", value: "v1.granted" }])+ expect(consentCommands()).toHaveLength(prior)+ window.removeEventListener("alook:analytics-consent-change", wake)+ })++ it("uses the committed Cookie while JSON remains pending and preserves an eventual response error", async () => {+ const cookie = installCookieStore()+ let rejectJson!: (error: Error) => void+ const json = new Promise((_resolve, reject) => { rejectJson = reject })+ vi.stubGlobal("fetch", vi.fn(async () => {+ document.cookie = "alook_analytics_consent=v1.granted; Path=/"+ cookie.change([{ name: "alook_analytics_consent", value: "v1.granted" }])+ return { ok: true, json: () => json }+ }))+ render(<><AnalyticsConsent /><AnalyticsPreferenceControl /></>)+ await screen.findByTestId(tid.analyticsConsentBanner)+ const control = screen.getByTestId(tid.analyticsPreferenceControl)+ fireEvent.click(within(control).getByRole("button", { name: "Allow analytics" }))+ await screen.findByTestId(tid.ahrefsAnalyticsFrame)+ expect(control).toHaveTextContent("Analytics cookies allowed")+ expect(consentCommands().at(-1)).toEqual(["consent", "update", expect.objectContaining({ analytics_storage: "granted" })])+ await act(async () => rejectJson(new Error("response unavailable")))+ expect(await screen.findByRole("alert")).toHaveTextContent("Couldn’t save this choice")+ expect(control).toHaveTextContent("Analytics cookies allowed")+ expect(screen.getByTestId(tid.ahrefsAnalyticsFrame)).toBeInTheDocument()+ })++ it.each(["focus", "pageshow", "visibilitychange"])("rereads on %s without promising unsupported cross-page notification", async type => {+ const view = render(<AnalyticsConsent />)+ await screen.findByTestId(tid.analyticsConsentBanner)+ document.cookie = "alook_analytics_consent=v1.granted; Path=/"+ expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()+ if (type === "visibilitychange") {+ vi.spyOn(document, "visibilityState", "get").mockReturnValue("visible")+ fireEvent(document, new Event(type))+ } else fireEvent(window, new Event(type))+ await screen.findByTestId(tid.ahrefsAnalyticsFrame)+ view.unmount()+ const count = consentCommands().length+ document.cookie = "alook_analytics_consent=v1.denied; Path=/"+ fireEvent(window, new Event("focus"))+ fireEvent(window, new Event("pageshow"))+ fireEvent(document, new Event("visibilitychange"))+ expect(consentCommands()).toHaveLength(count)+ vi.restoreAllMocks()+ })++ it("retains Native defaults, detail updates, optional gates and immediate Cookie-based disabling", async () => {+ platform.isTauri.mockReturnValue(true)+ document.cookie = "alook_analytics_consent=v1.granted; Path=/"+ window.dataLayer = []+ const cookie = installCookieStore()+ render(<AnalyticsConsent />)+ await screen.findByTestId("google-tag-manager")+ expect(cookie.added).not.toHaveBeenCalled()+ expect(consentCommands()[0]).toEqual(["consent", "default", expect.objectContaining({ analytics_storage: "granted" })])+ document.cookie = "alook_analytics_consent=v1.denied; Path=/"+ fireEvent(window, new CustomEvent("alook:analytics-consent-change", { detail: "denied" }))+ expect(screen.queryByTestId("google-tag-manager")).not.toBeInTheDocument()+ expect(screen.queryByTestId(tid.ahrefsAnalyticsFrame)).not.toBeInTheDocument()+ expect(Reflect.get(window, "ga-disable-G-STBCL8F4ZY")).toBe(true)+ expect(consentCommands().at(-1)).toEqual(["consent", "update", expect.objectContaining({ analytics_storage: "denied" })])+ })+})diff --git a/src/web/src/components/analytics-consent.tsx b/src/web/src/components/analytics-consent.tsxindex f9bd4f214..1a9249ac1 100644--- a/src/web/src/components/analytics-consent.tsx+++ b/src/web/src/components/analytics-consent.tsx@@ -8,8 +8,10 @@ import { useCallback, useEffect, useRef } from "react"import { GeneratedAvatar } from "@/components/avatar"import {ANALYTICS_CONSENT_CHANGE_EVENT,+ ANALYTICS_CONSENT_COOKIE,announceAnalyticsConsent,applyGoogleConsent,+ isPublicAnalyticsPath,persistAnalyticsConsent,readAnalyticsConsent,type AnalyticsConsentDecision,@@ -19,7 +21,6 @@ import styles from "./analytics-consent.module.css"const GTM_ID = "GTM-56VHCCQZ"const GA_DISABLE = "ga-disable-G-STBCL8F4ZY"-const isPublicAnalyticsPath = (path: string) => /^\/(?:pricing|contact|privacy|templates(?:\/[^/]+)?|blog(?:\/.*)?)?$/.test(path)function useStoredAnalyticsConsent(syncGoogleConsent = false) {const [ready, setReady] = useAtom(useCreateAtom(false))@@ -28,14 +29,23 @@ function useStoredAnalyticsConsent(syncGoogleConsent = false) {const decisionRef = useRef<AnalyticsConsentDecision | null>(null)useEffect(() => {- const stored = readAnalyticsConsent()- if (syncGoogleConsent && stored === "granted") applyGoogleConsent(stored, "default")- decisionRef.current = stored- setDecision(stored)- setNativeMobile(isTauri() && isMobile())- setReady(true)-+ const native = isTauri()+ const refresh = (announce = false, initial = false) => {+ const next = readAnalyticsConsent()+ const changed = next !== decisionRef.current+ if (syncGoogleConsent && (changed || initial)) {+ if (!native) applyGoogleConsent(next ?? "denied")+ else if (initial && next === "granted") applyGoogleConsent(next, "default")+ }+ decisionRef.current = next+ setDecision(next)+ if (syncGoogleConsent && announce && changed) announceAnalyticsConsent(next ?? "denied")+ }const onChange = (event: Event) => {+ if (!native) {+ refresh()+ return+ }const next = (event as CustomEvent<AnalyticsConsentDecision>).detailif (next !== "granted" && next !== "denied") returnif (syncGoogleConsent) {@@ -44,8 +54,40 @@ function useStoredAnalyticsConsent(syncGoogleConsent = false) {decisionRef.current = nextsetDecision(next)}+ const onCookieChange = (event: CookieChangeEvent) => {+ if ([...event.changed, ...event.deleted].some(cookie => cookie.name === ANALYTICS_CONSENT_COOKIE)) {+ refresh(true)+ }+ }+ const onResume = () => refresh(true)+ const onVisibility = () => {+ if (document.visibilityState === "visible") onResume()+ }window.addEventListener(ANALYTICS_CONSENT_CHANGE_EVENT, onChange)- return () => window.removeEventListener(ANALYTICS_CONSENT_CHANGE_EVENT, onChange)+ let cookieStore: CookieStore | undefined+ if (!native) {+ if (syncGoogleConsent) {+ try {+ cookieStore = window.cookieStore+ cookieStore?.addEventListener("change", onCookieChange)+ } catch {+ cookieStore = undefined+ }+ }+ window.addEventListener("focus", onResume)+ window.addEventListener("pageshow", onResume)+ document.addEventListener("visibilitychange", onVisibility)+ }+ refresh(!native, true)+ setNativeMobile(native && isMobile())+ setReady(true)+ return () => {+ window.removeEventListener(ANALYTICS_CONSENT_CHANGE_EVENT, onChange)+ cookieStore?.removeEventListener("change", onCookieChange)+ window.removeEventListener("focus", onResume)+ window.removeEventListener("pageshow", onResume)+ document.removeEventListener("visibilitychange", onVisibility)+ }}, [setDecision, setNativeMobile, setReady, syncGoogleConsent])return { ready, decision, nativeMobile }@@ -132,15 +174,17 @@ export function AnalyticsConsent() {const { ready, decision, nativeMobile } = useStoredAnalyticsConsent(true)const { choose, saving, error } = useAnalyticsConsentChoice()const allowed = ready && decision === "granted" && !!pathname && isPublicAnalyticsPath(pathname)+ const googleAllowed = ready && !!pathname && isPublicAnalyticsPath(pathname) && (!isTauri() || decision === "granted")useEffect(() => {+ if (!isTauri()) returnObject.defineProperty(window, GA_DISABLE, {configurable: true,get: () => readAnalyticsConsent() !== "granted" || !isPublicAnalyticsPath(window.location.pathname),})}, [])useEffect(() => {- if (decision !== "granted") return+ if (!isTauri() || decision !== "granted") returnconst referrer = new URL(document.referrer || window.location.origin)const safeReferrer = referrer.origin !== window.location.origin || isPublicAnalyticsPath(referrer.pathname)? `${referrer.origin}${referrer.pathname}` : ""@@ -150,7 +194,7 @@ export function AnalyticsConsent() {return (<>- {allowed ? <GoogleTagManager gtmId={GTM_ID} /> : null}+ {googleAllowed ? <GoogleTagManager gtmId={GTM_ID} /> : null}{allowed ? (<iframekey={pathname}@@ -171,10 +215,14 @@ export function AnalyticsConsent() {<div className={styles.bannerContent}><div className={styles.copy}><p className={styles.eyebrow}>PRIVACY · OPTIONAL SIGNAL</p>- <h2 className={styles.headline}>Analytics, only if you want</h2>+ <h2 className={styles.headline}>+ {isTauri() ? "Analytics, only if you want" : "Cookies are your choice"}+ </h2><p className={styles.description}>- Optional analytics help us understand which parts of Alook are useful. No ad- tracking. Read our{" "}+ {isTauri()+ ? "Optional analytics help us understand which parts of Alook are useful. "+ : "Google receives page and feature signals on our public website, even without analytics cookies. Allow analytics enables analytics cookies and other optional analytics. "}+ No ad tracking. Read our{" "}<ahref="/privacy#analytics-choices"className={styles.privacyLink}@@ -200,10 +248,10 @@ export function AnalyticsPreferenceControl() {const { ready, decision } = useStoredAnalyticsConsent()const { choose, saving, error } = useAnalyticsConsentChoice()const status = decision === "granted"- ? "Optional analytics allowed"+ ? "Analytics cookies allowed": decision === "denied"- ? "Only necessary cookies"- : "No choice saved"+ ? "Analytics cookies denied"+ : "No choice saved — analytics cookies denied"return (<sectiondiff --git a/src/web/src/components/privacy/privacy-policy-content.test.ts b/src/web/src/components/privacy/privacy-policy-content.test.tsindex 027651f78..4c3b1e735 100644--- a/src/web/src/components/privacy/privacy-policy-content.test.ts+++ b/src/web/src/components/privacy/privacy-policy-content.test.ts@@ -8,16 +8,23 @@ import {} from "./privacy-policy-content"describe("shared Privacy policy", () => {- it("preserves the published policy copy and update date", () => {+ it("preserves the shared policy and identifies the implementation date", () => {const html = renderToStaticMarkup(createElement(PrivacyPolicyContent))expect(html).toContain(`data-privacy-policy="${PRIVACY_POLICY.lastUpdated}"`)expect(html).toContain(`Last updated: ${PRIVACY_POLICY.lastUpdated}`)+ expect(PRIVACY_POLICY.lastUpdated).toBe("October 10, 2026")expect(html).toContain("Interpretation and Definitions")expect(html).toContain("Collecting and Using Your Personal Data")expect(html).toContain("Your Data Rights")expect(html).toContain("[email protected]")expect(html).not.toContain("durable background job")+ expect(html).toContain("even without analytics cookies")+ expect(html).toContain("other optional analytics")+ expect(html).toContain("180 days")+ expect(html).toContain("Google still receives signals without analytics cookies")+ expect(html).not.toContain("keeps Google Tag Manager and")+ expect(html).not.toContain("collected only after")})it("places analytics preferences after the policy content", () => {diff --git a/src/web/src/components/privacy/privacy-policy-content.tsx b/src/web/src/components/privacy/privacy-policy-content.tsxindex 2434d6504..e6e34d54b 100644--- a/src/web/src/components/privacy/privacy-policy-content.tsx+++ b/src/web/src/components/privacy/privacy-policy-content.tsx@@ -4,7 +4,7 @@ import { AnalyticsPreferenceControl } from "@/components/analytics-consent"export const PRIVACY_POLICY = {title: "Privacy Policy",description: "How Alook collects, uses, and protects your personal information.",- lastUpdated: "September 17, 2026",+ lastUpdated: "October 10, 2026",} as constconst linkClass =@@ -53,8 +53,9 @@ export function PrivacyPolicyContent({ className }: { className?: string }) {<h4 className="mt-6 mb-2 text-base font-medium">Usage Data</h4><p className="text-foreground/80">Necessary diagnostic data may be processed to keep the Service secure and reliable.- Optional analytics, such as the pages You visit and how You interact with product- features, is collected only after You choose to allow analytics in this browser.+ Google receives page and feature signals when You use our public website and Blog,+ even without analytics cookies. Allowing analytics enables analytics cookies and+ other optional analytics. We do not use ad tracking.</p><h4 className="mt-6 mb-2 text-base font-medium">@@ -72,8 +73,9 @@ export function PrivacyPolicyContent({ className }: { className?: string }) {We use necessary cookies to provide sign-in, security, and saved preferences. We useoptional analytics cookies only after You allow them. Your analytics choice is savedin a first-party cookie for 180 days and can be changed using the preference control- below at any time. Choosing only necessary cookies keeps Google Tag Manager and- optional analytics disabled.+ below at any time. Choosing only necessary cookies denies analytics cookies;+ Google still receives signals without analytics cookies on our public website and+ Blog. Other optional analytics require Your permission.</p></section>diff --git a/src/web/src/instrumentation-client.test.ts b/src/web/src/instrumentation-client.test.tsindex bbab377a2..c3ed05098 100644--- a/src/web/src/instrumentation-client.test.ts+++ b/src/web/src/instrumentation-client.test.ts@@ -1,6 +1,10 @@-import { beforeEach, expect, it, vi } from "vitest"+import { afterEach, beforeEach, expect, it, vi } from "vitest"const installReactScanMock = vi.fn()+const bootstrapObservabilityMock = vi.fn()+const onObservedRouterTransitionMock = vi.fn()++vi.mock("@/lib/observability/client", () => ({ bootstrapObservability: bootstrapObservabilityMock, onObservedRouterTransition: onObservedRouterTransitionMock }))vi.mock("@/lib/perf/react-scan-install", () => ({installReactScan: installReactScanMock,@@ -8,7 +12,9 @@ vi.mock("@/lib/perf/react-scan-install", () => ({beforeEach(() => {vi.resetModules()- installReactScanMock.mockReset()+ installReactScanMock.mockReset().mockResolvedValue(undefined)+ bootstrapObservabilityMock.mockReset()+ onObservedRouterTransitionMock.mockReset()})it("starts optional client diagnostics without making app boot await them", async () => {@@ -23,3 +29,41 @@ it("starts optional client diagnostics without making app boot await them", asynrejectInstall(new Error("diagnostics unavailable"))await Promise.resolve()})+++afterEach(() => vi.unstubAllGlobals())++it.each(["", "v1.denied", "v0.granted", "v1.granted"])("initializes the real Web entry synchronously from %s before its existing consumers", async cookie => {+ const browser = { location: new URL("https://alook.ai/?secret=query#hash"), dataLayer: [] as unknown[] }+ vi.stubGlobal("window", browser)+ vi.stubGlobal("document", { cookie: `alook_analytics_consent=${cookie}`, referrer: "https://alook.ai/c/me?secret=referrer" })+ bootstrapObservabilityMock.mockImplementation(() => {+ expect(Reflect.get(browser, "ga-disable-G-STBCL8F4ZY")).toBe(false)+ expect(browser.dataLayer.map(command => Array.from(command as IArguments))).toEqual([+ ["consent", "default", { analytics_storage: cookie === "v1.granted" ? "granted" : "denied", ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied" }],+ ["set", { page_location: "https://alook.ai/", page_referrer: "" }],+ ])+ browser.dataLayer.push({ event: "existing-consumer" })+ })+ const entry = await import("./instrumentation-client")+ expect(bootstrapObservabilityMock).toHaveBeenCalledWith("web")+ expect(installReactScanMock).toHaveBeenCalledOnce()+ entry.onRouterTransitionStart("/pricing?secret=route#hash")+ expect(Array.from(browser.dataLayer[3] as IArguments)).toEqual(["set", { page_location: "https://alook.ai/pricing", page_referrer: "" }])+ entry.onRouterTransitionStart("/c/me?secret=private")+ expect(browser.dataLayer).toHaveLength(4)+ expect(onObservedRouterTransitionMock.mock.calls).toEqual([["/pricing?secret=route#hash"], ["/c/me?secret=private"]])+ expect(JSON.stringify(browser.dataLayer)).not.toMatch(/secret|page_view/)+})++it("retains Native diagnostics and router telemetry without the Web bootstrap", async () => {+ const browser = { __TAURI__: {}, location: new URL("https://alook.ai/"), dataLayer: [] as unknown[] }+ vi.stubGlobal("window", browser)+ const entry = await import("./instrumentation-client")+ entry.onRouterTransitionStart("/pricing")+ expect(browser.dataLayer).toEqual([])+ expect(Reflect.has(browser, "ga-disable-G-STBCL8F4ZY")).toBe(false)+ expect(bootstrapObservabilityMock).toHaveBeenCalledWith("web")+ expect(onObservedRouterTransitionMock).toHaveBeenCalledWith("/pricing")+ expect(installReactScanMock).toHaveBeenCalledOnce()+})diff --git a/src/web/src/instrumentation-client.ts b/src/web/src/instrumentation-client.tsindex b7f047154..c6e2d9c00 100644--- a/src/web/src/instrumentation-client.ts+++ b/src/web/src/instrumentation-client.ts@@ -1,17 +1,14 @@-// Next.js client instrumentation entry — runs before the app hydrates, i.e.-// before react-dom installs its DevTools global hook. This is the ONLY place-// early enough to register react-scan's instrument() and capture the initial-// mount.-//-// Distinct from the server-side `instrumentation.ts` `register()` hook — do not-// conflate them. This file is diagnosis-only and self-noops unless-// NEXT_PUBLIC_PERF_TRACE=1 in a non-production build.-import { installReactScan } from "@/lib/perf/react-scan-install"import { bootstrapObservability, onObservedRouterTransition } from "@/lib/observability/client"+import { isTauri } from "@alook/shared"+import { bootstrapGoogleAnalytics, updateGooglePageFields } from "@/lib/analytics-consent"+if (!isTauri()) bootstrapGoogleAnalytics()bootstrapObservability("web")-export function onRouterTransitionStart(url: string) { onObservedRouterTransition(url) }+export function onRouterTransitionStart(url: string) {+ if (!isTauri()) updateGooglePageFields(url)+ onObservedRouterTransition(url)+}// Fire-and-forget: the guard inside is synchronous, only the dynamic// react-scan import is async. Any failure is swallowed so instrumentation candiff --git a/src/web/src/lib/analytics-consent.test.ts b/src/web/src/lib/analytics-consent.test.tsindex 712bf2a26..9a726db53 100644--- a/src/web/src/lib/analytics-consent.test.ts+++ b/src/web/src/lib/analytics-consent.test.ts@@ -4,6 +4,9 @@ import {analyticsConsentCookieValue,announceAnalyticsConsent,applyGoogleConsent,+ bootstrapGoogleAnalytics,+ isPublicAnalyticsPath,+ updateGooglePageFields,hasAnalyticsConsent,parseAnalyticsConsentCookie,persistAnalyticsConsent,@@ -37,7 +40,8 @@ describe("analytics consent browser contract", () => {applyGoogleConsent("granted", "default")expect(browser.dataLayer).toHaveLength(1)- expect(browser.dataLayer[0]).toEqual([+ expect(Object.prototype.toString.call(browser.dataLayer[0])).toBe("[object Arguments]")+ expect(Array.from(browser.dataLayer[0] as IArguments)).toEqual(["consent","default",{@@ -50,7 +54,7 @@ describe("analytics consent browser contract", () => {applyGoogleConsent("denied")- expect(browser.dataLayer[1]).toEqual([+ expect(Array.from(browser.dataLayer[1] as IArguments)).toEqual(["consent","update",{@@ -62,6 +66,50 @@ describe("analytics consent browser contract", () => {])})++ it.each([undefined, "", "v0.granted", "v1.invalid", "v1.denied", "v1.granted"])("boots from the original Cookie %s before measurement", value => {+ const browser = { location: new URL("https://alook.ai/pricing?private=query#fragment"), dataLayer: [] as unknown[] }+ vi.stubGlobal("window", browser)+ vi.stubGlobal("document", { cookie: value === undefined ? "" : `alook_analytics_consent=${value}`, referrer: "https://alook.ai/c/private?secret=referrer" })+ bootstrapGoogleAnalytics()+ expect(Reflect.get(browser, "ga-disable-G-STBCL8F4ZY")).toBe(false)+ expect(browser.dataLayer.map(command => Array.from(command as IArguments))).toEqual([+ ["consent", "default", { analytics_storage: value === "v1.granted" ? "granted" : "denied", ad_storage: "denied", ad_user_data: "denied", ad_personalization: "denied" }],+ ["set", { page_location: "https://alook.ai/pricing", page_referrer: "" }],+ ])+ browser.location = new URL("https://alook.ai/c/me")+ expect(Reflect.get(browser, "ga-disable-G-STBCL8F4ZY")).toBe(true)+ })++ it.each(["/", "/pricing", "/contact", "/privacy", "/templates", "/templates/public", "/blog", "/blog/public/child"])("retains public path %s", path => {+ expect(isPublicAnalyticsPath(path)).toBe(true)+ })++ it.each(["/c", "/c/me", "/sign-in", "/auth/callback", "/templates/public/child", "/pricing/extra"])("retains private path %s", path => {+ expect(isPublicAnalyticsPath(path)).toBe(false)+ })++ it.each(["https://outside.example/path?secret=external#private", "https://alook.ai/blog/public?secret=internal", "not a URL"])("sanitizes existing referrer %s", referrer => {+ const browser = { location: new URL("https://alook.ai/"), dataLayer: [] as unknown[] }+ vi.stubGlobal("window", browser)+ vi.stubGlobal("document", { referrer })+ updateGooglePageFields("/templates/public?secret=query#fragment")+ expect(Array.from(browser.dataLayer[0] as IArguments)).toEqual(["set", {+ page_location: "https://alook.ai/templates/public",+ page_referrer: referrer === "not a URL" ? "" : referrer.split("?")[0],+ }])+ const count = browser.dataLayer.length+ for (const href of ["/c/me?secret=private", "https://outside.example/pricing", "http://["]) updateGooglePageFields(href)+ expect(browser.dataLayer).toHaveLength(count)+ expect(JSON.stringify(browser.dataLayer)).not.toMatch(/secret|fragment|page_view/)+ })++ it("does not initialize browser measurement on the server", () => {+ vi.stubGlobal("window", undefined)+ expect(() => bootstrapGoogleAnalytics()).not.toThrow()+ expect(() => updateGooglePageFields("/pricing")).not.toThrow()+ })+it("persists only after the API confirms the same decision", async () => {const fetcher = vi.fn(async () => new Response(JSON.stringify({ decision: "granted" }),diff --git a/src/web/src/lib/analytics-consent.ts b/src/web/src/lib/analytics-consent.tsindex 7ae49318c..b99a5f4ac 100644--- a/src/web/src/lib/analytics-consent.ts+++ b/src/web/src/lib/analytics-consent.ts@@ -6,6 +6,43 @@ export const ANALYTICS_CONSENT_CHANGE_EVENT = "alook:analytics-consent-change"export type AnalyticsConsentDecision = "granted" | "denied"+export const isPublicAnalyticsPath = (path: string) => /^\/(?:pricing|contact|privacy|templates(?:\/[^/]+)?|blog(?:\/.*)?)?$/.test(path)++function googleCommand(..._args: unknown[]): void {+ window.dataLayer ??= []+ // eslint-disable-next-line prefer-rest-params -- Google commands use dataLayer.push(arguments).+ window.dataLayer.push(arguments)+}++export function updateGooglePageFields(href: string): void {+ if (typeof window === "undefined" || typeof document === "undefined") return+ try {+ const location = new URL(href, window.location.origin)+ if (location.origin !== window.location.origin || !isPublicAnalyticsPath(location.pathname)) return+ let safeReferrer = ""+ try {+ const referrer = new URL(document.referrer || window.location.origin)+ if (referrer.origin !== window.location.origin || isPublicAnalyticsPath(referrer.pathname)) {+ safeReferrer = `${referrer.origin}${referrer.pathname}`+ }+ } catch {}+ googleCommand("set", {+ page_location: `${location.origin}${location.pathname}`,+ page_referrer: safeReferrer,+ })+ } catch {}+}++export function bootstrapGoogleAnalytics(): void {+ if (typeof window === "undefined") return+ Object.defineProperty(window, "ga-disable-G-STBCL8F4ZY", {+ configurable: true,+ get: () => !isPublicAnalyticsPath(window.location.pathname),+ })+ applyGoogleConsent(readAnalyticsConsent() ?? "denied", "default")+ updateGooglePageFields(window.location.href)+}+export function analyticsConsentCookieValue(decision: AnalyticsConsentDecision): string {return `${ANALYTICS_CONSENT_VERSION}.${decision}`}@@ -42,11 +79,7 @@ export function applyGoogleConsent(mode: "default" | "update" = "update",): void {if (typeof window === "undefined") return- window.dataLayer ??= []- function gtag(...args: unknown[]) {- window.dataLayer?.push(args)- }- gtag("consent", mode, {+ googleCommand("consent", mode, {analytics_storage: decision,ad_storage: "denied",ad_user_data: "denied",diff --git a/src/web/src/lib/analytics.test.ts b/src/web/src/lib/analytics.test.tsindex d48026059..209a41573 100644--- a/src/web/src/lib/analytics.test.ts+++ b/src/web/src/lib/analytics.test.ts@@ -1,4 +1,4 @@-import { describe, it, expect, vi, beforeEach } from "vitest"+import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"const mocks = vi.hoisted(() => ({hasAnalyticsConsent: vi.fn(() => true),@@ -7,7 +7,8 @@ const mocks = vi.hoisted(() => ({vi.mock("@next/third-parties/google", () => ({sendGTMEvent: (...args: unknown[]) => mocks.sendGTMEvent(...args),}))-vi.mock("./analytics-consent", () => ({+vi.mock("./analytics-consent", async importOriginal => ({+ ...await importOriginal<typeof import("./analytics-consent")>(),hasAnalyticsConsent: () => mocks.hasAnalyticsConsent(),}))@@ -15,13 +16,15 @@ const mockSendGTMEvent = mocks.sendGTMEventimport { trackSignUp, trackSignInSuccess, trackInviteAccepted, trackCommunityRuntimeConnected, trackCommunityOnboardingCompleted, trackCommunityOnboardingSkipped, trackCommunityOnboardingStageCompleted, trackCommunityOnboardingStarted, trackFirstAgentReplyPersisted, trackHumanInvitationSent, trackHumanInvitationCopied, trackInvitedHumanJoined, trackGithubOutboundClicked, trackLandingCtaClicked, trackTemplatesBrowsed, trackCommunityWsFrameDropped, trackCommunityWsAuthFailure, trackCommunityWsLifecycleClose, trackCommunityWsLifecycleRecovery, trackCommunityWsLifecycleStage, trackCommunityWsReconcileComplete, trackCommunityWsReconcileFailure, trackCommunityWsRetryScheduled, toAnalyticsCurrentPlan, toAnalyticsPlanId, trackBeginCheckout, trackPricingCtaClick, trackPricingView } from "./analytics"+afterEach(() => vi.unstubAllGlobals())+describe("analytics utility", () => {beforeEach(() => {vi.clearAllMocks()mocks.hasAnalyticsConsent.mockReturnValue(true)})- it("drops events while analytics consent is absent or denied", () => {+ it("retains the original consent gate outside public Web", () => {mocks.hasAnalyticsConsent.mockReturnValue(false)trackSignUp("github")trackPricingView({ auth_state: "guest", current_plan: "none" })@@ -29,6 +32,44 @@ describe("analytics utility", () => {expect(mockSendGTMEvent).not.toHaveBeenCalled()})++ it.each(["/", "/pricing", "/contact", "/privacy", "/templates/public", "/blog/public"])("sends the original public payloads on %s without a grant", path => {+ mocks.hasAnalyticsConsent.mockReturnValue(false)+ vi.stubGlobal("window", { location: new URL(`https://alook.ai${path}?private=query`) })+ trackPricingView({ auth_state: "guest", current_plan: "none" })+ trackLandingCtaClicked({ cta_name: "get_started" })+ trackTemplatesBrowsed({ category_filter: "engineering" })+ trackGithubOutboundClicked("blog")+ expect(mockSendGTMEvent.mock.calls).toEqual([+ [{ event: "pricing_view", auth_state: "guest", current_plan: "none" }],+ [{ event: "landing_cta_clicked", cta_name: "get_started" }],+ [{ event: "templates_browsed", category_filter: "engineering" }],+ [{ event: "github_outbound_clicked", surface: "blog", destination: "alook_repo" }],+ ])+ })++ it.each(["/c/me", "/sign-in", "/templates/public/child"])("does not expand denied private events on %s or replay them later", path => {+ mocks.hasAnalyticsConsent.mockReturnValue(false)+ const browser = { location: new URL(`https://alook.ai${path}`) }+ vi.stubGlobal("window", browser)+ trackCommunityRuntimeConnected()+ trackSignUp("github")+ expect(mockSendGTMEvent).not.toHaveBeenCalled()+ browser.location = new URL("https://alook.ai/pricing")+ trackPricingView({ auth_state: "guest", current_plan: "none" })+ expect(mockSendGTMEvent.mock.calls).toEqual([[{ event: "pricing_view", auth_state: "guest", current_plan: "none" }]])+ })++ it("preserves the Native Allow gate on public paths", () => {+ vi.stubGlobal("window", { __TAURI__: {}, location: new URL("https://alook.ai/") })+ mocks.hasAnalyticsConsent.mockReturnValue(false)+ trackSignUp("github")+ expect(mockSendGTMEvent).not.toHaveBeenCalled()+ mocks.hasAnalyticsConsent.mockReturnValue(true)+ trackSignUp("github")+ expect(mockSendGTMEvent.mock.calls).toEqual([[{ event: "sign_up", method: "github" }]])+ })+describe("P0 — Core Funnel Events", () => {it("trackSignUp sends sign_up event", () => {trackSignUp("github")diff --git a/src/web/src/lib/analytics.ts b/src/web/src/lib/analytics.tsindex 063940e73..740f62a69 100644--- a/src/web/src/lib/analytics.ts+++ b/src/web/src/lib/analytics.ts@@ -1,7 +1,8 @@"use client";import { sendGTMEvent } from "@next/third-parties/google";-import { hasAnalyticsConsent } from "@/lib/analytics-consent"+import { isTauri } from "@alook/shared"+import { hasAnalyticsConsent, isPublicAnalyticsPath } from "@/lib/analytics-consent"const analyticsPlanIds = ["free", "studio", "house"] as const@@ -33,7 +34,8 @@ const pricingCtaIdByEntryPoint: Record<BillingEntryPoint, Partial<Record<Analyticonst analyticsPlanIdSet = new Set<string>(analyticsPlanIds)function sendConsentAwareGTMEvent(payload: Record<string, unknown>) {- if (!hasAnalyticsConsent()) return+ const publicWeb = typeof window !== "undefined" && !isTauri() && isPublicAnalyticsPath(window.location.pathname)+ if (!publicWeb && !hasAnalyticsConsent()) returntry {sendGTMEvent(payload)} catch {