Skip to content

(fix) bundle the referrers map into backend builds - #607

Merged
Blaumaus merged 1 commit into
Swetrix:mainfrom
GOAT0P:fix/referrer-name-filters
Sep 7, 2026
Merged

(fix) bundle the referrers map into backend builds#607
Blaumaus merged 1 commit into
Swetrix:mainfrom
GOAT0P:fix/referrer-name-filters

Conversation

@GOAT0P

@GOAT0P GOAT0P commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #606.

Changes

The backend loaded web/app/referrers.map.json from disk at runtime, but that file is outside the backend Docker build context. Published API images therefore cached an empty map and canonical referrer_name filters returned zero rows.

  • Vendor the canonical map in both backend apps and import it as a module.
  • Enable resolveJsonModule in both app build configurations so the map is emitted beside the compiled module.
  • Remove runtime filesystem probing, caching, and the empty-map fallback.
  • Test canonical-name resolution and require both backend copies to remain byte-identical to the web map.

Community Edition support

  • Your feature is implemented for the Swetrix Community Edition
  • This PR only updates the Cloud (Enterprise) Edition code (e.g. Paddle webhooks, blog, payouts, etc.)

Database migrations

  • Clickhouse / MySQL migrations added for this PR
  • No table schemas changed in this PR

Documentation

  • You have updated the documentation according to your PR
  • This PR did not change any publicly documented endpoints

Verification

  • Focused Jest test: 2 passed.
  • Formatting and targeted lint checks pass.
  • Community and Cloud TypeScript builds pass.
  • Both builds emit dist/analytics/utils/referrers.map.json.
  • Compiled modules contain no runtime readFileSync fallback.

Summary by CodeRabbit

  • New Features

    • Expanded analytics referral recognition across search engines, AI assistants, social networks, developer platforms, messaging services, and content sites.
    • Added categorization for search and AI referral sources to support clearer analytics insights.
  • Bug Fixes

    • Improved consistency of referral classification across cloud and community analytics, including case-insensitive referrer matching.
    • Standardized referral mappings across supported applications.

@CLAassistant

CLAassistant commented Sep 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 5a5945d8-5a0f-4de6-a128-2043de531d86

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 01108b5 and b48371b.

πŸ“’ Files selected for processing (7)
  • backend/apps/cloud/src/analytics/utils/referrers.map.json
  • backend/apps/cloud/src/analytics/utils/referrers.map.ts
  • backend/apps/cloud/tsconfig.app.json
  • backend/apps/community/src/analytics/utils/referrers.map.json
  • backend/apps/community/src/analytics/utils/referrers.map.ts
  • backend/apps/community/src/analytics/v2/__tests__/referrers.map.spec.ts
  • backend/apps/community/tsconfig.app.json

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


πŸ“ Walkthrough

Walkthrough

Both backend analytics apps now bundle and import identical referrer maps. Runtime filesystem lookup and fallback handling were removed. TypeScript JSON module resolution and tests were added.

Changes

Referrer map bundling

Layer / File(s) Summary
Static map integration and validation
backend/apps/{cloud,community}/src/analytics/utils/referrers.map.{json,ts}, backend/apps/{cloud,community}/tsconfig.app.json, backend/apps/community/src/analytics/v2/__tests__/referrers.map.spec.ts
The cloud and community apps now import bundled JSON maps. Filesystem probing, caching, and empty-map fallback logic were removed. Both maps contain the same referrer definitions, and tests verify case-insensitive lookup, unknown-name handling, and byte-for-byte map consistency.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: βšͺ Minimal Β· up to b4837

Canonical referrer filters now use a bundled map in both backend applications, restoring matching for known referrers while retaining raw-filter fallback behavior. No current merge-blocking risk remains.

Suggested reviewers: blaumaus

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly describes the primary change: bundling the referrers map into backend builds.
Description check βœ… Passed The description follows the repository template, explains the fix, identifies Community Edition support, confirms no migrations or endpoint changes, and records verification results.
Linked Issues check βœ… Passed The changes satisfy issue #606 by bundling the referrers map into both backend applications, removing runtime filesystem dependency, preserving canonical-name resolution, and adding consistency tests.
Out of Scope Changes check βœ… Passed The changed files and tests directly support issue #606 and the stated build-bundling fix. No unrelated code or database changes are present.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@Blaumaus
Blaumaus merged commit a351661 into Swetrix:main Sep 7, 2026
9 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: canonical referrer filters return zero results in self-hosted CE

3 participants