Skip to content

Feature/analytics intelligence engine#133

Open
Ritesh2332 wants to merge 9 commits into
Dev-Card:mainfrom
Ritesh2332:feature/analytics-intelligence-engine
Open

Feature/analytics intelligence engine#133
Ritesh2332 wants to merge 9 commits into
Dev-Card:mainfrom
Ritesh2332:feature/analytics-intelligence-engine

Conversation

@Ritesh2332

@Ritesh2332 Ritesh2332 commented May 17, 2026

Copy link
Copy Markdown

Summary

This PR improves analytics tracking for public profile and card views by enhancing the existing CardView system instead of introducing a separate analytics schema.

The implementation adds reusable tracking utilities, privacy-safe IP hashing, and cleaner route-level tracking while keeping the backend architecture lightweight and easier to maintain.

It also improves type safety in public analytics routes and lays the groundwork for future analytics and engagement insights.

Closes #28

What Changed

  • reused the existing CardView infrastructure for analytics tracking
  • added a centralized tracking utility for cleaner analytics integration
  • added SHA-256 hashing for viewer IP storage
  • improved query type safety in public routes
  • integrated analytics tracking into public profile and card views
  • removed the extra schema/migration layer after maintainer review feedback
  • resolved merge conflicts with upstream main

How to Test

  1. Start services:
docker compose up -d
  1. Run the backend:
pnpm dev
  1. Open a public profile route:
http://127.0.0.1:3000/api/u/<username>
  1. Verify that CardView entries are created in PostgreSQL.

@Harxhit Harxhit added the gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking. label May 17, 2026
Ritesh2332 and others added 2 commits May 20, 2026 11:01
- Remove EngagementEvent model, enum, and migration; reuse CardView
- Rewrite trackEvent() to create cardView rows with hashed viewerIp
- Revert docker-compose Postgres port to 5432:5432
- Remove package-lock.json (project uses pnpm)
- Resolve schema conflict with upstream Event/EventAttendee models

Co-authored-by: Cursor <cursoragent@cursor.com>
@ShantKhatri ShantKhatri added the critical Includes schema, architecture, or other critical core functionality changes. label May 20, 2026
@ShantKhatri ShantKhatri requested a review from Harxhit May 20, 2026 09:51
@ShantKhatri

Copy link
Copy Markdown
Contributor

@Harxhit , there are schema changes here, could you please review this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this as we do not need it.

Comment thread package-lock.json

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this.

Comment thread apps/backend/prisma/schema.prisma Outdated
userId String @map("user_id")
viewerId String? @map("viewer_id")

cardId String? @map("card_id")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add relation here

Comment thread apps/backend/prisma/schema.prisma Outdated
id String @id @default(uuid())

userId String @map("user_id")
viewerId String? @map("viewer_id")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add relation here

Comment thread apps/backend/prisma/schema.prisma Outdated
cardId String? @map("card_id") // null = default profile view
ownerId String @map("owner_id") // card/profile owner
viewerId String? @map("viewer_id") // null = anonymous web viewer
viewerIp String? @map("viewer_ip")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to hash the IP here.

Comment thread apps/backend/prisma/schema.prisma Outdated
@@ -30,18 +30,20 @@ model User {
viewedCards CardView[] @relation("cardViewer")
followLogs FollowLog[]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FollowLog model creation is missing.

Comment thread apps/backend/prisma/schema.prisma Outdated
LINK_CLICK
FOLLOW_ATTEMPT
FOLLOW_SUCCESS
QR_SCAN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is QR_SCAN event type?

Comment thread apps/backend/src/routes/public.ts Outdated

eventType: 'PROFILE_VIEW',

source: (request.query as any)?.source || 'link',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we not use any here breaks the type safety.

Comment thread docker-compose.yml

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes in this file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CardView and EngagementEvent are doing the same job

@Harxhit

Harxhit commented May 20, 2026

Copy link
Copy Markdown
Collaborator

@Ritesh2332 Please add the issues this PR closes so I can get better context and understand whether it also includes the API layer. Also fix the merge conflicts.

@Ritesh2332

Copy link
Copy Markdown
Author

Addressed the requested review feedback:

Ready for re-review.

@ShantKhatri

Copy link
Copy Markdown
Contributor

@Ritesh2332 Please fix merge conflicts.

Resolve conflicts in schema, auth, and public routes while keeping analytics trackEvent and upstream team/OAuth improvements.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread docker-compose.yml Outdated
- devcard-pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U devcard']
test: [ 'CMD-SHELL', 'pg_isready -U devcard' ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing changed here, so please remove the blank space changes.

@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

@Ritesh2332 is attempting to deploy a commit to the Prashantkumar Khatri's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

CI — Checks Failed

Backend — FAIL

Check Result
Lint FAIL
Test PASS
Typecheck FAIL

Mobile — SKIP

Check Result
Lint -
Test -

Web — SKIP

Check Result
Check -
Build -

Last updated: Sat, 06 Jun 2026 20:15:07 GMT

Resolve auth, public routes, and schema conflicts; keep trackEvent analytics with upstream service layer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

critical Includes schema, architecture, or other critical core functionality changes. gssoc:approved Required label for every approved PR. Gives the base +50 points and enables contribution tracking.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web: build a full analytics dashboard page at /devcard/analytics

3 participants