@launchdarkly/o11y 1.3.0 → 1.4.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/dist/index.d.ts CHANGED
@@ -104,15 +104,80 @@ declare type AttributeValue = string | number | boolean | Array<null | undefined
104
104
 
105
105
  declare class BufferedClass<T extends object> {
106
106
  protected _sdk: T;
107
+ /** True once an SDK instance has been attached via `load`. */
107
108
  protected _isLoaded: boolean;
109
+ /** True once the attached SDK has started and the buffer has drained. */
110
+ protected _isReady: boolean;
108
111
  protected _callBuffer: Array<Event_2>;
109
112
  protected _capacity: number;
110
113
  protected _droppedEvents: number;
111
114
  protected _exceededCapacity: boolean;
112
115
  protected _logger: Logger;
116
+ private _pendingStart?;
117
+ /**
118
+ * The last start or stop queued on the attached SDK while it runs. Starts
119
+ * and stops run in call order, so the final state follows the last call.
120
+ */
121
+ private _lastOp?;
113
122
  protected _bufferCall(method: string, args: any[]): any;
123
+ /** Calls the attached SDK directly, logging instead of throwing. */
124
+ protected _callSdk(method: string, args: any[]): any;
114
125
  protected _enqueue(event: Event_2): void;
115
- load(sdk: T): void;
126
+ /**
127
+ * Attach an SDK implementation. With `ready: false` (e.g. `manualStart`
128
+ * mode, or an SDK whose `start` is still running), telemetry keeps
129
+ * buffering until `markReady()` is called.
130
+ */
131
+ load(sdk: T, { ready, started }?: BufferedLoadOptions): void;
132
+ private _runPendingStart;
133
+ /**
134
+ * Starts the attached SDK and drains the buffer. Before `load` the start
135
+ * is deferred. Starts and stops run in call order: a start made while a
136
+ * stop is queued runs after that stop, while overlapping starts with no
137
+ * stop between them share one SDK start.
138
+ */
139
+ protected _start(): Promise<void>;
140
+ /**
141
+ * Stops the attached SDK. Before `load` it cancels a deferred start. Once
142
+ * attached, every stop is queued: it waits for an earlier start or stop,
143
+ * and a later start waits for the SDK's stop (including any async
144
+ * shutdown) to finish. Errors are logged rather than thrown.
145
+ */
146
+ protected _stop(stopSdk: () => unknown): Promise<void>;
147
+ /** Runs `op` once the previously queued start or stop has settled. */
148
+ private _queueOp;
149
+ /**
150
+ * Starts the attached SDK. Subclasses whose SDK owns a `start` method
151
+ * override this so a deferred start reaches the real implementation.
152
+ */
153
+ protected _startSdk(): Promise<void>;
154
+ /**
155
+ * Drains the buffered calls into the attached SDK and lets subsequent
156
+ * calls run directly.
157
+ */
158
+ protected markReady(): void;
159
+ /**
160
+ * Defers a start until `load` attaches an SDK. Returns a promise that
161
+ * resolves once the SDK has been attached, started and drained.
162
+ */
163
+ protected _deferStart(): Promise<void>;
164
+ /** Cancels a deferred start so it never runs; awaiting callers resolve. */
165
+ protected _cancelPendingStart(): void;
166
+ }
167
+
168
+ declare interface BufferedLoadOptions {
169
+ /**
170
+ * Whether the attached SDK has already been started.
171
+ * When `false` (e.g. `manualStart` mode), calls keep buffering until the
172
+ * SDK is started; a `start()` made before `load` runs at `load` time.
173
+ */
174
+ ready?: boolean;
175
+ /**
176
+ * With `ready: true`, the attached SDK's own start while it is still
177
+ * running. It is queued like a `start()`, so a `stop()` made meanwhile
178
+ * waits for it instead of being undone by it.
179
+ */
180
+ started?: Promise<unknown>;
116
181
  }
117
182
 
118
183
  declare type CanvasArg = SerializedCanvasArg | string | number | boolean | null | CanvasArg[];
@@ -180,14 +245,29 @@ declare type CommonOptions = {
180
245
  */
181
246
  storageMode?: 'sessionStorage' | 'localStorage';
182
247
  /**
183
- * By default, session data is stored in the `sessionStorage` of the browser.
248
+ * By default, session data is stored in the `localStorage` of the browser.
184
249
  * Set to `true` to store session data in a cookie instead.
185
250
  * This can help with compliance for cookie-consent regulation.
186
251
  */
187
252
  sessionCookie?: boolean;
253
+ /**
254
+ * Set the `Domain` attribute of the session cookie so the same session can
255
+ * be continued on different subdomains (e.g. `app.example.com` and
256
+ * `checkout.example.com` both see a cookie set for `example.com`).
257
+ * Only applies when `sessionCookie` is set to `true`.
258
+ * By default, the cookie is scoped to the exact host that created it.
259
+ */
260
+ sessionCookieDomain?: string;
188
261
  /**
189
262
  * Specifies if Highlight should not automatically initialize when the class is created.
190
263
  * This should be used with `.start()` and `.stop()` if you want to control when Highlight records.
264
+ *
265
+ * While `start()` has not been called, calls that can be deferred (logs,
266
+ * errors, metrics, `track`) are kept in memory and delivered once
267
+ * `start()` runs. `start()` and `stop()` can safely be called before the
268
+ * SDK has initialized: a start made too early resolves once the SDK is
269
+ * attached. Calls that cannot be deferred (synchronous span callbacks) run
270
+ * their callback on a no-op span while the SDK is not started.
191
271
  * @default false
192
272
  */
193
273
  manualStart?: boolean;
@@ -597,7 +677,8 @@ declare class Highlight_2 {
597
677
  getCurrentSessionURLWithTimestamp(): string;
598
678
  getCurrentSessionURL(): string | null;
599
679
  snapshot(element: HTMLCanvasElement): Promise<void>;
600
- addSessionFeedback({ timestamp, verbatim, user_email, user_name, }: {
680
+ /** @deprecated Session feedback is no longer supported. This is a no-op. */
681
+ addSessionFeedback(_feedback: {
601
682
  verbatim: string;
602
683
  timestamp: string;
603
684
  user_name?: string;
@@ -628,6 +709,7 @@ declare type HighlightClassOptions = {
628
709
  disableSessionRecording?: boolean;
629
710
  reportConsoleErrors?: boolean;
630
711
  consoleMethodsToRecord?: ConsoleMethods[];
712
+ recordLaunchDarklySdkLogs?: boolean;
631
713
  privacySetting?: PrivacySettingOption;
632
714
  maskAllInputs?: boolean;
633
715
  maskInputOptions?: MaskInputOptions;
@@ -657,6 +739,7 @@ declare type HighlightClassOptions = {
657
739
  sessionSecureID: string;
658
740
  storageMode?: 'sessionStorage' | 'localStorage';
659
741
  sessionCookie?: boolean;
742
+ sessionCookieDomain?: string;
660
743
  sendMode?: 'webworker' | 'local';
661
744
  otlpEndpoint?: HighlightOptions['otlpEndpoint'];
662
745
  otel?: HighlightOptions['otel'];
@@ -731,6 +814,14 @@ export declare type HighlightOptions = CommonOptions & {
731
814
  * @example consoleMethodsToRecord: ['log', 'info', 'error']
732
815
  */
733
816
  consoleMethodsToRecord?: ConsoleMethods[];
817
+ /**
818
+ * Specifies whether console output written by the LaunchDarkly SDK's own
819
+ * logger (lines prefixed `[LaunchDarkly]`) is recorded. Skipped by default:
820
+ * the lines describe the SDK, and the streaming URL they contain embeds
821
+ * the evaluation context.
822
+ * @default false
823
+ */
824
+ recordLaunchDarklySdkLogs?: boolean;
734
825
  enableSegmentIntegration?: boolean;
735
826
  /**
736
827
  * Specifies the environment your application is running in.
@@ -999,7 +1090,8 @@ declare interface HighlightPublicInterface {
999
1090
  getRecordingState: () => 'NotRecording' | 'Recording';
1000
1091
  options: HighlightOptions | undefined;
1001
1092
  /**
1002
- * Calling this will add a feedback comment to the session.
1093
+ * @deprecated Session feedback is no longer supported. This is a no-op and
1094
+ * will be removed in a future major version.
1003
1095
  */
1004
1096
  addSessionFeedback: (feedbackOptions: SessionFeedbackOptions) => void;
1005
1097
  snapshot: (element: HTMLCanvasElement) => Promise<void>;
@@ -1148,6 +1240,7 @@ declare interface LDClientMin {
1148
1240
  export declare let LDObserve: _LDObserve;
1149
1241
 
1150
1242
  declare class _LDObserve extends BufferedClass<Observe_2> implements Observe_2 {
1243
+ protected _startSdk(): Promise<void>;
1151
1244
  start(): Promise<void>;
1152
1245
  stop(): Promise<void>;
1153
1246
  recordGauge(metric: OTelMetric): any;
@@ -1157,6 +1250,7 @@ declare class _LDObserve extends BufferedClass<Observe_2> implements Observe_2 {
1157
1250
  recordUpDownCounter(metric: OTelMetric): any;
1158
1251
  startSpan(name: string, options: SpanOptions | ((span?: Span) => any), context?: Context | ((span?: Span) => any), fn?: (span?: Span) => any): any;
1159
1252
  startManualSpan(name: string, options: SpanOptions | ((span: Span) => any), context?: Context | ((span: Span) => any), fn?: (span: Span) => any): any;
1253
+ private _logNoopSpanWarning;
1160
1254
  register(client: LDClientMin, environmentMetadata: LDPluginEnvironmentMetadata): any;
1161
1255
  recordLog(message: any, level: ConsoleMethods, metadata?: Attributes): any;
1162
1256
  recordError(error: Error, message?: string, payload?: {
@@ -1175,7 +1269,9 @@ declare interface LDPlugin {
1175
1269
  export declare let LDRecord: _LDRecord;
1176
1270
 
1177
1271
  declare class _LDRecord extends BufferedClass<Record_3> implements Record_3 {
1272
+ private _deferredStartOptions?;
1178
1273
  getSession(): SessionDetails | null;
1274
+ protected _startSdk(): Promise<void>;
1179
1275
  start(options?: StartOptions): Promise<void>;
1180
1276
  stop(): void;
1181
1277
  addSessionProperties(properties: {
@@ -1217,10 +1313,15 @@ declare type loadedEvent = {
1217
1313
  data: unknown;
1218
1314
  };
1219
1315
 
1316
+ /**
1317
+ * Per-component debug logger. Like `sdkLog`, its output is SDK-internal: it
1318
+ * is written only in debug mode and never captured by the console recorder.
1319
+ */
1220
1320
  declare class Logger {
1221
1321
  debug: boolean | undefined;
1222
1322
  name: string | undefined;
1223
1323
  constructor(debug?: boolean, name?: string);
1324
+ private prefix;
1224
1325
  log(...data: any[]): void;
1225
1326
  warn(...data: any[]): void;
1226
1327
  }
@@ -1529,10 +1630,15 @@ export declare class Observe extends Plugin_2<ObserveOptions> implements LDPlugi
1529
1630
  declare interface Observe_2 {
1530
1631
  /**
1531
1632
  * Start the observability data capture when running in `manualStart` mode.
1633
+ * Can safely be called before the SDK has initialized (e.g. before the
1634
+ * plugin registers): the call resolves once the SDK is attached and
1635
+ * started, without throwing.
1532
1636
  */
1533
1637
  start: () => Promise<void>;
1534
1638
  /**
1535
1639
  * Stop the observability data capture.
1640
+ * Can safely be called before the SDK has initialized; before `start()`
1641
+ * it cancels a pending start instead of throwing.
1536
1642
  */
1537
1643
  stop: () => Promise<void>;
1538
1644
  /**
@@ -1686,6 +1792,15 @@ export declare type ObserveOptions = CommonOptions & {
1686
1792
  * @example consoleMethodsToRecord: ['log', 'info', 'error']
1687
1793
  */
1688
1794
  consoleMethodsToRecord?: ConsoleMethods[];
1795
+ /**
1796
+ * Specifies whether console output written by the LaunchDarkly SDK's own
1797
+ * logger (lines prefixed `[LaunchDarkly]`, e.g. stream connection
1798
+ * open/close messages) is recorded as logs. Those lines describe the SDK
1799
+ * rather than your application, and the streaming URL they contain embeds
1800
+ * the evaluation context, so they are skipped by default.
1801
+ * @default false
1802
+ */
1803
+ recordLaunchDarklySdkLogs?: boolean;
1689
1804
  /**
1690
1805
  * Specifies whether to record performance metrics (e.g. FPS, device memory).
1691
1806
  * @default true
@@ -1856,11 +1971,16 @@ declare interface Record_3 {
1856
1971
  /**
1857
1972
  * Start the session when running in `manualStart` mode.
1858
1973
  * Can be used to force start a new session.
1974
+ * Can safely be called before the SDK has initialized (e.g. before the
1975
+ * plugin registers): the call resolves once the SDK is attached and
1976
+ * started, without throwing.
1859
1977
  * @param options the session start options.
1860
1978
  */
1861
1979
  start: (options?: StartOptions) => Promise<void>;
1862
1980
  /**
1863
1981
  * Stop the session recording.
1982
+ * Can safely be called before the SDK has initialized; before `start()`
1983
+ * it cancels a pending start instead of throwing.
1864
1984
  */
1865
1985
  stop: () => void;
1866
1986
  /**
@@ -2116,7 +2236,8 @@ declare class RecordSDK implements Record_3 {
2116
2236
  getCurrentSessionURLWithTimestamp(): string;
2117
2237
  getCurrentSessionURL(): string | null;
2118
2238
  snapshot(element: HTMLCanvasElement): Promise<void>;
2119
- addSessionFeedback({ timestamp, verbatim, user_email, user_name, }: {
2239
+ /** @deprecated Session feedback is no longer supported. This is a no-op. */
2240
+ addSessionFeedback(_feedback: {
2120
2241
  verbatim: string;
2121
2242
  timestamp: string;
2122
2243
  user_name?: string;