@@ -10,6 +10,7 @@ import {
10
10
TypeMismatchError ,
11
11
} from '@openfeature/js-sdk' ;
12
12
import axios from 'axios' ;
13
+ import { copy } from 'copy-anything' ;
13
14
import { transformContext } from './context-transformer' ;
14
15
import { ProxyNotReady } from './errors/proxyNotReady' ;
15
16
import { ProxyTimeout } from './errors/proxyTimeout' ;
@@ -117,11 +118,11 @@ export class GoFeatureFlagProvider implements Provider {
117
118
*/
118
119
async callGoffDataCollection ( ) {
119
120
if ( this . dataCollectorBuffer ?. length === 0 ) {
120
- return
121
+ return ;
121
122
}
122
123
123
- const dataToSend = structuredClone ( this . dataCollectorBuffer ) ;
124
- this . dataCollectorBuffer = [ ]
124
+ const dataToSend = copy ( this . dataCollectorBuffer ) || [ ] ;
125
+ this . dataCollectorBuffer = [ ] ;
125
126
126
127
const request : DataCollectorRequest < boolean > = { events : dataToSend , meta : this . dataCollectorMetadata , }
127
128
const endpointURL = new URL ( this . endpoint ) ;
@@ -138,7 +139,7 @@ export class GoFeatureFlagProvider implements Provider {
138
139
} catch ( e ) {
139
140
this . logger ?. error ( `impossible to send the data to the collector: ${ e } ` )
140
141
// if we have an issue calling the collector we put the data back in the buffer
141
- this . dataCollectorBuffer = [ ...this . dataCollectorBuffer , ...dataToSend ]
142
+ this . dataCollectorBuffer = [ ...this . dataCollectorBuffer , ...dataToSend ] ;
142
143
}
143
144
}
144
145
0 commit comments