Skip to content

Conversation

ioannisj
Copy link
Contributor

@ioannisj ioannisj commented Oct 10, 2025

💡 Motivation and Context

Closes #362

Docs PR: PostHog/posthog.com#13204

  • Adds a config option to disable swizzling
  • Refactor PostHogSessionManager from singleton to SDK instance member in line with what js lib does

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@ioannisj
Copy link
Contributor Author

@marandaneto I'd like your take and thoughts on the following:

PostHogSessionManager is using swizzling here to detect user activity in the app as part of session rotation/expire logic.

I’d like to respect the config option to disable swizzling altogether in our code. How would you handle session manager here?

Options i see:

  1. remove dependency on sendEvent() entirely.
  2. first SDK instance that runs setup() decides swizzling for the common session manager
  3. session manager picks up swizzling config from PostHogSDK.shared singleton
  4. refactor so that each SDK instance runs its own session manager (and therefore inherits its config)

wdyt?

@ioannisj ioannisj force-pushed the feat/disable-swizzling branch from 6af52e2 to d43d48a Compare October 13, 2025 20:22
@ioannisj ioannisj marked this pull request as ready for review October 13, 2025 21:13
@ioannisj ioannisj requested a review from a team as a code owner October 13, 2025 21:13
Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

LGTM.
ps: just make sure the RN session replay plugin compiles and works correctly after the session manager changes

@ioannisj ioannisj merged commit 3918f4d into main Oct 15, 2025
11 checks passed
@ioannisj ioannisj deleted the feat/disable-swizzling branch October 15, 2025 12:49
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.

Avoid swizzling

2 participants