@zuplo/cli 7.7.8 → 7.7.10

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.
Files changed (154) hide show
  1. package/node_modules/@posthog/core/dist/error-tracking/parsers/base.d.ts.map +1 -1
  2. package/node_modules/@posthog/core/dist/error-tracking/parsers/base.js +19 -2
  3. package/node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs +19 -2
  4. package/node_modules/@posthog/core/dist/index.d.ts +7 -0
  5. package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
  6. package/node_modules/@posthog/core/dist/index.js +82 -21
  7. package/node_modules/@posthog/core/dist/index.mjs +4 -0
  8. package/node_modules/@posthog/core/dist/logs/index.d.ts +3 -2
  9. package/node_modules/@posthog/core/dist/logs/index.d.ts.map +1 -1
  10. package/node_modules/@posthog/core/dist/logs/index.js +28 -22
  11. package/node_modules/@posthog/core/dist/logs/index.mjs +29 -23
  12. package/node_modules/@posthog/core/dist/logs/logs-utils.js +1 -1
  13. package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +2 -2
  14. package/node_modules/@posthog/core/dist/logs/types.d.ts +2 -2
  15. package/node_modules/@posthog/core/dist/metrics/index.d.ts +5 -2
  16. package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
  17. package/node_modules/@posthog/core/dist/metrics/index.js +28 -14
  18. package/node_modules/@posthog/core/dist/metrics/index.mjs +29 -15
  19. package/node_modules/@posthog/core/dist/metrics/metrics-utils.d.ts.map +1 -1
  20. package/node_modules/@posthog/core/dist/metrics/metrics-utils.js +1 -2
  21. package/node_modules/@posthog/core/dist/metrics/metrics-utils.mjs +2 -3
  22. package/node_modules/@posthog/core/dist/metrics/types.d.ts +7 -0
  23. package/node_modules/@posthog/core/dist/metrics/types.d.ts.map +1 -1
  24. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +32 -4
  25. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
  26. package/node_modules/@posthog/core/dist/posthog-core-stateless.js +68 -20
  27. package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +68 -20
  28. package/node_modules/@posthog/core/dist/traces/config.d.ts +13 -0
  29. package/node_modules/@posthog/core/dist/traces/config.d.ts.map +1 -0
  30. package/node_modules/@posthog/core/dist/traces/config.js +101 -0
  31. package/node_modules/@posthog/core/dist/traces/config.mjs +63 -0
  32. package/node_modules/@posthog/core/dist/traces/context.d.ts +18 -0
  33. package/node_modules/@posthog/core/dist/traces/context.d.ts.map +1 -0
  34. package/node_modules/@posthog/core/dist/traces/context.js +53 -0
  35. package/node_modules/@posthog/core/dist/traces/context.mjs +15 -0
  36. package/node_modules/@posthog/core/dist/traces/ids.d.ts +12 -0
  37. package/node_modules/@posthog/core/dist/traces/ids.d.ts.map +1 -0
  38. package/node_modules/@posthog/core/dist/traces/ids.js +92 -0
  39. package/node_modules/@posthog/core/dist/traces/ids.mjs +42 -0
  40. package/node_modules/@posthog/core/dist/traces/index.d.ts +150 -0
  41. package/node_modules/@posthog/core/dist/traces/index.d.ts.map +1 -0
  42. package/node_modules/@posthog/core/dist/traces/index.js +552 -0
  43. package/node_modules/@posthog/core/dist/traces/index.mjs +514 -0
  44. package/node_modules/@posthog/core/dist/traces/otlp.d.ts +24 -0
  45. package/node_modules/@posthog/core/dist/traces/otlp.d.ts.map +1 -0
  46. package/node_modules/@posthog/core/dist/traces/otlp.js +158 -0
  47. package/node_modules/@posthog/core/dist/traces/otlp.mjs +108 -0
  48. package/node_modules/@posthog/core/dist/traces/sanitize.d.ts +32 -0
  49. package/node_modules/@posthog/core/dist/traces/sanitize.d.ts.map +1 -0
  50. package/node_modules/@posthog/core/dist/traces/sanitize.js +93 -0
  51. package/node_modules/@posthog/core/dist/traces/sanitize.mjs +43 -0
  52. package/node_modules/@posthog/core/dist/traces/span.d.ts +198 -0
  53. package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -0
  54. package/node_modules/@posthog/core/dist/traces/span.js +538 -0
  55. package/node_modules/@posthog/core/dist/traces/span.mjs +467 -0
  56. package/node_modules/@posthog/core/dist/traces/traceparent.d.ts +51 -0
  57. package/node_modules/@posthog/core/dist/traces/traceparent.d.ts.map +1 -0
  58. package/node_modules/@posthog/core/dist/traces/traceparent.js +116 -0
  59. package/node_modules/@posthog/core/dist/traces/traceparent.mjs +63 -0
  60. package/node_modules/@posthog/core/dist/traces/types.d.ts +114 -0
  61. package/node_modules/@posthog/core/dist/traces/types.d.ts.map +1 -0
  62. package/node_modules/@posthog/core/dist/traces/types.js +18 -0
  63. package/node_modules/@posthog/core/dist/traces/types.mjs +1 -0
  64. package/node_modules/@posthog/core/dist/utils/backoff.d.ts +23 -0
  65. package/node_modules/@posthog/core/dist/utils/backoff.d.ts.map +1 -0
  66. package/node_modules/@posthog/core/dist/utils/backoff.js +65 -0
  67. package/node_modules/@posthog/core/dist/utils/backoff.mjs +14 -0
  68. package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts +26 -0
  69. package/node_modules/@posthog/core/dist/utils/flush-timer.d.ts.map +1 -0
  70. package/node_modules/@posthog/core/dist/utils/flush-timer.js +67 -0
  71. package/node_modules/@posthog/core/dist/utils/flush-timer.mjs +29 -0
  72. package/node_modules/@posthog/core/dist/utils/index.d.ts +1 -0
  73. package/node_modules/@posthog/core/dist/utils/index.d.ts.map +1 -1
  74. package/node_modules/@posthog/core/dist/utils/index.js +22 -2
  75. package/node_modules/@posthog/core/dist/utils/index.mjs +8 -1
  76. package/node_modules/@posthog/core/dist/utils/json-utils.d.ts +7 -0
  77. package/node_modules/@posthog/core/dist/utils/json-utils.d.ts.map +1 -1
  78. package/node_modules/@posthog/core/dist/utils/json-utils.js +27 -0
  79. package/node_modules/@posthog/core/dist/utils/json-utils.mjs +25 -1
  80. package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts +13 -2
  81. package/node_modules/@posthog/core/dist/utils/otlp-resource.d.ts.map +1 -1
  82. package/node_modules/@posthog/core/dist/utils/otlp-resource.js +34 -7
  83. package/node_modules/@posthog/core/dist/utils/otlp-resource.mjs +26 -2
  84. package/node_modules/@posthog/core/dist/utils/retry-after.d.ts +55 -0
  85. package/node_modules/@posthog/core/dist/utils/retry-after.d.ts.map +1 -0
  86. package/node_modules/@posthog/core/dist/utils/retry-after.js +95 -0
  87. package/node_modules/@posthog/core/dist/utils/retry-after.mjs +50 -0
  88. package/node_modules/@posthog/core/package.json +3 -3
  89. package/node_modules/@posthog/core/src/error-tracking/parsers/base.spec.ts +77 -7
  90. package/node_modules/@posthog/core/src/error-tracking/parsers/base.ts +42 -19
  91. package/node_modules/@posthog/core/src/index.ts +18 -0
  92. package/node_modules/@posthog/core/src/logs/index.spec.ts +490 -2
  93. package/node_modules/@posthog/core/src/logs/index.ts +63 -31
  94. package/node_modules/@posthog/core/src/logs/logs-utils.ts +2 -2
  95. package/node_modules/@posthog/core/src/logs/types.ts +2 -2
  96. package/node_modules/@posthog/core/src/metrics/index.spec.ts +304 -0
  97. package/node_modules/@posthog/core/src/metrics/index.ts +53 -16
  98. package/node_modules/@posthog/core/src/metrics/metrics-utils.ts +2 -3
  99. package/node_modules/@posthog/core/src/metrics/types.ts +10 -2
  100. package/node_modules/@posthog/core/src/posthog-core-stateless.ts +157 -38
  101. package/node_modules/@posthog/core/src/traces/config.spec.ts +271 -0
  102. package/node_modules/@posthog/core/src/traces/config.ts +142 -0
  103. package/node_modules/@posthog/core/src/traces/context.ts +30 -0
  104. package/node_modules/@posthog/core/src/traces/ids.spec.ts +115 -0
  105. package/node_modules/@posthog/core/src/traces/ids.ts +75 -0
  106. package/node_modules/@posthog/core/src/traces/index.spec.ts +3269 -0
  107. package/node_modules/@posthog/core/src/traces/index.ts +1063 -0
  108. package/node_modules/@posthog/core/src/traces/live-spans.spec.ts +69 -0
  109. package/node_modules/@posthog/core/src/traces/otlp.spec.ts +368 -0
  110. package/node_modules/@posthog/core/src/traces/otlp.ts +191 -0
  111. package/node_modules/@posthog/core/src/traces/sanitize.ts +116 -0
  112. package/node_modules/@posthog/core/src/traces/span.spec.ts +1123 -0
  113. package/node_modules/@posthog/core/src/traces/span.ts +844 -0
  114. package/node_modules/@posthog/core/src/traces/traceparent.spec.ts +184 -0
  115. package/node_modules/@posthog/core/src/traces/traceparent.ts +172 -0
  116. package/node_modules/@posthog/core/src/traces/types.ts +140 -0
  117. package/node_modules/@posthog/core/src/utils/backoff.ts +44 -0
  118. package/node_modules/@posthog/core/src/utils/flush-timer.ts +50 -0
  119. package/node_modules/@posthog/core/src/utils/index.ts +8 -0
  120. package/node_modules/@posthog/core/src/utils/json-utils.ts +33 -0
  121. package/node_modules/@posthog/core/src/utils/otlp-resource.spec.ts +55 -9
  122. package/node_modules/@posthog/core/src/utils/otlp-resource.ts +45 -4
  123. package/node_modules/@posthog/core/src/utils/retry-after.ts +135 -0
  124. package/node_modules/@posthog/types/dist/index.d.ts +1 -0
  125. package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
  126. package/node_modules/@posthog/types/dist/posthog-config.d.ts +29 -9
  127. package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
  128. package/node_modules/@posthog/types/dist/traces.d.ts +387 -0
  129. package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -0
  130. package/node_modules/@posthog/types/dist/traces.js +18 -0
  131. package/node_modules/@posthog/types/dist/traces.mjs +1 -0
  132. package/node_modules/@posthog/types/package.json +1 -1
  133. package/node_modules/@posthog/types/src/index.ts +19 -0
  134. package/node_modules/@posthog/types/src/posthog-config.ts +29 -9
  135. package/node_modules/@posthog/types/src/traces.ts +429 -0
  136. package/node_modules/@zuplo/core/package.json +1 -1
  137. package/node_modules/@zuplo/graphql/package.json +1 -1
  138. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  139. package/node_modules/@zuplo/otel/package.json +1 -1
  140. package/node_modules/@zuplo/runtime/out/esm/{chunk-7ZX347IG.js → chunk-JTYJUJYO.js} +3 -3
  141. package/node_modules/@zuplo/runtime/out/esm/chunk-JTYJUJYO.js.map +1 -0
  142. package/node_modules/@zuplo/runtime/out/esm/chunk-M3VFT3HF.js +410 -0
  143. package/node_modules/@zuplo/runtime/out/esm/chunk-M3VFT3HF.js.map +1 -0
  144. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  145. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +3 -3
  146. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  147. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
  148. package/node_modules/@zuplo/runtime/out/types/index.d.ts +20 -1
  149. package/node_modules/@zuplo/runtime/package.json +1 -1
  150. package/package.json +11 -11
  151. package/node_modules/@zuplo/runtime/out/esm/chunk-7ZX347IG.js.map +0 -1
  152. package/node_modules/@zuplo/runtime/out/esm/chunk-DRQ5CMVC.js +0 -410
  153. package/node_modules/@zuplo/runtime/out/esm/chunk-DRQ5CMVC.js.map +0 -1
  154. /package/node_modules/@zuplo/runtime/out/esm/{chunk-DRQ5CMVC.js.LEGAL.txt → chunk-M3VFT3HF.js.LEGAL.txt} +0 -0
@@ -0,0 +1,538 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ NOOP_SPAN: ()=>NOOP_SPAN,
32
+ NoopSpan: ()=>NoopSpan,
33
+ PassThroughSpan: ()=>PassThroughSpan,
34
+ PostHogSpan: ()=>PostHogSpan,
35
+ applySpanLimits: ()=>applySpanLimits,
36
+ describeError: ()=>describeError,
37
+ inertSpan: ()=>inertSpan,
38
+ monotonicNow: ()=>monotonicNow,
39
+ nonNegativeCount: ()=>nonNegativeCount,
40
+ runWithActiveSpan: ()=>runWithActiveSpan,
41
+ truncateAttributeValue: ()=>truncateAttributeValue,
42
+ truncateAttributes: ()=>truncateAttributes
43
+ });
44
+ const external_traceparent_js_namespaceObject = require("./traceparent.js");
45
+ const external_sanitize_js_namespaceObject = require("./sanitize.js");
46
+ const index_js_namespaceObject = require("../utils/index.js");
47
+ const json_utils_js_namespaceObject = require("../utils/json-utils.js");
48
+ function monotonicNow() {
49
+ const perf = globalThis.performance;
50
+ return 'function' == typeof perf?.now ? perf.now() : void 0;
51
+ }
52
+ class PostHogSpan {
53
+ constructor(init, _onEnd, _logger){
54
+ this._onEnd = _onEnd;
55
+ this._logger = _logger;
56
+ this._events = [];
57
+ this._ended = false;
58
+ this._userAttributeCount = 0;
59
+ this._userEventCount = 0;
60
+ this._droppedAttributes = 0;
61
+ this._droppedEvents = 0;
62
+ this._traceId = init.traceId;
63
+ this._spanId = init.spanId;
64
+ this._parentSpanId = init.parentSpanId;
65
+ this._traceState = init.traceState;
66
+ this._traceFlags = init.traceFlags ?? external_traceparent_js_namespaceObject.TRACE_FLAGS_SAMPLED;
67
+ this._parentIsRemote = init.parentIsRemote ?? false;
68
+ this._name = init.name;
69
+ this._kind = init.kind;
70
+ this._autoKeys = new Set(init.autoAttributeKeys);
71
+ this._maxAttributes = init.maxAttributes;
72
+ this._maxEvents = init.maxEvents;
73
+ this._maxAttributesPerEvent = init.maxAttributesPerEvent;
74
+ this._maxAttributeValueLength = init.maxAttributeValueLength;
75
+ this._attributes = Object.create(null);
76
+ for (const key of Object.keys(init.attributes))this._writeAttribute(key, init.attributes[key]);
77
+ this._startMono = init.backdated ? void 0 : monotonicNow();
78
+ this._startTime = init.clockAnchor && void 0 !== this._startMono ? init.clockAnchor.wall + (this._startMono - init.clockAnchor.mono) : init.startTime;
79
+ if (void 0 !== this._startMono) this._clockAnchor = init.clockAnchor ?? {
80
+ wall: this._startTime,
81
+ mono: this._startMono
82
+ };
83
+ }
84
+ _now() {
85
+ if (void 0 !== this._startMono) {
86
+ const mono = monotonicNow();
87
+ if (void 0 !== mono) return this._startTime + Math.max(0, mono - this._startMono);
88
+ }
89
+ return Date.now();
90
+ }
91
+ _mutable(operation) {
92
+ if (this._ended) {
93
+ this._logger?.debug(`Ignoring ${operation} on a span that has already ended`);
94
+ return false;
95
+ }
96
+ return true;
97
+ }
98
+ _writeAttribute(key, value) {
99
+ if ((0, index_js_namespaceObject.isNullish)(value)) {
100
+ if (key in this._attributes && !this._autoKeys.has(key)) this._userAttributeCount--;
101
+ delete this._attributes[key];
102
+ return;
103
+ }
104
+ if (!this._autoKeys.has(key) && !(key in this._attributes)) {
105
+ if (this._userAttributeCount >= this._maxAttributes) return void this._droppedAttributes++;
106
+ this._userAttributeCount++;
107
+ }
108
+ this._attributes[key] = truncateAttributeValue(value, this._maxAttributeValueLength);
109
+ }
110
+ setAttribute(key, value) {
111
+ if (this._mutable('setAttribute')) this._writeAttribute(key, value);
112
+ return this;
113
+ }
114
+ setAttributes(attributes) {
115
+ if (this._mutable('setAttributes')) {
116
+ const safe = (0, json_utils_js_namespaceObject.assignUserAttributes)({}, attributes);
117
+ for (const key of Object.keys(safe))this._writeAttribute(key, safe[key]);
118
+ }
119
+ return this;
120
+ }
121
+ addEvent(name, attributes, timestamp) {
122
+ if (this._mutable('addEvent')) {
123
+ if (this._userEventCount >= this._maxEvents) {
124
+ this._droppedEvents++;
125
+ return this;
126
+ }
127
+ this._userEventCount++;
128
+ const bounded = attributes && boundAttributes(attributes, this._maxAttributesPerEvent, this._maxAttributeValueLength);
129
+ this._events.push({
130
+ name: (0, external_sanitize_js_namespaceObject.sanitizeName)(name, 'Span event name', this._maxAttributeValueLength, this._logger),
131
+ timestamp: (0, external_sanitize_js_namespaceObject.resolveSuppliedTime)(timestamp, this._now(), 'event timestamp', this._logger),
132
+ ...bounded && {
133
+ attributes: bounded.attributes,
134
+ ...bounded.dropped && {
135
+ droppedAttributesCount: bounded.dropped
136
+ }
137
+ }
138
+ });
139
+ }
140
+ return this;
141
+ }
142
+ setStatus(status, message) {
143
+ if (this._mutable('setStatus')) {
144
+ if ('ok' !== status && 'error' !== status) {
145
+ this._logger?.debug(`Ignoring unknown span status "${String(status)}"; expected "ok" or "error"`);
146
+ return this;
147
+ }
148
+ this._status = {
149
+ code: status,
150
+ ...message && {
151
+ message: truncateString(message, this._maxAttributeValueLength)
152
+ }
153
+ };
154
+ }
155
+ return this;
156
+ }
157
+ get statusIsExplicitlyOk() {
158
+ return this._status?.code === 'ok';
159
+ }
160
+ recordException(error) {
161
+ if (!this._mutable('recordException')) return this;
162
+ const { type, message, stack } = describeError(error);
163
+ this.addEvent(EXCEPTION_EVENT_NAME, {
164
+ 'exception.type': type,
165
+ 'exception.message': message,
166
+ ...stack && {
167
+ 'exception.stacktrace': stack
168
+ }
169
+ });
170
+ return this.setStatus('error', message);
171
+ }
172
+ updateName(name) {
173
+ if (this._mutable('updateName')) this._name = (0, external_sanitize_js_namespaceObject.sanitizeName)(name, 'Span name', this._maxAttributeValueLength, this._logger);
174
+ return this;
175
+ }
176
+ traceparent() {
177
+ return (0, external_traceparent_js_namespaceObject.formatTraceparent)(this._traceId, this._spanId, this._traceFlags);
178
+ }
179
+ tracestate() {
180
+ return this._traceState ?? null;
181
+ }
182
+ childContext() {
183
+ return {
184
+ traceId: this._traceId,
185
+ parentSpanId: this._spanId,
186
+ traceState: this._traceState,
187
+ traceFlags: this._traceFlags,
188
+ clockAnchor: this._clockAnchor
189
+ };
190
+ }
191
+ end(endTime) {
192
+ if (this._ended) return void this._logger?.debug('Ignoring end() on a span that has already ended');
193
+ this._ended = true;
194
+ const derived = this._now();
195
+ const resolved = (0, external_sanitize_js_namespaceObject.resolveSuppliedTime)(endTime, derived, 'end time', this._logger);
196
+ this._onEnd({
197
+ traceId: this._traceId,
198
+ spanId: this._spanId,
199
+ ...this._parentSpanId && {
200
+ parentSpanId: this._parentSpanId
201
+ },
202
+ ...this._traceState && {
203
+ traceState: this._traceState
204
+ },
205
+ traceFlags: this._traceFlags,
206
+ parentIsRemote: this._parentIsRemote,
207
+ name: this._name,
208
+ kind: this._kind,
209
+ ...this._status && {
210
+ status: this._status
211
+ },
212
+ attributes: {
213
+ ...this._attributes
214
+ },
215
+ events: this._events,
216
+ startTime: this._startTime,
217
+ endTime: (0, external_sanitize_js_namespaceObject.clampEndTime)(resolved, this._startTime),
218
+ ...this._droppedAttributes && {
219
+ droppedAttributesCount: this._droppedAttributes
220
+ },
221
+ ...this._droppedEvents && {
222
+ droppedEventsCount: this._droppedEvents
223
+ }
224
+ }, this._autoKeys);
225
+ }
226
+ }
227
+ const EXCEPTION_EVENT_NAME = 'exception';
228
+ const MAX_UINT32 = 0xffffffff;
229
+ function safeString(value) {
230
+ try {
231
+ return 'string' == typeof value ? value : String(value);
232
+ } catch {
233
+ return json_utils_js_namespaceObject.UNSERIALIZABLE_VALUE;
234
+ }
235
+ }
236
+ function nonNegativeCount(value) {
237
+ if ('number' != typeof value || !Number.isFinite(value) || value <= 0) return 0;
238
+ return Math.min(Math.floor(value), MAX_UINT32);
239
+ }
240
+ function orderedKeys(attributes, keysBeforeHook) {
241
+ if (!keysBeforeHook.length) return Object.keys(attributes);
242
+ const beforeHook = keysBeforeHook.filter((key)=>Object.prototype.propertyIsEnumerable.call(attributes, key));
243
+ const seen = new Set(beforeHook);
244
+ return [
245
+ ...beforeHook,
246
+ ...Object.keys(attributes).filter((key)=>!seen.has(key))
247
+ ];
248
+ }
249
+ function applySpanLimits(record, autoKeys, maxAttributes, maxEvents, maxAttributesPerEvent, maxAttributeValueLength, keysBeforeHook = []) {
250
+ let kept = 0;
251
+ let droppedAttributes = 0;
252
+ const attributes = {};
253
+ for (const key of orderedKeys(record.attributes, keysBeforeHook)){
254
+ const value = record.attributes[key];
255
+ if (!(0, index_js_namespaceObject.isNullish)(value)) {
256
+ if (!autoKeys.has(key)) {
257
+ if (kept >= maxAttributes) {
258
+ droppedAttributes++;
259
+ continue;
260
+ }
261
+ kept++;
262
+ }
263
+ Object.defineProperty(attributes, key, {
264
+ value: truncateAttributeValue(value, maxAttributeValueLength),
265
+ enumerable: true,
266
+ writable: true,
267
+ configurable: true
268
+ });
269
+ }
270
+ }
271
+ record.attributes = attributes;
272
+ if (droppedAttributes) record.droppedAttributesCount = nonNegativeCount(record.droppedAttributesCount) + droppedAttributes;
273
+ let keptEvents = 0;
274
+ let droppedEvents = 0;
275
+ const events = [];
276
+ for (const event of record.events){
277
+ if (keptEvents >= maxEvents) {
278
+ droppedEvents++;
279
+ continue;
280
+ }
281
+ keptEvents++;
282
+ if (event.attributes) {
283
+ const bounded = boundAttributes(event.attributes, maxAttributesPerEvent, maxAttributeValueLength);
284
+ event.attributes = bounded.attributes;
285
+ if (bounded.dropped) event.droppedAttributesCount = nonNegativeCount(event.droppedAttributesCount) + bounded.dropped;
286
+ }
287
+ events.push(event);
288
+ }
289
+ record.events = events;
290
+ if (droppedEvents) record.droppedEventsCount = nonNegativeCount(record.droppedEventsCount) + droppedEvents;
291
+ if (record.status?.message) record.status = {
292
+ ...record.status,
293
+ message: truncateString(safeString(record.status.message), maxAttributeValueLength)
294
+ };
295
+ }
296
+ class NoopSpan {
297
+ setAttribute() {
298
+ return this;
299
+ }
300
+ setAttributes() {
301
+ return this;
302
+ }
303
+ addEvent() {
304
+ return this;
305
+ }
306
+ setStatus() {
307
+ return this;
308
+ }
309
+ recordException() {
310
+ return this;
311
+ }
312
+ updateName() {
313
+ return this;
314
+ }
315
+ traceparent() {
316
+ return null;
317
+ }
318
+ tracestate() {
319
+ return null;
320
+ }
321
+ end() {}
322
+ }
323
+ const NOOP_SPAN = /* @__PURE__ */ new NoopSpan();
324
+ class PassThroughSpan extends NoopSpan {
325
+ constructor(_traceparent, _tracestate){
326
+ super(), this._traceparent = _traceparent, this._tracestate = _tracestate;
327
+ }
328
+ traceparent() {
329
+ return this._traceparent;
330
+ }
331
+ tracestate() {
332
+ return this._tracestate ?? null;
333
+ }
334
+ }
335
+ function readStack(error) {
336
+ try {
337
+ const stack = error.stack;
338
+ return 'string' == typeof stack && stack ? {
339
+ stack
340
+ } : {};
341
+ } catch {
342
+ return {};
343
+ }
344
+ }
345
+ function inertSpan(options, active) {
346
+ const parent = (0, external_traceparent_js_namespaceObject.traceparentHeader)(options?.parent) ?? active;
347
+ const inbound = 'string' == typeof parent || null == parent ? parent : readHandle(parent, 'traceparent');
348
+ const traceparent = (0, external_traceparent_js_namespaceObject.normalizeTraceparent)(inbound);
349
+ if (!traceparent) return NOOP_SPAN;
350
+ const tracestate = 'string' == typeof parent || null == parent ? options?.tracestate : readHandle(parent, 'tracestate');
351
+ return new PassThroughSpan(traceparent, (0, external_traceparent_js_namespaceObject.sanitizeTracestate)(tracestate));
352
+ }
353
+ function readHandle(parent, method) {
354
+ try {
355
+ const fn = parent[method];
356
+ return 'function' == typeof fn ? fn.call(parent) : void 0;
357
+ } catch {
358
+ return;
359
+ }
360
+ }
361
+ function truncateString(value, maxLength) {
362
+ return value.length > maxLength ? value.slice(0, maxLength) : value;
363
+ }
364
+ function truncateAttributeValue(value, maxLength) {
365
+ return truncateValue(value, maxLength, {
366
+ ancestors: new WeakSet(),
367
+ remainingNodes: json_utils_js_namespaceObject.MAX_JSON_SAFE_VALUE_NODES
368
+ }, 0);
369
+ }
370
+ function truncateValue(value, maxLength, state, depth) {
371
+ if (null === value || 'object' != typeof value) {
372
+ if ((0, index_js_namespaceObject.isNullish)(value)) return value;
373
+ if (state.remainingNodes <= 0) return value;
374
+ state.remainingNodes--;
375
+ return 'string' == typeof value ? truncateString(value, maxLength) : value;
376
+ }
377
+ if (state.ancestors.has(value)) return json_utils_js_namespaceObject.CIRCULAR_VALUE;
378
+ if (state.remainingNodes <= 0 || depth >= json_utils_js_namespaceObject.MAX_JSON_SAFE_VALUE_DEPTH) return value;
379
+ state.remainingNodes--;
380
+ state.ancestors.add(value);
381
+ try {
382
+ if (value instanceof Date) return value;
383
+ const resolved = resolveToJson(value);
384
+ if (resolved.selfDescribed) return (0, index_js_namespaceObject.isNullish)(resolved.value) ? String(resolved.value) : truncateValue(resolved.value, maxLength, state, depth + 1);
385
+ if ((0, index_js_namespaceObject.isArray)(value)) {
386
+ const walked = Math.min(value.length, json_utils_js_namespaceObject.MAX_JSON_SAFE_VALUE_ITEMS);
387
+ const boundedItems = [];
388
+ for(let index = 0; index < walked; index++)try {
389
+ boundedItems.push(truncateValue(value[index], maxLength, state, depth + 1));
390
+ } catch {
391
+ boundedItems.push(json_utils_js_namespaceObject.UNSERIALIZABLE_VALUE);
392
+ }
393
+ if (value.length > walked) boundedItems.length = value.length;
394
+ return boundedItems;
395
+ }
396
+ const bounded = {};
397
+ let emittable = 0;
398
+ for (const key of Object.keys(value)){
399
+ if (emittable >= json_utils_js_namespaceObject.MAX_JSON_SAFE_VALUE_ITEMS) break;
400
+ let boundedItem;
401
+ try {
402
+ boundedItem = truncateValue(value[key], maxLength, state, depth + 1);
403
+ } catch {
404
+ boundedItem = json_utils_js_namespaceObject.UNSERIALIZABLE_VALUE;
405
+ }
406
+ if (key && !(0, index_js_namespaceObject.isNullish)(boundedItem)) emittable++;
407
+ Object.defineProperty(bounded, key, {
408
+ value: boundedItem,
409
+ enumerable: true,
410
+ writable: true,
411
+ configurable: true
412
+ });
413
+ }
414
+ return bounded;
415
+ } catch {
416
+ return value;
417
+ } finally{
418
+ state.ancestors.delete(value);
419
+ }
420
+ }
421
+ function resolveToJson(value) {
422
+ try {
423
+ const toJSON = value.toJSON;
424
+ if ('function' == typeof toJSON) return {
425
+ selfDescribed: true,
426
+ value: toJSON.call(value)
427
+ };
428
+ } catch {}
429
+ return {
430
+ selfDescribed: false
431
+ };
432
+ }
433
+ function boundAttributes(source, max, maxLength) {
434
+ let keys;
435
+ try {
436
+ keys = Object.keys(source);
437
+ } catch {
438
+ return {
439
+ attributes: {},
440
+ dropped: 0
441
+ };
442
+ }
443
+ const attributes = {};
444
+ let kept = 0;
445
+ let dropped = 0;
446
+ for (const key of keys){
447
+ if (kept >= max) {
448
+ dropped++;
449
+ continue;
450
+ }
451
+ let value;
452
+ try {
453
+ value = truncateAttributeValue(source[key], maxLength);
454
+ } catch {
455
+ value = json_utils_js_namespaceObject.UNSERIALIZABLE_VALUE;
456
+ }
457
+ if (!(0, index_js_namespaceObject.isNullish)(value)) {
458
+ kept++;
459
+ Object.defineProperty(attributes, key, {
460
+ value,
461
+ enumerable: true,
462
+ writable: true,
463
+ configurable: true
464
+ });
465
+ }
466
+ }
467
+ return {
468
+ attributes,
469
+ dropped
470
+ };
471
+ }
472
+ function truncateAttributes(attributes, maxLength) {
473
+ for (const key of Object.keys(attributes))attributes[key] = truncateAttributeValue(attributes[key], maxLength);
474
+ return attributes;
475
+ }
476
+ function runWithActiveSpan(contextManager, span, fn) {
477
+ return span === NOOP_SPAN ? fn(span) : contextManager.with(span, ()=>fn(span));
478
+ }
479
+ function describeError(error) {
480
+ try {
481
+ const stack = readStack(error);
482
+ if ((0, index_js_namespaceObject.isError)(error)) return {
483
+ type: error.name || 'Error',
484
+ message: error.message || '',
485
+ ...stack
486
+ };
487
+ if ('string' == typeof error) return {
488
+ type: 'string',
489
+ message: error
490
+ };
491
+ if (error && 'object' == typeof error) {
492
+ const maybe = error;
493
+ if ('string' == typeof maybe.message) return {
494
+ type: 'string' == typeof maybe.name ? maybe.name : 'Object',
495
+ message: maybe.message,
496
+ ...stack
497
+ };
498
+ }
499
+ return {
500
+ type: typeof error,
501
+ message: String(error)
502
+ };
503
+ } catch {
504
+ return {
505
+ type: typeof error,
506
+ message: ''
507
+ };
508
+ }
509
+ }
510
+ exports.NOOP_SPAN = __webpack_exports__.NOOP_SPAN;
511
+ exports.NoopSpan = __webpack_exports__.NoopSpan;
512
+ exports.PassThroughSpan = __webpack_exports__.PassThroughSpan;
513
+ exports.PostHogSpan = __webpack_exports__.PostHogSpan;
514
+ exports.applySpanLimits = __webpack_exports__.applySpanLimits;
515
+ exports.describeError = __webpack_exports__.describeError;
516
+ exports.inertSpan = __webpack_exports__.inertSpan;
517
+ exports.monotonicNow = __webpack_exports__.monotonicNow;
518
+ exports.nonNegativeCount = __webpack_exports__.nonNegativeCount;
519
+ exports.runWithActiveSpan = __webpack_exports__.runWithActiveSpan;
520
+ exports.truncateAttributeValue = __webpack_exports__.truncateAttributeValue;
521
+ exports.truncateAttributes = __webpack_exports__.truncateAttributes;
522
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
523
+ "NOOP_SPAN",
524
+ "NoopSpan",
525
+ "PassThroughSpan",
526
+ "PostHogSpan",
527
+ "applySpanLimits",
528
+ "describeError",
529
+ "inertSpan",
530
+ "monotonicNow",
531
+ "nonNegativeCount",
532
+ "runWithActiveSpan",
533
+ "truncateAttributeValue",
534
+ "truncateAttributes"
535
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
536
+ Object.defineProperty(exports, '__esModule', {
537
+ value: true
538
+ });