Skip to content

Task 009: Consolidate analytics provider scripts - #7

Merged
Igloczek merged 1 commit into
masterfrom
task/009-consolidate-analytics-scripts
Jun 30, 2026
Merged

Igloczek merged 1 commit into
masterfrom
task/009-consolidate-analytics-scripts

Conversation

@Igloczek

@Igloczek Igloczek commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Implements tasks/009-consolidate-analytics-scripts.md from the ponytail audit backlog.

Goal

Replace five near-identical analytics modules and a dispatcher with one table-driven file.

Scope

  • Merge google-analytics.ts, umami-analytics.ts, plausible-analytics.ts, matomo-analytics.ts, rybbit-analytics.ts into a single module (e.g. analytics-scripts.ts).
  • Keep analytics.ts as a thin dispatcher or inline the switch into the caller.
  • Preserve exact script output for each provider type (no behavior change).

Acceptance criteria

  • src/server/analytics/ contains at most two files (dispatcher + scripts map), down from six.
  • Each supported analytics type still injects the same script snippet string as before.
  • bun run lint passes.
  • bun run build succeeds.
  • Manual spot-check: enable each analytics type in settings and confirm script appears in status page HTML (or unit test if added).

Depends on

Nothing.

Verification

bun run lint
bun run build
ls src/server/analytics/

Audit reference

Finding #15 — analytics provider split.

@Igloczek

Copy link
Copy Markdown
Collaborator Author

/ponytail-review

  • Scope: Only analytics provider consolidation; no changes to status page UI or socket handlers.
  • Behavior: Script snippet strings preserved (Google gtag, defer tags for umami/plausible/rybbit, Matomo inline tracker).
  • Structure: Table-driven analyticsScripts map with requiresScriptUrl + build per provider.
  • Tests: 8 new unit tests assert per-provider HTML output and config validation.

9 files changed, 266 insertions(+), 226 deletions(-)

Merge five near-identical per-provider analytics modules into a single
analytics-scripts.ts map. Keep analytics.ts as a thin dispatcher that
looks up providers and validates config. Add unit tests for all five
provider script outputs.

Task 009 — Finding #15.
@Igloczek
Igloczek force-pushed the task/009-consolidate-analytics-scripts branch from 27b4695 to 791ccf9 Compare June 30, 2026 11:44
@Igloczek
Igloczek merged commit 5b1b699 into master Jun 30, 2026
1 check passed
@Igloczek
Igloczek deleted the task/009-consolidate-analytics-scripts branch June 30, 2026 12:58
Igloczek added a commit that referenced this pull request Aug 8, 2026
…ripts

Task 009: Consolidate analytics provider scripts
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.

1 participant