Skip to content

feat: add config option to disable swizzling - #388

Merged
ioannisj merged 8 commits into
mainfrom
feat/disable-swizzling
Oct 15, 2025
Merged

ioannisj merged 8 commits into
mainfrom
feat/disable-swizzling

Conversation

@ioannisj

@ioannisj ioannisj commented Oct 10, 2025 •

Copy link
Copy Markdown
Contributor

💡 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
Copy Markdown
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?

Comment thread PostHog/PostHogConfig.swift Resolved
@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 October 13, 2025 21:13
Comment thread PostHog/PostHogConfig.swift Resolved
Comment thread PostHog/PostHogSessionManager.swift Resolved
Comment thread CHANGELOG.md Resolved

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

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

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