@launchdarkly/o11y 1.3.1 → 1.4.1

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;
@@ -383,6 +398,7 @@ declare type HighlightClassOptions = {
383
398
  sessionSecureID: string;
384
399
  storageMode?: 'sessionStorage' | 'localStorage';
385
400
  sessionCookie?: boolean;
401
+ sessionCookieDomain?: string;
386
402
  sendMode?: 'webworker' | 'local';
387
403
  otlpEndpoint?: HighlightOptions['otlpEndpoint'];
388
404
  otel?: HighlightOptions['otel'];
@@ -1167,11 +1183,16 @@ declare interface Record_3 {
1167
1183
  /**
1168
1184
  * Start the session when running in `manualStart` mode.
1169
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.
1170
1189
  * @param options the session start options.
1171
1190
  */
1172
1191
  start: (options?: StartOptions) => Promise<void>;
1173
1192
  /**
1174
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.
1175
1196
  */
1176
1197
  stop: () => void;
1177
1198
  /**
@@ -1427,7 +1448,8 @@ declare class RecordSDK implements Record_3 {
1427
1448
  getCurrentSessionURLWithTimestamp(): string;
1428
1449
  getCurrentSessionURL(): string | null;
1429
1450
  snapshot(element: HTMLCanvasElement): Promise<void>;
1430
- addSessionFeedback({ timestamp, verbatim, user_email, user_name, }: {
1451
+ /** @deprecated Session feedback is no longer supported. This is a no-op. */
1452
+ addSessionFeedback(_feedback: {
1431
1453
  verbatim: string;
1432
1454
  timestamp: string;
1433
1455
  user_name?: string;
package/dist/record.js CHANGED
@@ -1,7 +1,7 @@
1
- import "./common-BjaGmQrE.js";
2
- import { R as i } from "./record-BZHDLKsW.js";
1
+ import "./common-D8kkCWo3.js";
2
+ import { R as i } from "./record-DG2IcHxO.js";
3
3
  import "./LDRecord.js";
4
- import "./buffer-BjzLorpP.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.1",
3
+ "version": "1.4.1",
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-BjzLorpP.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-DhF3vCDR.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LDObserve-DhF3vCDR.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,aAAa,OAAO;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,YAAY;AAAA,IAAA;AAAA,IAEb,cAAc,CAACC,GAAcC,MAA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K,EAA4ClB;EAGrD;AAAA,EAEA,gBACCiB,GACAN,GACAC,GACAC,GACC;;AACD,WAAK,KAAK,YAGH,KAAK,YAAY,mBAAmB,CAACI,GAAMN,GAASC,GAASC,CAAE,CAAC,KAF/DK,IAAAR,EAAoBC,GAASC,GAASC,CAAE,MAAxC,gBAAAK,EAA4ClB;EAGrD;AAAA,EAEA,SACCmB,GACAC,GACC;AACD,WAAO,KAAK,YAAY,YAAY,CAACD,GAAQC,CAAmB,CAAC;AAAA,EAClE;AAAA,EAEA,UAAUC,GAAcC,GAAuBC,GAAuB;AACrE,WAAO,KAAK,YAAY,aAAa,CAACF,GAASC,GAAOC,CAAQ,CAAC;AAAA,EAChE;AAAA,EAEA,YACCC,GACAH,GACAI,GACAC,GACAC,GACC;AACD,WAAO,KAAK,YAAY,eAAe;AAAA,MACtCH;AAAA,MACAH;AAAA,MACAI;AAAA,MACAC;AAAA,MACAC;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAEA,0BAA0BC,GAAyB;AAClD,WAAO,KAAK,YAAY,6BAA6B,CAACA,CAAW,CAAC;AAAA,EACnE;AAAA,EAEA,4BAAoD;AACnD,WAAO,KAAK,YAAY,6BAA6B,EAAE;AAAA,EACxD;AACD;AAOO,IAAIC;AACP,OAAO,cAAe,cACrB,WAAW,YACdA,IAAY,WAAW,aAEvBA,IAAY,IAAIf,EAAA,GAChB,WAAW,YAAYe,KAGxBA,IAAY,IAAIf,EAAA;"}
@@ -1,124 +0,0 @@
1
- var f = Object.defineProperty;
2
- var g = (s, e, t) => e in s ? f(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var r = (s, e, t) => g(s, typeof e != "symbol" ? e + "" : e, t);
4
- const c = {}, p = [
5
- "debug",
6
- "log",
7
- "info",
8
- "warn",
9
- "error"
10
- ], l = Symbol.for("@launchdarkly/o11y.sdkLogger"), h = (() => {
11
- try {
12
- return (c == null ? void 0 : c.DEBUG) === "true";
13
- } catch (s) {
14
- return !1;
15
- }
16
- })(), a = (() => {
17
- var t;
18
- const s = globalThis, e = (t = s[l]) != null ? t : s[l] = {
19
- debugEnabled: !1,
20
- suppressDepth: 0
21
- };
22
- return h && (e.debugEnabled = !0), e;
23
- })(), x = (s) => {
24
- a.debugEnabled = s;
25
- }, b = () => a.debugEnabled, E = () => a.suppressDepth > 0, i = (s) => {
26
- a.suppressDepth++;
27
- try {
28
- return s();
29
- } finally {
30
- a.suppressDepth--;
31
- }
32
- }, y = (s) => p.includes(s) ? s : "log", _ = (s, ...e) => {
33
- a.debugEnabled && i(() => {
34
- var t;
35
- try {
36
- ((t = console[y(s)]) != null ? t : console.log).apply(console, e);
37
- } catch (o) {
38
- }
39
- });
40
- }, d = /* @__PURE__ */ Object.create(null), n = (s, e, ...t) => {
41
- const o = `[@launchdarkly plugins]: (${s}): `;
42
- _(e, o, ...t);
43
- }, D = (s, e, t, ...o) => {
44
- d[`${s}-${e}`] || (d[`${s}-${e}`] = !0, n(s, t, ...o));
45
- };
46
- class L {
47
- constructor(e, t) {
48
- r(this, "debug");
49
- r(this, "name");
50
- this.debug = e, this.name = t;
51
- }
52
- prefix() {
53
- let e = `[${Date.now()}]`;
54
- return this.name && (e += ` - ${this.name}`), e;
55
- }
56
- log(...e) {
57
- this.debug && i(
58
- () => console.log.apply(console, [this.prefix(), ...e])
59
- );
60
- }
61
- warn(...e) {
62
- (this.debug || b()) && i(
63
- () => console.warn.apply(console, [this.prefix(), ...e])
64
- );
65
- }
66
- }
67
- class $ {
68
- constructor() {
69
- r(this, "_sdk");
70
- r(this, "_isLoaded", !1);
71
- r(this, "_callBuffer", []);
72
- r(this, "_capacity", 1e5);
73
- r(this, "_droppedEvents", 0);
74
- r(this, "_exceededCapacity", !1);
75
- r(this, "_logger", new L());
76
- }
77
- _bufferCall(e, t) {
78
- if (this._isLoaded)
79
- try {
80
- return this._sdk[e](...t);
81
- } catch (o) {
82
- n(
83
- `Error executing buffered call to ${e}:`,
84
- "error",
85
- o
86
- );
87
- }
88
- else {
89
- this._enqueue({ method: e, args: t });
90
- return;
91
- }
92
- }
93
- _enqueue(e) {
94
- this._callBuffer.length < this._capacity ? (this._callBuffer.push(e), this._exceededCapacity = !1) : (this._exceededCapacity || (this._exceededCapacity = !0, n(
95
- "Exceeded event queue capacity. Increase capacity to avoid dropping events.",
96
- "warn"
97
- )), this._droppedEvents += 1);
98
- }
99
- load(e) {
100
- this._sdk = e, this._isLoaded = !0;
101
- for (const { method: t, args: o } of this._callBuffer)
102
- try {
103
- this._sdk[t](...o);
104
- } catch (u) {
105
- n(
106
- `Error executing buffered call to ${t}:`,
107
- "error",
108
- u
109
- );
110
- }
111
- this._callBuffer = [];
112
- }
113
- }
114
- export {
115
- $ as B,
116
- L,
117
- _ as a,
118
- E as b,
119
- b as c,
120
- D as d,
121
- n as i,
122
- x as s
123
- };
124
- //# sourceMappingURL=buffer-BjzLorpP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer-BjzLorpP.js","sources":["../src/client/utils/sdkLogger.ts","../src/sdk/util.ts","../src/client/logger.ts","../src/sdk/buffer.ts"],"sourcesContent":["/**\n * SDK-internal diagnostics.\n *\n * Everything the SDK says about itself (exporter failures, init warnings,\n * internal catch blocks) goes through here rather than straight to `console`:\n *\n * 1. It only reaches the developer console when the SDK is in debug mode\n * (`debug: true` or a `DebugOptions` object in the plugin options, or a\n * `DEBUG=true` build). A production page is not filled with\n * `[@launchdarkly/observability]` lines the app owner cannot act on.\n * 2. While it is being written, the console recorder is told to stand down\n * (see `isSdkConsoleOutput`), so the line is never captured and shipped\n * back as one of the customer's own log records. Before this, a failing\n * OTLP export surfaced as error-level `launchdarkly.js.log` rows in the\n * customer's own project.\n */\n\nexport type SdkLogLevel = 'debug' | 'log' | 'info' | 'warn' | 'error'\n\nconst SDK_LOG_LEVELS: readonly SdkLogLevel[] = [\n\t'debug',\n\t'log',\n\t'info',\n\t'warn',\n\t'error',\n]\n\ntype SdkLoggerState = { debugEnabled: boolean; suppressDepth: number }\n\n/**\n * `@launchdarkly/observability` and `@launchdarkly/session-replay` each bundle\n * their own copy of this module, and the console recorder lives in only one\n * of them. A module-level counter would therefore not be seen across copies:\n * session replay's diagnostics would be recorded by the observability\n * plugin's console recorder (and the bundler drops the counter entirely in a\n * copy that never reads it). Keep the state on the global object under a\n * registry symbol so every copy on the page shares it.\n */\nconst SDK_LOGGER_STATE_KEY = Symbol.for('@launchdarkly/o11y.sdkLogger')\n\nconst buildDebugEnabled = (() => {\n\ttry {\n\t\treturn import.meta.env?.DEBUG === 'true'\n\t} catch {\n\t\treturn false\n\t}\n})()\n\nconst state: SdkLoggerState = (() => {\n\tconst holder = globalThis as unknown as Record<symbol, SdkLoggerState>\n\tconst shared = (holder[SDK_LOGGER_STATE_KEY] ??= {\n\t\tdebugEnabled: false,\n\t\tsuppressDepth: 0,\n\t})\n\tif (buildDebugEnabled) {\n\t\tshared.debugEnabled = true\n\t}\n\treturn shared\n})()\n\n/**\n * Turns SDK-internal console diagnostics on or off. Called by the SDK entry\n * points when the `debug` option is set; tests may call it directly.\n */\nexport const setSdkDebugLogging = (enabled: boolean) => {\n\tstate.debugEnabled = enabled\n}\n\nexport const isSdkDebugLogging = () => state.debugEnabled\n\n/**\n * True while the SDK itself is writing to the console. The console recorder\n * checks this and skips the call so SDK diagnostics never become customer\n * log records, in any mode.\n */\nexport const isSdkConsoleOutput = () => state.suppressDepth > 0\n\n/**\n * Runs `fn` with console recording suspended. Console patches are\n * synchronous, so a depth counter is enough to scope the suspension.\n */\nexport const withoutConsoleRecording = <T>(fn: () => T): T => {\n\tstate.suppressDepth++\n\ttry {\n\t\treturn fn()\n\t} finally {\n\t\tstate.suppressDepth--\n\t}\n}\n\nconst toSdkLogLevel = (level: string): SdkLogLevel =>\n\t(SDK_LOG_LEVELS as readonly string[]).includes(level)\n\t\t? (level as SdkLogLevel)\n\t\t: 'log'\n\n/**\n * Writes an SDK-internal diagnostic to the console, but only in debug mode,\n * and never into the console recorder.\n */\nexport const sdkLog = (level: SdkLogLevel | string, ...args: unknown[]) => {\n\tif (!state.debugEnabled) {\n\t\treturn\n\t}\n\twithoutConsoleRecording(() => {\n\t\ttry {\n\t\t\tconst method = console[toSdkLogLevel(level)] ?? console.log\n\t\t\tmethod.apply(console, args)\n\t\t} catch {\n\t\t\t// a broken console must never break the SDK\n\t\t}\n\t})\n}\n","import { sdkLog } from '../client/utils/sdkLogger'\n\n// Object for tracking previously logged messages.\nconst loggedIds = Object.create(null)\n\n/**\n * SDK-internal diagnostic. Reaches the developer console only in debug mode\n * and is never recorded as one of the customer's log records (it used to be\n * both printed unconditionally and shipped as a `warn` log into the\n * customer's project).\n */\nexport const internalLog = (\n\tcontext: string,\n\tlevel: keyof Console,\n\t...msg: any\n) => {\n\tconst prefix = `[@launchdarkly plugins]: (${context}): `\n\tsdkLog(level as string, prefix, ...msg)\n}\n\n/**\n * Utility to help avoid logging the same message multiple times.\n *\n * This is helpful to prevent spamming the logs with sticky error conditions.\n * For example if local storage cannot be written to, then each attempt to\n * write would fail, and logging each time would spam the logs.\n *\n * @param logOnceId - A message with this ID will only be logged one time for the given context.\n * @param context - The context of the message.\n * @param level - The level of the message.\n * @param msg - The message to log.\n */\nexport const internalLogOnce = (\n\tcontext: string,\n\tlogOnceId: string,\n\tlevel: keyof Console,\n\t...msg: any\n) => {\n\tif (loggedIds[`${context}-${logOnceId}`]) {\n\t\treturn\n\t}\n\tloggedIds[`${context}-${logOnceId}`] = true\n\tinternalLog(context, level, ...msg)\n}\n","import { isSdkDebugLogging, withoutConsoleRecording } from './utils/sdkLogger'\n\n/**\n * Per-component debug logger. Like `sdkLog`, its output is SDK-internal: it\n * is written only in debug mode and never captured by the console recorder.\n */\nexport class Logger {\n\tdebug: boolean | undefined\n\tname: string | undefined\n\n\tconstructor(debug?: boolean, name?: string) {\n\t\tthis.debug = debug\n\t\tthis.name = name\n\t}\n\n\tprivate prefix() {\n\t\tlet prefix = `[${Date.now()}]`\n\t\tif (this.name) {\n\t\t\tprefix += ` - ${this.name}`\n\t\t}\n\t\treturn prefix\n\t}\n\n\tlog(...data: any[]) {\n\t\tif (this.debug) {\n\t\t\twithoutConsoleRecording(() =>\n\t\t\t\tconsole.log.apply(console, [this.prefix(), ...data]),\n\t\t\t)\n\t\t}\n\t}\n\n\twarn(...data: any[]) {\n\t\tif (this.debug || isSdkDebugLogging()) {\n\t\t\twithoutConsoleRecording(() =>\n\t\t\t\tconsole.warn.apply(console, [this.prefix(), ...data]),\n\t\t\t)\n\t\t}\n\t}\n}\n","import { Logger } from '../client/logger'\nimport { internalLog } from './util'\n\ntype Event = { method: string; args: any[] }\n\nexport class BufferedClass<T extends object> {\n\tprotected _sdk!: T\n\tprotected _isLoaded = false\n\tprotected _callBuffer: Array<Event> = []\n\tprotected _capacity: number = 100_000\n\tprotected _droppedEvents: number = 0\n\tprotected _exceededCapacity: boolean = false\n\tprotected _logger = new Logger()\n\n\tprotected _bufferCall(method: string, args: any[]) {\n\t\tif (this._isLoaded) {\n\t\t\t// If already loaded, execute the method directly\n\t\t\ttry {\n\t\t\t\treturn (this._sdk as any)[method](...args)\n\t\t\t} catch (error) {\n\t\t\t\tinternalLog(\n\t\t\t\t\t`Error executing buffered call to ${method}:`,\n\t\t\t\t\t'error',\n\t\t\t\t\terror,\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\t// Otherwise buffer the call\n\t\t\tthis._enqueue({ method, args })\n\t\t\treturn undefined\n\t\t}\n\t}\n\n\tprotected _enqueue(event: Event) {\n\t\tif (this._callBuffer.length < this._capacity) {\n\t\t\tthis._callBuffer.push(event)\n\t\t\tthis._exceededCapacity = false\n\t\t} else {\n\t\t\tif (!this._exceededCapacity) {\n\t\t\t\tthis._exceededCapacity = true\n\t\t\t\tinternalLog(\n\t\t\t\t\t'Exceeded event queue capacity. Increase capacity to avoid dropping events.',\n\t\t\t\t\t'warn',\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis._droppedEvents += 1\n\t\t}\n\t}\n\n\tload(sdk: T) {\n\t\tthis._sdk = sdk\n\t\tthis._isLoaded = true\n\n\t\t// Process buffered calls\n\t\tfor (const { method, args } of this._callBuffer) {\n\t\t\ttry {\n\t\t\t\t;(this._sdk as any)[method](...args)\n\t\t\t} catch (error) {\n\t\t\t\tinternalLog(\n\t\t\t\t\t`Error executing buffered call to ${method}:`,\n\t\t\t\t\t'error',\n\t\t\t\t\terror,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\t// Clear the buffer\n\t\tthis._callBuffer = []\n\t}\n}\n"],"names":["SDK_LOG_LEVELS","SDK_LOGGER_STATE_KEY","buildDebugEnabled","__vite_import_meta_env__","e","state","holder","shared","_a","setSdkDebugLogging","enabled","isSdkDebugLogging","isSdkConsoleOutput","withoutConsoleRecording","fn","toSdkLogLevel","level","sdkLog","args","loggedIds","internalLog","context","msg","prefix","internalLogOnce","logOnceId","Logger","debug","name","__publicField","data","BufferedClass","method","error","event","sdk"],"mappings":";;;cAmBMA,IAAyC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAaMC,IAAuB,OAAO,IAAI,8BAA8B,GAEhEC,KAAqB,MAAM;AAChC,MAAI;AACH,YAAOC,KAAA,gBAAAA,EAAiB,WAAU;AAAA,EACnC,SAAQC,GAAA;AACP,WAAO;AAAA,EACR;AACD,GAAA,GAEMC,KAAyB,MAAM;;AACpC,QAAMC,IAAS,YACTC,KAAUC,IAAAF,EAAAL,OAAA,OAAAO,IAAAF,EAAAL,KAAiC;AAAA,IAChD,cAAc;AAAA,IACd,eAAe;AAAA,EAAA;AAEhB,SAAIC,MACHK,EAAO,eAAe,KAEhBA;AACR,GAAA,GAMaE,IAAqB,CAACC,MAAqB;AACvD,EAAAL,EAAM,eAAeK;AACtB,GAEaC,IAAoB,MAAMN,EAAM,cAOhCO,IAAqB,MAAMP,EAAM,gBAAgB,GAMjDQ,IAA0B,CAAIC,MAAmB;AAC7D,EAAAT,EAAM;AACN,MAAI;AACH,WA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