Skip to content

Commit dc7e74a

Browse files
committed
Inline LD types
1 parent 6e22c17 commit dc7e74a

File tree

4 files changed

+972
-65
lines changed

4 files changed

+972
-65
lines changed

packages/browser/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
},
5050
"devDependencies": {
5151
"@sentry-internal/integration-shims": "8.37.1",
52-
"fake-indexeddb": "^4.0.1",
53-
"launchdarkly-js-client-sdk": "^3.5.0"
52+
"fake-indexeddb": "^4.0.1"
5453
},
5554
"scripts": {
5655
"build": "run-p build:transpile build:bundle build:types",

packages/browser/src/integrations/featureFlags/launchdarkly/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Client, Event, EventHint, IntegrationFn } from '@sentry/types';
2-
import type { LDContext, LDEvaluationDetail, LDInspectionFlagUsedHandler } from 'launchdarkly-js-client-sdk';
2+
import type { LDContext, LDEvaluationDetail, LDInspectionFlagUsedHandler } from './types';
33

44
import { insertToFlagBuffer } from '../../../utils/featureFlags'
55
import { defineIntegration, getCurrentScope } from '@sentry/core';
Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,50 @@
1-
//TODO: inline LD types so we can drop it from devDeps
1+
/**
2+
* Inline definitions of LaunchDarkly types so we don't have to include their
3+
* SDK in devDependencies. These are only for type-checking and can be extended
4+
* as needed - for exact definitions, reference `launchdarkly-js-client-sdk`.
5+
*/
6+
7+
/**
8+
* Currently, the Sentry integration does not read from values of this type.
9+
*/
10+
export type LDContext = object;
11+
12+
/**
13+
* An object that combines the result of a feature flag evaluation with information about
14+
* how it was calculated.
15+
*/
16+
export interface LDEvaluationDetail {
17+
value: unknown;
18+
// unused optional props: variationIndex and reason
19+
}
20+
21+
/**
22+
* Callback interface for collecting information about the SDK at runtime.
23+
*
24+
* This interface is used to collect information about flag usage.
25+
*
26+
* This interface should not be used by the application to access flags for the purpose of controlling application
27+
* flow. It is intended for monitoring, analytics, or debugging purposes.
28+
*/
29+
export interface LDInspectionFlagUsedHandler {
30+
type: 'flag-used';
31+
32+
/**
33+
* Name of the inspector. Will be used for logging issues with the inspector.
34+
*/
35+
name: string;
36+
37+
/**
38+
* If `true`, then the inspector will be ran synchronously with evaluation.
39+
* Synchronous inspectors execute inline with evaluation and care should be taken to ensure
40+
* they have minimal performance overhead.
41+
*/
42+
synchronous?: boolean;
43+
44+
/**
45+
* This method is called when a flag is accessed via a variation method, or it can be called based on actions in
46+
* wrapper SDKs which have different methods of tracking when a flag was accessed. It is not called when a call is made
47+
* to allFlags.
48+
*/
49+
method: (flagKey: string, flagDetail: LDEvaluationDetail, context: LDContext) => void;
50+
}

0 commit comments

Comments
 (0)