@@ -12,11 +12,7 @@ import type { SegmentClient } from '../analytics';
1212import { DestinationMetadataEnrichment } from './DestinationMetadataEnrichment' ;
1313import { QueueFlushingPlugin } from './QueueFlushingPlugin' ;
1414import { defaultApiHost , defaultConfig } from '../constants' ;
15- import {
16- translateHTTPError ,
17- classifyError ,
18- parseRetryAfter ,
19- } from '../errors' ;
15+ import { translateHTTPError , classifyError , parseRetryAfter } from '../errors' ;
2016import { RetryManager } from '../backoff/RetryManager' ;
2117
2218const MAX_EVENTS_PER_BATCH = 100 ;
@@ -66,7 +62,9 @@ export class SegmentDestination extends DestinationPlugin {
6662 */
6763 private async uploadBatch ( batch : SegmentEvent [ ] ) : Promise < BatchResult > {
6864 const config = this . analytics ?. getConfig ( ) ?? defaultConfig ;
69- const messageIds = batch . map ( ( e ) => e . messageId ) . filter ( ( id ) : id is string => ! ! id ) ;
65+ const messageIds = batch
66+ . map ( ( e ) => e . messageId )
67+ . filter ( ( id ) : id is string => ! ! id ) ;
7068
7169 try {
7270 const res = await uploadEvents ( {
@@ -95,9 +93,12 @@ export class SegmentDestination extends DestinationPlugin {
9593
9694 // Classify error
9795 const classification = classifyError ( res . status , {
98- default4xxBehavior : config . httpConfig ?. backoffConfig ?. default4xxBehavior ,
99- default5xxBehavior : config . httpConfig ?. backoffConfig ?. default5xxBehavior ,
100- statusCodeOverrides : config . httpConfig ?. backoffConfig ?. statusCodeOverrides ,
96+ default4xxBehavior :
97+ config . httpConfig ?. backoffConfig ?. default4xxBehavior ,
98+ default5xxBehavior :
99+ config . httpConfig ?. backoffConfig ?. default5xxBehavior ,
100+ statusCodeOverrides :
101+ config . httpConfig ?. backoffConfig ?. statusCodeOverrides ,
101102 rateLimitEnabled : config . httpConfig ?. rateLimitConfig ?. enabled ,
102103 } ) ;
103104
@@ -233,7 +234,9 @@ export class SegmentDestination extends DestinationPlugin {
233234
234235 // Handle successes - dequeue
235236 if ( aggregation . successfulMessageIds . length > 0 ) {
236- await this . queuePlugin . dequeueByMessageIds ( aggregation . successfulMessageIds ) ;
237+ await this . queuePlugin . dequeueByMessageIds (
238+ aggregation . successfulMessageIds
239+ ) ;
237240
238241 // Reset retry manager on success
239242 if ( this . retryManager ) {
@@ -249,7 +252,9 @@ export class SegmentDestination extends DestinationPlugin {
249252
250253 // Handle permanent errors - dequeue (drop)
251254 if ( aggregation . permanentErrorMessageIds . length > 0 ) {
252- await this . queuePlugin . dequeueByMessageIds ( aggregation . permanentErrorMessageIds ) ;
255+ await this . queuePlugin . dequeueByMessageIds (
256+ aggregation . permanentErrorMessageIds
257+ ) ;
253258 this . analytics ?. logger . error (
254259 `Dropped ${ aggregation . permanentErrorMessageIds . length } events due to permanent errors`
255260 ) ;
@@ -301,7 +306,10 @@ export class SegmentDestination extends DestinationPlugin {
301306 const config = analytics . getConfig ( ) ;
302307
303308 // Initialize retry manager (handles both 429 rate limiting and transient errors)
304- if ( config . httpConfig ?. rateLimitConfig || config . httpConfig ?. backoffConfig ) {
309+ if (
310+ config . httpConfig ?. rateLimitConfig ||
311+ config . httpConfig ?. backoffConfig
312+ ) {
305313 this . retryManager = new RetryManager (
306314 config . writeKey ,
307315 config . storePersistor ,
0 commit comments