Repository navigation
fix(events): succeed on the event endpoint's reply and send each queued event once - #16
Merged
Merged
Conversation
…ed event once
The event endpoint replies {eventId, acknowledged}; EventResponse required
a success field, so every trackEvent threw a DecodingError after the
event was stored, queued it, and sent it again on each flush and, from
the persisted queue, on later launches. EventResponse reads the real
reply with both fields optional.
An event is queued only after a network error or a 5xx. A queued event
the server rejects is dropped, and one that fails again goes back to the
head of the queue, so events keep their order. Version 0.3.2.
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.
Summary
POST /api/sdk/v1/eventreplies{"eventId": "...", "acknowledged": true}.EventResponserequired asuccessfield the endpoint has never sent, sojson['success'] as boolthrew on every reply. The result, for everytrackEvent,trackRevenueandtrackScreenView:DecodingErrorto the app, queued the event and persisted the queue;flushQueue()sent the head of the queue again (stored again, failed to decode again, re-queued at the tail), and the persisted queue carried the events into later launches.Changes
EventResponsereadseventIdandacknowledged, both optional, so any 2xx reply decodes. It isn't exported, so no public API changes.NetworkError, or anInvalidResponseErrorwith no status or a 5xx. A 4xx is thrown and not queued.flushQueue(): a queued event that fails with a retryable error goes back to the head of the queue (EventQueue.requeueFront) and the flush stops; one the server rejects is dropped and the flush continues. Events used to go back to the tail, reordering the queue.pubspec.yaml,SdkInfo.version, CHANGELOG, README pin, example lockfile.Events already persisted on a device by earlier versions are sent once more on the next flush and then leave the queue.
Tests
test/events/event_server_contract_test.dartrunsEventTrackerover the realNetworkManagerandEventQueue, answered in the server's reply shapes:trackEventsucceeds and queues nothing; a flush sends each queued event once; a still-failing event keeps its place; a 4xx is not queued; a rejected queued event is dropped and the rest are sent. All 5 fail against the previous code.event_response_test.dartdecodes the real reply and an empty one. Event tracker mocks use the real reply shape.flutter test: 148 passed.flutter analyze: no issues.dart format: clean.build_runneroutput committed.The same decoding bug was fixed in the iOS (1.5.0) and Android (1.4.0) SDKs.