Commit e35de89
feat(e2e-cli): add flush-retry loop with drop detection (#1175)
* feat(e2e-cli): add flush-retry loop to simulate real flush policy
The CLI previously called flush() once and exited, so events that
received retryable errors (5xx, 429) stayed in the queue with no
retry. This implements the retry loop that flush policies drive in a
real app: flush → check pending → wait for backoff → repeat.
- Flush-retry loop respects maxRetries from test config
- Forward-compatible with tapi RetryManager (reads backoff state when
available, falls back to fixed delay on master)
- Tracks permanently dropped events via logger interception
- Reports success=false when events remain or are dropped
- Computes sentBatches from delivered event count
- Enables retry test suite in e2e-config.json
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* style: remove redundant inline comments from e2e CLI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: restore pre-existing comments removed in previous commit
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: use real flush policies instead of manual retry loop
Instead of manually calling flush() in a loop and reading private
RetryManager state, let the SDK's built-in flush policies drive
retries. TimerFlushPolicy fires every flushInterval (100ms default
for e2e), and the RetryManager gates actual uploads during backoff.
The CLI just triggers the initial flush, then polls pendingEvents()
until the queue drains or 30s timeout.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(e2e-cli): wire maxRetries, error reporting, and BROWSER_BATCHING
- Pass maxRetries from test config into httpConfig overrides so the SDK
enforces retry limits during e2e tests
- Set output.error when permanentDropCount > 0 so failure reporting tests
get a truthy error field
- Add BROWSER_BATCHING=true to e2e-config.json to skip tests that assume
ephemeral per-request batching (RN uses persistent queue re-chunking)
- Add jsx: react to tsconfig.json for .tsx transitive imports
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* style: remove verbose inline comments from e2e CLI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(e2e-cli): simplify cli.ts with extracted helper functions
Extract buildConfig, dispatchEvent, waitForQueueDrain, and
interceptDropCount from main(). Drop redundant per-event validation
warnings and error handling. 367 -> 256 lines.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(e2e-cli): improve robustness of flush-retry helpers
- Return boolean from waitForQueueDrain to indicate drain vs timeout
- Add JSDoc for interceptDropCount noting coupling to SegmentDestination log format
- Add console.warn in dispatchEvent when events are skipped for missing fields
- Add comment on sentBatches approximation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(core): expose droppedEvents() on SegmentClient
Replace fragile log-interception pattern in e2e-cli with a proper
counter on SegmentDestination. The CLI now calls client.droppedEvents()
instead of monkey-patching logger.error and regex-matching drop messages.
- Add droppedEventCount property to SegmentDestination
- Add droppedEvents() accessor on SegmentClient (mirrors pendingEvents)
- Remove interceptDropCount helper from e2e-cli
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* style: fix prettier formatting in e2e CLI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(e2e-cli): remove retry test suite until retry stack is integrated
The retry e2e tests require RetryManager and SegmentDestination retry
wiring from downstream branches. Re-enable once that stack lands.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: replace droppedEventCount API with errorHandler callback
Remove custom droppedEventCount/droppedEvents() API in favor of the
existing errorHandler callback. Add ErrorType.EventsDropped so consumers
can filter for drop events. Wire CLI to use errorHandler for counting.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat: add metadata field to SegmentError for structured payloads
Add optional metadata field to SegmentError so consumers can access
structured data without parsing. Update CLI to read droppedCount from
metadata instead of incrementing by 1.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 3f0234e commit e35de89
File tree
5 files changed
+145
-192
lines changed- e2e-cli
- src
- packages/core/src
5 files changed
+145
-192
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
78 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
79 | 174 | | |
80 | 175 | | |
81 | 176 | | |
82 | 177 | | |
83 | 178 | | |
84 | | - | |
85 | 179 | | |
86 | 180 | | |
87 | 181 | | |
| |||
104 | 198 | | |
105 | 199 | | |
106 | 200 | | |
107 | | - | |
108 | | - | |
| 201 | + | |
109 | 202 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
134 | 210 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 211 | | |
142 | 212 | | |
143 | | - | |
144 | 213 | | |
145 | 214 | | |
146 | 215 | | |
147 | 216 | | |
148 | 217 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | 218 | | |
153 | 219 | | |
154 | | - | |
155 | | - | |
156 | 220 | | |
157 | 221 | | |
158 | | - | |
159 | 222 | | |
160 | 223 | | |
161 | 224 | | |
162 | 225 | | |
163 | | - | |
164 | 226 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 227 | + | |
305 | 228 | | |
306 | 229 | | |
307 | 230 | | |
308 | | - | |
309 | 231 | | |
| 232 | + | |
310 | 233 | | |
311 | | - | |
312 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
313 | 250 | | |
314 | 251 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
318 | 259 | | |
319 | 260 | | |
320 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments