@sentry/browser 8.41.0-beta.1 → 8.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/npm/cjs/client.js +1 -1
- package/build/npm/cjs/client.js.map +1 -1
- package/build/npm/cjs/eventbuilder.js.map +1 -1
- package/build/npm/cjs/helpers.js +25 -21
- package/build/npm/cjs/helpers.js.map +1 -1
- package/build/npm/cjs/index.js +0 -9
- package/build/npm/cjs/index.js.map +1 -1
- package/build/npm/cjs/integrations/breadcrumbs.js +3 -0
- package/build/npm/cjs/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/cjs/integrations/browserapierrors.js +41 -63
- package/build/npm/cjs/integrations/browserapierrors.js.map +1 -1
- package/build/npm/cjs/integrations/contextlines.js.map +1 -1
- package/build/npm/cjs/integrations/globalhandlers.js.map +1 -1
- package/build/npm/cjs/integrations/httpclient.js +6 -6
- package/build/npm/cjs/integrations/httpclient.js.map +1 -1
- package/build/npm/cjs/integrations/linkederrors.js.map +1 -1
- package/build/npm/cjs/integrations/reportingobserver.js +7 -6
- package/build/npm/cjs/integrations/reportingobserver.js.map +1 -1
- package/build/npm/cjs/integrations/spotlight.js.map +1 -1
- package/build/npm/cjs/metrics.js.map +1 -1
- package/build/npm/cjs/profiling/integration.js.map +1 -1
- package/build/npm/cjs/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/profiling/utils.js +0 -3
- package/build/npm/cjs/profiling/utils.js.map +1 -1
- package/build/npm/cjs/sdk.js +1 -1
- package/build/npm/cjs/sdk.js.map +1 -1
- package/build/npm/cjs/stack-parsers.js.map +1 -1
- package/build/npm/cjs/tracing/backgroundtab.js.map +1 -1
- package/build/npm/cjs/tracing/browserTracingIntegration.js +12 -13
- package/build/npm/cjs/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/cjs/tracing/request.js +6 -21
- package/build/npm/cjs/tracing/request.js.map +1 -1
- package/build/npm/cjs/transports/fetch.js.map +1 -1
- package/build/npm/cjs/transports/offline.js.map +1 -1
- package/build/npm/cjs/userfeedback.js.map +1 -1
- package/build/npm/cjs/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/esm/client.js +1 -1
- package/build/npm/esm/client.js.map +1 -1
- package/build/npm/esm/eventbuilder.js.map +1 -1
- package/build/npm/esm/helpers.js +25 -21
- package/build/npm/esm/helpers.js.map +1 -1
- package/build/npm/esm/index.js +0 -3
- package/build/npm/esm/index.js.map +1 -1
- package/build/npm/esm/integrations/breadcrumbs.js +3 -0
- package/build/npm/esm/integrations/breadcrumbs.js.map +1 -1
- package/build/npm/esm/integrations/browserapierrors.js +41 -63
- package/build/npm/esm/integrations/browserapierrors.js.map +1 -1
- package/build/npm/esm/integrations/contextlines.js.map +1 -1
- package/build/npm/esm/integrations/globalhandlers.js.map +1 -1
- package/build/npm/esm/integrations/httpclient.js +6 -6
- package/build/npm/esm/integrations/httpclient.js.map +1 -1
- package/build/npm/esm/integrations/linkederrors.js.map +1 -1
- package/build/npm/esm/integrations/reportingobserver.js +7 -6
- package/build/npm/esm/integrations/reportingobserver.js.map +1 -1
- package/build/npm/esm/integrations/spotlight.js.map +1 -1
- package/build/npm/esm/metrics.js.map +1 -1
- package/build/npm/esm/package.json +1 -1
- package/build/npm/esm/profiling/integration.js.map +1 -1
- package/build/npm/esm/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/profiling/utils.js +0 -3
- package/build/npm/esm/profiling/utils.js.map +1 -1
- package/build/npm/esm/sdk.js +1 -1
- package/build/npm/esm/sdk.js.map +1 -1
- package/build/npm/esm/stack-parsers.js.map +1 -1
- package/build/npm/esm/tracing/backgroundtab.js.map +1 -1
- package/build/npm/esm/tracing/browserTracingIntegration.js +13 -14
- package/build/npm/esm/tracing/browserTracingIntegration.js.map +1 -1
- package/build/npm/esm/tracing/request.js +7 -22
- package/build/npm/esm/tracing/request.js.map +1 -1
- package/build/npm/esm/transports/fetch.js.map +1 -1
- package/build/npm/esm/transports/offline.js.map +1 -1
- package/build/npm/esm/userfeedback.js.map +1 -1
- package/build/npm/esm/utils/lazyLoadIntegration.js.map +1 -1
- package/build/npm/types/client.d.ts +2 -3
- package/build/npm/types/client.d.ts.map +1 -1
- package/build/npm/types/eventbuilder.d.ts +1 -1
- package/build/npm/types/eventbuilder.d.ts.map +1 -1
- package/build/npm/types/exports.d.ts +1 -1
- package/build/npm/types/exports.d.ts.map +1 -1
- package/build/npm/types/feedbackAsync.d.ts +1 -1
- package/build/npm/types/feedbackSync.d.ts +1 -1
- package/build/npm/types/helpers.d.ts +8 -12
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +4 -7
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/breadcrumbs.d.ts +1 -1
- package/build/npm/types/integrations/breadcrumbs.d.ts.map +1 -1
- package/build/npm/types/integrations/browserapierrors.d.ts +1 -1
- package/build/npm/types/integrations/browserapierrors.d.ts.map +1 -1
- package/build/npm/types/integrations/contextlines.d.ts +2 -2
- package/build/npm/types/integrations/contextlines.d.ts.map +1 -1
- package/build/npm/types/integrations/globalhandlers.d.ts +1 -1
- package/build/npm/types/integrations/globalhandlers.d.ts.map +1 -1
- package/build/npm/types/integrations/httpclient.d.ts +1 -1
- package/build/npm/types/integrations/httpclient.d.ts.map +1 -1
- package/build/npm/types/integrations/httpcontext.d.ts +1 -1
- package/build/npm/types/integrations/httpcontext.d.ts.map +1 -1
- package/build/npm/types/integrations/linkederrors.d.ts +1 -1
- package/build/npm/types/integrations/linkederrors.d.ts.map +1 -1
- package/build/npm/types/integrations/reportingobserver.d.ts +1 -1
- package/build/npm/types/integrations/reportingobserver.d.ts.map +1 -1
- package/build/npm/types/integrations/spotlight.d.ts +2 -2
- package/build/npm/types/integrations/spotlight.d.ts.map +1 -1
- package/build/npm/types/metrics.d.ts +1 -1
- package/build/npm/types/metrics.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts +1 -1
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts +1 -1
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/sdk.d.ts +1 -1
- package/build/npm/types/sdk.d.ts.map +1 -1
- package/build/npm/types/stack-parsers.d.ts +2 -2
- package/build/npm/types/stack-parsers.d.ts.map +1 -1
- package/build/npm/types/tracing/backgroundtab.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts +2 -3
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts +4 -3
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types/transports/fetch.d.ts +1 -1
- package/build/npm/types/transports/fetch.d.ts.map +1 -1
- package/build/npm/types/transports/offline.d.ts +1 -2
- package/build/npm/types/transports/offline.d.ts.map +1 -1
- package/build/npm/types/transports/types.d.ts +1 -1
- package/build/npm/types/transports/types.d.ts.map +1 -1
- package/build/npm/types/userfeedback.d.ts +1 -1
- package/build/npm/types/userfeedback.d.ts.map +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts +1 -1
- package/build/npm/types/utils/lazyLoadIntegration.d.ts.map +1 -1
- package/build/npm/types-ts3.8/client.d.ts +2 -3
- package/build/npm/types-ts3.8/eventbuilder.d.ts +1 -1
- package/build/npm/types-ts3.8/exports.d.ts +1 -1
- package/build/npm/types-ts3.8/feedbackAsync.d.ts +1 -1
- package/build/npm/types-ts3.8/feedbackSync.d.ts +1 -1
- package/build/npm/types-ts3.8/helpers.d.ts +8 -12
- package/build/npm/types-ts3.8/index.d.ts +4 -7
- package/build/npm/types-ts3.8/integrations/breadcrumbs.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/browserapierrors.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/contextlines.d.ts +2 -2
- package/build/npm/types-ts3.8/integrations/globalhandlers.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/httpclient.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/httpcontext.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/linkederrors.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/reportingobserver.d.ts +1 -1
- package/build/npm/types-ts3.8/integrations/spotlight.d.ts +2 -2
- package/build/npm/types-ts3.8/metrics.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/integration.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/startProfileForSpan.d.ts +1 -1
- package/build/npm/types-ts3.8/profiling/utils.d.ts +1 -1
- package/build/npm/types-ts3.8/sdk.d.ts +1 -1
- package/build/npm/types-ts3.8/stack-parsers.d.ts +2 -2
- package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +2 -3
- package/build/npm/types-ts3.8/tracing/request.d.ts +4 -3
- package/build/npm/types-ts3.8/transports/fetch.d.ts +1 -1
- package/build/npm/types-ts3.8/transports/offline.d.ts +1 -2
- package/build/npm/types-ts3.8/transports/types.d.ts +1 -1
- package/build/npm/types-ts3.8/userfeedback.d.ts +1 -1
- package/build/npm/types-ts3.8/utils/lazyLoadIntegration.d.ts +1 -1
- package/package.json +7 -8
- package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js +0 -55
- package/build/npm/cjs/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
- package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js +0 -37
- package/build/npm/cjs/integrations/featureFlags/openfeature/integration.js.map +0 -1
- package/build/npm/cjs/utils/featureFlags.js +0 -97
- package/build/npm/cjs/utils/featureFlags.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js +0 -52
- package/build/npm/esm/integrations/featureFlags/launchdarkly/integration.js.map +0 -1
- package/build/npm/esm/integrations/featureFlags/openfeature/integration.js +0 -34
- package/build/npm/esm/integrations/featureFlags/openfeature/integration.js.map +0 -1
- package/build/npm/esm/utils/featureFlags.js +0 -92
- package/build/npm/esm/utils/featureFlags.js.map +0 -1
- package/build/npm/types/integrations/featureFlags/launchdarkly/index.d.ts +0 -2
- package/build/npm/types/integrations/featureFlags/launchdarkly/index.d.ts.map +0 -1
- package/build/npm/types/integrations/featureFlags/launchdarkly/integration.d.ts +0 -25
- package/build/npm/types/integrations/featureFlags/launchdarkly/integration.d.ts.map +0 -1
- package/build/npm/types/integrations/featureFlags/launchdarkly/types.d.ts +0 -44
- package/build/npm/types/integrations/featureFlags/launchdarkly/types.d.ts.map +0 -1
- package/build/npm/types/integrations/featureFlags/openfeature/index.d.ts +0 -2
- package/build/npm/types/integrations/featureFlags/openfeature/index.d.ts.map +0 -1
- package/build/npm/types/integrations/featureFlags/openfeature/integration.d.ts +0 -16
- package/build/npm/types/integrations/featureFlags/openfeature/integration.d.ts.map +0 -1
- package/build/npm/types/integrations/featureFlags/openfeature/types.d.ts +0 -86
- package/build/npm/types/integrations/featureFlags/openfeature/types.d.ts.map +0 -1
- package/build/npm/types/utils/featureFlags.d.ts +0 -34
- package/build/npm/types/utils/featureFlags.d.ts.map +0 -1
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/index.d.ts +0 -2
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/integration.d.ts +0 -25
- package/build/npm/types-ts3.8/integrations/featureFlags/launchdarkly/types.d.ts +0 -44
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/index.d.ts +0 -2
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/integration.d.ts +0 -16
- package/build/npm/types-ts3.8/integrations/featureFlags/openfeature/types.d.ts +0 -86
- package/build/npm/types-ts3.8/utils/featureFlags.d.ts +0 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Event } from '@sentry/
|
|
1
|
+
import { Event } from '@sentry/core';
|
|
2
2
|
export type SpotlightConnectionOptions = {
|
|
3
3
|
/**
|
|
4
4
|
* Set this if the Spotlight Sidecar is not running on localhost:8969
|
|
@@ -12,7 +12,7 @@ export declare const INTEGRATION_NAME = "SpotlightBrowser";
|
|
|
12
12
|
*
|
|
13
13
|
* Learn more about spotlight at https://spotlightjs.com
|
|
14
14
|
*/
|
|
15
|
-
export declare const spotlightBrowserIntegration: (options?: Partial<SpotlightConnectionOptions> | undefined) => import("@sentry/
|
|
15
|
+
export declare const spotlightBrowserIntegration: (options?: Partial<SpotlightConnectionOptions> | undefined) => import("@sentry/core").Integration;
|
|
16
16
|
/**
|
|
17
17
|
* Flags if the event is a transaction created from an interaction with the spotlight UI.
|
|
18
18
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const browserProfilingIntegration: () => import("@sentry/
|
|
1
|
+
export declare const browserProfilingIntegration: () => import("@sentry/core").Integration;
|
|
2
2
|
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DebugImage, Envelope, Event, EventEnvelope, Profile, Span, ThreadCpuProfile } from '@sentry/
|
|
1
|
+
import { DebugImage, Envelope, Event, EventEnvelope, Profile, Span, ThreadCpuProfile } from '@sentry/core';
|
|
2
2
|
import { JSSelfProfile, JSSelfProfiler } from './jsSelfProfiling';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, DsnLike, Integration, Options, UserFeedback } from '@sentry/
|
|
1
|
+
import { Client, DsnLike, Integration, Options, UserFeedback } from '@sentry/core';
|
|
2
2
|
import { BrowserOptions } from './client';
|
|
3
3
|
/** Get the default integrations for the browser SDK. */
|
|
4
4
|
export declare function getDefaultIntegrations(_options: Options): Integration[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { StackLineParser } from '@sentry/
|
|
1
|
+
import { StackLineParser } from '@sentry/core';
|
|
2
2
|
export declare const chromeStackLineParser: StackLineParser;
|
|
3
3
|
export declare const geckoStackLineParser: StackLineParser;
|
|
4
4
|
export declare const winjsStackLineParser: StackLineParser;
|
|
5
5
|
export declare const opera10StackLineParser: StackLineParser;
|
|
6
6
|
export declare const opera11StackLineParser: StackLineParser;
|
|
7
7
|
export declare const defaultStackLineParsers: StackLineParser[];
|
|
8
|
-
export declare const defaultStackParser: import("@sentry/
|
|
8
|
+
export declare const defaultStackParser: import("@sentry/core").StackParser;
|
|
9
9
|
//# sourceMappingURL=stack-parsers.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Client, StartSpanOptions } from '@sentry/
|
|
2
|
-
import { Span } from '@sentry/types';
|
|
1
|
+
import { Client, Span, StartSpanOptions } from '@sentry/core';
|
|
3
2
|
export declare const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
|
|
4
3
|
/** Options for Browser Tracing integration */
|
|
5
4
|
export interface BrowserTracingOptions {
|
|
@@ -120,7 +119,7 @@ export interface BrowserTracingOptions {
|
|
|
120
119
|
*/
|
|
121
120
|
export declare const browserTracingIntegration: (_options?: Partial<BrowserTracingOptions>) => {
|
|
122
121
|
name: string;
|
|
123
|
-
afterAllSetup(client: Client<import("@sentry/
|
|
122
|
+
afterAllSetup(client: Client<import("@sentry/core").ClientOptions<import("@sentry/core").BaseTransportOptions>>): void;
|
|
124
123
|
};
|
|
125
124
|
/**
|
|
126
125
|
* Manually start a page load span.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, HandlerDataXhr, Span } from '@sentry/
|
|
1
|
+
import { Client, HandlerDataXhr, Span } from '@sentry/core';
|
|
2
2
|
/** Options for Request Instrumentation */
|
|
3
3
|
export interface RequestInstrumentationOptions {
|
|
4
4
|
/**
|
|
@@ -40,7 +40,8 @@ export interface RequestInstrumentationOptions {
|
|
|
40
40
|
*
|
|
41
41
|
* Default: true
|
|
42
42
|
*/
|
|
43
|
-
traceXHR: boolean
|
|
43
|
+
traceXHR: boolean;
|
|
44
|
+
/**
|
|
44
45
|
* Flag to disable tracking of long-lived streams, like server-sent events (SSE) via fetch.
|
|
45
46
|
* Do not enable this in case you have live streams or very long running streams.
|
|
46
47
|
*
|
|
@@ -48,7 +49,7 @@ export interface RequestInstrumentationOptions {
|
|
|
48
49
|
* (https://github.com/getsentry/sentry-javascript/issues/13950)
|
|
49
50
|
*
|
|
50
51
|
* Default: false
|
|
51
|
-
|
|
52
|
+
*/
|
|
52
53
|
trackFetchStreamPerformance: boolean;
|
|
53
54
|
/**
|
|
54
55
|
* If true, Sentry will capture http timings and add them to the corresponding http spans.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OfflineTransportOptions } from '@sentry/core';
|
|
2
|
-
import { BaseTransportOptions, Transport } from '@sentry/types';
|
|
1
|
+
import { BaseTransportOptions, OfflineTransportOptions, Transport } from '@sentry/core';
|
|
3
2
|
type Store = <T>(callback: (store: IDBObjectStore) => T | PromiseLike<T>) => Promise<T>;
|
|
4
3
|
/** Create or open an IndexedDb store */
|
|
5
4
|
export declare function createStore(dbName: string, storeName: string): Store;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseTransportOptions } from '@sentry/
|
|
1
|
+
import { BaseTransportOptions } from '@sentry/core';
|
|
2
2
|
export interface BrowserTransportOptions extends BaseTransportOptions {
|
|
3
3
|
/** Fetch API init parameters. Used by the FetchTransport */
|
|
4
4
|
fetchOptions?: RequestInit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/browser",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.42.0",
|
|
4
4
|
"description": "Official Sentry SDK for browsers",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
|
|
@@ -39,15 +39,14 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sentry-internal/browser-utils": "8.
|
|
43
|
-
"@sentry-internal/feedback": "8.
|
|
44
|
-
"@sentry-internal/replay": "8.
|
|
45
|
-
"@sentry-internal/replay-canvas": "8.
|
|
46
|
-
"@sentry/core": "8.
|
|
47
|
-
"@sentry/types": "8.41.0-beta.1"
|
|
42
|
+
"@sentry-internal/browser-utils": "8.42.0",
|
|
43
|
+
"@sentry-internal/feedback": "8.42.0",
|
|
44
|
+
"@sentry-internal/replay": "8.42.0",
|
|
45
|
+
"@sentry-internal/replay-canvas": "8.42.0",
|
|
46
|
+
"@sentry/core": "8.42.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@sentry-internal/integration-shims": "8.
|
|
49
|
+
"@sentry-internal/integration-shims": "8.42.0",
|
|
51
50
|
"fake-indexeddb": "^4.0.1"
|
|
52
51
|
},
|
|
53
52
|
"scripts": {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
const core = require('@sentry/core');
|
|
4
|
-
const featureFlags = require('../../../utils/featureFlags.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sentry integration for capturing feature flags from LaunchDarkly.
|
|
8
|
-
*
|
|
9
|
-
* See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* import * as Sentry from '@sentry/browser';
|
|
14
|
-
* import {launchDarklyIntegration, buildLaunchDarklyFlagUsedInspector} from '@sentry/browser';
|
|
15
|
-
* import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
|
|
16
|
-
*
|
|
17
|
-
* Sentry.init(..., integrations: [launchDarklyIntegration()])
|
|
18
|
-
* const ldClient = LaunchDarkly.initialize(..., {inspectors: [buildLaunchDarklyFlagUsedHandler()]});
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
const launchDarklyIntegration = core.defineIntegration(() => {
|
|
22
|
-
return {
|
|
23
|
-
name: 'LaunchDarkly',
|
|
24
|
-
|
|
25
|
-
processEvent(event, _hint, _client) {
|
|
26
|
-
return featureFlags.copyFlagsFromScopeToEvent(event);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}) ;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* LaunchDarkly hook that listens for flag evaluations and updates the `flags`
|
|
33
|
-
* context in our Sentry scope. This needs to be registered as an
|
|
34
|
-
* 'inspector' in LaunchDarkly initialize() options, separately from
|
|
35
|
-
* `launchDarklyIntegration`. Both are needed to collect feature flags on error.
|
|
36
|
-
*/
|
|
37
|
-
function buildLaunchDarklyFlagUsedHandler() {
|
|
38
|
-
return {
|
|
39
|
-
name: 'sentry-flag-auditor',
|
|
40
|
-
type: 'flag-used',
|
|
41
|
-
|
|
42
|
-
synchronous: true,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Handle a flag evaluation by storing its name and value on the current scope.
|
|
46
|
-
*/
|
|
47
|
-
method: (flagKey, flagDetail, _context) => {
|
|
48
|
-
featureFlags.insertFlagToScope(flagKey, flagDetail.value);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
exports.buildLaunchDarklyFlagUsedHandler = buildLaunchDarklyFlagUsedHandler;
|
|
54
|
-
exports.launchDarklyIntegration = launchDarklyIntegration;
|
|
55
|
-
//# sourceMappingURL=integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../../../src/integrations/featureFlags/launchdarkly/integration.ts"],"sourcesContent":["import type { Client, Event, EventHint, IntegrationFn } from '@sentry/types';\nimport type { LDContext, LDEvaluationDetail, LDInspectionFlagUsedHandler } from './types';\n\nimport { defineIntegration } from '@sentry/core';\nimport { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';\n\n/**\n * Sentry integration for capturing feature flags from LaunchDarkly.\n *\n * See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.\n *\n * @example\n * ```\n * import * as Sentry from '@sentry/browser';\n * import {launchDarklyIntegration, buildLaunchDarklyFlagUsedInspector} from '@sentry/browser';\n * import * as LaunchDarkly from 'launchdarkly-js-client-sdk';\n *\n * Sentry.init(..., integrations: [launchDarklyIntegration()])\n * const ldClient = LaunchDarkly.initialize(..., {inspectors: [buildLaunchDarklyFlagUsedHandler()]});\n * ```\n */\nexport const launchDarklyIntegration = defineIntegration(() => {\n return {\n name: 'LaunchDarkly',\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return copyFlagsFromScopeToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * LaunchDarkly hook that listens for flag evaluations and updates the `flags`\n * context in our Sentry scope. This needs to be registered as an\n * 'inspector' in LaunchDarkly initialize() options, separately from\n * `launchDarklyIntegration`. Both are needed to collect feature flags on error.\n */\nexport function buildLaunchDarklyFlagUsedHandler(): LDInspectionFlagUsedHandler {\n return {\n name: 'sentry-flag-auditor',\n type: 'flag-used',\n\n synchronous: true,\n\n /**\n * Handle a flag evaluation by storing its name and value on the current scope.\n */\n method: (flagKey: string, flagDetail: LDEvaluationDetail, _context: LDContext) => {\n insertFlagToScope(flagKey, flagDetail.value);\n },\n };\n}\n"],"names":["defineIntegration","copyFlagsFromScopeToEvent","insertFlagToScope"],"mappings":";;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,uBAAwB,GAAEA,sBAAiB,CAAC,MAAM;AAC/D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,cAAc;;AAExB,IAAI,YAAY,CAAC,KAAK,EAAS,KAAK,EAAa,OAAO,EAAiB;AACzE,MAAM,OAAOC,sCAAyB,CAAC,KAAK,CAAC;AAC7C,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,GAAgC;AAChF,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,qBAAqB;AAC/B,IAAI,IAAI,EAAE,WAAW;;AAErB,IAAI,WAAW,EAAE,IAAI;;AAErB;AACA;AACA;AACA,IAAI,MAAM,EAAE,CAAC,OAAO,EAAU,UAAU,EAAsB,QAAQ,KAAgB;AACtF,MAAMC,8BAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC;AAClD,KAAK;AACL,GAAG;AACH;;;;;"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
const core = require('@sentry/core');
|
|
4
|
-
const featureFlags = require('../../../utils/featureFlags.js');
|
|
5
|
-
|
|
6
|
-
const openFeatureIntegration = core.defineIntegration(() => {
|
|
7
|
-
return {
|
|
8
|
-
name: 'OpenFeature',
|
|
9
|
-
|
|
10
|
-
processEvent(event, _hint, _client) {
|
|
11
|
-
return featureFlags.copyFlagsFromScopeToEvent(event);
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}) ;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* OpenFeature Hook class implementation.
|
|
18
|
-
*/
|
|
19
|
-
class OpenFeatureIntegrationHook {
|
|
20
|
-
/**
|
|
21
|
-
* Successful evaluation result.
|
|
22
|
-
*/
|
|
23
|
-
after(_hookContext, evaluationDetails) {
|
|
24
|
-
featureFlags.insertFlagToScope(evaluationDetails.flagKey, evaluationDetails.value);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* On error evaluation result.
|
|
29
|
-
*/
|
|
30
|
-
error(hookContext, _error, _hookHints) {
|
|
31
|
-
featureFlags.insertFlagToScope(hookContext.flagKey, hookContext.defaultValue);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.OpenFeatureIntegrationHook = OpenFeatureIntegrationHook;
|
|
36
|
-
exports.openFeatureIntegration = openFeatureIntegration;
|
|
37
|
-
//# sourceMappingURL=integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../../../src/integrations/featureFlags/openfeature/integration.ts"],"sourcesContent":["/**\n * OpenFeature integration.\n *\n * Add the openFeatureIntegration() function call to your integration lists.\n * Add the integration hook to your OpenFeature object.\n * - OpenFeature.getClient().addHooks(new OpenFeatureIntegrationHook());\n */\nimport type { Client, Event, EventHint, IntegrationFn } from '@sentry/types';\nimport type { EvaluationDetails, HookContext, HookHints, JsonValue, OpenFeatureHook } from './types';\n\nimport { defineIntegration } from '@sentry/core';\nimport { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';\n\nexport const openFeatureIntegration = defineIntegration(() => {\n return {\n name: 'OpenFeature',\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return copyFlagsFromScopeToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * OpenFeature Hook class implementation.\n */\nexport class OpenFeatureIntegrationHook implements OpenFeatureHook {\n /**\n * Successful evaluation result.\n */\n public after(_hookContext: Readonly<HookContext<JsonValue>>, evaluationDetails: EvaluationDetails<JsonValue>): void {\n insertFlagToScope(evaluationDetails.flagKey, evaluationDetails.value);\n }\n\n /**\n * On error evaluation result.\n */\n public error(hookContext: Readonly<HookContext<JsonValue>>, _error: unknown, _hookHints?: HookHints): void {\n insertFlagToScope(hookContext.flagKey, hookContext.defaultValue);\n }\n}\n"],"names":["defineIntegration","copyFlagsFromScopeToEvent","insertFlagToScope"],"mappings":";;;;;MAaa,sBAAuB,GAAEA,sBAAiB,CAAC,MAAM;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;;AAEvB,IAAI,YAAY,CAAC,KAAK,EAAS,KAAK,EAAa,OAAO,EAAiB;AACzE,MAAM,OAAOC,sCAAyB,CAAC,KAAK,CAAC;AAC7C,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACO,MAAM,4BAAsD;AACnE;AACA;AACA;AACA,GAAS,KAAK,CAAC,YAAY,EAAoC,iBAAiB,EAAsC;AACtH,IAAIC,8BAAiB,CAAC,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC;AACzE;;AAEA;AACA;AACA;AACA,GAAS,KAAK,CAAC,WAAW,EAAoC,MAAM,EAAW,UAAU,EAAoB;AAC7G,IAAIA,8BAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC;AACpE;AACA;;;;;"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
const core = require('@sentry/core');
|
|
4
|
-
const debugBuild = require('../debug-build.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Ordered LRU cache for storing feature flags in the scope context. The name
|
|
8
|
-
* of each flag in the buffer is unique, and the output of getAll() is ordered
|
|
9
|
-
* from oldest to newest.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Max size of the LRU flag buffer stored in Sentry scope and event contexts.
|
|
14
|
-
*/
|
|
15
|
-
const FLAG_BUFFER_SIZE = 100;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Copies feature flags that are in current scope context to the event context
|
|
19
|
-
*/
|
|
20
|
-
function copyFlagsFromScopeToEvent(event) {
|
|
21
|
-
const scope = core.getCurrentScope();
|
|
22
|
-
const flagContext = scope.getScopeData().contexts.flags;
|
|
23
|
-
const flagBuffer = flagContext ? flagContext.values : [];
|
|
24
|
-
|
|
25
|
-
if (!flagBuffer.length) {
|
|
26
|
-
return event;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (event.contexts === undefined) {
|
|
30
|
-
event.contexts = {};
|
|
31
|
-
}
|
|
32
|
-
event.contexts.flags = { values: [...flagBuffer] };
|
|
33
|
-
return event;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Creates a feature flags values array in current context if it does not exist
|
|
38
|
-
* and inserts the flag into a FeatureFlag array while maintaining ordered LRU
|
|
39
|
-
* properties. Not thread-safe. After inserting:
|
|
40
|
-
* - `flags` is sorted in order of recency, with the newest flag at the end.
|
|
41
|
-
* - No other flags with the same name exist in `flags`.
|
|
42
|
-
* - The length of `flags` does not exceed `maxSize`. The oldest flag is evicted
|
|
43
|
-
* as needed.
|
|
44
|
-
*
|
|
45
|
-
* @param name Name of the feature flag to insert.
|
|
46
|
-
* @param value Value of the feature flag.
|
|
47
|
-
* @param maxSize Max number of flags the buffer should store. It's recommended
|
|
48
|
-
* to keep this consistent across insertions. Default is FLAG_BUFFER_SIZE
|
|
49
|
-
*/
|
|
50
|
-
function insertFlagToScope(name, value, maxSize = FLAG_BUFFER_SIZE) {
|
|
51
|
-
const scopeContexts = core.getCurrentScope().getScopeData().contexts;
|
|
52
|
-
if (!scopeContexts.flags) {
|
|
53
|
-
scopeContexts.flags = { values: [] };
|
|
54
|
-
}
|
|
55
|
-
const flags = scopeContexts.flags.values ;
|
|
56
|
-
insertToFlagBuffer(flags, name, value, maxSize);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Exported for tests
|
|
61
|
-
*/
|
|
62
|
-
function insertToFlagBuffer(flags, name, value, maxSize) {
|
|
63
|
-
// Currently only accepts boolean values
|
|
64
|
-
if (typeof value !== 'boolean') {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (flags.length > maxSize) {
|
|
69
|
-
debugBuild.DEBUG_BUILD && core.logger.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Check if the flag is already in the buffer - O(n)
|
|
74
|
-
const index = flags.findIndex(f => f.flag === name);
|
|
75
|
-
|
|
76
|
-
if (index !== -1) {
|
|
77
|
-
// The flag was found, remove it from its current position - O(n)
|
|
78
|
-
flags.splice(index, 1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (flags.length === maxSize) {
|
|
82
|
-
// If at capacity, pop the earliest flag - O(n)
|
|
83
|
-
flags.shift();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Push the flag to the end - O(1)
|
|
87
|
-
flags.push({
|
|
88
|
-
flag: name,
|
|
89
|
-
result: value,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
exports.FLAG_BUFFER_SIZE = FLAG_BUFFER_SIZE;
|
|
94
|
-
exports.copyFlagsFromScopeToEvent = copyFlagsFromScopeToEvent;
|
|
95
|
-
exports.insertFlagToScope = insertFlagToScope;
|
|
96
|
-
exports.insertToFlagBuffer = insertToFlagBuffer;
|
|
97
|
-
//# sourceMappingURL=featureFlags.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"featureFlags.js","sources":["../../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope, logger } from '@sentry/core';\nimport type { Event, FeatureFlag } from '@sentry/types';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const FLAG_BUFFER_SIZE = 100;\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\nexport function copyFlagsFromScopeToEvent(event: Event): Event {\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Creates a feature flags values array in current context if it does not exist\n * and inserts the flag into a FeatureFlag array while maintaining ordered LRU\n * properties. Not thread-safe. After inserting:\n * - `flags` is sorted in order of recency, with the newest flag at the end.\n * - No other flags with the same name exist in `flags`.\n * - The length of `flags` does not exceed `maxSize`. The oldest flag is evicted\n * as needed.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. It's recommended\n * to keep this consistent across insertions. Default is FLAG_BUFFER_SIZE\n */\nexport function insertFlagToScope(name: string, value: unknown, maxSize: number = FLAG_BUFFER_SIZE): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values as FeatureFlag[];\n insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests\n */\nexport function insertToFlagBuffer(flags: FeatureFlag[], name: string, value: unknown, maxSize: number): void {\n // Currently only accepts boolean values\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && logger.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n"],"names":["getCurrentScope","DEBUG_BUILD","logger"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAM,gBAAiB,GAAE;;AAEhC;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,KAAK,EAAgB;AAC/D,EAAE,MAAM,KAAA,GAAQA,oBAAe,EAAE;AACjC,EAAE,MAAM,WAAY,GAAE,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,KAAK;AACzD,EAAE,MAAM,UAAW,GAAE,WAAY,GAAE,WAAW,CAAC,MAAA,GAAS,EAAE;;AAE1D,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;AAC1B,IAAI,OAAO,KAAK;AAChB;;AAEA,EAAE,IAAI,KAAK,CAAC,QAAS,KAAI,SAAS,EAAE;AACpC,IAAI,KAAK,CAAC,QAAS,GAAE,EAAE;AACvB;AACA,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAM,GAAE,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,GAAG;AACpD,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAAU,KAAK,EAAW,OAAO,GAAW,gBAAgB,EAAQ;AAC1G,EAAE,MAAM,aAAc,GAAEA,oBAAe,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ;AACjE,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;AAC5B,IAAI,aAAa,CAAC,KAAM,GAAE,EAAE,MAAM,EAAE,EAAC,EAAG;AACxC;AACA,EAAE,MAAM,KAAM,GAAE,aAAa,CAAC,KAAK,CAAC,MAAO;AAC3C,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AACjD;;AAEA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAiB,IAAI,EAAU,KAAK,EAAW,OAAO,EAAgB;AAC9G;AACA,EAAE,IAAI,OAAO,KAAM,KAAI,SAAS,EAAE;AAClC,IAAI;AACJ;;AAEA,EAAE,IAAI,KAAK,CAAC,MAAO,GAAE,OAAO,EAAE;AAC9B,IAAIC,sBAAA,IAAeC,WAAM,CAAC,KAAK,CAAC,CAAC,0EAA0E,EAAE,OAAO,CAAC,CAAA,CAAA;AACA,IAAA;AACA;;AAEA;AACA,EAAA,MAAA,KAAA,GAAA,KAAA,CAAA,SAAA,CAAA,CAAA,IAAA,CAAA,CAAA,IAAA,KAAA,IAAA,CAAA;;AAEA,EAAA,IAAA,KAAA,KAAA,CAAA,CAAA,EAAA;AACA;AACA,IAAA,KAAA,CAAA,MAAA,CAAA,KAAA,EAAA,CAAA,CAAA;AACA;;AAEA,EAAA,IAAA,KAAA,CAAA,MAAA,KAAA,OAAA,EAAA;AACA;AACA,IAAA,KAAA,CAAA,KAAA,EAAA;AACA;;AAEA;AACA,EAAA,KAAA,CAAA,IAAA,CAAA;AACA,IAAA,IAAA,EAAA,IAAA;AACA,IAAA,MAAA,EAAA,KAAA;AACA,GAAA,CAAA;AACA;;;;;;;"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { defineIntegration } from '@sentry/core';
|
|
2
|
-
import { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Sentry integration for capturing feature flags from LaunchDarkly.
|
|
6
|
-
*
|
|
7
|
-
* See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```
|
|
11
|
-
* import * as Sentry from '@sentry/browser';
|
|
12
|
-
* import {launchDarklyIntegration, buildLaunchDarklyFlagUsedInspector} from '@sentry/browser';
|
|
13
|
-
* import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
|
|
14
|
-
*
|
|
15
|
-
* Sentry.init(..., integrations: [launchDarklyIntegration()])
|
|
16
|
-
* const ldClient = LaunchDarkly.initialize(..., {inspectors: [buildLaunchDarklyFlagUsedHandler()]});
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
const launchDarklyIntegration = defineIntegration(() => {
|
|
20
|
-
return {
|
|
21
|
-
name: 'LaunchDarkly',
|
|
22
|
-
|
|
23
|
-
processEvent(event, _hint, _client) {
|
|
24
|
-
return copyFlagsFromScopeToEvent(event);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}) ;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* LaunchDarkly hook that listens for flag evaluations and updates the `flags`
|
|
31
|
-
* context in our Sentry scope. This needs to be registered as an
|
|
32
|
-
* 'inspector' in LaunchDarkly initialize() options, separately from
|
|
33
|
-
* `launchDarklyIntegration`. Both are needed to collect feature flags on error.
|
|
34
|
-
*/
|
|
35
|
-
function buildLaunchDarklyFlagUsedHandler() {
|
|
36
|
-
return {
|
|
37
|
-
name: 'sentry-flag-auditor',
|
|
38
|
-
type: 'flag-used',
|
|
39
|
-
|
|
40
|
-
synchronous: true,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Handle a flag evaluation by storing its name and value on the current scope.
|
|
44
|
-
*/
|
|
45
|
-
method: (flagKey, flagDetail, _context) => {
|
|
46
|
-
insertFlagToScope(flagKey, flagDetail.value);
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { buildLaunchDarklyFlagUsedHandler, launchDarklyIntegration };
|
|
52
|
-
//# sourceMappingURL=integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../../../src/integrations/featureFlags/launchdarkly/integration.ts"],"sourcesContent":["import type { Client, Event, EventHint, IntegrationFn } from '@sentry/types';\nimport type { LDContext, LDEvaluationDetail, LDInspectionFlagUsedHandler } from './types';\n\nimport { defineIntegration } from '@sentry/core';\nimport { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';\n\n/**\n * Sentry integration for capturing feature flags from LaunchDarkly.\n *\n * See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.\n *\n * @example\n * ```\n * import * as Sentry from '@sentry/browser';\n * import {launchDarklyIntegration, buildLaunchDarklyFlagUsedInspector} from '@sentry/browser';\n * import * as LaunchDarkly from 'launchdarkly-js-client-sdk';\n *\n * Sentry.init(..., integrations: [launchDarklyIntegration()])\n * const ldClient = LaunchDarkly.initialize(..., {inspectors: [buildLaunchDarklyFlagUsedHandler()]});\n * ```\n */\nexport const launchDarklyIntegration = defineIntegration(() => {\n return {\n name: 'LaunchDarkly',\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return copyFlagsFromScopeToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * LaunchDarkly hook that listens for flag evaluations and updates the `flags`\n * context in our Sentry scope. This needs to be registered as an\n * 'inspector' in LaunchDarkly initialize() options, separately from\n * `launchDarklyIntegration`. Both are needed to collect feature flags on error.\n */\nexport function buildLaunchDarklyFlagUsedHandler(): LDInspectionFlagUsedHandler {\n return {\n name: 'sentry-flag-auditor',\n type: 'flag-used',\n\n synchronous: true,\n\n /**\n * Handle a flag evaluation by storing its name and value on the current scope.\n */\n method: (flagKey: string, flagDetail: LDEvaluationDetail, _context: LDContext) => {\n insertFlagToScope(flagKey, flagDetail.value);\n },\n };\n}\n"],"names":[],"mappings":";;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,uBAAwB,GAAE,iBAAiB,CAAC,MAAM;AAC/D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,cAAc;;AAExB,IAAI,YAAY,CAAC,KAAK,EAAS,KAAK,EAAa,OAAO,EAAiB;AACzE,MAAM,OAAO,yBAAyB,CAAC,KAAK,CAAC;AAC7C,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,GAAgC;AAChF,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,qBAAqB;AAC/B,IAAI,IAAI,EAAE,WAAW;;AAErB,IAAI,WAAW,EAAE,IAAI;;AAErB;AACA;AACA;AACA,IAAI,MAAM,EAAE,CAAC,OAAO,EAAU,UAAU,EAAsB,QAAQ,KAAgB;AACtF,MAAM,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC;AAClD,KAAK;AACL,GAAG;AACH;;;;"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { defineIntegration } from '@sentry/core';
|
|
2
|
-
import { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags.js';
|
|
3
|
-
|
|
4
|
-
const openFeatureIntegration = defineIntegration(() => {
|
|
5
|
-
return {
|
|
6
|
-
name: 'OpenFeature',
|
|
7
|
-
|
|
8
|
-
processEvent(event, _hint, _client) {
|
|
9
|
-
return copyFlagsFromScopeToEvent(event);
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
}) ;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* OpenFeature Hook class implementation.
|
|
16
|
-
*/
|
|
17
|
-
class OpenFeatureIntegrationHook {
|
|
18
|
-
/**
|
|
19
|
-
* Successful evaluation result.
|
|
20
|
-
*/
|
|
21
|
-
after(_hookContext, evaluationDetails) {
|
|
22
|
-
insertFlagToScope(evaluationDetails.flagKey, evaluationDetails.value);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* On error evaluation result.
|
|
27
|
-
*/
|
|
28
|
-
error(hookContext, _error, _hookHints) {
|
|
29
|
-
insertFlagToScope(hookContext.flagKey, hookContext.defaultValue);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { OpenFeatureIntegrationHook, openFeatureIntegration };
|
|
34
|
-
//# sourceMappingURL=integration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../../../src/integrations/featureFlags/openfeature/integration.ts"],"sourcesContent":["/**\n * OpenFeature integration.\n *\n * Add the openFeatureIntegration() function call to your integration lists.\n * Add the integration hook to your OpenFeature object.\n * - OpenFeature.getClient().addHooks(new OpenFeatureIntegrationHook());\n */\nimport type { Client, Event, EventHint, IntegrationFn } from '@sentry/types';\nimport type { EvaluationDetails, HookContext, HookHints, JsonValue, OpenFeatureHook } from './types';\n\nimport { defineIntegration } from '@sentry/core';\nimport { copyFlagsFromScopeToEvent, insertFlagToScope } from '../../../utils/featureFlags';\n\nexport const openFeatureIntegration = defineIntegration(() => {\n return {\n name: 'OpenFeature',\n\n processEvent(event: Event, _hint: EventHint, _client: Client): Event {\n return copyFlagsFromScopeToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * OpenFeature Hook class implementation.\n */\nexport class OpenFeatureIntegrationHook implements OpenFeatureHook {\n /**\n * Successful evaluation result.\n */\n public after(_hookContext: Readonly<HookContext<JsonValue>>, evaluationDetails: EvaluationDetails<JsonValue>): void {\n insertFlagToScope(evaluationDetails.flagKey, evaluationDetails.value);\n }\n\n /**\n * On error evaluation result.\n */\n public error(hookContext: Readonly<HookContext<JsonValue>>, _error: unknown, _hookHints?: HookHints): void {\n insertFlagToScope(hookContext.flagKey, hookContext.defaultValue);\n }\n}\n"],"names":[],"mappings":";;;MAaa,sBAAuB,GAAE,iBAAiB,CAAC,MAAM;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;;AAEvB,IAAI,YAAY,CAAC,KAAK,EAAS,KAAK,EAAa,OAAO,EAAiB;AACzE,MAAM,OAAO,yBAAyB,CAAC,KAAK,CAAC;AAC7C,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACO,MAAM,4BAAsD;AACnE;AACA;AACA;AACA,GAAS,KAAK,CAAC,YAAY,EAAoC,iBAAiB,EAAsC;AACtH,IAAI,iBAAiB,CAAC,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC;AACzE;;AAEA;AACA;AACA;AACA,GAAS,KAAK,CAAC,WAAW,EAAoC,MAAM,EAAW,UAAU,EAAoB;AAC7G,IAAI,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,YAAY,CAAC;AACpE;AACA;;;;"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { getCurrentScope, logger } from '@sentry/core';
|
|
2
|
-
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Ordered LRU cache for storing feature flags in the scope context. The name
|
|
6
|
-
* of each flag in the buffer is unique, and the output of getAll() is ordered
|
|
7
|
-
* from oldest to newest.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Max size of the LRU flag buffer stored in Sentry scope and event contexts.
|
|
12
|
-
*/
|
|
13
|
-
const FLAG_BUFFER_SIZE = 100;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Copies feature flags that are in current scope context to the event context
|
|
17
|
-
*/
|
|
18
|
-
function copyFlagsFromScopeToEvent(event) {
|
|
19
|
-
const scope = getCurrentScope();
|
|
20
|
-
const flagContext = scope.getScopeData().contexts.flags;
|
|
21
|
-
const flagBuffer = flagContext ? flagContext.values : [];
|
|
22
|
-
|
|
23
|
-
if (!flagBuffer.length) {
|
|
24
|
-
return event;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (event.contexts === undefined) {
|
|
28
|
-
event.contexts = {};
|
|
29
|
-
}
|
|
30
|
-
event.contexts.flags = { values: [...flagBuffer] };
|
|
31
|
-
return event;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Creates a feature flags values array in current context if it does not exist
|
|
36
|
-
* and inserts the flag into a FeatureFlag array while maintaining ordered LRU
|
|
37
|
-
* properties. Not thread-safe. After inserting:
|
|
38
|
-
* - `flags` is sorted in order of recency, with the newest flag at the end.
|
|
39
|
-
* - No other flags with the same name exist in `flags`.
|
|
40
|
-
* - The length of `flags` does not exceed `maxSize`. The oldest flag is evicted
|
|
41
|
-
* as needed.
|
|
42
|
-
*
|
|
43
|
-
* @param name Name of the feature flag to insert.
|
|
44
|
-
* @param value Value of the feature flag.
|
|
45
|
-
* @param maxSize Max number of flags the buffer should store. It's recommended
|
|
46
|
-
* to keep this consistent across insertions. Default is FLAG_BUFFER_SIZE
|
|
47
|
-
*/
|
|
48
|
-
function insertFlagToScope(name, value, maxSize = FLAG_BUFFER_SIZE) {
|
|
49
|
-
const scopeContexts = getCurrentScope().getScopeData().contexts;
|
|
50
|
-
if (!scopeContexts.flags) {
|
|
51
|
-
scopeContexts.flags = { values: [] };
|
|
52
|
-
}
|
|
53
|
-
const flags = scopeContexts.flags.values ;
|
|
54
|
-
insertToFlagBuffer(flags, name, value, maxSize);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Exported for tests
|
|
59
|
-
*/
|
|
60
|
-
function insertToFlagBuffer(flags, name, value, maxSize) {
|
|
61
|
-
// Currently only accepts boolean values
|
|
62
|
-
if (typeof value !== 'boolean') {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (flags.length > maxSize) {
|
|
67
|
-
DEBUG_BUILD && logger.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Check if the flag is already in the buffer - O(n)
|
|
72
|
-
const index = flags.findIndex(f => f.flag === name);
|
|
73
|
-
|
|
74
|
-
if (index !== -1) {
|
|
75
|
-
// The flag was found, remove it from its current position - O(n)
|
|
76
|
-
flags.splice(index, 1);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (flags.length === maxSize) {
|
|
80
|
-
// If at capacity, pop the earliest flag - O(n)
|
|
81
|
-
flags.shift();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Push the flag to the end - O(1)
|
|
85
|
-
flags.push({
|
|
86
|
-
flag: name,
|
|
87
|
-
result: value,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export { FLAG_BUFFER_SIZE, copyFlagsFromScopeToEvent, insertFlagToScope, insertToFlagBuffer };
|
|
92
|
-
//# sourceMappingURL=featureFlags.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"featureFlags.js","sources":["../../../../src/utils/featureFlags.ts"],"sourcesContent":["import { getCurrentScope, logger } from '@sentry/core';\nimport type { Event, FeatureFlag } from '@sentry/types';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/**\n * Ordered LRU cache for storing feature flags in the scope context. The name\n * of each flag in the buffer is unique, and the output of getAll() is ordered\n * from oldest to newest.\n */\n\n/**\n * Max size of the LRU flag buffer stored in Sentry scope and event contexts.\n */\nexport const FLAG_BUFFER_SIZE = 100;\n\n/**\n * Copies feature flags that are in current scope context to the event context\n */\nexport function copyFlagsFromScopeToEvent(event: Event): Event {\n const scope = getCurrentScope();\n const flagContext = scope.getScopeData().contexts.flags;\n const flagBuffer = flagContext ? flagContext.values : [];\n\n if (!flagBuffer.length) {\n return event;\n }\n\n if (event.contexts === undefined) {\n event.contexts = {};\n }\n event.contexts.flags = { values: [...flagBuffer] };\n return event;\n}\n\n/**\n * Creates a feature flags values array in current context if it does not exist\n * and inserts the flag into a FeatureFlag array while maintaining ordered LRU\n * properties. Not thread-safe. After inserting:\n * - `flags` is sorted in order of recency, with the newest flag at the end.\n * - No other flags with the same name exist in `flags`.\n * - The length of `flags` does not exceed `maxSize`. The oldest flag is evicted\n * as needed.\n *\n * @param name Name of the feature flag to insert.\n * @param value Value of the feature flag.\n * @param maxSize Max number of flags the buffer should store. It's recommended\n * to keep this consistent across insertions. Default is FLAG_BUFFER_SIZE\n */\nexport function insertFlagToScope(name: string, value: unknown, maxSize: number = FLAG_BUFFER_SIZE): void {\n const scopeContexts = getCurrentScope().getScopeData().contexts;\n if (!scopeContexts.flags) {\n scopeContexts.flags = { values: [] };\n }\n const flags = scopeContexts.flags.values as FeatureFlag[];\n insertToFlagBuffer(flags, name, value, maxSize);\n}\n\n/**\n * Exported for tests\n */\nexport function insertToFlagBuffer(flags: FeatureFlag[], name: string, value: unknown, maxSize: number): void {\n // Currently only accepts boolean values\n if (typeof value !== 'boolean') {\n return;\n }\n\n if (flags.length > maxSize) {\n DEBUG_BUILD && logger.error(`[Feature Flags] insertToFlagBuffer called on a buffer larger than maxSize=${maxSize}`);\n return;\n }\n\n // Check if the flag is already in the buffer - O(n)\n const index = flags.findIndex(f => f.flag === name);\n\n if (index !== -1) {\n // The flag was found, remove it from its current position - O(n)\n flags.splice(index, 1);\n }\n\n if (flags.length === maxSize) {\n // If at capacity, pop the earliest flag - O(n)\n flags.shift();\n }\n\n // Push the flag to the end - O(1)\n flags.push({\n flag: name,\n result: value,\n });\n}\n"],"names":[],"mappings":";;;AAIA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAM,gBAAiB,GAAE;;AAEhC;AACA;AACA;AACO,SAAS,yBAAyB,CAAC,KAAK,EAAgB;AAC/D,EAAE,MAAM,KAAA,GAAQ,eAAe,EAAE;AACjC,EAAE,MAAM,WAAY,GAAE,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,KAAK;AACzD,EAAE,MAAM,UAAW,GAAE,WAAY,GAAE,WAAW,CAAC,MAAA,GAAS,EAAE;;AAE1D,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;AAC1B,IAAI,OAAO,KAAK;AAChB;;AAEA,EAAE,IAAI,KAAK,CAAC,QAAS,KAAI,SAAS,EAAE;AACpC,IAAI,KAAK,CAAC,QAAS,GAAE,EAAE;AACvB;AACA,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAM,GAAE,EAAE,MAAM,EAAE,CAAC,GAAG,UAAU,GAAG;AACpD,EAAE,OAAO,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,IAAI,EAAU,KAAK,EAAW,OAAO,GAAW,gBAAgB,EAAQ;AAC1G,EAAE,MAAM,aAAc,GAAE,eAAe,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ;AACjE,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;AAC5B,IAAI,aAAa,CAAC,KAAM,GAAE,EAAE,MAAM,EAAE,EAAC,EAAG;AACxC;AACA,EAAE,MAAM,KAAM,GAAE,aAAa,CAAC,KAAK,CAAC,MAAO;AAC3C,EAAE,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;AACjD;;AAEA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,KAAK,EAAiB,IAAI,EAAU,KAAK,EAAW,OAAO,EAAgB;AAC9G;AACA,EAAE,IAAI,OAAO,KAAM,KAAI,SAAS,EAAE;AAClC,IAAI;AACJ;;AAEA,EAAE,IAAI,KAAK,CAAC,MAAO,GAAE,OAAO,EAAE;AAC9B,IAAI,WAAA,IAAe,MAAM,CAAC,KAAK,CAAC,CAAC,0EAA0E,EAAE,OAAO,CAAC,CAAA,CAAA;AACA,IAAA;AACA;;AAEA;AACA,EAAA,MAAA,KAAA,GAAA,KAAA,CAAA,SAAA,CAAA,CAAA,IAAA,CAAA,CAAA,IAAA,KAAA,IAAA,CAAA;;AAEA,EAAA,IAAA,KAAA,KAAA,CAAA,CAAA,EAAA;AACA;AACA,IAAA,KAAA,CAAA,MAAA,CAAA,KAAA,EAAA,CAAA,CAAA;AACA;;AAEA,EAAA,IAAA,KAAA,CAAA,MAAA,KAAA,OAAA,EAAA;AACA;AACA,IAAA,KAAA,CAAA,KAAA,EAAA;AACA;;AAEA;AACA,EAAA,KAAA,CAAA,IAAA,CAAA;AACA,IAAA,IAAA,EAAA,IAAA;AACA,IAAA,MAAA,EAAA,KAAA;AACA,GAAA,CAAA;AACA;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/featureFlags/launchdarkly/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { LDInspectionFlagUsedHandler } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Sentry integration for capturing feature flags from LaunchDarkly.
|
|
4
|
-
*
|
|
5
|
-
* See the [feature flag documentation](https://develop.sentry.dev/sdk/expected-features/#feature-flags) for more information.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```
|
|
9
|
-
* import * as Sentry from '@sentry/browser';
|
|
10
|
-
* import {launchDarklyIntegration, buildLaunchDarklyFlagUsedInspector} from '@sentry/browser';
|
|
11
|
-
* import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
|
|
12
|
-
*
|
|
13
|
-
* Sentry.init(..., integrations: [launchDarklyIntegration()])
|
|
14
|
-
* const ldClient = LaunchDarkly.initialize(..., {inspectors: [buildLaunchDarklyFlagUsedHandler()]});
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const launchDarklyIntegration: () => import("@sentry/types").Integration;
|
|
18
|
-
/**
|
|
19
|
-
* LaunchDarkly hook that listens for flag evaluations and updates the `flags`
|
|
20
|
-
* context in our Sentry scope. This needs to be registered as an
|
|
21
|
-
* 'inspector' in LaunchDarkly initialize() options, separately from
|
|
22
|
-
* `launchDarklyIntegration`. Both are needed to collect feature flags on error.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildLaunchDarklyFlagUsedHandler(): LDInspectionFlagUsedHandler;
|
|
25
|
-
//# sourceMappingURL=integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/featureFlags/launchdarkly/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiC,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAK1F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,2CAQV,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,gCAAgC,IAAI,2BAA2B,CAc9E"}
|