diff --git a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/init.js b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/init.js index 3e9a79894532..dc92fbc296a4 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/init.js @@ -7,7 +7,7 @@ window.UnleashClient = class { }; window.Sentry = Sentry; -window.sentryUnleashIntegration = Sentry.unleashIntegration({unleashClientClass: window.UnleashClient}); +window.sentryUnleashIntegration = Sentry.unleashIntegration({ unleashClientClass: window.UnleashClient }); Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', diff --git a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/test.ts b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/test.ts index 70c25fa8f560..dacb1c0154a3 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/test.ts +++ b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/badSignature/test.ts @@ -41,9 +41,15 @@ sentryTest('Logs and returns if isEnabled does not match expected signature', as // Expected error logs. expect(errorLogs).toEqual( expect.arrayContaining([ - expect.stringContaining('[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: my-feature (string), result: my-feature (string)'), - expect.stringContaining('[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: 999 (number), result: 999 (number)'), - expect.stringContaining('[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: [object Object] (object), result: [object Object] (object)'), + expect.stringContaining( + '[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: my-feature (string), result: my-feature (string)', + ), + expect.stringContaining( + '[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: 999 (number), result: 999 (number)', + ), + expect.stringContaining( + '[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: [object Object] (object), result: [object Object] (object)', + ), ]), ); }); diff --git a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/init.js b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/init.js index 2a991bfde3f0..9f1f28730cf7 100644 --- a/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/init.js +++ b/dev-packages/browser-integration-tests/suites/integrations/featureFlags/unleash/init.js @@ -41,7 +41,7 @@ window.UnleashClient = class { }; window.Sentry = Sentry; -window.sentryUnleashIntegration = Sentry.unleashIntegration({unleashClientClass: window.UnleashClient}); +window.sentryUnleashIntegration = Sentry.unleashIntegration({ unleashClientClass: window.UnleashClient }); Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', diff --git a/packages/browser/src/integrations/featureFlags/unleash/integration.ts b/packages/browser/src/integrations/featureFlags/unleash/integration.ts index 29652a1273d8..e910b6946573 100644 --- a/packages/browser/src/integrations/featureFlags/unleash/integration.ts +++ b/packages/browser/src/integrations/featureFlags/unleash/integration.ts @@ -29,20 +29,22 @@ import type { UnleashClient, UnleashClientClass } from './types'; * Sentry.captureException(new Error('something went wrong')); * ``` */ -export const unleashIntegration = defineIntegration(({unleashClientClass}: {unleashClientClass: UnleashClientClass}) => { - return { - name: 'Unleash', +export const unleashIntegration = defineIntegration( + ({ unleashClientClass }: { unleashClientClass: UnleashClientClass }) => { + return { + name: 'Unleash', - processEvent(event: Event, _hint: EventHint, _client: Client): Event { - return copyFlagsFromScopeToEvent(event); - }, + processEvent(event: Event, _hint: EventHint, _client: Client): Event { + return copyFlagsFromScopeToEvent(event); + }, - setupOnce() { - const unleashClientPrototype = unleashClientClass.prototype as UnleashClient; - fill(unleashClientPrototype, 'isEnabled', _wrappedIsEnabled); - }, - }; -}) satisfies IntegrationFn; + setupOnce() { + const unleashClientPrototype = unleashClientClass.prototype as UnleashClient; + fill(unleashClientPrototype, 'isEnabled', _wrappedIsEnabled); + }, + }; + }, +) satisfies IntegrationFn; /** * Wraps the UnleashClient.isEnabled method to capture feature flag evaluations. Its only side effect is writing to Sentry scope. @@ -53,7 +55,9 @@ export const unleashIntegration = defineIntegration(({unleashClientClass}: {unle * @param original - The original method. * @returns Wrapped method. Results should match the original. */ -function _wrappedIsEnabled(original: (this: UnleashClient, ...args: unknown[]) => unknown): (this: UnleashClient, ...args: unknown[]) => unknown { +function _wrappedIsEnabled( + original: (this: UnleashClient, ...args: unknown[]) => unknown, +): (this: UnleashClient, ...args: unknown[]) => unknown { return function (this: UnleashClient, ...args: unknown[]): unknown { const toggleName = args[0]; const result = original.apply(this, args); @@ -61,7 +65,9 @@ function _wrappedIsEnabled(original: (this: UnleashClient, ...args: unknown[]) = if (typeof toggleName === 'string' && typeof result === 'boolean') { insertFlagToScope(toggleName, result); } else { - logger.error(`[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${toggleName} (${typeof toggleName}), result: ${result} (${typeof result})`); + logger.error( + `[Feature Flags] UnleashClient.isEnabled does not match expected signature. arg0: ${toggleName} (${typeof toggleName}), result: ${result} (${typeof result})`, + ); } return result; };