|
9 | 9 | IFlagsmithResponse, |
10 | 10 | IFlagsmithTrait, |
11 | 11 | IInitConfig, |
| 12 | + ISentry, |
12 | 13 | IState, |
13 | 14 | ITraits, |
14 | 15 | LoadingState, |
@@ -167,7 +168,6 @@ const Flagsmith = class { |
167 | 168 | console.error(e) |
168 | 169 | } |
169 | 170 | } |
170 | | - |
171 | 171 | if (this.dtrum) { |
172 | 172 | try { |
173 | 173 | const traits: DynatraceObject = { |
@@ -286,36 +286,38 @@ const Flagsmith = class { |
286 | 286 | ticks: number|null= null |
287 | 287 | timer: number|null= null |
288 | 288 | dtrum= null |
| 289 | + sentryClient: ISentry | null = null |
289 | 290 | withTraits?: ITraits|null= null |
290 | 291 | cacheOptions = {ttl:0, skipAPI: false, loadStale: false, storageKey: undefined as string|undefined} |
291 | 292 | async init(config: IInitConfig) { |
292 | 293 | const evaluationContext = toEvaluationContext(config.evaluationContext || this.evaluationContext); |
293 | 294 | try { |
294 | 295 | const { |
295 | | - environmentID, |
| 296 | + AsyncStorage: _AsyncStorage, |
| 297 | + _trigger, |
| 298 | + _triggerLoadingState, |
| 299 | + angularHttpClient, |
296 | 300 | api = defaultAPI, |
297 | | - headers, |
298 | | - onChange, |
| 301 | + applicationMetadata, |
299 | 302 | cacheFlags, |
| 303 | + cacheOptions, |
300 | 304 | datadogRum, |
301 | | - onError, |
302 | 305 | defaultFlags, |
303 | | - fetch: fetchImplementation, |
304 | | - preventFetch, |
305 | | - enableLogs, |
306 | | - enableDynatrace, |
307 | 306 | enableAnalytics, |
308 | | - realtime, |
| 307 | + enableDynatrace, |
| 308 | + enableLogs, |
| 309 | + environmentID, |
309 | 310 | eventSourceUrl= "https://realtime.flagsmith.com/", |
310 | | - AsyncStorage: _AsyncStorage, |
| 311 | + fetch: fetchImplementation, |
| 312 | + headers, |
311 | 313 | identity, |
312 | | - traits, |
| 314 | + onChange, |
| 315 | + onError, |
| 316 | + preventFetch, |
| 317 | + realtime, |
| 318 | + sentryClient, |
313 | 319 | state, |
314 | | - cacheOptions, |
315 | | - angularHttpClient, |
316 | | - _trigger, |
317 | | - _triggerLoadingState, |
318 | | - applicationMetadata, |
| 320 | + traits, |
319 | 321 | } = config; |
320 | 322 | evaluationContext.environment = environmentID ? {apiKey: environmentID} : evaluationContext.environment; |
321 | 323 | if (!evaluationContext.environment || !evaluationContext.environment.apiKey) { |
@@ -396,6 +398,9 @@ const Flagsmith = class { |
396 | 398 | } |
397 | 399 | } |
398 | 400 |
|
| 401 | + if(sentryClient) { |
| 402 | + this.sentryClient = sentryClient |
| 403 | + } |
399 | 404 | if (angularHttpClient) { |
400 | 405 | // @ts-expect-error |
401 | 406 | _fetch = angularFetch(angularHttpClient); |
@@ -759,6 +764,15 @@ const Flagsmith = class { |
759 | 764 | if ((usingNewOptions && !options.skipAnalytics) || !options) { |
760 | 765 | this.evaluateFlag(key, "ENABLED"); |
761 | 766 | } |
| 767 | + if(this.sentryClient) { |
| 768 | + try { |
| 769 | + this.sentryClient.getIntegrationByName( |
| 770 | + "FeatureFlags", |
| 771 | + )?.addFeatureFlag?.(key, res); |
| 772 | + } catch (e) { |
| 773 | + console.error(e) |
| 774 | + } |
| 775 | + } |
762 | 776 |
|
763 | 777 | return res; |
764 | 778 | }; |
|
0 commit comments