Skip to content

feat: add client identity tracking and PostHog userId mapping#78

Merged
HugoRCD merged 1 commit intomainfrom
EVL-76
Feb 14, 2026
Merged

feat: add client identity tracking and PostHog userId mapping#78
HugoRCD merged 1 commit intomainfrom
EVL-76

Conversation

@HugoRCD
Copy link
Owner

@HugoRCD HugoRCD commented Feb 14, 2026

This pull request introduces a user identity context to the client logging system, allowing you to associate logs with user information (such as userId and orgId) across the client, server, and external drains like PostHog. It also updates documentation, playground tests, and the PostHog adapter to support and demonstrate this new identity feature. The changes ensure that identity fields are automatically included in all client logs, can be overridden per event, and are correctly mapped to analytics drains.

@HugoRCD HugoRCD self-assigned this Feb 14, 2026
@HugoRCD HugoRCD requested a review from Copilot February 14, 2026 16:10
@vercel
Copy link

vercel bot commented Feb 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evlog-docs Ready Ready Preview, Comment, Open in v0 Feb 14, 2026 4:11pm

@github-actions
Copy link
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 14, 2026

npm i https://pkg.pr.new/evlog@78

commit: 0cde4b1

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a comprehensive user identity tracking system for the evlog client logging framework, enabling automatic association of logs with user information across the entire stack.

Changes:

  • Added setIdentity() and clearIdentity() functions for client-side identity context management
  • Updated PostHog adapter to automatically map event.userId to PostHog's distinct_id field with a proper fallback chain
  • Added comprehensive test coverage for identity tracking and PostHog userId mapping
  • Enhanced documentation with identity usage examples and PostHog integration details
  • Added interactive playground demos for identity feature testing

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/evlog/src/runtime/client/log.ts Core implementation of identity context with setIdentity() and clearIdentity() functions, spreads identity fields into all emitted logs
packages/evlog/src/adapters/posthog.ts Updated distinct_id mapping to use fallback chain: config.distinctId → event.userId (if string) → event.service
packages/evlog/src/nuxt/module.ts Added auto-imports for setIdentity and clearIdentity functions
packages/evlog/test/identity.test.ts Comprehensive test suite covering identity setting, clearing, overrides, tagged logs, multiple fields, and replacement behavior
packages/evlog/test/adapters/posthog.test.ts Added tests for userId-to-distinct_id mapping, priority handling, and non-string userId fallback
apps/playground/app/pages/index.vue Added interactive handlers for testing identity set, log, override, and clear operations
apps/playground/app/config/tests.config.ts Added Identity test section with four interactive test cases demonstrating identity features
apps/docs/content/3.adapters/4.posthog.md Updated PostHog documentation to explain distinct_id fallback chain and automatic userId mapping
apps/docs/content/1.getting-started/2.installation.md Added Client Identity section with usage examples and auth middleware integration pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@HugoRCD HugoRCD merged commit 64032ad into main Feb 14, 2026
19 checks passed
@HugoRCD HugoRCD deleted the EVL-76 branch February 14, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants