@@ -20,7 +20,7 @@ import { insertToFlagBuffer } from '@sentry/utils';
20
20
* const ldClient = LDClient.initialize(..., inspectors: [SentryInspector]);
21
21
* ```
22
22
*/
23
- export const launchDarklyIntegration = ( ( _options ?: LaunchDarklyOptions ) => {
23
+ export const buildLaunchDarklyIntegration = ( ( _options ?: LaunchDarklyOptions ) => {
24
24
return {
25
25
name : 'launchdarkly' ,
26
26
@@ -44,26 +44,27 @@ export const launchDarklyIntegration = ((_options?: LaunchDarklyOptions) => {
44
44
* This needs to be registered separately in the LDClient, after initializing
45
45
* Sentry.
46
46
*/
47
- export class SentryInspector implements LDInspectionFlagUsedHandler {
48
- public name = 'sentry-flag-auditor' ;
49
-
50
- public type = 'flag-used' as const ;
47
+ export function buildSentryFlagUsedInspector ( ) : LDInspectionFlagUsedHandler {
48
+ return {
49
+ name : 'sentry-flag-auditor' ,
50
+ type : 'flag-used' ,
51
51
52
- // We don't want the handler to impact the performance of the user's flag evaluations.
53
- public synchronous = false ;
52
+ // We don't want the handler to impact the performance of the user's flag evaluations.
53
+ synchronous : false ,
54
54
55
- /**
56
- * Handle a flag evaluation by storing its name and value on the current scope.
57
- */
58
- public method ( flagKey : string , flagDetail : LDEvaluationDetail , _context : LDContext ) : void {
59
- if ( typeof flagDetail . value === 'boolean' ) {
60
- const scopeContexts = Sentry . getCurrentScope ( ) . getScopeData ( ) . contexts ;
61
- if ( ! scopeContexts . flags ) {
62
- scopeContexts . flags = { values : [ ] }
55
+ /**
56
+ * Handle a flag evaluation by storing its name and value on the current scope.
57
+ */
58
+ method : ( flagKey : string , flagDetail : LDEvaluationDetail , _context : LDContext ) => {
59
+ if ( typeof flagDetail . value === 'boolean' ) {
60
+ const scopeContexts = Sentry . getCurrentScope ( ) . getScopeData ( ) . contexts ;
61
+ if ( ! scopeContexts . flags ) {
62
+ scopeContexts . flags = { values : [ ] }
63
+ }
64
+ const flagBuffer = scopeContexts . flags . values ;
65
+ insertToFlagBuffer ( flagBuffer , flagKey , flagDetail . value ) ;
63
66
}
64
- const flagBuffer = scopeContexts . flags . values ;
65
- insertToFlagBuffer ( flagBuffer , flagKey , flagDetail . value ) ;
67
+ return ;
66
68
}
67
- return ;
68
69
}
69
70
}
0 commit comments