Skip to content

Revert recent analytics updates#935

Merged
stktung merged 3 commits intomasterfrom
revert-recent-analytics-updates
Dec 1, 2025
Merged

Revert recent analytics updates#935
stktung merged 3 commits intomasterfrom
revert-recent-analytics-updates

Conversation

@stktung
Copy link
Copy Markdown
Contributor

@stktung stktung commented Dec 1, 2025

User description

These analytical changes might be related to JS issue found here #934


PR Type

Bug fix


Description

  • Revert analytics tracking changes causing JavaScript issues

  • Remove Reo analytics script and replace with CommonRoom

  • Restore error handling in client routing logic

  • Add Business Institution 247 tracking script

  • Simplify PostHog configuration by removing capture_pageview


Diagram Walkthrough

flowchart LR
  A["Analytics Changes"] -->|Revert| B["Remove Reo Script"]
  A -->|Replace| C["Add CommonRoom Script"]
  D["Client Routing"] -->|Restore| E["Error Handling Logic"]
  F["PostHog Config"] -->|Simplify| G["Remove capture_pageview"]
  H["Tracking"] -->|Add| I["Business Institution 247"]
Loading

File Walkthrough

Relevant files
Enhancement
commonRoom.js
Add CommonRoom analytics tracking script                                 

docs/.vuepress/public/js/commonRoom.js

  • New file created to load CommonRoom signals script
  • Implements async script loading with fallback queue system
  • Provides page, identify, and form tracking methods
+18/-0   
Bug fix
reo.js
Remove Reo analytics script                                                           

docs/.vuepress/public/js/reo.js

  • File completely removed as part of analytics revert
  • Previously contained Reo analytics initialization code
+0/-6     
client.ts
Update analytics tracking and routing logic                           

docs/.vuepress/client.ts

  • Add onMounted import from Vue for lifecycle management
  • Remove error handling checks in client routing functions
  • Replace window.posthog with window.analytics for page tracking
  • Add setup hook with route path validation
  • Reformat indentation in multiple route handlers
+26/-34 
config.ts
Update tracking scripts and configuration                               

docs/.vuepress/config.ts

  • Add Business Institution 247 tracking script before cookie consent
  • Replace Reo script with CommonRoom script in head configuration
  • Add /js/snippet.js script reference
  • Reorder script attributes for consistency
  • Remove capture_pageview from PostHog initialization
+15/-10 
usePosthog.ts
Simplify PostHog configuration                                                     

docs/.vuepress/lib/usePosthog.ts

  • Remove capture_pageview: false configuration option
  • Simplify PostHog initialization to only set API host
+1/-2     

@stktung stktung requested a review from a team as a code owner December 1, 2025 15:20
@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 1, 2025

Docs build

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Dec 1, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🔴
Hardcoded analytics key

Description: A long‑lived PostHog API key ('phc_DeHBgHGersY4LmDlADnPrsCPOAmMO7QFOH8f4DVEVmD') is
hardcoded in the client code, exposing it to the public and enabling unauthorized data
collection or misuse if the key has elevated permissions.
usePosthog.ts [5-7]

Referred Code
posthog.init('phc_DeHBgHGersY4LmDlADnPrsCPOAmMO7QFOH8f4DVEVmD', {
    api_host: 'https://phog.kurrent.io'
});
Pre‑consent tracking

Description: Third‑party tracking scripts (Business Intuition 247 pixel and JS) are loaded before
cookie consent and without consent gating, potentially violating user privacy regulations
and site consent policies.
config.ts [81-89]

Referred Code
// Business Institution 247, before the user accepts cookie
['script', {
    type: 'text/javascript',
    src: 'https://secure.businessintuition247.com/js/264384.js',
}],
['noscript', {},
    '<img alt="" src="https://secure.businessintuition247.com/264384.png" style="display:none;" />'
],
Unvetted third‑party script

Description: The CommonRoom loader creates a global 'signals' array with method proxies that accept
arbitrary arguments and relies on an external script without integrity or consent checks,
enabling potential data exfiltration or PII leakage if misused or if the third‑party
script is compromised.
commonRoom.js [5-17]

Referred Code
script.src = 'https://cdn.cr-relay.com/v1/site/da9bc552-0721-4931-aae9-9706006d2986/signals.js';
script.async = true;
window.signals = Object.assign(
    [],
    ['page', 'identify', 'form'].reduce(function (acc, method) {
        acc[method] = function () {
            signals.push([method, arguments]);
            return signals;
        };
        return acc;
    }, {})
);
document.head.appendChild(script);
Inconsistent consent gating

Description: The “consent‑only” Business Intuition 247 loader is included as type='text/plain' but an
additional pre‑consent script/pixel was added earlier; this split increases the risk of
inconsistent consent enforcement and unintended tracking activation.
config.ts [112-120]

Referred Code
['script', {src: '/js/snippet.js'}],

// Business Institution 247 “consent‑only” loader
['script', {
    type: 'text/plain',
    'data-cookiecategory': 'marketing',
    src: 'https://secure.businessintuition247.com/js/sc/264384.js',
}],
Missing script integrity/consent

Description: A local script '/js/commonRoom.js' is included without SRI or defer/async attributes and
may execute before consent is obtained, risking early tracking and supply‑chain exposure.
config.ts [130-131]

Referred Code
// CommonRoom
['script', {src: "/js/commonRoom.js"}],
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status:
Non-descriptive name: The temporary variable a used for analytics is not self-descriptive and should use a
meaningful name like analytics for clarity.

Referred Code
const a = window.analytics;
if (a) {
    setTimeout(() => {
        a.page({
            site: "docs",
            url: window.location.origin + to.fullPath,

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Removed guards: Several client routing handlers removed fallback/guard logic for missing version/startPage
values, potentially causing navigation to invalid routes without handling edge cases.

Referred Code
addDynamicRoute(`/clients/${clients}/latest/:pathMatch(.*)*`, to => {
  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
  return `/clients/${to.params.lang}/${latestVersion?.version}/${to.params.pathMatch}`;
});
addDynamicRoute(`/clients/${clients}/latest`, to => {
  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
  return `/clients/${to.params.lang}/${latestVersion?.version}/${latestVersion?.startPage}`;
});
addDynamicRoute(`/clients/${clients}/legacy/:version`, to => {
  const version = to.params.version;
  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === `legacy/${version}`)
  return `/clients/${to.params.lang}/legacy/${to.params.version}/${latestVersion?.startPage}`;
});
addDynamicRoute(`/clients/${clients}/legacy`, to => {
  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path.startsWith('legacy/'))
  return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
})
addDynamicRoute(`/clients/${clients}/:version`, to => {
  const version = to.params.version;
  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === version)
  return `/clients/${to.params.lang}/${version}/${latestVersion?.startPage}`;


 ... (clipped 5 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing audit logs: The new routing and analytics changes add/modify tracking calls but do not introduce or
reference audit logging for critical security-relevant actions, which may be acceptable
for a docs site but cannot be confirmed from the diff alone.

Referred Code
router.afterEach((to, from) => {
    if (typeof window === "undefined" || to.path === from.path || removeHtml(to.path) === removeHtml(from.path)) return;
    const esData = findEsMeta(to);
    posthog.capture('$pageview', {
        site: "docs",
        version: esData?.version,
        category: esData?.category,
    });
    const a = window.analytics;
    if (a) {
        setTimeout(() => {
            a.page({
                site: "docs",
                url: window.location.origin + to.fullPath,
                title: to.meta.t,
                version: esData?.version,

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Third-party scripts: New external scripts (Business Intuition 247, CommonRoom, snippet.js) are added without
visible consent gating or integrity checks in this diff, which may impact security and
privacy depending on site policy.

Referred Code
// Business Institution 247, before the user accepts cookie
['script', {
    type: 'text/javascript',
    src: 'https://secure.businessintuition247.com/js/264384.js',
}],
['noscript', {},
    '<img alt="" src="https://secure.businessintuition247.com/264384.png" style="display:none;" />'
],

// Scarf
['noscript', {},
    '<img referrerpolicy="no-referrer-when-downgrade" src="https://static.scarf.sh/a.png?x-pxid=a2c83cb1-95a4-4437-91e2-ab0211cc0298" />'
],

// Cookiebot banner
['script', {
    id: 'Cookiebot',
    src: 'https://consent.cookiebot.com/uc.js',
    'data-cbid': 'ee971b30-e872-46e8-b421-706ef26d9dcc',
    'data-blockingmode': 'auto',
    type: 'text/javascript',


 ... (clipped 31 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Dec 1, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
PR removes critical routing error handling

The PR removes essential null-checks in docs/.vuepress/client.ts dynamic route
handlers, which contradicts the PR's goal of restoring error handling. This
change could lead to broken navigation and should be reverted.

Examples:

docs/.vuepress/client.ts [124-125]
          const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
          return `/clients/${to.params.lang}/${latestVersion?.version}/${to.params.pathMatch}`;
docs/.vuepress/client.ts [128-129]
          const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
          return `/clients/${to.params.lang}/${latestVersion?.version}/${latestVersion?.startPage}`;

Solution Walkthrough:

Before:

addDynamicRoute(`/clients/.../latest/...`, to => {
  const latestVersion = __VERSIONS__.all.find(x => ...);
  // No check if latestVersion is found
  return `/clients/${to.params.lang}/${latestVersion?.version}/${to.params.pathMatch}`;
});

addDynamicRoute(`/clients/.../legacy`, to => {
  const latestVersion = __VERSIONS__.all.find(x => ...);
  // No check if latestVersion is found
  return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
});

After:

addDynamicRoute(`/clients/.../latest/...`, to => {
  const latestVersion = __VERSIONS__.all.find(x => ...);
  if (!latestVersion?.version) {
      return `/clients/`; // Fallback to a safe URL
  }
  return `/clients/${to.params.lang}/${latestVersion.version}/${to.params.pathMatch}`;
});

addDynamicRoute(`/clients/.../legacy`, to => {
  const latestVersion = __VERSIONS__.all.find(x => ...);
  if (!latestVersion?.version || !latestVersion?.startPage) {
      return `/clients/`; // Fallback to a safe URL
  }
  return `/clients/${to.params.lang}/${latestVersion.path}/${latestVersion.startPage}`;
});
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical regression where error handling is removed from routing logic in docs/.vuepress/client.ts, directly contradicting the PR's stated goal and likely causing broken navigation.

High
Possible issue
Prevent broken redirects with undefined

Restore the removed checks for latestVersion in dynamic route handlers to
prevent generating broken URLs with 'undefined' segments and ensure a fallback
redirect.

docs/.vuepress/client.ts [123-148]

 addDynamicRoute(`/clients/${clients}/latest/:pathMatch(.*)*`, to => {
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
-  return `/clients/${to.params.lang}/${latestVersion?.version}/${to.params.pathMatch}`;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
+    if (!latestVersion?.version) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/${latestVersion?.version}/${to.params.pathMatch}`;
 });
 addDynamicRoute(`/clients/${clients}/latest`, to => {
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
-  return `/clients/${to.params.lang}/${latestVersion?.version}/${latestVersion?.startPage}`;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions?.[0];
+    if (!latestVersion?.version || !latestVersion?.startPage) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/${latestVersion.version}/${latestVersion.startPage}`;
 });
 addDynamicRoute(`/clients/${clients}/legacy/:version`, to => {
-  const version = to.params.version;
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === `legacy/${version}`)
-  return `/clients/${to.params.lang}/legacy/${to.params.version}/${latestVersion?.startPage}`;
+    const version = to.params.version;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === `legacy/${version}`)
+    if (!latestVersion?.version || !latestVersion?.startPage) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/legacy/${to.params.version}/${latestVersion?.startPage}`;
 });
 addDynamicRoute(`/clients/${clients}/legacy`, to => {
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path.startsWith('legacy/'))
-  return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path.startsWith('legacy/'))
+    if (!latestVersion?.version || !latestVersion?.startPage) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
 })
 addDynamicRoute(`/clients/${clients}/:version`, to => {
-  const version = to.params.version;
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === version)
-  return `/clients/${to.params.lang}/${version}/${latestVersion?.startPage}`;
+    const version = to.params.version;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions.find(v => v.path === version)
+    if (!latestVersion?.version || !latestVersion?.startPage) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/${version}/${latestVersion?.startPage}`;
 });
 addDynamicRoute(`/clients/${clients}`, to => {
-  const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
-  return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
+    const latestVersion = __VERSIONS__.all.find(x => x.id === `${to.params.lang}-client`)?.versions[0]
+    if (!latestVersion?.version || !latestVersion?.startPage) {
+        return `/clients/`;
+    }
+    return `/clients/${to.params.lang}/${latestVersion?.path}/${latestVersion?.startPage}`;
 })
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a regression where removing null checks will lead to broken URLs, which is a significant bug affecting user navigation.

High
Organization
best practice
Gate marketing scripts behind consent
Suggestion Impact:The CommonRoom script tag was removed, effectively preventing it from loading before consent, aligning with the suggestion to not load it until consent.

code diff:

-        // CommonRoom
-        ['script', {src: "/js/commonRoom.js"}],
-

Gate marketing/analytics loaders behind Cookiebot by using type="text/plain"
with data-cookiecategory and avoid loading them before consent.

docs/.vuepress/config.ts [81-131]

-// Business Institution 247, before the user accepts cookie
+// Business Institution 247 “consent‑only” loader (do not load before consent)
 ['script', {
-    type: 'text/javascript',
-    src: 'https://secure.businessintuition247.com/js/264384.js',
+  src: 'https://secure.businessintuition247.com/js/264384.js',
+  type: 'text/plain',
+  'data-cookiecategory': 'marketing'
 }],
-['noscript', {},
-    '<img alt="" src="https://secure.businessintuition247.com/264384.png" style="display:none;" />'
-],
+['noscript', {}, ''],
 ...
-// CommonRoom
-['script', {src: "/js/commonRoom.js"}],
+// CommonRoom (load only after consent)
+['script', {
+  src: "/js/commonRoom.js",
+  type: 'text/plain',
+  'data-cookiecategory': 'marketing'
+}],

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why:
Relevant best practice - Load non-essential and marketing scripts only after consent and mark them with appropriate Cookiebot attributes to ensure GDPR compliance.

Low
General
Remove empty and ineffective statement

Remove the empty if (route.path !== "/") ; statement from the onMounted hook as
it has no effect and is likely leftover code.

docs/.vuepress/client.ts [204-210]

 setup() {
     onMounted(() => {
         const route = useRoute();
-        if (route.path !== "/") ;
+        if (route.path !== "/") {
+            // Intended logic for non-root paths can be added here.
+        }
     });
-
 },
  • Apply / Chat
Suggestion importance[1-10]: 3

__

Why: The suggestion correctly identifies an empty if statement, which is dead code, and recommends its removal to improve code clarity.

Low
  • Update

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Dec 1, 2025

Deploying documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: de94dd4
Status: ✅  Deploy successful!
Preview URL: https://bc84e5c9.documentation-21k.pages.dev
Branch Preview URL: https://revert-recent-analytics-upda.documentation-21k.pages.dev

View logs

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 1, 2025

Docs build

@stktung stktung merged commit 432a41d into master Dec 1, 2025
3 checks passed
@stktung stktung deleted the revert-recent-analytics-updates branch December 1, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants