Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow a caller to override the generated session id #105

Closed

Conversation

pauldambra
Copy link
Member

Problem

see private zendesk ticket: https://posthoghelp.zendesk.com/agent/tickets/5224

A posthog-node user was explicitly setting $session_id on events and we were silently ignoring it.

Changes

Allows a caller to override $session_id

Release info Sub-libraries affected

Bump level

  • Major
  • Minor
  • Patch

Libraries affected

  • All of them
  • posthog-web
  • posthog-node
  • posthog-react-native

Changelog notes

  • Added support for explicitly overriding $session_id

@@ -677,7 +677,7 @@ export abstract class PostHogCore extends PostHogCoreStateless {
...this.sessionProps, // Followed by session properties
...(properties || {}), // Followed by user specified properties
...this.getCommonEventProperties(), // Followed by FF props
$session_id: this.getSessionId(),
$session_id: properties?.['$session_id'] || this.getSessionId(),
Copy link
Contributor

Choose a reason for hiding this comment

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

flyby, this is not changing anything in posthog-node.

posthog-node uses the PostHogCoreStateless client (and not PostHogCore), and has separate tests for it in the posthog-node folder

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually not 100% sure how we could ignore a property or override it like so in posthog-node 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

🤯

Copy link
Contributor

Choose a reason for hiding this comment

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

to test, go to cd examples/example-node and then yarn ts-node example.ts and change example.ts to do what you want to do

@pauldambra pauldambra closed this Aug 23, 2023
@marandaneto marandaneto deleted the feat/allow-caller-to-override-the-session-id branch September 18, 2024 10:17
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