feat: Profile identification#593
Conversation
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (6)
π§ Files skipped from review as they are similar to previous changes (4)
π WalkthroughWalkthroughAdds visitor identification through public analytics endpoints, ClickHouse profile aliases, canonicalized analytics queries, JavaScript and Node tracker APIs, and documentation for identify/reset behavior. ChangesVisitor identity linking
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Visitor
participant Tracker
participant IdentifyAPI
participant AnalyticsService
participant AnalyticsStore
Visitor->>Tracker: identify(profileId)
Tracker->>IdentifyAPI: POST identify
IdentifyAPI->>AnalyticsService: validate request and resolve identities
AnalyticsService->>AnalyticsStore: link anonymous and identified profiles
IdentifyAPI-->>Tracker: return canonical profileId
Tracker-->>Visitor: use identified profile for tracking
Possibly related PRs
π₯ Pre-merge checks | β 4 | β 1β Failed checks (1 warning)
β Passed checks (4 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
π§Ή Nitpick comments (1)
backend/apps/cloud/src/analytics/analytics.service.ts (1)
2466-2499: π Performance & Scalability | π΅ Trivial | β‘ Quick winConsider negative caching for unlinked anon lookups.
getUserProfileForAnononly writes to Redis on a positive hit (Line 2494-2496). The overwhelmingly common case β an anonymous profile that was never identified β falls through to aprofile_aliasesClickHouse query on every call. This runs on hot read paths (getSessionDetails,resolveProfileIdentity), so a short-lived negative cache (e.g. a sentinel value with a small TTL) would remove a per-request CH round-trip.π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/apps/cloud/src/analytics/analytics.service.ts` around lines 2466 - 2499, Update getUserProfileForAnon to cache unlinked lookups using a dedicated sentinel value with a short TTL, return null when that sentinel is read, and continue returning cached userProfileId values normally. Store the sentinel when ClickHouse finds no userProfileId while preserving the existing positive-cache behavior.
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/apps/cloud/src/analytics/analytics.controller.ts`:
- Around line 3308-3320: Add the same rate-limit and bot checks used by the
other public ingestion routes to the identify handlers in
backend/apps/cloud/src/analytics/analytics.controller.ts (lines 3308-3320) and
backend/apps/community/src/analytics/analytics.controller.ts (lines 2799-2811),
applying them before validation or the profile-linking flow in identify. Ensure
both public endpoints invoke checkRateLimit and checkBot consistently.
---
Nitpick comments:
In `@backend/apps/cloud/src/analytics/analytics.service.ts`:
- Around line 2466-2499: Update getUserProfileForAnon to cache unlinked lookups
using a dedicated sentinel value with a short TTL, return null when that
sentinel is read, and continue returning cached userProfileId values normally.
Store the sentinel when ClickHouse finds no userProfileId while preserving the
existing positive-cache behavior.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c03edfbe-1647-4222-9c36-f7fe7ee91ce5
π Files selected for processing (17)
backend/apps/cloud/src/analytics/analytics.controller.tsbackend/apps/cloud/src/analytics/analytics.service.tsbackend/apps/cloud/src/analytics/dto/identify.dto.tsbackend/apps/community/src/analytics/analytics.controller.tsbackend/apps/community/src/analytics/analytics.service.tsbackend/apps/community/src/analytics/dto/identify.dto.tsbackend/migrations/clickhouse/2026_07_17_profile_aliases.jsbackend/migrations/clickhouse/initialise_database.jsdocs/content/docs/analytics-dashboard/profiles-and-sessions.mdxdocs/content/docs/api/events.mdxdocs/content/docs/script-reference.mdxdocs/content/docs/visitor-identification.mdxpackages/tracker-js/README.mdpackages/tracker-js/src/Lib.tspackages/tracker-js/src/index.tspackages/tracker-node/README.mdpackages/tracker-node/src/index.ts
Changes
If applicable, please describe what changes were made in this pull request.
Community Edition support
Database migrations
Documentation
Summary by CodeRabbit