@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/record.d.ts CHANGED
@@ -146,14 +146,29 @@ declare type CommonOptions = {
146
146
  */
147
147
  storageMode?: 'sessionStorage' | 'localStorage';
148
148
  /**
149
- * By default, session data is stored in the `sessionStorage` of the browser.
149
+ * By default, session data is stored in the `localStorage` of the browser.
150
150
  * Set to `true` to store session data in a cookie instead.
151
151
  * This can help with compliance for cookie-consent regulation.
152
152
  */
153
153
  sessionCookie?: boolean;
154
+ /**
155
+ * Set the `Domain` attribute of the session cookie so the same session can
156
+ * be continued on different subdomains (e.g. `app.example.com` and
157
+ * `checkout.example.com` both see a cookie set for `example.com`).
158
+ * Only applies when `sessionCookie` is set to `true`.
159
+ * By default, the cookie is scoped to the exact host that created it.
160
+ */
161
+ sessionCookieDomain?: string;
154
162
  /**
155
163
  * Specifies if Highlight should not automatically initialize when the class is created.
156
164
  * This should be used with `.start()` and `.stop()` if you want to control when Highlight records.
165
+ *
166
+ * While `start()` has not been called, calls that can be deferred (logs,
167
+ * errors, metrics, `track`) are kept in memory and delivered once
168
+ * `start()` runs. `start()` and `stop()` can safely be called before the
169
+ * SDK has initialized: a start made too early resolves once the SDK is
170
+ * attached. Calls that cannot be deferred (synchronous span callbacks) run
171
+ * their callback on a no-op span while the SDK is not started.
157
172
  * @default false
158
173
  */
159
174
  manualStart?: boolean;
@@ -353,6 +368,7 @@ declare type HighlightClassOptions = {
353
368
  disableSessionRecording?: boolean;
354
369
  reportConsoleErrors?: boolean;
355
370
  consoleMethodsToRecord?: ConsoleMethods[];
371
+ recordLaunchDarklySdkLogs?: boolean;
356
372
  privacySetting?: PrivacySettingOption;
357
373
  maskAllInputs?: boolean;
358
374
  maskInputOptions?: MaskInputOptions;
@@ -382,6 +398,7 @@ declare type HighlightClassOptions = {
382
398
  sessionSecureID: string;
383
399
  storageMode?: 'sessionStorage' | 'localStorage';
384
400
  sessionCookie?: boolean;
401
+ sessionCookieDomain?: string;
385
402
  sendMode?: 'webworker' | 'local';
386
403
  otlpEndpoint?: HighlightOptions['otlpEndpoint'];
387
404
  otel?: HighlightOptions['otel'];
@@ -451,6 +468,14 @@ declare type HighlightOptions = CommonOptions & {
451
468
  * @example consoleMethodsToRecord: ['log', 'info', 'error']
452
469
  */
453
470
  consoleMethodsToRecord?: ConsoleMethods[];
471
+ /**
472
+ * Specifies whether console output written by the LaunchDarkly SDK's own
473
+ * logger (lines prefixed `[LaunchDarkly]`) is recorded. Skipped by default:
474
+ * the lines describe the SDK, and the streaming URL they contain embeds
475
+ * the evaluation context.
476
+ * @default false
477
+ */
478
+ recordLaunchDarklySdkLogs?: boolean;
454
479
  enableSegmentIntegration?: boolean;
455
480
  /**
456
481
  * Specifies the environment your application is running in.
@@ -687,10 +712,15 @@ declare type loadedEvent = {
687
712
  data: unknown;
688
713
  };
689
714
 
715
+ /**
716
+ * Per-component debug logger. Like `sdkLog`, its output is SDK-internal: it
717
+ * is written only in debug mode and never captured by the console recorder.
718
+ */
690
719
  declare class Logger {
691
720
  debug: boolean | undefined;
692
721
  name: string | undefined;
693
722
  constructor(debug?: boolean, name?: string);
723
+ private prefix;
694
724
  log(...data: any[]): void;
695
725
  warn(...data: any[]): void;
696
726
  }
@@ -989,6 +1019,15 @@ declare type ObserveOptions = CommonOptions & {
989
1019
  * @example consoleMethodsToRecord: ['log', 'info', 'error']
990
1020
  */
991
1021
  consoleMethodsToRecord?: ConsoleMethods[];
1022
+ /**
1023
+ * Specifies whether console output written by the LaunchDarkly SDK's own
1024
+ * logger (lines prefixed `[LaunchDarkly]`, e.g. stream connection
1025
+ * open/close messages) is recorded as logs. Those lines describe the SDK
1026
+ * rather than your application, and the streaming URL they contain embeds
1027
+ * the evaluation context, so they are skipped by default.
1028
+ * @default false
1029
+ */
1030
+ recordLaunchDarklySdkLogs?: boolean;
992
1031
  /**
993
1032
  * Specifies whether to record performance metrics (e.g. FPS, device memory).
994
1033
  * @default true
@@ -1144,11 +1183,16 @@ declare interface Record_3 {
1144
1183
  /**
1145
1184
  * Start the session when running in `manualStart` mode.
1146
1185
  * Can be used to force start a new session.
1186
+ * Can safely be called before the SDK has initialized (e.g. before the
1187
+ * plugin registers): the call resolves once the SDK is attached and
1188
+ * started, without throwing.
1147
1189
  * @param options the session start options.
1148
1190
  */
1149
1191
  start: (options?: StartOptions) => Promise<void>;
1150
1192
  /**
1151
1193
  * Stop the session recording.
1194
+ * Can safely be called before the SDK has initialized; before `start()`
1195
+ * it cancels a pending start instead of throwing.
1152
1196
  */
1153
1197
  stop: () => void;
1154
1198
  /**
@@ -1404,7 +1448,8 @@ declare class RecordSDK implements Record_3 {
1404
1448
  getCurrentSessionURLWithTimestamp(): string;
1405
1449
  getCurrentSessionURL(): string | null;
1406
1450
  snapshot(element: HTMLCanvasElement): Promise<void>;
1407
- addSessionFeedback({ timestamp, verbatim, user_email, user_name, }: {
1451
+ /** @deprecated Session feedback is no longer supported. This is a no-op. */
1452
+ addSessionFeedback(_feedback: {
1408
1453
  verbatim: string;
1409
1454
  timestamp: string;
1410
1455
  user_name?: string;
package/dist/record.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./common-BkAGcE30.js";
2
- import { R as i } from "./record-DTawahUk.js";
1
+ import "./common-7gIdCuSo.js";
2
+ import { R as i } from "./record-CwkFdJT0.js";
3
3
  import "./LDRecord.js";
4
- import "./buffer-DIFxvF2Q.js";
4
+ import "./buffer-CwCRPuMA.js";
5
5
  export {
6
6
  i as Record
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/o11y",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Shared browser foundation for @launchdarkly/observability and @launchdarkly/session-replay. Capture frontend metrics, errors, logs, traces, and session replays.",
5
5
  "keywords": [
6
6
  "launchdarkly",
@@ -1,92 +0,0 @@
1
- import { B as f } from "./buffer-DIFxvF2Q.js";
2
- const i = () => {
3
- const t = {
4
- end: () => {
5
- },
6
- spanContext: () => ({
7
- traceId: "",
8
- spanId: "",
9
- traceFlags: 0
10
- }),
11
- setAttribute: (r, e) => t,
12
- setAttributes: (r) => t,
13
- addEvent: (r, e, s) => t,
14
- addLinks: (r) => t,
15
- setStatus: (r) => t,
16
- recordException: () => {
17
- },
18
- addLink: () => t,
19
- updateName: () => t,
20
- isRecording: () => !1
21
- };
22
- return t;
23
- };
24
- function o(t, r, e) {
25
- if (typeof e == "function")
26
- return e;
27
- if (typeof r == "function")
28
- return r;
29
- if (typeof t == "function")
30
- return t;
31
- }
32
- class l extends f {
33
- start() {
34
- return this._sdk.start();
35
- }
36
- stop() {
37
- return this._sdk.stop();
38
- }
39
- recordGauge(r) {
40
- return this._bufferCall("recordGauge", [r]);
41
- }
42
- recordCount(r) {
43
- return this._bufferCall("recordCount", [r]);
44
- }
45
- recordIncr(r) {
46
- return this._bufferCall("recordIncr", [r]);
47
- }
48
- recordHistogram(r) {
49
- return this._bufferCall("recordHistogram", [r]);
50
- }
51
- recordUpDownCounter(r) {
52
- return this._bufferCall("recordUpDownCounter", [r]);
53
- }
54
- // The callback holds the caller's own work, so it must never be buffered:
55
- // deferring it would replay that work at an arbitrary later time, or drop it.
56
- startSpan(r, e, s, a) {
57
- var n;
58
- return this._isLoaded ? this._bufferCall("startSpan", [r, e, s, a]) : (n = o(e, s, a)) == null ? void 0 : n(i());
59
- }
60
- startManualSpan(r, e, s, a) {
61
- var n;
62
- return this._isLoaded ? this._bufferCall("startManualSpan", [r, e, s, a]) : (n = o(e, s, a)) == null ? void 0 : n(i());
63
- }
64
- register(r, e) {
65
- return this._bufferCall("register", [r, e]);
66
- }
67
- recordLog(r, e, s) {
68
- return this._bufferCall("recordLog", [r, e, s]);
69
- }
70
- recordError(r, e, s, a, n) {
71
- return this._bufferCall("recordError", [
72
- r,
73
- e,
74
- s,
75
- a,
76
- n
77
- ]);
78
- }
79
- setLDContextKeyAttributes(r) {
80
- return this._bufferCall("setLDContextKeyAttributes", [r]);
81
- }
82
- getLDContextKeyAttributes() {
83
- return this._bufferCall("getLDContextKeyAttributes", []);
84
- }
85
- }
86
- let u;
87
- typeof globalThis != "undefined" ? globalThis.LDObserve ? u = globalThis.LDObserve : (u = new l(), globalThis.LDObserve = u) : u = new l();
88
- export {
89
- u as L,
90
- i as g
91
- };
92
- //# sourceMappingURL=LDObserve-CHIjcqIn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LDObserve-CHIjcqIn.js","sources":["../src/client/otel/utils.ts","../src/sdk/LDObserve.ts"],"sourcesContent":["import {\n\tAttributes,\n\tAttributeValue,\n\tLink,\n\tSpan,\n\tSpanStatus,\n\tTimeInput,\n} from '@opentelemetry/api'\n\nexport const getNoopSpan = () => {\n\tconst noopSpan: Span = {\n\t\tend: () => {},\n\t\tspanContext: () => ({\n\t\t\ttraceId: '',\n\t\t\tspanId: '',\n\t\t\ttraceFlags: 0,\n\t\t}),\n\t\tsetAttribute: (_key: string, _value: AttributeValue) => noopSpan,\n\t\tsetAttributes: (_attributes: Attributes) => noopSpan,\n\t\taddEvent: (\n\t\t\t_name: string,\n\t\t\t_attributesOrStartTime?: Attributes | TimeInput,\n\t\t\t_startTime?: TimeInput,\n\t\t) => noopSpan,\n\t\taddLinks: (_links: Link[]) => noopSpan,\n\t\tsetStatus: (_status: SpanStatus) => noopSpan,\n\t\trecordException: () => {},\n\t\taddLink: () => noopSpan,\n\t\tupdateName: () => noopSpan,\n\t\tisRecording: () => false,\n\t}\n\n\treturn noopSpan\n}\n","import type { Observe } from '../api/observe'\nimport type { LDClient } from '../integrations/launchdarkly'\nimport type { ErrorMessageType } from '../client/types/shared-types'\nimport type { OTelMetric as Metric } from '../client/types/types'\nimport type { Attributes, Context, Span, SpanOptions } from '@opentelemetry/api'\nimport type { LDPluginEnvironmentMetadata } from '../plugins/plugin'\nimport { BufferedClass } from './buffer'\nimport { getNoopSpan } from '../client/otel/utils'\nimport { ConsoleMethods } from '../client/types/client'\n\n/**\n * Resolves the span callback from whichever argument position it was passed in,\n * matching the overloads `startSpan` and `startManualSpan` accept.\n */\nfunction resolveSpanCallback(\n\toptions: unknown,\n\tcontext: unknown,\n\tfn: unknown,\n): ((span: Span) => any) | undefined {\n\tif (typeof fn === 'function') {\n\t\treturn fn as (span: Span) => any\n\t}\n\tif (typeof context === 'function') {\n\t\treturn context as (span: Span) => any\n\t}\n\tif (typeof options === 'function') {\n\t\treturn options as (span: Span) => any\n\t}\n\treturn undefined\n}\n\nclass _LDObserve extends BufferedClass<Observe> implements Observe {\n\tstart() {\n\t\t// avoid buffering the start call\n\t\treturn this._sdk.start()\n\t}\n\n\tstop() {\n\t\t// avoid buffering the stop call\n\t\treturn this._sdk.stop()\n\t}\n\n\trecordGauge(metric: Metric) {\n\t\treturn this._bufferCall('recordGauge', [metric])\n\t}\n\n\trecordCount(metric: Metric) {\n\t\treturn this._bufferCall('recordCount', [metric])\n\t}\n\n\trecordIncr(metric: Omit<Metric, 'value'>) {\n\t\treturn this._bufferCall('recordIncr', [metric])\n\t}\n\n\trecordHistogram(metric: Metric) {\n\t\treturn this._bufferCall('recordHistogram', [metric])\n\t}\n\n\trecordUpDownCounter(metric: Metric) {\n\t\treturn this._bufferCall('recordUpDownCounter', [metric])\n\t}\n\n\t// The callback holds the caller's own work, so it must never be buffered:\n\t// deferring it would replay that work at an arbitrary later time, or drop it.\n\tstartSpan(\n\t\tname: string,\n\t\toptions: SpanOptions | ((span?: Span) => any),\n\t\tcontext?: Context | ((span?: Span) => any),\n\t\tfn?: (span?: Span) => any,\n\t) {\n\t\tif (!this._isLoaded) {\n\t\t\treturn resolveSpanCallback(options, context, fn)?.(getNoopSpan())\n\t\t}\n\t\treturn this._bufferCall('startSpan', [name, options, context, fn])\n\t}\n\n\tstartManualSpan(\n\t\tname: string,\n\t\toptions: SpanOptions | ((span: Span) => any),\n\t\tcontext?: Context | ((span: Span) => any),\n\t\tfn?: (span: Span) => any,\n\t) {\n\t\tif (!this._isLoaded) {\n\t\t\treturn resolveSpanCallback(options, context, fn)?.(getNoopSpan())\n\t\t}\n\t\treturn this._bufferCall('startManualSpan', [name, options, context, fn])\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\trecordLog(message: any, level: ConsoleMethods, metadata?: Attributes) {\n\t\treturn this._bufferCall('recordLog', [message, level, metadata])\n\t}\n\n\trecordError(\n\t\terror: Error,\n\t\tmessage?: string,\n\t\tpayload?: { [key: string]: string },\n\t\tsource?: string,\n\t\ttype?: ErrorMessageType,\n\t) {\n\t\treturn this._bufferCall('recordError', [\n\t\t\terror,\n\t\t\tmessage,\n\t\t\tpayload,\n\t\t\tsource,\n\t\t\ttype,\n\t\t])\n\t}\n\n\tsetLDContextKeyAttributes(contextKeys: Attributes) {\n\t\treturn this._bufferCall('setLDContextKeyAttributes', [contextKeys])\n\t}\n\n\tgetLDContextKeyAttributes(): Attributes | undefined {\n\t\treturn this._bufferCall('getLDContextKeyAttributes', [])\n\t}\n}\n\ninterface GlobalThis {\n\tLDObserve?: _LDObserve\n}\ndeclare var globalThis: GlobalThis\n\nexport let LDObserve!: _LDObserve\nif (typeof globalThis !== 'undefined') {\n\tif (globalThis.LDObserve) {\n\t\tLDObserve = globalThis.LDObserve\n\t} else {\n\t\tLDObserve = new _LDObserve()\n\t\tglobalThis.LDObserve = LDObserve\n\t}\n} else {\n\tLDObserve = new _LDObserve()\n}\n"],"names":["getNoopSpan","noopSpan","_key","_value","_attributes","_name","_attributesOrStartTime","_startTime","_links","_status","resolveSpanCallback","options","context","fn","_LDObserve","BufferedClass","metric","name","_a","client","environmentMetadata","message","level","metadata","error","payload","source","type","contextKeys","LDObserve"],"mappings":";AASO,MAAMA,IAAc,MAAM;AAChC,QAAMC,IAAiB;AAAA,IACtB,KAAK,MAAM;AAAA,IAAC;AAAA,IACZ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