@launchdarkly/o11y 0.0.0-stage → 1.2.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.
@@ -0,0 +1,149 @@
1
+ import { EvaluationSeriesContext } from '@launchdarkly/js-client-sdk';
2
+ import { EvaluationSeriesData } from '@launchdarkly/js-client-sdk';
3
+ import { Hook as Hook_2 } from '@launchdarkly/js-client-sdk';
4
+ import { LDEvaluationReason } from '@launchdarkly/js-client-sdk';
5
+ import { LDFlagValue } from '@launchdarkly/js-client-sdk';
6
+ import { LDPluginEnvironmentMetadata } from '@launchdarkly/js-client-sdk';
7
+
8
+ declare class BufferedClass<T extends object> {
9
+ protected _sdk: T;
10
+ protected _isLoaded: boolean;
11
+ protected _callBuffer: Array<Event_2>;
12
+ protected _capacity: number;
13
+ protected _droppedEvents: number;
14
+ protected _exceededCapacity: boolean;
15
+ protected _logger: Logger;
16
+ protected _bufferCall(method: string, args: any[]): any;
17
+ protected _enqueue(event: Event_2): void;
18
+ load(sdk: T): void;
19
+ }
20
+
21
+ declare type Event_2 = {
22
+ method: string;
23
+ args: any[];
24
+ };
25
+
26
+ /**
27
+ * Interface for extending SDK functionality via hooks.
28
+ */
29
+ declare type Hook = Omit<Hook_2, 'afterEvaluation'> & {
30
+ /**
31
+ * This method is called during the execution of the variation method
32
+ * after the flag value has been determined. The method is executed synchronously.
33
+ *
34
+ * @param hookContext Contains read-only information about the evaluation
35
+ * being performed.
36
+ * @param data A record associated with each stage of hook invocations. Each
37
+ * stage is called with the data of the previous stage for a series.
38
+ * @param detail The result of the evaluation. This value should not be
39
+ * modified.
40
+ * @returns Data to use when executing the next state of the hook in the evaluation series. It is
41
+ * recommended to expand the previous input into the return. This helps ensure your stage remains
42
+ * compatible moving forward as more stages are added.
43
+ * ```js
44
+ * return {...data, "my-new-field": /*my data/*}
45
+ * ```
46
+ */
47
+ afterEvaluation?(hookContext: EvaluationSeriesContext, data: EvaluationSeriesData, detail: {
48
+ /**
49
+ * The result of the flag evaluation. This will be either one of the flag's variations or
50
+ * the default value that was passed to `LDClient.variationDetail`.
51
+ */
52
+ value: LDFlagValue;
53
+ /**
54
+ * The index of the returned value within the flag's list of variations, e.g. 0 for the
55
+ * first variation-- or `null` if the default value was returned.
56
+ */
57
+ variationIndex?: number | null;
58
+ /**
59
+ * An object describing the main factor that influenced the flag evaluation value.
60
+ */
61
+ reason?: LDEvaluationReason | null;
62
+ }): EvaluationSeriesData;
63
+ };
64
+
65
+ declare interface LDClientMin {
66
+ track(key: string, data?: any, metricValue?: number): void;
67
+ identify(ctx: any): void;
68
+ addHook(hook: Hook): void;
69
+ }
70
+
71
+ export declare let LDRecord: _LDRecord;
72
+
73
+ declare class _LDRecord extends BufferedClass<Record_2> implements Record_2 {
74
+ getSession(): SessionDetails | null;
75
+ start(options?: StartOptions): Promise<void>;
76
+ stop(): void;
77
+ addSessionProperties(properties: {
78
+ [key: string]: any;
79
+ }): any;
80
+ getRecordingState(): any;
81
+ snapshot(element: HTMLCanvasElement): any;
82
+ register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): any;
83
+ }
84
+
85
+ declare class Logger {
86
+ debug: boolean | undefined;
87
+ name: string | undefined;
88
+ constructor(debug?: boolean, name?: string);
89
+ log(...data: any[]): void;
90
+ warn(...data: any[]): void;
91
+ }
92
+
93
+ declare interface Record_2 {
94
+ /**
95
+ * Start the session when running in `manualStart` mode.
96
+ * Can be used to force start a new session.
97
+ * @param options the session start options.
98
+ */
99
+ start: (options?: StartOptions) => Promise<void>;
100
+ /**
101
+ * Stop the session recording.
102
+ */
103
+ stop: () => void;
104
+ /**
105
+ * Add custom session-level properties. These are attached to the current session
106
+ * and are searchable, but do not create timeline Track events.
107
+ */
108
+ addSessionProperties: (properties: {
109
+ [key: string]: any;
110
+ }) => void;
111
+ /**
112
+ * Snapshot an HTML <canvas> element in WebGL manual snapshotting mode.
113
+ * See {@link https://www.highlight.io/docs/getting-started/browser/replay-configuration/canvas#manual-snapshotting}
114
+ * for more information.
115
+ */
116
+ snapshot: (element: HTMLCanvasElement) => Promise<void>;
117
+ getSession: () => SessionDetails | null;
118
+ getRecordingState: () => 'NotRecording' | 'Recording';
119
+ register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): void;
120
+ getHooks?(metadata: LDPluginEnvironmentMetadata): Hook[];
121
+ }
122
+
123
+ declare interface SessionDetails {
124
+ /** The URL to view the session. */
125
+ url: string;
126
+ /** The URL to view the session at the time getSessionDetails was called during the session recording. */
127
+ urlWithTimestamp: string;
128
+ /** The secure ID of the session. */
129
+ sessionSecureID: string;
130
+ }
131
+
132
+ declare interface StartOptions {
133
+ /**
134
+ * Specifies whether console warn messages should not be created.
135
+ */
136
+ silent?: boolean;
137
+ /**
138
+ * Starts a new recording session even if one was stopped recently.
139
+ */
140
+ forceNew?: boolean;
141
+ /**
142
+ * Key to use to determine the sessionSecureID in order to override session generation logic.
143
+ * If a sessionKey is provided, the session will be combined with the previous session with the same key.
144
+ * Otherwise, the current session logic will be used to generate a sessionSecureID.
145
+ */
146
+ sessionKey?: string;
147
+ }
148
+
149
+ export { }
@@ -0,0 +1,48 @@
1
+ var a = (l, e, r) => new Promise((f, d) => {
2
+ var h = (s) => {
3
+ try {
4
+ i(r.next(s));
5
+ } catch (o) {
6
+ d(o);
7
+ }
8
+ }, u = (s) => {
9
+ try {
10
+ i(r.throw(s));
11
+ } catch (o) {
12
+ d(o);
13
+ }
14
+ }, i = (s) => s.done ? f(s.value) : Promise.resolve(s.value).then(h, u);
15
+ i((r = r.apply(l, e)).next());
16
+ });
17
+ import { B as g } from "./buffer-DIFxvF2Q.js";
18
+ class n extends g {
19
+ getSession() {
20
+ return this._isLoaded ? this._bufferCall("getSession", []) : null;
21
+ }
22
+ start(e) {
23
+ return a(this, null, function* () {
24
+ return this._sdk.start(e);
25
+ });
26
+ }
27
+ stop() {
28
+ return this._sdk.stop();
29
+ }
30
+ addSessionProperties(e) {
31
+ return this._bufferCall("addSessionProperties", [e]);
32
+ }
33
+ getRecordingState() {
34
+ return this._isLoaded ? this._bufferCall("getRecordingState", []) : "NotRecording";
35
+ }
36
+ snapshot(e) {
37
+ return this._isLoaded ? this._bufferCall("snapshot", [e]) : Promise.resolve(void 0);
38
+ }
39
+ register(e, r) {
40
+ return this._bufferCall("register", [e, r]);
41
+ }
42
+ }
43
+ let t;
44
+ typeof globalThis != "undefined" ? globalThis.LDRecord ? t = globalThis.LDRecord : (t = new n(), globalThis.LDRecord = t) : t = new n();
45
+ export {
46
+ t as LDRecord
47
+ };
48
+ //# sourceMappingURL=LDRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LDRecord.js","sources":["../src/sdk/LDRecord.ts"],"sourcesContent":["import type { Record } from '../api/record'\nimport type { SessionDetails } from '../client'\nimport type { LDClient } from '../integrations/launchdarkly'\nimport type { StartOptions } from '../client/types/types'\nimport type { LDPluginEnvironmentMetadata } from '../plugins/plugin'\nimport { BufferedClass } from './buffer'\n\nclass _LDRecord extends BufferedClass<Record> implements Record {\n\tgetSession(): SessionDetails | null {\n\t\treturn this._isLoaded ? this._bufferCall('getSession', []) : null\n\t}\n\n\tasync start(options?: StartOptions) {\n\t\t// avoid buffering the start call\n\t\treturn this._sdk.start(options)\n\t}\n\n\tstop() {\n\t\t// avoid buffering the stop call\n\t\treturn this._sdk.stop()\n\t}\n\n\taddSessionProperties(properties: { [key: string]: any }) {\n\t\treturn this._bufferCall('addSessionProperties', [properties])\n\t}\n\n\tgetRecordingState() {\n\t\treturn this._isLoaded\n\t\t\t? this._bufferCall('getRecordingState', [])\n\t\t\t: ('NotRecording' as const)\n\t}\n\n\tsnapshot(element: HTMLCanvasElement) {\n\t\treturn this._isLoaded\n\t\t\t? this._bufferCall('snapshot', [element])\n\t\t\t: Promise.resolve(undefined)\n\t}\n\n\tregister(\n\t\tclient: LDClient,\n\t\tenvironmentMetadata: LDPluginEnvironmentMetadata,\n\t) {\n\t\treturn this._bufferCall('register', [client, environmentMetadata])\n\t}\n}\n\ninterface GlobalThis {\n\tLDRecord?: _LDRecord\n}\ndeclare var globalThis: GlobalThis\n\nexport let LDRecord!: _LDRecord\nif (typeof globalThis !== 'undefined') {\n\tif (globalThis.LDRecord) {\n\t\tLDRecord = globalThis.LDRecord\n\t} else {\n\t\tLDRecord = new _LDRecord()\n\t\tglobalThis.LDRecord = LDRecord\n\t}\n} else {\n\tLDRecord = new _LDRecord()\n}\n"],"names":["_LDRecord","BufferedClass","options","__async","properties","element","client","environmentMetadata","LDRecord"],"mappings":";;;;;;;;;;;;;;;;;AAOA,MAAMA,UAAkBC,EAAwC;AAAA,EAC/D,aAAoC;AACnC,WAAO,KAAK,YAAY,KAAK,YAAY,cAAc,CAAA,CAAE,IAAI;AAAA,EAC9D;AAAA,EAEM,MAAMC,GAAwB;AAAA,WAAAC,EAAA;AAEnC,aAAO,KAAK,KAAK,MAAMD,CAAO;AAAA,IAC/B;AAAA;AAAA,EAEA,OAAO;AAEN,WAAO,KAAK,KAAK,KAAA;AAAA,EAClB;AAAA,EAEA,qBAAqBE,GAAoC;AACxD,WAAO,KAAK,YAAY,wBAAwB,CAACA,CAAU,CAAC;AAAA,EAC7D;AAAA,EAEA,oBAAoB;AACnB,WAAO,KAAK,YACT,KAAK,YAAY,qBAAqB,CAAA,CAAE,IACvC;AAAA,EACL;AAAA,EAEA,SAASC,GAA4B;AACpC,WAAO,KAAK,YACT,KAAK,YAAY,YAAY,CAACA,CAAO,CAAC,IACtC,QAAQ,QAAQ,MAAS;AAAA,EAC7B;AAAA,EAEA,SACCC,GACAC,GACC;AACD,WAAO,KAAK,YAAY,YAAY,CAACD,GAAQC,CAAmB,CAAC;AAAA,EAClE;AACD;AAOO,IAAIC;AACP,OAAO,cAAe,cACrB,WAAW,WACdA,IAAW,WAAW,YAEtBA,IAAW,IAAIR,EAAA,GACf,WAAW,WAAWQ,KAGvBA,IAAW,IAAIR,EAAA;"}