Skip to content

fix(website): prevent duplicate startTracking causing rudderQueue error#2617

Open
tolzhabayev wants to merge 1 commit intomainfrom
fix/tracking-double-init
Open

fix(website): prevent duplicate startTracking causing rudderQueue error#2617
tolzhabayev wants to merge 1 commit intomainfrom
fix/tracking-double-init

Conversation

@tolzhabayev
Copy link
Copy Markdown
Collaborator

Guard startTracking with a module-level initialized flag so route changes and React strict-mode double-effects do not append a second rudderstack script, whose onload would iterate an already-drained (undefined) rudderQueue and throw TypeError: rudderQueue is not iterable.

@Ukochka — does this look right to you? If so, would you be up for porting the same fix to the other Grafana sub-sites that share this tracking module?

Guard startTracking with a module-level initialized flag so route changes
and React strict-mode double-effects do not append a second rudderstack
script, whose onload would iterate an already-drained (undefined) queue.
Copilot AI review requested due to automatic review settings May 6, 2026 14:22
@tolzhabayev tolzhabayev requested a review from a team as a code owner May 6, 2026 14:22
@tolzhabayev tolzhabayev self-assigned this May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

❌ This PR cannot be merged until the following issues are addressed:

  • This PR is missing one of the following labels: patch, minor, major, no-changelog.
  • Optionally if using a patch, minor or major label also add the release label if you would like this PR to trigger npm package publishing.
🏷️ More info about which labels to use
  • If the changes only affect the docs website, documentation, or this repository's tooling add the no-changelog label.
  • If there are changes to any of the npm packages src files please choose from one of the following labels:
    • 🐛 if this PR fixes a bug add the patch label
    • 🚀 if this PR includes an enhancement add the minor label
    • 💥 if this PR includes a breaking change add the major label
  • Optionally, if you would like this PR to publish new versions of packages when it is merged add the release label.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a production runtime error in the Docusaurus website tracking integration by preventing startTracking() from running more than once per module load. This avoids appending the RudderStack SDK script multiple times (e.g., via route changes and React strict-mode double effects), which previously could cause the SDK onload handler to iterate an already-drained rudderQueue and throw TypeError: rudderQueue is not iterable.

Changes:

  • Add a module-level trackingInitialized flag.
  • Guard startTracking() so it becomes a one-time initializer when shouldTrack is true.

@grafana-plugins-platform-bot grafana-plugins-platform-bot Bot moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

2 participants