From d482f73ed87c6c746df73d7238b2ef11ea8b71f8 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 10:02:58 -0300 Subject: [PATCH 1/9] chore(Tracking): Stop loading LinkedIn, Albacross and Universal Analytics in the app Co-Authored-By: Claude Opus 5.5 --- .../environment-variables.md | 2 -- frontend/api/dev-routes.js | 3 -- frontend/api/index.js | 8 ----- frontend/common/stores/account-store.js | 6 ---- frontend/common/stores/feature-list-store.ts | 1 - frontend/common/stores/organisation-store.js | 1 - frontend/env/project_prod.js | 1 - .../components/pages/home-page/HomePage.tsx | 18 ----------- frontend/web/index.handlebars | 3 -- frontend/web/project/api.ts | 18 ----------- frontend/web/project/libs.js | 31 ------------------- 11 files changed, 92 deletions(-) diff --git a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md index 8a5f8f4d3164..360ef84c391d 100644 --- a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md +++ b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md @@ -86,7 +86,6 @@ relevant section below for more details. `/api/v1/` through to `PROXY_API_URL`. If you are using this, any setting to `FLAGSMITH_API_URL` will be ignored and the browser will use the frontend node server to send API requests. Do not prepend `api/v1/` - it will be added automatically. -- `GOOGLE_ANALYTICS_API_KEY`: Google Analytics key to track API usage. - `PYLON_APP_ID`: Pylon in-app chat widget App ID. - `FIRST_PROMOTER_ID`: First Promoter ID for checkout affiliates. - `ALLOW_SIGNUPS`: **DEPRECATED** in favour of `PREVENT_SIGNUP` in the API. Determines whether to prevent manual signups @@ -99,7 +98,6 @@ relevant section below for more details. - `REO_API_KEY`: The Reo key to use for behaviour tracking. - `MIXPANEL_API_KEY`: Mixpanel analytics key to use for behaviour tracking. - `SENTRY_API_KEY`: Sentry key for error reporting. -- `ALBACROSS_CLIENT_ID`: Albacross client ID key for behaviour tracking. - `BASE_URL`: Used for specifying a base URL path that's ignored during routing if serving from a subdirectory. - `USE_SECURE_COOKIES`: Enable/disable the use of secure cookies. If deploying the frontend in a private network without a domain/SSL cert, disable secure cookies to ensure that session token is persisted. Default: true. diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index 49a8a62f7af7..7af0c09888cd 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -31,7 +31,6 @@ module.exports = function setupRoutes(app) { { name: 'superUserCreateOnly', value: envToBool('ONLY_SUPERUSERS_CAN_CREATE_ORGANISATIONS', false) }, { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, - { name: 'ga', value: process.env.GOOGLE_ANALYTICS_API_KEY }, { name: 'sha', value: sha }, { name: 'pylonAppId', value: process.env.PYLON_APP_ID }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, @@ -48,8 +47,6 @@ module.exports = function setupRoutes(app) { { name: 'delighted', value: process.env.DELIGHTED_API_KEY }, { name: 'capterraKey', value: process.env.CAPTERRA_API_KEY }, { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false) }, - { name: 'linkedinPartnerTracking', value: envToBool('LINKEDIN_PARTNER_TRACKING', false) }, - { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 5b5c9284c187..9af9a9e0c080 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -67,7 +67,6 @@ app.get('/config/project-overrides', (req, res) => { }, { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, - { name: 'ga', value: process.env.GOOGLE_ANALYTICS_API_KEY }, { name: 'sha', value: sha }, { name: 'pylonAppId', value: process.env.PYLON_APP_ID }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, @@ -107,11 +106,6 @@ app.get('/config/project-overrides', (req, res) => { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false), }, - { - name: 'linkedinPartnerTracking', - value: envToBool('LINKEDIN_PARTNER_TRACKING', false), - }, - { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, @@ -295,10 +289,8 @@ app.post('/api/webflow/webhook', (req, res) => { // Catch all to render index template app.get('/', (req, res) => { - const linkedin = process.env.LINKEDIN || '' return res.render('index', { isDev, - linkedin, }) }) diff --git a/frontend/common/stores/account-store.js b/frontend/common/stores/account-store.js index cb701c588edb..ac2a66c82b13 100644 --- a/frontend/common/stores/account-store.js +++ b/frontend/common/stores/account-store.js @@ -131,12 +131,6 @@ const controller = { }) } } - - if (Project.linkedinConversionId) { - window.lintrk?.('track', { - conversion_id: Project.linkedinConversionId, - }) - } }) }, deleteOrganisation: () => { diff --git a/frontend/common/stores/feature-list-store.ts b/frontend/common/stores/feature-list-store.ts index 4b06187083fa..3c1d58cacad2 100644 --- a/frontend/common/stores/feature-list-store.ts +++ b/frontend/common/stores/feature-list-store.ts @@ -189,7 +189,6 @@ const controller = { }, value: flag.name, }) - window.lintrk?.('track', { conversion_id: 16798354 }) } else { flagsmith.trackEvent('feature_created', { metadata: { diff --git a/frontend/common/stores/organisation-store.js b/frontend/common/stores/organisation-store.js index 9a1b7499ac92..cc1caf8bd3c0 100644 --- a/frontend/common/stores/organisation-store.js +++ b/frontend/common/stores/organisation-store.js @@ -57,7 +57,6 @@ const controller = { .then((res) => createSampleUser(res, envName, project)) }), ).then((res) => { - window.lintrk?.('track', { conversion_id: 16798346 }) project.environments = res store.model.projects = store.model.projects.concat(project) getStore().dispatch(projectService.util.invalidateTags(['Project'])) diff --git a/frontend/env/project_prod.js b/frontend/env/project_prod.js index 8f0dc98013f3..37cc25bedb7c 100644 --- a/frontend/env/project_prod.js +++ b/frontend/env/project_prod.js @@ -44,7 +44,6 @@ const Project = { region: 'eu1', }, - linkedinConversionId: 16798338, // This is used for Sentry tracking maintenance: false, plans: { diff --git a/frontend/web/components/pages/home-page/HomePage.tsx b/frontend/web/components/pages/home-page/HomePage.tsx index 2b87540d2cdf..22e7b3740d0e 100644 --- a/frontend/web/components/pages/home-page/HomePage.tsx +++ b/frontend/web/components/pages/home-page/HomePage.tsx @@ -137,27 +137,12 @@ const HomePage: React.FC = () => { API.setCookie('marketing_consent_given', 'true') }, []) - const addAlbacross = () => { - // @ts-ignore - window._nQc = Project.albacross - const script = document.createElement('script') - script.type = 'text/javascript' - script.async = true - script.src = 'https://serve.albacross.com/track.js' - script.id = 'albacross' - document.body.appendChild(script) - } - useEffect(() => { if (!E2E) { const emailField = (document.querySelector('input[name="firstName"]') || document.querySelector('input[name="email"]')) as HTMLInputElement emailField?.focus() } - - if (Project.albacross && location.pathname.indexOf('signup') !== -1) { - addAlbacross() - } }, [location.pathname]) useEffect(() => { @@ -166,9 +151,6 @@ const HomePage: React.FC = () => { if (plan) { API.setCookie('plan', plan) } - if (Project.albacross && location.pathname.indexOf('signup') !== -1) { - addAlbacross() - } if (document.location.href.includes('oauth')) { const oAuthUtms = Utils.getUtmsFromUrl(document.location.href) const parts = document.location.href.split('oauth/') diff --git a/frontend/web/index.handlebars b/frontend/web/index.handlebars index e1d5ef2be951..9e11d7bce877 100644 --- a/frontend/web/index.handlebars +++ b/frontend/web/index.handlebars @@ -104,7 +104,4 @@ {{/if}} -{{#if linkedin}} - -{{/if}} diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index 039667a3deee..934b95248b74 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -331,24 +331,6 @@ const API = { extra?: Record }): void { try { - if (Project.ga) { - if (Project.logAnalytics) console.log('ANALYTICS EVENT', data) - if (!data || !data.category || !data.event) - return console.error('Invalid event provided', data) - if (data.category === 'First') - API.postEvent( - `${data.event}${ - data.extra ? ` ${JSON.stringify(data.extra)}` : '' - }`, - 'first_events', - ) - ga('send', { - eventAction: data.event, - eventCategory: data.category, - eventLabel: data.label, - hitType: 'event', - }) - } if (Project.amplitude) { amplitude.track(data.event, { category: data.category, diff --git a/frontend/web/project/libs.js b/frontend/web/project/libs.js index 4d6adceca99a..d15f96a6d886 100644 --- a/frontend/web/project/libs.js +++ b/frontend/web/project/libs.js @@ -45,16 +45,6 @@ window.NavLink = NavLink; // Analytics — not loaded in E2E runs, where widgets can overlay the UI const disableThirdPartyScripts = !!window.E2E -if (Project.ga && !disableThirdPartyScripts) { - (function (i, s, o, g, r, a, m) { - i.GoogleAnalyticsObject = r; i[r] = i[r] || function () { - (i[r].q = i[r].q || []).push(arguments); - }, i[r].l = 1 * new Date(); a = s.createElement(o), - m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); - }(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga')); - ga('create', Project.ga, 'auto'); -} - if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Sentry !== 'undefined') { Sentry.init({ dsn: Project.sentry, @@ -66,27 +56,6 @@ if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Se if (Project.delighted) { !(function (e, t, r, n) { if (!e[n]) { for (var a = e[n] = [], i = ['survey', 'reset', 'config', 'init', 'set', 'get', 'event', 'identify', 'track', 'page', 'screen', 'group', 'alias'], s = 0; s < i.length; s++) { const c = i[s]; a[c] = a[c] || (function (e) { return function () { const t = Array.prototype.slice.call(arguments); a.push([e, t]); }; }(c)); }a.SNIPPET_VERSION = '1.0.1'; const o = t.createElement('script'); o.type = 'text/javascript', o.async = !0, o.src = `https://d2yyd1h5u9mauk.cloudfront.net/integrations/web/v1/library/${r}/${n}.js`; const p = t.getElementsByTagName('script')[0]; p.parentNode.insertBefore(o, p); } }(window, document, Project.delighted, 'delighted')); } -if(Project.linkedinPartnerTracking) { - const _linkedin_partner_id = "5747572"; - window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; - window._linkedin_data_partner_ids.push(_linkedin_partner_id); - (function(l) { - if (!l){window.lintrk = function(a,b){window.lintrk.q.push([a,b])}; - window.lintrk.q=[]} - var s = document.getElementsByTagName("script")[0]; - var b = document.createElement("script"); - b.type = "text/javascript";b.async = true; - b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js"; - s.parentNode.insertBefore(b, s);})(window.lintrk); - var img = document.createElement("img"); - img.setAttribute("height", "1"); - img.setAttribute("width", "1"); - img.setAttribute("style", "display:none;"); - img.setAttribute("alt", ""); - img.setAttribute("src", "https://px.ads.linkedin.com/collect/?pid=5747572&fmt=gif"); - document.body.appendChild(img); -} - if(Project.hubspot && !disableThirdPartyScripts) { // Must be set before the script loads. The chat widget is loaded by // common/loadChat behind the hubspot_chat flag, not by chatflow targeting. From 3c3bd9435aa8bf39fd7116364c97897e12f9edd8 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 10:21:59 -0300 Subject: [PATCH 2/9] chore(Tracking): Remove Delighted surveys The Delighted library now returns 502, so surveys could no longer load. Co-Authored-By: Claude Opus 5.5 --- frontend/.eslintrc.js | 1 - frontend/api/dev-routes.js | 1 - frontend/api/index.js | 1 - frontend/global.d.ts | 8 -------- frontend/web/project/api.ts | 19 ------------------- frontend/web/project/libs.js | 3 --- 6 files changed, 33 deletions(-) diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 61f797791960..dcfe41e72141 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -158,7 +158,6 @@ module.exports = { '__DEV__': true, 'closeModal': true, 'closeModal2': true, - 'delighted': true, 'describe': true, 'em': true, 'flagsmith': true, diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index 7af0c09888cd..0ae226cdf482 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -44,7 +44,6 @@ module.exports = function setupRoutes(app) { { name: 'flagsmithRealtime', value: envToBool('ENABLE_FLAGSMITH_REALTIME', false) }, { name: 'amplitude', value: process.env.AMPLITUDE_API_KEY }, { name: 'reo', value: process.env.REO_API_KEY }, - { name: 'delighted', value: process.env.DELIGHTED_API_KEY }, { name: 'capterraKey', value: process.env.CAPTERRA_API_KEY }, { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false) }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 9af9a9e0c080..44a53db07c02 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -100,7 +100,6 @@ app.get('/config/project-overrides', (req, res) => { }, { name: 'amplitude', value: process.env.AMPLITUDE_API_KEY }, { name: 'reo', value: process.env.REO_API_KEY }, - { name: 'delighted', value: process.env.DELIGHTED_API_KEY }, { name: 'capterraKey', value: process.env.CAPTERRA_API_KEY }, { name: 'hideInviteLinks', diff --git a/frontend/global.d.ts b/frontend/global.d.ts index 3cbae08305a1..ecbbc2b3ad37 100644 --- a/frontend/global.d.ts +++ b/frontend/global.d.ts @@ -25,14 +25,6 @@ declare global { command: 'send', fields: UniversalAnalytics.PageviewFieldsObject, ): void - const delighted: { - survey: (opts: { - createdAt: string - email: string - name: string - properties: Record - }) => void - } const openModal: ( title: ReactNode, body?: ReactNode, diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index 934b95248b74..3bca9de49f3e 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -3,9 +3,7 @@ import data from 'common/data/base/_data' // @ts-ignore import { loadReoScript, ReoInstance } from 'reodotdev' import * as amplitude from '@amplitude/analytics-browser' -import isFreeEmailDomain from 'common/utils/isFreeEmailDomain' import { groupBy } from 'lodash' -import getUserDisplayName from 'common/utils/getUserDisplayName' import Cookies from 'js-cookie' import Project from 'common/project' import { AccountModel, User } from 'common/types/responses' @@ -165,23 +163,6 @@ const API = { ((flagsmith.getTrait('logins') as number) || 0) + 1, ), ) - .then(() => { - const organisation = AccountStore.getOrganisation() - const emailDomain = user.email.split('@')[1] || '' - const freeDomain = isFreeEmailDomain(emailDomain) - if ( - !freeDomain && - typeof delighted !== 'undefined' && - flagsmith.hasFeature('delighted') - ) { - delighted.survey({ - createdAt: user.date_joined || new Date().toISOString(), - email: user.email, - name: getUserDisplayName(user), - properties: { company: organisation?.name }, - }) - } - }) }, getCookie(key: string): string | undefined { diff --git a/frontend/web/project/libs.js b/frontend/web/project/libs.js index d15f96a6d886..f7a099553415 100644 --- a/frontend/web/project/libs.js +++ b/frontend/web/project/libs.js @@ -53,9 +53,6 @@ if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Se }); } -if (Project.delighted) { - !(function (e, t, r, n) { if (!e[n]) { for (var a = e[n] = [], i = ['survey', 'reset', 'config', 'init', 'set', 'get', 'event', 'identify', 'track', 'page', 'screen', 'group', 'alias'], s = 0; s < i.length; s++) { const c = i[s]; a[c] = a[c] || (function (e) { return function () { const t = Array.prototype.slice.call(arguments); a.push([e, t]); }; }(c)); }a.SNIPPET_VERSION = '1.0.1'; const o = t.createElement('script'); o.type = 'text/javascript', o.async = !0, o.src = `https://d2yyd1h5u9mauk.cloudfront.net/integrations/web/v1/library/${r}/${n}.js`; const p = t.getElementsByTagName('script')[0]; p.parentNode.insertBefore(o, p); } }(window, document, Project.delighted, 'delighted')); -} if(Project.hubspot && !disableThirdPartyScripts) { // Must be set before the script loads. The chat widget is loaded by // common/loadChat behind the hubspot_chat flag, not by chatflow targeting. From fb400e2060a58bdecfdac4d1cb2a1784f69b2c8a Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 10:26:49 -0300 Subject: [PATCH 3/9] chore(Tracking): Remove Amplitude Engagement Nothing in Guides & Surveys is live, and its owner has left. Co-Authored-By: Claude Opus 5.5 --- frontend/global.d.ts | 5 ----- frontend/package-lock.json | 16 ---------------- frontend/package.json | 1 - frontend/web/components/App.js | 2 -- frontend/web/project/api.ts | 11 ----------- 5 files changed, 35 deletions(-) diff --git a/frontend/global.d.ts b/frontend/global.d.ts index ecbbc2b3ad37..4b513c366abe 100644 --- a/frontend/global.d.ts +++ b/frontend/global.d.ts @@ -84,11 +84,6 @@ declare global { interface Window { E2E: boolean - engagement: { - init(apiKey: string, options?: InitOptions): void - plugin(): unknown - boot(options: BootOptions): Promise - } } } diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 48cf10d299af..b844b07922d8 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "dependencies": { "@amplitude/analytics-browser": "^2.11.3", - "@amplitude/engagement-browser": "^0.0.5", "@amplitude/plugin-session-replay-browser": "^1.6.24", "@babel/core": "7.29.6", "@babel/plugin-proposal-class-properties": "^7.12.1", @@ -198,12 +197,6 @@ "zen-observable": "0.10.0" } }, - "node_modules/@amplitude/analytics-types": { - "version": "2.8.4", - "resolved": "https://registry.npmjs.org/@amplitude/analytics-types/-/analytics-types-2.8.4.tgz", - "integrity": "sha512-jQ8WY1aPbpBshl0L/0YEeQn/wZlBr8Jlqc20qf8nbuDuimFy8RqAkE+BVaMI86FCkr3AJ7PjMXkGwCSbUx88CA==", - "license": "MIT" - }, "node_modules/@amplitude/element-selector": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@amplitude/element-selector/-/element-selector-0.3.2.tgz", @@ -213,15 +206,6 @@ "tslib": "^2.4.1" } }, - "node_modules/@amplitude/engagement-browser": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/@amplitude/engagement-browser/-/engagement-browser-0.0.5.tgz", - "integrity": "sha512-jjOPzkCcuxqzKW6RcxUKndDKygyJjcF2T05CbdJV2pheH52iAy228wR8WosOp1L8umaupswWN5TWJCj8HYHIbA==", - "license": "MIT", - "dependencies": { - "@amplitude/analytics-types": "2.8.4" - } - }, "node_modules/@amplitude/experiment-core": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/@amplitude/experiment-core/-/experiment-core-0.7.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index 5962abdd8127..84028f02300c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -48,7 +48,6 @@ }, "dependencies": { "@amplitude/analytics-browser": "^2.11.3", - "@amplitude/engagement-browser": "^0.0.5", "@amplitude/plugin-session-replay-browser": "^1.6.24", "@babel/core": "7.29.6", "@babel/plugin-proposal-class-properties": "^7.12.1", diff --git a/frontend/web/components/App.js b/frontend/web/components/App.js index b8e73fcd2ecc..f5b2443acb58 100644 --- a/frontend/web/components/App.js +++ b/frontend/web/components/App.js @@ -3,7 +3,6 @@ import get from 'lodash/get' import find from 'lodash/find' import { matchPath, withRouter } from 'react-router-dom' import * as amplitude from '@amplitude/analytics-browser' -import { plugin as engagementPlugin } from '@amplitude/engagement-browser' import { sessionReplayPlugin } from '@amplitude/plugin-session-replay-browser' import TwoFactorPrompt from './SimpleTwoFactor/prompt' import Maintenance from './Maintenance' @@ -88,7 +87,6 @@ const App = class extends Component { defaultTracking: true, serverZone: 'EU', }) - amplitude.add(engagementPlugin()) const sessionReplayTracking = sessionReplayPlugin({ sampleRate: 0.5, serverZone: 'EU', diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index 3bca9de49f3e..74c8dbdbfd28 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -120,17 +120,6 @@ const API = { const amplitudeUserId = user.uuid || id amplitude.setUserId(amplitudeUserId) API.trackTraits({ email: id }) - if (window.engagement) { - window.engagement.boot({ - integrations: [ - { - track: (event: any) => - amplitude.track(event.event_type, event.event_properties), - }, - ], - user: { user_id: amplitudeUserId, user_properties: {} }, - }) - } } }, From 101ed6c626529ddd9c3f5e154e849bbfc26641d8 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 10:27:55 -0300 Subject: [PATCH 4/9] chore(Support): Remove the Pylon chat widget HubSpot chat is on for everyone, so Pylon could no longer load. Co-Authored-By: Claude Opus 5.5 --- .../environment-variables.md | 1 - frontend/api/dev-routes.js | 1 - frontend/api/index.js | 1 - frontend/common/__tests__/loadChat.test.ts | 35 +------ frontend/common/loadChat.ts | 91 +------------------ .../components/pages/GettingStartedPage.tsx | 5 +- frontend/web/project/api.ts | 4 +- 7 files changed, 9 insertions(+), 129 deletions(-) diff --git a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md index 360ef84c391d..8843796ddede 100644 --- a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md +++ b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md @@ -86,7 +86,6 @@ relevant section below for more details. `/api/v1/` through to `PROXY_API_URL`. If you are using this, any setting to `FLAGSMITH_API_URL` will be ignored and the browser will use the frontend node server to send API requests. Do not prepend `api/v1/` - it will be added automatically. -- `PYLON_APP_ID`: Pylon in-app chat widget App ID. - `FIRST_PROMOTER_ID`: First Promoter ID for checkout affiliates. - `ALLOW_SIGNUPS`: **DEPRECATED** in favour of `PREVENT_SIGNUP` in the API. Determines whether to prevent manual signups without invites. Set it to any value to allow signups. diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index 0ae226cdf482..c51cc55f5744 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -32,7 +32,6 @@ module.exports = function setupRoutes(app) { { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, { name: 'sha', value: sha }, - { name: 'pylonAppId', value: process.env.PYLON_APP_ID }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, { name: 'sentry', value: process.env.SENTRY_API_KEY }, { name: 'api', value: process.env.FLAGSMITH_PROXY_API_URL ? '/api/v1/' : process.env.FLAGSMITH_API_URL }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 44a53db07c02..847461157d22 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -68,7 +68,6 @@ app.get('/config/project-overrides', (req, res) => { { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, { name: 'sha', value: sha }, - { name: 'pylonAppId', value: process.env.PYLON_APP_ID }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, { name: 'sentry', value: process.env.SENTRY_API_KEY }, { diff --git a/frontend/common/__tests__/loadChat.test.ts b/frontend/common/__tests__/loadChat.test.ts index 3cfde042397f..f4c8b05812b6 100644 --- a/frontend/common/__tests__/loadChat.test.ts +++ b/frontend/common/__tests__/loadChat.test.ts @@ -77,7 +77,7 @@ beforeEach(() => { }) describe('getChatProvider', () => { - it('returns hubspot when only hubspot_chat is on', () => { + it('returns hubspot when hubspot_chat is on', () => { // Given setFlags(['hubspot_chat']) @@ -85,25 +85,9 @@ describe('getChatProvider', () => { expect(getChatProvider()).toBe('hubspot') }) - it('prefers hubspot while both flags are on', () => { - // Given - setFlags(['hubspot_chat', 'pylon_chat']) - - // When / Then - expect(getChatProvider()).toBe('hubspot') - }) - - it('returns pylon when only pylon_chat is on', () => { - // Given - setFlags(['pylon_chat']) - - // When / Then - expect(getChatProvider()).toBe('pylon') - }) - it('keeps HubSpot to paid plans when hubspot_chat has no value', () => { // Given - setFlags(['hubspot_chat', 'pylon_chat']) + setFlags(['hubspot_chat']) mockUtils.isOrgOnFreePlan.mockReturnValue(true) // When / Then @@ -128,15 +112,6 @@ describe('getChatProvider', () => { // When / Then expect(getChatProvider()).toBe('hubspot') }) - - it('keeps Pylon to paid plans', () => { - // Given - setFlags(['pylon_chat']) - mockUtils.isOrgOnFreePlan.mockReturnValue(true) - - // When / Then - expect(getChatProvider()).toBeNull() - }) }) describe('openChat', () => { @@ -192,19 +167,17 @@ describe('openChat', () => { }) describe('identifyChatUser', () => { - it('hides Pylon and loads HubSpot when hubspot_chat is on', async () => { + it('loads HubSpot when hubspot_chat is on', async () => { // Given - setFlags(['hubspot_chat', 'pylon_chat']) + setFlags(['hubspot_chat']) const widget = hubSpotWidget(false) window.HubSpotConversations = { widget } - window.Pylon = jest.fn() // When identifyChatUser() await flushPromises() // Then - expect(window.Pylon).toHaveBeenCalledWith('hideChatBubble') expect(widget.load).toHaveBeenCalledWith({ widgetOpen: false }) }) diff --git a/frontend/common/loadChat.ts b/frontend/common/loadChat.ts index ace22b6aa37e..cc9a9ed972a5 100644 --- a/frontend/common/loadChat.ts +++ b/frontend/common/loadChat.ts @@ -1,7 +1,5 @@ declare global { interface Window { - Pylon?: ((...args: unknown[]) => void) & { q?: unknown[][] } - pylon?: { chat_settings: Record } hsConversationsSettings?: { loadImmediately?: boolean identificationEmail?: string @@ -22,22 +20,17 @@ declare global { import AccountStore from './stores/account-store' import { getStore } from './store' import { getHubspotChatToken } from './services/useHubspotChatToken' -import getUserDisplayName from './utils/getUserDisplayName' import Utils from './utils/utils' import { AccountModel, HubspotChatToken } from './types/responses' -import Project from './project' -const defaultPylonID = '028babb7-d93f-4e32-be6a-59db190a084f' const SUPPORT_EMAIL_URL = 'mailto:support@flagsmith.com' -export type ChatProvider = 'hubspot' | 'pylon' +export type ChatProvider = 'hubspot' // hubspot_chat's value sets who gets HubSpot chat: "all" opens it to every // plan, anything else (including no value) keeps it to paid plans. const HUBSPOT_CHAT_ALL_PLANS = 'all' -// HubSpot wins while both flags are on, so turning hubspot_chat on is enough -// to switch provider. export function getChatProvider(): ChatProvider | null { const isFreePlan = Utils.isOrgOnFreePlan() if (Utils.getFlagsmithHasFeature('hubspot_chat')) { @@ -46,59 +39,9 @@ export function getChatProvider(): ChatProvider | null { .toLowerCase() return audience === HUBSPOT_CHAT_ALL_PLANS || !isFreePlan ? 'hubspot' : null } - if (Utils.getFlagsmithHasFeature('pylon_chat') && !isFreePlan) return 'pylon' return null } -async function loadPylon(pylonAppId: string) { - if (window.Pylon) { - return - } - - await new Promise((resolve, reject) => { - const t = document - const n: ((...args: unknown[]) => void) & { q?: unknown[][] } = - Object.assign((...args: unknown[]) => n.q!.push(args), { q: [] }) - window.Pylon = n - - const s = t.createElement('script') - s.setAttribute('type', 'text/javascript') - s.setAttribute('async', 'true') - s.setAttribute('src', `https://widget.usepylon.com/widget/${pylonAppId}`) - s.onload = () => resolve(undefined) - s.onerror = reject - const firstScript = t.getElementsByTagName('script')[0] - firstScript.parentNode?.insertBefore(s, firstScript) - }) -} - -function setupPylon() { - const user = AccountStore.getUser() as AccountModel - if (typeof window.Pylon === 'undefined' || !user) { - return - } - - try { - window.pylon = { - chat_settings: { - account_id: String(user.id), - app_id: Project.pylonAppId || defaultPylonID, - email: user.email, - email_hash: user.pylon_email_signature, - name: getUserDisplayName(user), - }, - } - } catch (error) { - console.error('Error setting up Pylon:', error) - } -} - -function hidePylon() { - if (typeof window.Pylon !== 'undefined') { - window.Pylon('hideChatBubble') - } -} - let isLoadingHubSpot = false let openHubSpotOnLoad = false // load() was called. status().loaded stays false until HubSpot's iframe is @@ -203,21 +146,12 @@ function removeHubSpot() { } export function hideChat() { - hidePylon() removeHubSpot() } export function identifyChatUser() { - const provider = getChatProvider() - if (provider === 'hubspot') { - hidePylon() + if (getChatProvider() === 'hubspot') { showHubSpot() - } else if (provider === 'pylon') { - removeHubSpot() - setupPylon() - if (typeof window.Pylon !== 'undefined') { - window.Pylon('showChatBubble') - } } else { hideChat() } @@ -235,27 +169,6 @@ export function openChat() { } return } - if (provider === 'pylon' && typeof window.Pylon !== 'undefined') { - window.Pylon('show') - setupPylon() - return - } // No chat for this org, or the widget was blocked: email beats a dead click. window.location.href = SUPPORT_EMAIL_URL } - -export default async function loadChat(forceDefaultAPIKey?: boolean) { - try { - const isWidget = document.location.href.includes('/widget') - if (isWidget) return - - if (getChatProvider() === 'pylon') { - const pylonId = forceDefaultAPIKey ? defaultPylonID : Project.pylonAppId - if (pylonId) { - await loadPylon(pylonId) - } - } - } catch (error) { - console.error('Failed to initialize chat widget:', error) - } -} diff --git a/frontend/web/components/pages/GettingStartedPage.tsx b/frontend/web/components/pages/GettingStartedPage.tsx index b494fe3bc618..556398bbc0bf 100644 --- a/frontend/web/components/pages/GettingStartedPage.tsx +++ b/frontend/web/components/pages/GettingStartedPage.tsx @@ -1,7 +1,7 @@ import React, { FC, useEffect, useState } from 'react' import PageTitle from 'components/PageTitle' import Button from 'components/base/forms/Button' -import loadChat, { openChat } from 'common/loadChat' +import { openChat } from 'common/loadChat' import Utils from 'common/utils/utils' import ConfigProvider from 'common/providers/ConfigProvider' import Icon from 'components/icons/Icon' @@ -27,8 +27,7 @@ const GettingStartedPage: FC = () => { document.body.classList.remove('full-screen') } }, []) - async function onChatClick() { - await loadChat(true) + function onChatClick() { openChat() } diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index 74c8dbdbfd28..e0d3eef67ee9 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -10,7 +10,7 @@ import { AccountModel, User } from 'common/types/responses' import AccountStore from 'common/stores/account-store' import flagsmith from '@flagsmith/flagsmith' import Utils from 'common/utils/utils' -import loadChat, { identifyChatUser } from 'common/loadChat' +import { identifyChatUser } from 'common/loadChat' // Days, or an absolute date. This is js-cookie's own attribute type, spelled // out because the package ships no types. @@ -80,10 +80,8 @@ const API = { await API.flagsmithIdentify() - // Load and setup chat widget based on feature flag const isWidget = document.location.href.includes('/widget') if (!E2E && !isWidget) { - await loadChat() identifyChatUser() } From 55dea4164c1d0a6eb0c5888a092e972e3a11b9bc Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 11:20:17 -0300 Subject: [PATCH 5/9] fix(Tracking): Keep first-event Slack notifications without Google Analytics They were sent only when GA was configured. trackPage is now a no-op until its callers are removed. Co-Authored-By: Claude Opus 5.5 --- frontend/.eslintrc.js | 1 - frontend/global.d.ts | 13 ------------- frontend/web/project/api.ts | 23 ++++++++++------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index dcfe41e72141..3b451c57fba6 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -161,7 +161,6 @@ module.exports = { 'describe': true, 'em': true, 'flagsmith': true, - 'ga': true, 'heap': true, 'hljs': true, 'hot': true, diff --git a/frontend/global.d.ts b/frontend/global.d.ts index 4b513c366abe..e410ca900bef 100644 --- a/frontend/global.d.ts +++ b/frontend/global.d.ts @@ -10,21 +10,8 @@ export type OpenConfirm = { noText?: string } import { TooltipProps } from './web/components/Tooltip' -declare namespace UniversalAnalytics { - interface PageviewFieldsObject { - hitType: 'pageview' | 'event' - location?: string - page?: string - title?: string - [key: string]: any - } -} export declare const openModal: (name?: string) => Promise declare global { - function ga( - command: 'send', - fields: UniversalAnalytics.PageviewFieldsObject, - ): void const openModal: ( title: ReactNode, body?: ReactNode, diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index e0d3eef67ee9..b4132f9c75d0 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -299,6 +299,13 @@ const API = { extra?: Record }): void { try { + // First-time events also notify the team in Slack, via /api/event. + if (data.category === 'First') { + API.postEvent( + `${data.event}${data.extra ? ` ${JSON.stringify(data.extra)}` : ''}`, + 'first_events', + ) + } if (Project.amplitude) { amplitude.track(data.event, { category: data.category, @@ -310,19 +317,9 @@ const API = { } }, - // `path` overrides the reported location, e.g. for removing - // tokens in URLs - trackPage(title: string, path?: string): void { - if (Project.ga) - ga('send', { - hitType: 'pageview', - location: path - ? `${document.location.origin}${path}` - : document.location.href, - page: path ?? document.location.pathname, - title, - }) - }, + // Page views were only sent to Universal Analytics. Removed with its callers + // in a follow-up. + trackPage(): void {}, trackTraits(traits: Record): void { try { From 2ba0494a580ccb3798ddcfc120876300510ba25d Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 11:25:33 -0300 Subject: [PATCH 6/9] fix(Tracking): Ignore failed first-event notifications Co-Authored-By: Claude Opus 5.5 --- frontend/web/project/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index b4132f9c75d0..9567c29f467a 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -304,7 +304,7 @@ const API = { API.postEvent( `${data.event}${data.extra ? ` ${JSON.stringify(data.extra)}` : ''}`, 'first_events', - ) + )?.catch(() => {}) } if (Project.amplitude) { amplitude.track(data.event, { From 4c9ed439127a57eed08ff2fd44aa1753ee16659b Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 11:37:00 -0300 Subject: [PATCH 7/9] chore(Tracking): Keep LinkedIn and Albacross until marketing confirms Their removal moves to its own PR. Co-Authored-By: Claude Opus 5.5 --- .../environment-variables.md | 1 + frontend/api/dev-routes.js | 2 ++ frontend/api/index.js | 7 +++++++ frontend/common/stores/account-store.js | 6 ++++++ frontend/common/stores/feature-list-store.ts | 1 + frontend/common/stores/organisation-store.js | 1 + frontend/env/project_prod.js | 1 + .../components/pages/home-page/HomePage.tsx | 18 ++++++++++++++++ frontend/web/index.handlebars | 3 +++ frontend/web/project/libs.js | 21 +++++++++++++++++++ 10 files changed, 61 insertions(+) diff --git a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md index 8843796ddede..ce7413d110a1 100644 --- a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md +++ b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md @@ -97,6 +97,7 @@ relevant section below for more details. - `REO_API_KEY`: The Reo key to use for behaviour tracking. - `MIXPANEL_API_KEY`: Mixpanel analytics key to use for behaviour tracking. - `SENTRY_API_KEY`: Sentry key for error reporting. +- `ALBACROSS_CLIENT_ID`: Albacross client ID key for behaviour tracking. - `BASE_URL`: Used for specifying a base URL path that's ignored during routing if serving from a subdirectory. - `USE_SECURE_COOKIES`: Enable/disable the use of secure cookies. If deploying the frontend in a private network without a domain/SSL cert, disable secure cookies to ensure that session token is persisted. Default: true. diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index c51cc55f5744..7e7cad00348e 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -45,6 +45,8 @@ module.exports = function setupRoutes(app) { { name: 'reo', value: process.env.REO_API_KEY }, { name: 'capterraKey', value: process.env.CAPTERRA_API_KEY }, { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false) }, + { name: 'linkedinPartnerTracking', value: envToBool('LINKEDIN_PARTNER_TRACKING', false) }, + { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 847461157d22..2e80a458c7a2 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -104,6 +104,11 @@ app.get('/config/project-overrides', (req, res) => { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false), }, + { + name: 'linkedinPartnerTracking', + value: envToBool('LINKEDIN_PARTNER_TRACKING', false), + }, + { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, @@ -287,8 +292,10 @@ app.post('/api/webflow/webhook', (req, res) => { // Catch all to render index template app.get('/', (req, res) => { + const linkedin = process.env.LINKEDIN || '' return res.render('index', { isDev, + linkedin, }) }) diff --git a/frontend/common/stores/account-store.js b/frontend/common/stores/account-store.js index ac2a66c82b13..cb701c588edb 100644 --- a/frontend/common/stores/account-store.js +++ b/frontend/common/stores/account-store.js @@ -131,6 +131,12 @@ const controller = { }) } } + + if (Project.linkedinConversionId) { + window.lintrk?.('track', { + conversion_id: Project.linkedinConversionId, + }) + } }) }, deleteOrganisation: () => { diff --git a/frontend/common/stores/feature-list-store.ts b/frontend/common/stores/feature-list-store.ts index 3c1d58cacad2..4b06187083fa 100644 --- a/frontend/common/stores/feature-list-store.ts +++ b/frontend/common/stores/feature-list-store.ts @@ -189,6 +189,7 @@ const controller = { }, value: flag.name, }) + window.lintrk?.('track', { conversion_id: 16798354 }) } else { flagsmith.trackEvent('feature_created', { metadata: { diff --git a/frontend/common/stores/organisation-store.js b/frontend/common/stores/organisation-store.js index cc1caf8bd3c0..9a1b7499ac92 100644 --- a/frontend/common/stores/organisation-store.js +++ b/frontend/common/stores/organisation-store.js @@ -57,6 +57,7 @@ const controller = { .then((res) => createSampleUser(res, envName, project)) }), ).then((res) => { + window.lintrk?.('track', { conversion_id: 16798346 }) project.environments = res store.model.projects = store.model.projects.concat(project) getStore().dispatch(projectService.util.invalidateTags(['Project'])) diff --git a/frontend/env/project_prod.js b/frontend/env/project_prod.js index 37cc25bedb7c..8f0dc98013f3 100644 --- a/frontend/env/project_prod.js +++ b/frontend/env/project_prod.js @@ -44,6 +44,7 @@ const Project = { region: 'eu1', }, + linkedinConversionId: 16798338, // This is used for Sentry tracking maintenance: false, plans: { diff --git a/frontend/web/components/pages/home-page/HomePage.tsx b/frontend/web/components/pages/home-page/HomePage.tsx index 22e7b3740d0e..2b87540d2cdf 100644 --- a/frontend/web/components/pages/home-page/HomePage.tsx +++ b/frontend/web/components/pages/home-page/HomePage.tsx @@ -137,12 +137,27 @@ const HomePage: React.FC = () => { API.setCookie('marketing_consent_given', 'true') }, []) + const addAlbacross = () => { + // @ts-ignore + window._nQc = Project.albacross + const script = document.createElement('script') + script.type = 'text/javascript' + script.async = true + script.src = 'https://serve.albacross.com/track.js' + script.id = 'albacross' + document.body.appendChild(script) + } + useEffect(() => { if (!E2E) { const emailField = (document.querySelector('input[name="firstName"]') || document.querySelector('input[name="email"]')) as HTMLInputElement emailField?.focus() } + + if (Project.albacross && location.pathname.indexOf('signup') !== -1) { + addAlbacross() + } }, [location.pathname]) useEffect(() => { @@ -151,6 +166,9 @@ const HomePage: React.FC = () => { if (plan) { API.setCookie('plan', plan) } + if (Project.albacross && location.pathname.indexOf('signup') !== -1) { + addAlbacross() + } if (document.location.href.includes('oauth')) { const oAuthUtms = Utils.getUtmsFromUrl(document.location.href) const parts = document.location.href.split('oauth/') diff --git a/frontend/web/index.handlebars b/frontend/web/index.handlebars index 9e11d7bce877..e1d5ef2be951 100644 --- a/frontend/web/index.handlebars +++ b/frontend/web/index.handlebars @@ -104,4 +104,7 @@ {{/if}} +{{#if linkedin}} + +{{/if}} diff --git a/frontend/web/project/libs.js b/frontend/web/project/libs.js index f7a099553415..8c5a30773185 100644 --- a/frontend/web/project/libs.js +++ b/frontend/web/project/libs.js @@ -53,6 +53,27 @@ if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Se }); } +if(Project.linkedinPartnerTracking) { + const _linkedin_partner_id = "5747572"; + window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; + window._linkedin_data_partner_ids.push(_linkedin_partner_id); + (function(l) { + if (!l){window.lintrk = function(a,b){window.lintrk.q.push([a,b])}; + window.lintrk.q=[]} + var s = document.getElementsByTagName("script")[0]; + var b = document.createElement("script"); + b.type = "text/javascript";b.async = true; + b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js"; + s.parentNode.insertBefore(b, s);})(window.lintrk); + var img = document.createElement("img"); + img.setAttribute("height", "1"); + img.setAttribute("width", "1"); + img.setAttribute("style", "display:none;"); + img.setAttribute("alt", ""); + img.setAttribute("src", "https://px.ads.linkedin.com/collect/?pid=5747572&fmt=gif"); + document.body.appendChild(img); +} + if(Project.hubspot && !disableThirdPartyScripts) { // Must be set before the script loads. The chat widget is loaded by // common/loadChat behind the hubspot_chat flag, not by chatflow targeting. From 89739d531f538303bf4e507e0e1455c60fec3f31 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 11:47:27 -0300 Subject: [PATCH 8/9] chore(Tracking): Keep Universal Analytics until marketing confirms Its script also feeds the app's GA4 property. The first-event Slack notification stays independent of it. Co-Authored-By: Claude Opus 5.5 --- .../environment-variables.md | 1 + frontend/.eslintrc.js | 1 + frontend/api/dev-routes.js | 1 + frontend/api/index.js | 1 + frontend/global.d.ts | 13 ++++++++++ frontend/web/project/api.ts | 24 ++++++++++++++++--- frontend/web/project/libs.js | 10 ++++++++ 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md index ce7413d110a1..b82840c46a34 100644 --- a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md +++ b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md @@ -86,6 +86,7 @@ relevant section below for more details. `/api/v1/` through to `PROXY_API_URL`. If you are using this, any setting to `FLAGSMITH_API_URL` will be ignored and the browser will use the frontend node server to send API requests. Do not prepend `api/v1/` - it will be added automatically. +- `GOOGLE_ANALYTICS_API_KEY`: Google Analytics key to track API usage. - `FIRST_PROMOTER_ID`: First Promoter ID for checkout affiliates. - `ALLOW_SIGNUPS`: **DEPRECATED** in favour of `PREVENT_SIGNUP` in the API. Determines whether to prevent manual signups without invites. Set it to any value to allow signups. diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 3b451c57fba6..dcfe41e72141 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -161,6 +161,7 @@ module.exports = { 'describe': true, 'em': true, 'flagsmith': true, + 'ga': true, 'heap': true, 'hljs': true, 'hot': true, diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index 7e7cad00348e..019e17d22045 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -31,6 +31,7 @@ module.exports = function setupRoutes(app) { { name: 'superUserCreateOnly', value: envToBool('ONLY_SUPERUSERS_CAN_CREATE_ORGANISATIONS', false) }, { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, + { name: 'ga', value: process.env.GOOGLE_ANALYTICS_API_KEY }, { name: 'sha', value: sha }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, { name: 'sentry', value: process.env.SENTRY_API_KEY }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 2e80a458c7a2..76445cfe42b3 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -67,6 +67,7 @@ app.get('/config/project-overrides', (req, res) => { }, { name: 'flagsmith', value: process.env.FLAGSMITH_ON_FLAGSMITH_API_KEY }, { name: 'headway', value: process.env.HEADWAY_API_KEY }, + { name: 'ga', value: process.env.GOOGLE_ANALYTICS_API_KEY }, { name: 'sha', value: sha }, { name: 'fpr', value: process.env.FIRST_PROMOTER_ID }, { name: 'sentry', value: process.env.SENTRY_API_KEY }, diff --git a/frontend/global.d.ts b/frontend/global.d.ts index e410ca900bef..4b513c366abe 100644 --- a/frontend/global.d.ts +++ b/frontend/global.d.ts @@ -10,8 +10,21 @@ export type OpenConfirm = { noText?: string } import { TooltipProps } from './web/components/Tooltip' +declare namespace UniversalAnalytics { + interface PageviewFieldsObject { + hitType: 'pageview' | 'event' + location?: string + page?: string + title?: string + [key: string]: any + } +} export declare const openModal: (name?: string) => Promise declare global { + function ga( + command: 'send', + fields: UniversalAnalytics.PageviewFieldsObject, + ): void const openModal: ( title: ReactNode, body?: ReactNode, diff --git a/frontend/web/project/api.ts b/frontend/web/project/api.ts index 9567c29f467a..1bfb3593fc42 100644 --- a/frontend/web/project/api.ts +++ b/frontend/web/project/api.ts @@ -306,6 +306,14 @@ const API = { 'first_events', )?.catch(() => {}) } + if (Project.ga) { + ga('send', { + eventAction: data.event, + eventCategory: data.category, + eventLabel: data.label, + hitType: 'event', + }) + } if (Project.amplitude) { amplitude.track(data.event, { category: data.category, @@ -317,9 +325,19 @@ const API = { } }, - // Page views were only sent to Universal Analytics. Removed with its callers - // in a follow-up. - trackPage(): void {}, + // `path` overrides the reported location, e.g. for removing + // tokens in URLs + trackPage(title: string, path?: string): void { + if (Project.ga) + ga('send', { + hitType: 'pageview', + location: path + ? `${document.location.origin}${path}` + : document.location.href, + page: path ?? document.location.pathname, + title, + }) + }, trackTraits(traits: Record): void { try { diff --git a/frontend/web/project/libs.js b/frontend/web/project/libs.js index 8c5a30773185..8561ff97b7ca 100644 --- a/frontend/web/project/libs.js +++ b/frontend/web/project/libs.js @@ -45,6 +45,16 @@ window.NavLink = NavLink; // Analytics — not loaded in E2E runs, where widgets can overlay the UI const disableThirdPartyScripts = !!window.E2E +if (Project.ga && !disableThirdPartyScripts) { + (function (i, s, o, g, r, a, m) { + i.GoogleAnalyticsObject = r; i[r] = i[r] || function () { + (i[r].q = i[r].q || []).push(arguments); + }, i[r].l = 1 * new Date(); a = s.createElement(o), + m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m); + }(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga')); + ga('create', Project.ga, 'auto'); +} + if (typeof SENTRY_RELEASE_VERSION !== 'undefined' && Project.sentry && typeof Sentry !== 'undefined') { Sentry.init({ dsn: Project.sentry, From 917e65dfc965cfc342d998a8a8a386dc91c1609d Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Thu, 26 Nov 2026 11:53:25 -0300 Subject: [PATCH 9/9] chore(Tracking): Remove Albacross from the app The contract was cancelled in 2024, so it no longer did anything for us. Co-Authored-By: Claude Opus 5.5 --- .../environment-variables.md | 1 - frontend/api/dev-routes.js | 1 - frontend/api/index.js | 1 - .../components/pages/home-page/HomePage.tsx | 18 ------------------ 4 files changed, 21 deletions(-) diff --git a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md index b82840c46a34..abc0cd04c365 100644 --- a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md +++ b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md @@ -98,7 +98,6 @@ relevant section below for more details. - `REO_API_KEY`: The Reo key to use for behaviour tracking. - `MIXPANEL_API_KEY`: Mixpanel analytics key to use for behaviour tracking. - `SENTRY_API_KEY`: Sentry key for error reporting. -- `ALBACROSS_CLIENT_ID`: Albacross client ID key for behaviour tracking. - `BASE_URL`: Used for specifying a base URL path that's ignored during routing if serving from a subdirectory. - `USE_SECURE_COOKIES`: Enable/disable the use of secure cookies. If deploying the frontend in a private network without a domain/SSL cert, disable secure cookies to ensure that session token is persisted. Default: true. diff --git a/frontend/api/dev-routes.js b/frontend/api/dev-routes.js index 019e17d22045..2688b1a9e0e2 100644 --- a/frontend/api/dev-routes.js +++ b/frontend/api/dev-routes.js @@ -47,7 +47,6 @@ module.exports = function setupRoutes(app) { { name: 'capterraKey', value: process.env.CAPTERRA_API_KEY }, { name: 'hideInviteLinks', value: envToBool('DISABLE_INVITE_LINKS', false) }, { name: 'linkedinPartnerTracking', value: envToBool('LINKEDIN_PARTNER_TRACKING', false) }, - { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, diff --git a/frontend/api/index.js b/frontend/api/index.js index 76445cfe42b3..b55a82a2311a 100755 --- a/frontend/api/index.js +++ b/frontend/api/index.js @@ -109,7 +109,6 @@ app.get('/config/project-overrides', (req, res) => { name: 'linkedinPartnerTracking', value: envToBool('LINKEDIN_PARTNER_TRACKING', false), }, - { name: 'albacross', value: process.env.ALBACROSS_CLIENT_ID }, { name: 'useSecureCookies', value: envToBool('USE_SECURE_COOKIES', true) }, { name: 'cookieSameSite', value: process.env.USE_SECURE_COOKIES }, { name: 'cookieAuthEnabled', value: process.env.COOKIE_AUTH_ENABLED }, diff --git a/frontend/web/components/pages/home-page/HomePage.tsx b/frontend/web/components/pages/home-page/HomePage.tsx index 2b87540d2cdf..22e7b3740d0e 100644 --- a/frontend/web/components/pages/home-page/HomePage.tsx +++ b/frontend/web/components/pages/home-page/HomePage.tsx @@ -137,27 +137,12 @@ const HomePage: React.FC = () => { API.setCookie('marketing_consent_given', 'true') }, []) - const addAlbacross = () => { - // @ts-ignore - window._nQc = Project.albacross - const script = document.createElement('script') - script.type = 'text/javascript' - script.async = true - script.src = 'https://serve.albacross.com/track.js' - script.id = 'albacross' - document.body.appendChild(script) - } - useEffect(() => { if (!E2E) { const emailField = (document.querySelector('input[name="firstName"]') || document.querySelector('input[name="email"]')) as HTMLInputElement emailField?.focus() } - - if (Project.albacross && location.pathname.indexOf('signup') !== -1) { - addAlbacross() - } }, [location.pathname]) useEffect(() => { @@ -166,9 +151,6 @@ const HomePage: React.FC = () => { if (plan) { API.setCookie('plan', plan) } - if (Project.albacross && location.pathname.indexOf('signup') !== -1) { - addAlbacross() - } if (document.location.href.includes('oauth')) { const oAuthUtms = Utils.getUtmsFromUrl(document.location.href) const parts = document.location.href.split('oauth/')