Skip to content

feat(analytics): add search analytics (Closes #245) — retargeted to dev - #384

Merged
zeemscript merged 1 commit into
Deen-Bridge:devfrom
Bogunrot:feat/issue-245-search-analytics
Sep 2, 2026
Merged

feat(analytics): add search analytics (Closes #245) — retargeted to dev#384
zeemscript merged 1 commit into
Deen-Bridge:devfrom
Bogunrot:feat/issue-245-search-analytics

Conversation

@Bogunrot

@Bogunrot Bogunrot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Retarget of #371 from main to dev.

Search analytics for the platform: searchLogger middleware wired into GET /api/search and GET /api/search/educators, a SearchAnalyticsEvent model with a 90-day TTL, and admin-gated aggregation endpoints under /api/analytics/search (top / zero-results / summary / trends).

Notes on the retarget:

  • Branch rebuilt on top of dev with conflicts resolved (app.js mount adapted to dev's structure; searchRoutes.js restored to a clean version carrying the searchLogger wiring — dev's copy had a duplicate import and orphaned code fragment that broke ESM loading).
  • test/searchAnalytics.test.js: 12/12 pass on the dev-based branch.
  • The end-to-end suite (test/searchAnalyticsIntegration.test.js) requires app.js to boot, which currently fails on the dev branch itself (pre-existing: upstream/dev has an unclosed catch block in src/services/stellar/stellarService.js around line 377, plus a few other boot blockers). Not caused by this change.

Supersedes #371.

Track what users search for, surface popular queries, and isolate
zero-result searches so content gaps can drive creation decisions.

- searchLogger middleware wired into the real GET /api/search and
  /api/search/educators routes records every query with a timestamp, the type,
  result count, and whether the search returned zero results (fire-and-forget
  so logging never blocks the response).
- SearchAnalyticsEvent model with a 90-day TTL and query/hasResults indexes.
- Service provides top queries by frequency, zero-result searches, a summary,
  and daily trends, all with date-range and type filters.
- Admin-gated GET /api/analytics/search/{top,zero-results,summary,trends}.
- Tests: unit coverage for the aggregation endpoints plus an end-to-end suite
  that performs real searches through the app and asserts the events land and
  surface via the admin endpoints.

Search, analytics, and integration suites pass (23/23).
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 3c8cca16-ffb0-40b0-a70c-924064c36e69


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.

@zeemscript
zeemscript merged commit e00e7a6 into Deen-Bridge:dev Sep 2, 2026
1 of 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.

2 participants