refactor(live-notifications): emit lifecycle as CDP track events#745
Draft
mahmoud-elmorabea wants to merge 2 commits into
Draft
refactor(live-notifications): emit lifecycle as CDP track events#745mahmoud-elmorabea wants to merge 2 commits into
mahmoud-elmorabea wants to merge 2 commits into
Conversation
Replace the bespoke /v1/live_activities REST client with two CDP track events per the SDK→CDP contract: - "Live Notification" eventType=start (local start via public API) - "Live Notification" eventType=end (user dismissal) - "Live Notification Token" registrationType=push_to_start (per enabled type) All contract fields ride under `properties` (the Segment track envelope is fixed; the edge reads them there). `deviceId` is the FCM token and doubles as `pushToStartToken`; `instanceUUID` is the client-generated activity id. Events are gated on an identified user (auth-only). The instance-token flow is dropped — Android has no per-instance push token. The dismiss receiver now carries instanceUUID + activityType on the delete PendingIntent and reads the FCM token to emit `end`. Retry/flush is handled by the data pipeline, so the HTTP client, backoff and instance registration are removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sample app builds 📱Below you will find the list of the latest versions of the sample apps. It's recommended to always download the latest builds of the sample apps to accurately test the pull request. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/live-notifications #745 +/- ##
================================================================
- Coverage 66.80% 66.70% -0.10%
Complexity 1041 1041
================================================================
Files 177 177
Lines 5711 5713 +2
Branches 786 785 -1
================================================================
- Hits 3815 3811 -4
- Misses 1607 1617 +10
+ Partials 289 285 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
📏 SDK Binary Size Comparison Report
|
|
Build available to test |
|
|
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.
What
Moves the Android live-notification lifecycle off the bespoke
/v1/live_activities/*REST API and onto CDP track events, matching the agreed SDK→CDP contract.propertiesstartLive NotificationeventType=start,instanceUUID,deviceId,platform=android,activityType,payload?endLive NotificationeventType=end,instanceUUID,deviceId,platform,activityTyperegister_push_to_startLive Notification TokenregistrationType=push_to_start,activityType,platform,deviceId,pushToStartTokenDecisions baked in (confirmed with backend)
properties— the SegmentTrackEventenvelope is fixed, so the edge reads them there (verified the same constraint holds on iOS).deviceId= FCM token, and doubles aspushToStartToken(Android has no separate push-to-start token).instanceUUID= client-generated activity id for local starts.Mechanics
LiveNotificationLifecycleClientis now a thin mapper overDataPipeline.track; HTTP client, retry/backoff andregisterInstanceremoved (the pipeline owns batching/retry/flush).PendingIntentnow carriesinstanceUUID+activityType; the dismiss receiver reads the FCM token and emitsend.Testing
:messagingpush:testDebugUnitTest+:messagingpush:lintDebuggreen.register_push_to_startper enabled type, withdeviceId == pushToStartToken.startwith fullpayloadandplatform=android.endcovered by unit test (reportEnd) — see note below.Live notifications are rendered with
setOngoing(true), so Android blocks swipe-to-dismiss — the dismiss receiver (ourendtrigger) won't fire from a user swipe in practice. This predates this PR but is in direct tension with the contract's "SDK sendsendonly when the user cancels the notification." Worth a follow-up decision (dropsetOngoing, or triggerendanother way).🤖 Generated with Claude Code