fix: send the push unregister DELETE even after opt-out (#675) - #688
Merged
Conversation
Contributor
posthog-android Compliance ReportDate: 2026-08-10 16:59:56 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
Contributor
Prompt To Fix All With AI### Issue 1
posthog/src/test/java/com/posthog/internal/PostHogPushSubscriptionManagerTest.kt:363
**Remove stale failure claim**
This comment says the regression test “fails today,” even though this PR fixes the behavior and the test now passes, making the test’s current status harder for maintainers to interpret.
```suggestion
// Regression test for posthog-android#675.
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "chore: point changeset at the posthog co..." | Re-trigger Greptile |
marandaneto
reviewed
Aug 10, 2026
marandaneto
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opting out did not stop Workflows push.
unregisterPushNotificationToken()resolves before the DELETE runs, andperformUnregisterbegan withif (closed || config.optOut) return. The normal opt-out flow —unregisterPushNotificationToken()thensetOptOut(true)— let opt-out flipconfig.optOutbefore the executor ran the unregister, so the DELETE silently parked. The server-side subscription stayed active for the whole opted-out period and Workflows kept delivering to a device that opted out (#675).Change
performUnregisterno longer gates onconfig.optOut, only onclosed. A DELETE removes data rather than collecting it, so opt-out must block registration and sends but not cleanup. The register and send paths keep theirconfig.optOutguards unchanged.How did you test this code?
opt-out during an in-flight unregister strands the DELETE (#675): registers a token, blocks the manager's single executor thread, queuesunregisterCurrent()behind it, flipsconfig.optOutbefore it runs, then releases. Asserts a DELETE reaches the mock server. Fails on the pre-fix code (reproduces the bug), passes with the fix.PostHogPushSubscriptionManagerTestsuite passes via./gradlew :posthog:test.adb reverse). Registered a token, then ranunregisterPushNotificationToken()thenoptOut(). The DELETE reached the backend (200). Rebuilt with the pre-fixconfig.optOutguard and the same flow logged the unregister but sent no DELETE.Not in this PR
#675 also reports that
optIn()does not refetch the token or re-register. That half is fixed separately in #689.Note
Draft. Directed by @dmarchuk; implemented and verified locally by Claude while @ioannisj is out.