Skip to content

feat: start and stop integrations on opt out#438

Draft
MohitMandalia wants to merge 5 commits intoPostHog:mainfrom
MohitMandalia:stop-all-integrations-on-opt-out
Draft

feat: start and stop integrations on opt out#438
MohitMandalia wants to merge 5 commits intoPostHog:mainfrom
MohitMandalia:stop-all-integrations-on-opt-out

Conversation

@MohitMandalia
Copy link
Contributor

@MohitMandalia MohitMandalia commented Feb 21, 2026

💡 Motivation and Context

Closes #242

💚 How did you test it?

  • Wrote unit tests
  • Ran the app.

📝 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.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

@MohitMandalia MohitMandalia force-pushed the stop-all-integrations-on-opt-out branch from 847c6ef to 3fc6d8f Compare February 21, 2026 13:53
@MohitMandalia MohitMandalia force-pushed the stop-all-integrations-on-opt-out branch from 3fc6d8f to ccdfabe Compare February 21, 2026 14:22
@MohitMandalia MohitMandalia marked this pull request as ready for review February 21, 2026 14:22
@MohitMandalia MohitMandalia requested a review from a team as a code owner February 21, 2026 14:22
@marandaneto
Copy link
Member

not all integrations should be uninstalled/installed again
PostHogAppInstallIntegration will capture another event if installed again, which should not.
PostHogLifecycleObserverIntegration cannot be uninstalled otherwise the lastUpdatedSession wont be updated
there are more cases like this, i think this issue is a bit more complicated than that

@marandaneto marandaneto marked this pull request as draft February 23, 2026 11:47
@MohitMandalia
Copy link
Contributor Author

not all integrations should be uninstalled/installed again
PostHogAppInstallIntegration will capture another event if installed again, which should not.
PostHogLifecycleObserverIntegration cannot be uninstalled otherwise the lastUpdatedSession wont be updated
there are more cases like this, i think this issue is a bit more complicated than that

Yup got it, no worries I will take some time to read through and discuss until its ready.

@MohitMandalia
Copy link
Contributor Author

MohitMandalia commented Feb 24, 2026

not all integrations should be uninstalled/installed again PostHogAppInstallIntegration will capture another event if installed again, which should not. PostHogLifecycleObserverIntegration cannot be uninstalled otherwise the lastUpdatedSession wont be updated there are more cases like this, i think this issue is a bit more complicated than that

A similar concern must be for iOS as well PostHog/posthog-ios#280 if not better to check maybe.

@MohitMandalia
Copy link
Contributor Author

MohitMandalia commented Feb 25, 2026

@marandaneto Can we define the main goal of this PR?

Based on what I think there are few implementations which should not be uninstalled:

Ok to Uninstall:

  • ReplayIntegration
  • SurveysIntegration
  • ErrorTrackingAutoCapture

should not Uninstall:

  • ActivityLifecycleCallback
  • LogCat
  • SendCachedEvents
  • AppInstalled
  • LifecycleObserver

@marandaneto
Copy link
Member

@marandaneto Can we define the main goal of this PR?

Based on what I think there are few implementations which should not be uninstalled:

Ok to Uninstall:

  • ReplayIntegration
  • SurveysIntegration
  • ErrorTrackingAutoCapture

should not Uninstall:

  • ActivityLifecycleCallback
  • LogCat
  • SendCachedEvents
  • AppInstalled
  • LifecycleObserver

sorry busy with other things this week, will take a look next week
you dont necessarily need to uninstall but stop to consume resources if its not going to be used
you can check one by one and see "does this need to be running if the SDK is not capturing any event anyway?"

@MohitMandalia
Copy link
Contributor Author

MohitMandalia commented Feb 26, 2026

@marandaneto Can we define the main goal of this PR?
Based on what I think there are few implementations which should not be uninstalled:
Ok to Uninstall:

  • ReplayIntegration
  • SurveysIntegration
  • ErrorTrackingAutoCapture

should not Uninstall:

  • ActivityLifecycleCallback
  • LogCat
  • SendCachedEvents
  • AppInstalled
  • LifecycleObserver

sorry busy with other things this week, will take a look next week you dont necessarily need to uninstall but stop to consume resources if its not going to be used you can check one by one and see "does this need to be running if the SDK is not capturing any event anyway?"

No worries take your time. I would be posting whatever questions I have.

  • what exactly is the difference between stop and uninstall? other than the main class reference and integrated boolean coz in both stop and uninstall we might release the resources. Just asking to get some context.

@ioannisj
Copy link
Collaborator

not all integrations should be uninstalled/installed again PostHogAppInstallIntegration will capture another event if installed again, which should not. PostHogLifecycleObserverIntegration cannot be uninstalled otherwise the lastUpdatedSession wont be updated there are more cases like this, i think this issue is a bit more complicated than that

A similar concern must be for iOS as well PostHog/posthog-ios#280 if not better to check maybe.

@MohitMandalia iOS is okay for PostHogAppInstallIntegration since we depend on a static var to avoid capturing duplicate events.
SessionManager doesn't depend on an integration for managing session, so all good there

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.

Stop all integrations like session replay and autocapture on opt-out

3 participants