@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.
@@ -0,0 +1,248 @@
1
+ var b = Object.defineProperty;
2
+ var S = (s, e, t) => e in s ? b(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var a = (s, e, t) => S(s, typeof e != "symbol" ? e + "" : e, t);
4
+ var d = (s, e, t) => new Promise((r, i) => {
5
+ var u = (n) => {
6
+ try {
7
+ h(t.next(n));
8
+ } catch (p) {
9
+ i(p);
10
+ }
11
+ }, l = (n) => {
12
+ try {
13
+ h(t.throw(n));
14
+ } catch (p) {
15
+ i(p);
16
+ }
17
+ }, h = (n) => n.done ? r(n.value) : Promise.resolve(n.value).then(u, l);
18
+ h((t = t.apply(s, e)).next());
19
+ });
20
+ const f = {}, k = [
21
+ "debug",
22
+ "log",
23
+ "info",
24
+ "warn",
25
+ "error"
26
+ ], g = Symbol.for("@launchdarkly/o11y.sdkLogger"), v = (() => {
27
+ try {
28
+ return (f == null ? void 0 : f.DEBUG) === "true";
29
+ } catch (s) {
30
+ return !1;
31
+ }
32
+ })(), c = (() => {
33
+ var t;
34
+ const s = globalThis, e = (t = s[g]) != null ? t : s[g] = {
35
+ debugEnabled: !1,
36
+ suppressDepth: 0
37
+ };
38
+ return v && (e.debugEnabled = !0), e;
39
+ })(), D = (s) => {
40
+ c.debugEnabled = s;
41
+ }, L = () => c.debugEnabled, x = () => c.suppressDepth > 0, _ = (s) => {
42
+ c.suppressDepth++;
43
+ try {
44
+ return s();
45
+ } finally {
46
+ c.suppressDepth--;
47
+ }
48
+ }, m = (s) => k.includes(s) ? s : "log", E = (s, ...e) => {
49
+ c.debugEnabled && _(() => {
50
+ var t;
51
+ try {
52
+ ((t = console[m(s)]) != null ? t : console.log).apply(console, e);
53
+ } catch (r) {
54
+ }
55
+ });
56
+ }, y = /* @__PURE__ */ Object.create(null), o = (s, e, ...t) => {
57
+ const r = `[@launchdarkly plugins]: (${s}): `;
58
+ E(e, r, ...t);
59
+ }, q = (s, e, t, ...r) => {
60
+ y[`${s}-${e}`] || (y[`${s}-${e}`] = !0, o(s, t, ...r));
61
+ };
62
+ class O {
63
+ constructor(e, t) {
64
+ a(this, "debug");
65
+ a(this, "name");
66
+ this.debug = e, this.name = t;
67
+ }
68
+ prefix() {
69
+ let e = `[${Date.now()}]`;
70
+ return this.name && (e += ` - ${this.name}`), e;
71
+ }
72
+ log(...e) {
73
+ this.debug && _(
74
+ () => console.log.apply(console, [this.prefix(), ...e])
75
+ );
76
+ }
77
+ warn(...e) {
78
+ (this.debug || L()) && _(
79
+ () => console.warn.apply(console, [this.prefix(), ...e])
80
+ );
81
+ }
82
+ }
83
+ class $ {
84
+ constructor() {
85
+ a(this, "_sdk");
86
+ /** True once an SDK instance has been attached via `load`. */
87
+ a(this, "_isLoaded", !1);
88
+ /** True once the attached SDK has started and the buffer has drained. */
89
+ a(this, "_isReady", !1);
90
+ a(this, "_callBuffer", []);
91
+ a(this, "_capacity", 1e5);
92
+ a(this, "_droppedEvents", 0);
93
+ a(this, "_exceededCapacity", !1);
94
+ a(this, "_logger", new O());
95
+ a(this, "_pendingStart");
96
+ /**
97
+ * The last start or stop queued on the attached SDK while it runs. Starts
98
+ * and stops run in call order, so the final state follows the last call.
99
+ */
100
+ a(this, "_lastOp");
101
+ }
102
+ _bufferCall(e, t) {
103
+ if (this._isReady)
104
+ return this._callSdk(e, t);
105
+ this._enqueue({ method: e, args: t });
106
+ }
107
+ /** Calls the attached SDK directly, logging instead of throwing. */
108
+ _callSdk(e, t) {
109
+ try {
110
+ return this._sdk[e](...t);
111
+ } catch (r) {
112
+ o(
113
+ `Error executing buffered call to ${e}:`,
114
+ "error",
115
+ r
116
+ );
117
+ }
118
+ }
119
+ _enqueue(e) {
120
+ this._callBuffer.length < this._capacity ? (this._callBuffer.push(e), this._exceededCapacity = !1) : (this._exceededCapacity || (this._exceededCapacity = !0, o(
121
+ "Exceeded event queue capacity. Increase capacity to avoid dropping events.",
122
+ "warn"
123
+ )), this._droppedEvents += 1);
124
+ }
125
+ /**
126
+ * Attach an SDK implementation. With `ready: false` (e.g. `manualStart`
127
+ * mode, or an SDK whose `start` is still running), telemetry keeps
128
+ * buffering until `markReady()` is called.
129
+ */
130
+ load(e, { ready: t = !0, started: r } = {}) {
131
+ this._sdk = e, this._isLoaded = !0;
132
+ const i = this._pendingStart;
133
+ this._pendingStart = void 0, t ? (this.markReady(), r ? this._queueOp("start", () => d(this, null, function* () {
134
+ yield r;
135
+ })).catch((l) => {
136
+ o("Error starting the SDK", "error", l);
137
+ }).then(() => i == null ? void 0 : i.resolve()) : i == null || i.resolve()) : i && this._runPendingStart(i);
138
+ }
139
+ _runPendingStart(e) {
140
+ return d(this, null, function* () {
141
+ try {
142
+ yield this._start();
143
+ } catch (t) {
144
+ o("Error starting the SDK", "error", t);
145
+ }
146
+ e.resolve();
147
+ });
148
+ }
149
+ /**
150
+ * Starts the attached SDK and drains the buffer. Before `load` the start
151
+ * is deferred. Starts and stops run in call order: a start made while a
152
+ * stop is queued runs after that stop, while overlapping starts with no
153
+ * stop between them share one SDK start.
154
+ */
155
+ _start() {
156
+ var e;
157
+ return this._isLoaded ? ((e = this._lastOp) == null ? void 0 : e.kind) === "start" ? this._lastOp.promise : this._queueOp("start", () => d(this, null, function* () {
158
+ try {
159
+ yield this._startSdk();
160
+ } finally {
161
+ this.markReady();
162
+ }
163
+ })) : this._deferStart();
164
+ }
165
+ /**
166
+ * Stops the attached SDK. Before `load` it cancels a deferred start. Once
167
+ * attached, every stop is queued: it waits for an earlier start or stop,
168
+ * and a later start waits for the SDK's stop (including any async
169
+ * shutdown) to finish. Errors are logged rather than thrown.
170
+ */
171
+ _stop(e) {
172
+ return this._isLoaded ? this._queueOp("stop", () => d(this, null, function* () {
173
+ try {
174
+ yield e();
175
+ } catch (t) {
176
+ o("Error stopping the SDK", "error", t);
177
+ }
178
+ })) : (this._cancelPendingStart(), Promise.resolve());
179
+ }
180
+ /** Runs `op` once the previously queued start or stop has settled. */
181
+ _queueOp(e, t) {
182
+ var u;
183
+ const r = (u = this._lastOp) == null ? void 0 : u.promise, i = (r ? r.then(t, t) : t()).finally(
184
+ () => {
185
+ var l;
186
+ ((l = this._lastOp) == null ? void 0 : l.promise) === i && (this._lastOp = void 0);
187
+ }
188
+ );
189
+ return this._lastOp = { kind: e, promise: i }, i;
190
+ }
191
+ /**
192
+ * Starts the attached SDK. Subclasses whose SDK owns a `start` method
193
+ * override this so a deferred start reaches the real implementation.
194
+ */
195
+ _startSdk() {
196
+ return d(this, null, function* () {
197
+ });
198
+ }
199
+ /**
200
+ * Drains the buffered calls into the attached SDK and lets subsequent
201
+ * calls run directly.
202
+ */
203
+ markReady() {
204
+ if (!this._isReady) {
205
+ this._isReady = !0;
206
+ for (const { method: e, args: t } of this._callBuffer)
207
+ try {
208
+ this._sdk[e](...t);
209
+ } catch (r) {
210
+ o(
211
+ `Error executing buffered call to ${e}:`,
212
+ "error",
213
+ r
214
+ );
215
+ }
216
+ this._callBuffer = [];
217
+ }
218
+ }
219
+ /**
220
+ * Defers a start until `load` attaches an SDK. Returns a promise that
221
+ * resolves once the SDK has been attached, started and drained.
222
+ */
223
+ _deferStart() {
224
+ if (!this._pendingStart) {
225
+ let e;
226
+ const t = new Promise((r) => {
227
+ e = r;
228
+ });
229
+ this._pendingStart = { promise: t, resolve: e };
230
+ }
231
+ return this._pendingStart.promise;
232
+ }
233
+ /** Cancels a deferred start so it never runs; awaiting callers resolve. */
234
+ _cancelPendingStart() {
235
+ this._pendingStart && (this._pendingStart.resolve(), this._pendingStart = void 0);
236
+ }
237
+ }
238
+ export {
239
+ $ as B,
240
+ O as L,
241
+ E as a,
242
+ x as b,
243
+ L as c,
244
+ q as d,
245
+ o as i,
246
+ D as s
247
+ };
248
+ //# sourceMappingURL=buffer-CwCRPuMA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer-CwCRPuMA.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 interface BufferedLoadOptions {\n\t/**\n\t * Whether the attached SDK has already been started.\n\t * When `false` (e.g. `manualStart` mode), calls keep buffering until the\n\t * SDK is started; a `start()` made before `load` runs at `load` time.\n\t */\n\tready?: boolean\n\t/**\n\t * With `ready: true`, the attached SDK's own start while it is still\n\t * running. It is queued like a `start()`, so a `stop()` made meanwhile\n\t * waits for it instead of being undone by it.\n\t */\n\tstarted?: Promise<unknown>\n}\n\ninterface PendingStart {\n\tpromise: Promise<void>\n\tresolve: () => void\n}\n\nexport class BufferedClass<T extends object> {\n\tprotected _sdk!: T\n\t/** True once an SDK instance has been attached via `load`. */\n\tprotected _isLoaded = false\n\t/** True once the attached SDK has started and the buffer has drained. */\n\tprotected _isReady = 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\tprivate _pendingStart?: PendingStart\n\t/**\n\t * The last start or stop queued on the attached SDK while it runs. Starts\n\t * and stops run in call order, so the final state follows the last call.\n\t */\n\tprivate _lastOp?: { kind: 'start' | 'stop'; promise: Promise<unknown> }\n\n\tprotected _bufferCall(method: string, args: any[]) {\n\t\tif (this._isReady) {\n\t\t\t// If ready, execute the method directly\n\t\t\treturn this._callSdk(method, args)\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\t/** Calls the attached SDK directly, logging instead of throwing. */\n\tprotected _callSdk(method: string, args: any[]) {\n\t\ttry {\n\t\t\treturn (this._sdk as any)[method](...args)\n\t\t} catch (error) {\n\t\t\tinternalLog(\n\t\t\t\t`Error executing buffered call to ${method}:`,\n\t\t\t\t'error',\n\t\t\t\terror,\n\t\t\t)\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\t/**\n\t * Attach an SDK implementation. With `ready: false` (e.g. `manualStart`\n\t * mode, or an SDK whose `start` is still running), telemetry keeps\n\t * buffering until `markReady()` is called.\n\t */\n\tload(sdk: T, { ready = true, started }: BufferedLoadOptions = {}) {\n\t\tthis._sdk = sdk\n\t\tthis._isLoaded = true\n\n\t\tconst pending = this._pendingStart\n\t\tthis._pendingStart = undefined\n\t\tif (ready) {\n\t\t\t// The SDK is already started (not `manualStart`), so an early\n\t\t\t// `start()` must not start it a second time.\n\t\t\tthis.markReady()\n\t\t\tif (started) {\n\t\t\t\t// Queue the SDK's own start so later stops and starts run after it.\n\t\t\t\tconst queued = this._queueOp('start', async () => {\n\t\t\t\t\tawait started\n\t\t\t\t}).catch((error) => {\n\t\t\t\t\tinternalLog(`Error starting the SDK`, 'error', error)\n\t\t\t\t})\n\t\t\t\tvoid queued.then(() => pending?.resolve())\n\t\t\t} else {\n\t\t\t\tpending?.resolve()\n\t\t\t}\n\t\t} else if (pending) {\n\t\t\t// `start()` was called before any SDK was attached: honor it now.\n\t\t\tvoid this._runPendingStart(pending)\n\t\t}\n\t}\n\n\tprivate async _runPendingStart(pending: PendingStart) {\n\t\ttry {\n\t\t\tawait this._start()\n\t\t} catch (error) {\n\t\t\tinternalLog(`Error starting the SDK`, 'error', error)\n\t\t}\n\t\tpending.resolve()\n\t}\n\n\t/**\n\t * Starts the attached SDK and drains the buffer. Before `load` the start\n\t * is deferred. Starts and stops run in call order: a start made while a\n\t * stop is queued runs after that stop, while overlapping starts with no\n\t * stop between them share one SDK start.\n\t */\n\tprotected _start(): Promise<void> {\n\t\tif (!this._isLoaded) {\n\t\t\treturn this._deferStart()\n\t\t}\n\t\tif (this._lastOp?.kind === 'start') {\n\t\t\treturn this._lastOp.promise as Promise<void>\n\t\t}\n\t\treturn this._queueOp('start', async () => {\n\t\t\ttry {\n\t\t\t\tawait this._startSdk()\n\t\t\t} finally {\n\t\t\t\tthis.markReady()\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Stops the attached SDK. Before `load` it cancels a deferred start. Once\n\t * attached, every stop is queued: it waits for an earlier start or stop,\n\t * and a later start waits for the SDK's stop (including any async\n\t * shutdown) to finish. Errors are logged rather than thrown.\n\t */\n\tprotected _stop(stopSdk: () => unknown): Promise<void> {\n\t\tif (!this._isLoaded) {\n\t\t\tthis._cancelPendingStart()\n\t\t\treturn Promise.resolve()\n\t\t}\n\t\treturn this._queueOp('stop', async () => {\n\t\t\ttry {\n\t\t\t\tawait stopSdk()\n\t\t\t} catch (error) {\n\t\t\t\tinternalLog(`Error stopping the SDK`, 'error', error)\n\t\t\t}\n\t\t})\n\t}\n\n\t/** Runs `op` once the previously queued start or stop has settled. */\n\tprivate _queueOp<R>(\n\t\tkind: 'start' | 'stop',\n\t\top: () => Promise<R>,\n\t): Promise<R> {\n\t\tconst previous = this._lastOp?.promise\n\t\tconst promise = (previous ? previous.then(op, op) : op()).finally(\n\t\t\t() => {\n\t\t\t\tif (this._lastOp?.promise === promise) {\n\t\t\t\t\tthis._lastOp = undefined\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tthis._lastOp = { kind, promise }\n\t\treturn promise\n\t}\n\n\t/**\n\t * Starts the attached SDK. Subclasses whose SDK owns a `start` method\n\t * override this so a deferred start reaches the real implementation.\n\t */\n\tprotected async _startSdk(): Promise<void> {}\n\n\t/**\n\t * Drains the buffered calls into the attached SDK and lets subsequent\n\t * calls run directly.\n\t */\n\tprotected markReady() {\n\t\tif (this._isReady) {\n\t\t\treturn\n\t\t}\n\t\tthis._isReady = 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\t/**\n\t * Defers a start until `load` attaches an SDK. Returns a promise that\n\t * resolves once the SDK has been attached, started and drained.\n\t */\n\tprotected _deferStart(): Promise<void> {\n\t\tif (!this._pendingStart) {\n\t\t\tlet resolve!: () => void\n\t\t\tconst promise = new Promise<void>((res) => {\n\t\t\t\tresolve = res\n\t\t\t})\n\t\t\tthis._pendingStart = { promise, resolve }\n\t\t}\n\t\treturn this._pendingStart.promise\n\t}\n\n\t/** Cancels a deferred start so it never runs; awaiting callers resolve. */\n\tprotected _cancelPendingStart() {\n\t\tif (this._pendingStart) {\n\t\t\tthis._pendingStart.resolve()\n\t\t\tthis._pendingStart = undefined\n\t\t}\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","ready","started","pending","__async","stopSdk","kind","op","previous","promise","resolve","res"],"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,MA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