Never inject a duplicate stats.js tag when one is already present - #53
Merged
Merged
Conversation
The "already installed" check only matched single-line tracker tags, so a prettier-formatted multi-line <Script /> slipped past it; the audience installer also only inspected the top-ranked candidate file, missing installs living in a lower-ranked one. Add hasTrackerReference (any reference to the tracker origin's /stats.js counts as installed), apply it in previewInstallAtPath and the install probe, and make the audience installer scan all candidate files before injecting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the Audience Hub / tracker installer adding a second
stats.jsscript tag to repos that already have one.Two gaps caused it:
<Script … />(which prettier produces for any tag with 3+ attributes) slipped past it.Fix
hasTrackerReference(content)inlib/github/install-tracker.ts: any reference to the tracker origin's/stats.jscounts as installed, regardless of formatting.previewInstallAtPathand the install probe (covers the tracker installer UI flow too).installAudienceHubnow does two passes: scan all candidate files for an existing reference first; only inject when none has it.Test plan
npm run typecheckcleannpm test— 344 passed; new tests cover single-line, multi-line, and absent-tag cases forhasTrackerReference🤖 Generated with Claude Code