Repository navigation
fix: preserve analytics evaluations tracked during in-flight or failed flushes - #329
shafiktanbir wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval skipped because this PR is from an external contributor.
Re-trigger cubic
|
Hi @shafiktanbir, thanks for the contribution! Is this work related to any open issue? Please help us understand where you come from, and how this impacts your Flagsmith installation. |
|
Hi @emyller, thanks for taking a look! This isn't tied to an open issue (I was reading through #304 and how the Node SDK handles background flushing alongside EventProcessor in #325 while evaluating feature-flag SDKs for Node/TypeScript services, so we don't have a live Flagsmith deployment impacted by this). While reading
Happy to open an issue first if you prefer tracking it there, or close this PR if |
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
AnalyticsProcessor.flush()clearedthis.analyticsData = {}only afterawait this.currentFlush, so anytrackFeature()calls made while the HTTP POST was in flight were discarded once the request resolved. Also,fetchonly rejects on network failures, so non-2xx API responses did not raise an error and dropped the flushed counts.This copies and clears
this.analyticsDatabefore starting the request, drains evaluations queued during an in-flight flush once a flush succeeds, checksresponse.okwhen a Response object is returned, and restores any unsent batch counts back intothis.analyticsDataon error.How did you test this code?
Added unit tests in
tests/sdk/analytics.test.tscovering evaluations tracked while a flush is in flight and non-ok HTTP responses, and rannpx prettier --check sdk/analytics.ts tests/sdk/analytics.test.ts,npm test, andnpm run test:esm-buildlocally.