@launchdarkly/o11y 0.0.0-stage → 1.1.26
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/LICENSE +13 -0
- package/README.md +15 -2
- package/dist/LDObserve-CHIjcqIn.js +92 -0
- package/dist/LDObserve-CHIjcqIn.js.map +1 -0
- package/dist/LDObserve.d.ts +645 -0
- package/dist/LDObserve.js +6 -0
- package/dist/LDObserve.js.map +1 -0
- package/dist/LDRecord.d.ts +149 -0
- package/dist/LDRecord.js +48 -0
- package/dist/LDRecord.js.map +1 -0
- package/dist/assets/highlight-client-worker-DsbKMpxq.js.map +1 -0
- package/dist/buffer-DIFxvF2Q.js +102 -0
- package/dist/buffer-DIFxvF2Q.js.map +1 -0
- package/dist/common-DTkqplI4.js +4587 -0
- package/dist/common-DTkqplI4.js.map +1 -0
- package/dist/index.d.ts +2772 -0
- package/dist/index.js +1657 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +495 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/observe-BLBJc_WZ.js +12196 -0
- package/dist/observe-BLBJc_WZ.js.map +1 -0
- package/dist/observe.d.ts +1195 -0
- package/dist/observe.js +8 -0
- package/dist/observe.js.map +1 -0
- package/dist/record-B0JnsHlu.js +11270 -0
- package/dist/record-B0JnsHlu.js.map +1 -0
- package/dist/record.d.ts +1725 -0
- package/dist/record.js +8 -0
- package/dist/record.js.map +1 -0
- package/package.json +158 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2025 Catamorphic, Co.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @launchdarkly/o11y
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared browser foundation for LaunchDarkly Observability and Session Replay.
|
|
4
|
+
|
|
5
|
+
This package holds the implementation that powers:
|
|
6
|
+
|
|
7
|
+
- [`@launchdarkly/observability`](https://www.npmjs.com/package/@launchdarkly/observability) — frontend errors, logs, traces, and metrics
|
|
8
|
+
- [`@launchdarkly/session-replay`](https://www.npmjs.com/package/@launchdarkly/session-replay) — session replay recording
|
|
9
|
+
- [`highlight.run`](https://www.npmjs.com/package/highlight.run) — compatibility alias for existing highlight.io users
|
|
10
|
+
|
|
11
|
+
Most applications should install `@launchdarkly/observability` and/or
|
|
12
|
+
`@launchdarkly/session-replay` rather than depending on this package directly.
|
|
13
|
+
See the [SDK reference](https://docs.launchdarkly.com/sdk/observability).
|
|
14
|
+
|
|
15
|
+
Session replay recording is powered by the
|
|
16
|
+
[launchdarkly/rrweb](https://github.com/launchdarkly/rrweb) fork.
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,aAAa,OAAO;AAAA,MACnB,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,YAAY;AAAA,IAAA;AAAA,IAEb,cAAc,CAACC,GAAcC,MAA2BF;AAAA,IACxD,eAAe,CAACG,MAA4BH;AAAA,IAC5C,UAAU,CACTI,GACAC,GACAC,MACIN;AAAA,IACL,UAAU,CAACO,MAAmBP;AAAA,IAC9B,WAAW,CAACQ,MAAwBR;AAAA,IACpC,iBAAiB,MAAM;AAAA,IAAC;AAAA,IACxB,SAAS,MAAMA;AAAA,IACf,YAAY,MAAMA;AAAA,IAClB,aAAa,MAAM;AAAA,EAAA;AAGpB,SAAOA;AACR;ACnBA,SAASS,EACRC,GACAC,GACAC,GACoC;AACpC,MAAI,OAAOA,KAAO;AACjB,WAAOA;AAER,MAAI,OAAOD,KAAY;AACtB,WAAOA;AAER,MAAI,OAAOD,KAAY;AACtB,WAAOA;AAGT;AAEA,MAAMG,UAAmBC,EAA0C;AAAA,EAClE,QAAQ;AAEP,WAAO,KAAK,KAAK,MAAA;AAAA,EAClB;AAAA,EAEA,OAAO;AAEN,WAAO,KAAK,KAAK,KAAA;AAAA,EAClB;AAAA,EAEA,YAAYC,GAAgB;AAC3B,WAAO,KAAK,YAAY,eAAe,CAACA,CAAM,CAAC;AAAA,EAChD;AAAA,EAEA,YAAYA,GAAgB;AAC3B,WAAO,KAAK,YAA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