Skip to content

Fix collect endpoint for custom tracker filenames - #263

Merged
benvinegar merged 1 commit into
mainfrom
fix/custom-tracker-collect-url
Sep 5, 2026
Merged

Fix collect endpoint for custom tracker filenames#263
benvinegar merged 1 commit into
mainfrom
fix/custom-tracker-collect-url

Conversation

@benvinegar

Copy link
Copy Markdown
Owner

Overview

  • derive the collect endpoint as a sibling of the loaded tracker script with the URL API
  • support custom tracker filenames while preserving deployment subpaths
  • discard script query strings and fragments from the reporting endpoint
  • add focused regression coverage for default/custom filenames, subpaths, and query/hash behavior

Closes #243.

Test evidence

  • pnpm --filter @counterscale/tracker exec vitest run — 10 files, 135 tests passed
  • pnpm --filter @counterscale/tracker typecheck — passed
  • pnpm --filter @counterscale/tracker lint — passed with 62 pre-existing warnings and no errors
  • pnpm --filter @counterscale/tracker build — passed
  • git diff --check — passed

Residual risks

  • None identified; endpoint construction relies on the browser-standard URL resolution used by supported runtimes.

This PR description was generated by Pi using OpenAI GPT-5.6 Sol

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.91%. Comparing base (7edfdad) to head (cd7b96b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #263   +/-   ##
=======================================
  Coverage   83.91%   83.91%           
=======================================
  Files          55       55           
  Lines        1878     1878           
  Branches      517      517           
=======================================
  Hits         1576     1576           
  Misses        266      266           
  Partials       36       36           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benvinegar

Copy link
Copy Markdown
Owner Author

Independent browser and network evidence

Verified commit cd7b96b41774062bb7f5934c592dc4bc863966d2 in a real Chromium browser using the tracker bundle built from this PR.

Browser probe showing custom script, cache, and collect requests

The bundle loaded from nested custom filename:

/deployments/counterscale/assets/custom-analytics-name.js?build=263&channel=review#loader-fragment

It then issued sibling /cache and /collect requests. The script query and fragment did not leak into the reporting endpoint. All 5 custom probe assertions, 135 Vitest tests, and 9 Chromium integration tests passed.

Artifacts:

Limitation: the independent probe used Chromium on loopback HTTP; WebKit was unavailable.

This comment was generated by Pi using OpenAI GPT-5.6 Sol

@benvinegar
benvinegar merged commit fe226f6 into main Sep 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Using a custom tracking script name gives error

1 participant