Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Biome check
  • Loading branch information
aliu39 committed Feb 6, 2025
commit 694acfe02ce9c3efdfc1110d5714f6520e3ff033
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Client, Event, EventHint, IntegrationFn } from '@sentry/core';

import { defineIntegration } from '@sentry/core';
import { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';
import type { StatsigClient, FeatureGate } from './types';
import type { FeatureGate, StatsigClient } from './types';

/**
* Sentry integration for capturing feature flag evaluations from the Statsig js-client SDK.
Expand All @@ -27,20 +27,18 @@ import type { StatsigClient, FeatureGate } from './types';
* Sentry.captureException(new Error('something went wrong'));
* ```
*/
export const statsigIntegration = defineIntegration(
({ statsigClient }: { statsigClient: StatsigClient }) => {
return {
name: 'Statsig',
export const statsigIntegration = defineIntegration(({ statsigClient }: { statsigClient: StatsigClient }) => {
return {
name: 'Statsig',

processEvent(event: Event, _hint: EventHint, _client: Client): Event {
return copyFlagsFromScopeToEvent(event);
},
processEvent(event: Event, _hint: EventHint, _client: Client): Event {
return copyFlagsFromScopeToEvent(event);
},

setup() {
statsigClient.on('gate_evaluation', (event: { gate: FeatureGate }) => {
insertFlagToScope(event.gate.name, event.gate.value);
});
},
};
},
) satisfies IntegrationFn;
setup() {
statsigClient.on('gate_evaluation', (event: { gate: FeatureGate }) => {
insertFlagToScope(event.gate.name, event.gate.value);
});
},
};
}) satisfies IntegrationFn;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ type EventNameToEventDataMap = {
export interface StatsigClient {
on(
event: keyof EventNameToEventDataMap,
callback: (data: EventNameToEventDataMap[keyof EventNameToEventDataMap]) => void
callback: (data: EventNameToEventDataMap[keyof EventNameToEventDataMap]) => void,
): void;
}
Loading