autotel 6.4.1 → 7.0.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.
Files changed (166) hide show
  1. package/README.md +30 -23
  2. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.cts → attribute-redacting-processor-CvBE0z1p.d.cts} +33 -1
  3. package/dist/{attribute-redacting-processor-Pk7lAzWd.d.ts → attribute-redacting-processor-CvBE0z1p.d.ts} +33 -1
  4. package/dist/attribute-redacting-processor.cjs +34 -32
  5. package/dist/attribute-redacting-processor.d.cts +1 -1
  6. package/dist/attribute-redacting-processor.d.ts +1 -1
  7. package/dist/attribute-redacting-processor.js +35 -32
  8. package/dist/{attributes-aDmJYral.cjs → attributes-Cxys8tgr.cjs} +34 -35
  9. package/dist/{attributes-B7wix2VG.js → attributes-Dt4YUYbP.js} +34 -35
  10. package/dist/attributes.cjs +1 -1
  11. package/dist/attributes.d.cts +1 -1
  12. package/dist/attributes.d.ts +1 -1
  13. package/dist/attributes.js +1 -1
  14. package/dist/auto.cjs +1 -1
  15. package/dist/auto.js +1 -1
  16. package/dist/business-baggage.cjs +19 -12
  17. package/dist/business-baggage.d.cts +8 -3
  18. package/dist/business-baggage.d.ts +8 -3
  19. package/dist/business-baggage.js +19 -12
  20. package/dist/{canonical-log-line-processor-DxtBGZIi.cjs → canonical-log-line-processor-DolzdawH.cjs} +43 -32
  21. package/dist/{canonical-log-line-processor-B4WgG-VS.d.cts → canonical-log-line-processor-cPB4Axk-.d.ts} +4 -3
  22. package/dist/{canonical-log-line-processor-B0vq_QR6.js → canonical-log-line-processor-hFUmS__K.js} +43 -32
  23. package/dist/{canonical-log-line-processor-CL_J7gb5.d.ts → canonical-log-line-processor-l0Aqe6yp.d.cts} +4 -3
  24. package/dist/config.d.cts +1 -1
  25. package/dist/config.d.ts +1 -1
  26. package/dist/{correlated-events-kSwLo3mi.cjs → correlated-events-CcuknWnU.cjs} +2 -1
  27. package/dist/{correlated-events-Bzh5y-UB.js → correlated-events-DwMMbItg.js} +3 -1
  28. package/dist/correlation-id.cjs +1 -1
  29. package/dist/correlation-id.js +1 -1
  30. package/dist/db.cjs +34 -19
  31. package/dist/db.js +34 -19
  32. package/dist/decorators.cjs +4 -2
  33. package/dist/decorators.d.cts +16 -11
  34. package/dist/decorators.d.ts +16 -11
  35. package/dist/decorators.js +4 -2
  36. package/dist/{define-event-CGG048HE.d.cts → define-event-BNeuKUPv.d.cts} +1 -1
  37. package/dist/{define-event-B2z1SBe7.d.ts → define-event-Bd8f8mST.d.ts} +1 -1
  38. package/dist/diagnostics.cjs +18 -16
  39. package/dist/diagnostics.d.cts +14 -10
  40. package/dist/diagnostics.d.ts +14 -10
  41. package/dist/diagnostics.js +18 -16
  42. package/dist/{event-subscriber-CWh8sTGh.d.cts → event-subscriber-DMACQA-1.d.cts} +19 -9
  43. package/dist/{event-subscriber-CWh8sTGh.d.ts → event-subscriber-DMACQA-1.d.ts} +19 -9
  44. package/dist/event-subscriber.d.cts +2 -2
  45. package/dist/event-subscriber.d.ts +2 -2
  46. package/dist/{event-testing-D0qWfqAy.d.cts → event-testing-CBtnJXE5.d.cts} +1 -1
  47. package/dist/{event-testing-CA2mIx1E.d.ts → event-testing-CkPgV3Ii.d.ts} +1 -1
  48. package/dist/event-testing.d.cts +1 -1
  49. package/dist/event-testing.d.ts +1 -1
  50. package/dist/event.cjs +1 -1
  51. package/dist/event.d.cts +5 -5
  52. package/dist/event.d.ts +5 -5
  53. package/dist/event.js +1 -1
  54. package/dist/exception-fingerprint.cjs +133 -0
  55. package/dist/exception-fingerprint.d.cts +51 -0
  56. package/dist/exception-fingerprint.d.ts +51 -0
  57. package/dist/exception-fingerprint.js +126 -0
  58. package/dist/{functional-AT22vCw6.d.ts → functional-CJn2zY4o.d.cts} +96 -39
  59. package/dist/{functional-e6jw5zQj.d.cts → functional-DXy1cHFF.d.ts} +96 -39
  60. package/dist/{functional-qZxRcIBp.cjs → functional-Da6Yv64r.cjs} +27 -15
  61. package/dist/{functional-0o9xSedq.js → functional-uSbNnnxK.js} +27 -15
  62. package/dist/functional.cjs +1 -1
  63. package/dist/functional.d.cts +2 -2
  64. package/dist/functional.d.ts +2 -2
  65. package/dist/functional.js +1 -1
  66. package/dist/http.cjs +11 -8
  67. package/dist/http.js +11 -8
  68. package/dist/{index-DolOVX6F.d.ts → index-CwrNAsgk.d.ts} +22 -26
  69. package/dist/{index-BPcxVucm.d.cts → index-DQHf4cNl.d.cts} +22 -26
  70. package/dist/index.cjs +41 -35
  71. package/dist/index.d.cts +45 -30
  72. package/dist/index.d.ts +45 -30
  73. package/dist/index.js +41 -35
  74. package/dist/{init-CsODvlau.d.ts → init-BgnYi2sm.d.ts} +94 -90
  75. package/dist/{init-BnxHAi2M.cjs → init-D4m5rCmD.cjs} +142 -123
  76. package/dist/{init-Cc7-vvzj.d.cts → init-DrlL1eis.d.cts} +94 -90
  77. package/dist/{init-BxfZ3Vbw.js → init-JtX-KKz_.js} +137 -124
  78. package/dist/instrumentation.cjs +2 -2
  79. package/dist/instrumentation.js +2 -2
  80. package/dist/{logger-D3Ej3DII.js → logger-DdPp__xW.js} +63 -54
  81. package/dist/{logger-CN4xpzMd.d.cts → logger-S1Fgl0g3.d.cts} +0 -20
  82. package/dist/{logger-CN4xpzMd.d.ts → logger-S1Fgl0g3.d.ts} +0 -20
  83. package/dist/{logger-thMPLpOG.cjs → logger-Sm66cjKl.cjs} +63 -54
  84. package/dist/logger.cjs +1 -1
  85. package/dist/logger.d.cts +1 -1
  86. package/dist/logger.d.ts +1 -1
  87. package/dist/logger.js +1 -1
  88. package/dist/messaging-adapters.cjs +26 -12
  89. package/dist/messaging-adapters.d.cts +0 -30
  90. package/dist/messaging-adapters.d.ts +0 -30
  91. package/dist/messaging-adapters.js +26 -12
  92. package/dist/messaging.cjs +37 -34
  93. package/dist/messaging.d.cts +21 -62
  94. package/dist/messaging.d.ts +21 -62
  95. package/dist/messaging.js +37 -34
  96. package/dist/{metric-testing-CpvP3ZIa.d.cts → metric-testing-86WO1wan.d.cts} +1 -1
  97. package/dist/{metric-testing-CWm6UhaR.d.ts → metric-testing-CbCxdPBp.d.ts} +1 -1
  98. package/dist/metric-testing.d.cts +1 -1
  99. package/dist/metric-testing.d.ts +1 -1
  100. package/dist/metric.d.cts +3 -3
  101. package/dist/metric.d.ts +3 -3
  102. package/dist/{node-require-vROmTeJ8.js → node-require-DSPjaw_l.js} +3 -2
  103. package/dist/{node-require-PFqDihze.cjs → node-require-EifOMikz.cjs} +3 -2
  104. package/dist/parse-error.cjs +18 -12
  105. package/dist/parse-error.d.cts +2 -1
  106. package/dist/parse-error.d.ts +2 -1
  107. package/dist/parse-error.js +19 -12
  108. package/dist/policy.cjs +0 -0
  109. package/dist/policy.js +0 -0
  110. package/dist/processors.cjs +1 -1
  111. package/dist/processors.d.cts +1 -1
  112. package/dist/processors.d.ts +1 -1
  113. package/dist/processors.js +1 -1
  114. package/dist/{sampling-BR9fkSwx.d.cts → sampling-CM5S2Lp3.d.ts} +5 -6
  115. package/dist/{sampling-CP3e7-Yr.d.ts → sampling-CmRdnXUi.d.cts} +5 -6
  116. package/dist/sampling.cjs +3 -2
  117. package/dist/sampling.d.cts +1 -1
  118. package/dist/sampling.d.ts +1 -1
  119. package/dist/sampling.js +3 -2
  120. package/dist/semantic-helpers.cjs +9 -9
  121. package/dist/semantic-helpers.d.cts +1 -1
  122. package/dist/semantic-helpers.d.ts +1 -1
  123. package/dist/semantic-helpers.js +9 -9
  124. package/dist/{stable-hash-ChFBIhNt.js → stable-hash-BkoAYVks.js} +4 -3
  125. package/dist/{stable-hash-CS9BxvVQ.cjs → stable-hash-C0pOegH_.cjs} +4 -3
  126. package/dist/{structured-error-CHg7DoIQ.cjs → structured-error--_wXpd_C.cjs} +34 -25
  127. package/dist/{structured-error-9--cxBay.js → structured-error-YIuka-FE.js} +34 -25
  128. package/dist/test-span-collector.cjs +15 -8
  129. package/dist/test-span-collector.js +15 -8
  130. package/dist/testing.cjs +16 -18
  131. package/dist/testing.d.cts +7 -6
  132. package/dist/testing.d.ts +7 -6
  133. package/dist/testing.js +16 -18
  134. package/dist/{trace-context-IuyoPyNq.d.cts → trace-context-C1Cn1q0y.d.cts} +8 -7
  135. package/dist/{trace-context-IuyoPyNq.d.ts → trace-context-f89xPJbK.d.ts} +8 -7
  136. package/dist/trace-helpers.cjs +16 -13
  137. package/dist/trace-helpers.d.cts +9 -4
  138. package/dist/trace-helpers.d.ts +9 -4
  139. package/dist/trace-helpers.js +16 -13
  140. package/dist/tracer-provider.cjs +8 -12
  141. package/dist/tracer-provider.js +8 -12
  142. package/dist/validate.cjs +22 -20
  143. package/dist/validate.d.cts +3 -2
  144. package/dist/validate.d.ts +3 -2
  145. package/dist/validate.js +22 -20
  146. package/dist/values-BenyvWKz.js +141 -0
  147. package/dist/values-CeMH-mYG.d.cts +8 -0
  148. package/dist/values-CeMH-mYG.d.ts +8 -0
  149. package/dist/values-DApyq53y.cjs +267 -0
  150. package/dist/webhook.cjs +3 -3
  151. package/dist/webhook.d.cts +1 -1
  152. package/dist/webhook.d.ts +1 -1
  153. package/dist/webhook.js +3 -3
  154. package/dist/workflow-distributed.cjs +9 -7
  155. package/dist/workflow-distributed.d.cts +9 -8
  156. package/dist/workflow-distributed.d.ts +9 -8
  157. package/dist/workflow-distributed.js +9 -7
  158. package/dist/workflow.cjs +26 -17
  159. package/dist/workflow.d.cts +1 -28
  160. package/dist/workflow.d.ts +1 -28
  161. package/dist/workflow.js +26 -17
  162. package/dist/yaml-config.cjs +26 -11
  163. package/dist/yaml-config.d.cts +9 -3
  164. package/dist/yaml-config.d.ts +9 -3
  165. package/dist/yaml-config.js +26 -11
  166. package/package.json +6 -1
@@ -1,7 +1,8 @@
1
+ import { _ as readProperty, f as describeValue, h as isFunction, i as asNumber, l as asString, r as asFunction, s as asRecord, t as asBoolean } from "./values-BenyvWKz.js";
1
2
  import { getForceFlushableProvider } from "./tracer-provider.js";
2
3
  import { getConfig as getConfig$1 } from "./config.js";
3
4
  import { AUTOTEL_SAMPLING_RATE, resolveSamplingPreset, samplingPresets } from "./sampling.js";
4
- import { n as safeRequire, t as requireModule } from "./node-require-vROmTeJ8.js";
5
+ import { n as safeRequire, t as requireModule } from "./node-require-DSPjaw_l.js";
5
6
  import { TailSamplingSpanProcessor } from "./tail-sampling-processor.js";
6
7
  import { FilteringSpanProcessor } from "./filtering-span-processor.js";
7
8
  import { PolicyLogRecordProcessor, policySpanFilter, setPolicies, watchPolicyFile } from "./policy.js";
@@ -9,8 +10,8 @@ import { SpanNameNormalizingProcessor } from "./span-name-normalizer.js";
9
10
  import { AttributeRedactingProcessor, REDACTOR_PRESETS, normalizeAttributeRedactorConfig } from "./attribute-redacting-processor.js";
10
11
  import { t as PrettyConsoleExporter } from "./pretty-console-exporter-DqKl_q9z.js";
11
12
  import { loadYamlConfig } from "./yaml-config.js";
12
- import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-B0vq_QR6.js";
13
- import { r as recordStructuredError } from "./structured-error-9--cxBay.js";
13
+ import { t as CanonicalLogLineProcessor } from "./canonical-log-line-processor-hFUmS__K.js";
14
+ import { r as recordStructuredError } from "./structured-error-YIuka-FE.js";
14
15
  import { resetMetrics } from "./metric.js";
15
16
  import { NodeSDK } from "@opentelemetry/sdk-node";
16
17
  import { AlwaysOffSampler, AlwaysOnSampler, BatchSpanProcessor, ConsoleSpanExporter, ParentBasedSampler, SamplingDecision, SimpleSpanProcessor, TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
@@ -25,6 +26,37 @@ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
25
26
  import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
26
27
  import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
27
28
 
29
+ //#region src/init-logger.ts
30
+ const LOG_LEVELS = {
31
+ debug: 0,
32
+ info: 1,
33
+ warn: 2,
34
+ error: 3
35
+ };
36
+ /** Silent logger used until and unless the application opts into diagnostics. */
37
+ const silentLogger = {
38
+ info: () => {},
39
+ warn: () => {},
40
+ error: () => {},
41
+ debug: () => {}
42
+ };
43
+ /** Apply the resolved silence and minimum-level settings to a logger. */
44
+ function wrapLogger(base, silent, minLevel) {
45
+ if (silent) return silentLogger;
46
+ const threshold = LOG_LEVELS[minLevel];
47
+ const wrap = (fn, level) => {
48
+ if (LOG_LEVELS[level] < threshold) return (() => {});
49
+ return ((...args) => fn(...args));
50
+ };
51
+ return {
52
+ debug: wrap(base.debug, "debug"),
53
+ info: wrap(base.info, "info"),
54
+ warn: wrap(base.warn, "warn"),
55
+ error: wrap(base.error, "error")
56
+ };
57
+ }
58
+
59
+ //#endregion
28
60
  //#region src/posthog-logs.ts
29
61
  var RedactingLogRecordProcessor = class {
30
62
  wrapped;
@@ -34,10 +66,15 @@ var RedactingLogRecordProcessor = class {
34
66
  this.redact = redact;
35
67
  }
36
68
  onEmit(logRecord, context) {
37
- if (logRecord.body && typeof logRecord.body === "string") logRecord.body = this.redact(logRecord.body);
38
- if (logRecord.attributes) {
39
- for (const [key, value] of Object.entries(logRecord.attributes)) if (typeof value === "string") logRecord.attributes[key] = this.redact(value);
40
- else if (Array.isArray(value)) logRecord.attributes[key] = value.map((item) => typeof item === "string" ? this.redact(item) : item);
69
+ const body = asString(logRecord.body);
70
+ if (body) logRecord.body = this.redact(body);
71
+ if (logRecord.attributes) for (const [key, value] of Object.entries(logRecord.attributes)) {
72
+ const text = asString(value);
73
+ if (text !== void 0) logRecord.attributes[key] = this.redact(text);
74
+ else if (Array.isArray(value)) logRecord.attributes[key] = value.map((item) => {
75
+ const entry = asString(item);
76
+ return entry === void 0 ? item : this.redact(entry);
77
+ });
41
78
  }
42
79
  this.wrapped.onEmit(logRecord, context);
43
80
  }
@@ -533,6 +570,11 @@ var TokenBucketRateLimiter = class {
533
570
 
534
571
  //#endregion
535
572
  //#region src/trace-context.ts
573
+ const spansWithExplicitStatus = /* @__PURE__ */ new WeakSet();
574
+ /** Whether a TraceContext consumer explicitly chose this span's status. */
575
+ function hasExplicitSpanStatus(span) {
576
+ return spansWithExplicitStatus.has(span);
577
+ }
536
578
  /**
537
579
  * AsyncLocalStorage for storing the active context with baggage
538
580
  * This allows setters to update the context and have it persist
@@ -586,7 +628,7 @@ function updateActiveContext(newContext) {
586
628
  asyncLocal.enterWith(newContext);
587
629
  return;
588
630
  }
589
- if (typeof manager.with === "function") manager.with(newContext, () => {});
631
+ if (isFunction(manager.with)) manager.with(newContext, () => {});
590
632
  }
591
633
  /**
592
634
  * Create a TraceContext from an OpenTelemetry Span
@@ -609,15 +651,18 @@ function createTraceContext(span) {
609
651
  correlationId: spanContext.traceId.slice(0, 16),
610
652
  setAttribute: span.setAttribute.bind(span),
611
653
  setAttributes: span.setAttributes.bind(span),
612
- setStatus: span.setStatus.bind(span),
654
+ setStatus: (status) => {
655
+ spansWithExplicitStatus.add(span);
656
+ span.setStatus(status);
657
+ },
613
658
  recordException: span.recordException.bind(span),
614
659
  addEvent: span.addEvent.bind(span),
615
660
  addLink: span.addLink.bind(span),
616
661
  addLinks: span.addLinks.bind(span),
617
662
  updateName: span.updateName.bind(span),
618
663
  isRecording: span.isRecording.bind(span),
619
- recordError: (error) => {
620
- const err = error instanceof Error ? error : new Error(String(error));
664
+ recordError: (cause) => {
665
+ const err = cause instanceof Error ? cause : new Error(String(cause));
621
666
  recordStructuredError(traceCtx, err);
622
667
  },
623
668
  track: (event, data) => {
@@ -667,12 +712,11 @@ function createTraceContext(span) {
667
712
  }
668
713
  if (!baggage) return;
669
714
  const prefix = namespace ? `${namespace}.` : "";
670
- const result = {};
671
- for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix)) {
672
- const fieldName = key.slice(prefix.length);
673
- result[fieldName] = entry.value;
674
- } else if (!namespace) result[key] = entry.value;
675
- return Object.keys(result).length > 0 ? result : void 0;
715
+ const entries = [];
716
+ for (const [key, entry] of baggage.getAllEntries()) if (namespace && key.startsWith(prefix)) entries.push([key.slice(prefix.length), entry.value]);
717
+ else if (!namespace) entries.push([key, entry.value]);
718
+ const result = Object.fromEntries(entries);
719
+ return entries.length > 0 ? result : void 0;
676
720
  }),
677
721
  setTypedBaggage: ((namespace, value) => {
678
722
  const currentContext = getActiveContextWithBaggage();
@@ -1378,7 +1422,7 @@ var ValidationError = class extends Error {
1378
1422
  * Throws ValidationError if invalid
1379
1423
  */
1380
1424
  function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
1381
- if (typeof eventName !== "string") throw new ValidationError(`Event name must be a string, got ${typeof eventName}`);
1425
+ if (asString(eventName) === void 0) throw new ValidationError(`Event name must be a string, got ${describeValue(eventName)}`);
1382
1426
  const trimmed = eventName.trim();
1383
1427
  if (trimmed.length === 0) throw new ValidationError("Event name cannot be empty");
1384
1428
  if (trimmed.length > config.maxEventNameLength) throw new ValidationError(`Event name too long (${trimmed.length} chars). Max: ${config.maxEventNameLength}`);
@@ -1391,14 +1435,14 @@ function validateEventName(eventName, config = DEFAULT_CONFIG$1) {
1391
1435
  */
1392
1436
  function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
1393
1437
  if (attributes === void 0 || attributes === null) return;
1394
- if (typeof attributes !== "object" || Array.isArray(attributes)) throw new ValidationError("Attributes must be an object");
1438
+ if (!asRecord(attributes)) throw new ValidationError("Attributes must be an object");
1395
1439
  const keys = Object.keys(attributes);
1396
1440
  if (keys.length > config.maxAttributeCount) throw new ValidationError(`Too many attributes (${keys.length}). Max: ${config.maxAttributeCount}`);
1397
1441
  const sanitized = {};
1398
1442
  for (const key of keys) {
1399
1443
  if (key.length > config.maxAttributeKeyLength) throw new ValidationError(`Attribute key too long: "${key.slice(0, 20)}..." (${key.length} chars). Max: ${config.maxAttributeKeyLength}`);
1400
1444
  const value = attributes[key];
1401
- if (typeof value === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key))) {
1445
+ if (isSensitiveString(key, value, config)) {
1402
1446
  sanitized[key] = "[REDACTED]";
1403
1447
  continue;
1404
1448
  }
@@ -1407,29 +1451,35 @@ function validateAttributes(attributes, config = DEFAULT_CONFIG$1) {
1407
1451
  return sanitized;
1408
1452
  }
1409
1453
  /**
1454
+ * Whether this key/value pair is a credential to redact. Strings only:
1455
+ * numeric and boolean values are not credentials, and replacing them with the
1456
+ * literal '[REDACTED]' leaks no signal while breaking every consumer that
1457
+ * treats them as a number.
1458
+ */
1459
+ function isSensitiveString(key, value, config) {
1460
+ return asString(value) !== void 0 && config.sensitivePatterns.some((pattern) => pattern.test(key));
1461
+ }
1462
+ /**
1410
1463
  * Sanitize attribute value (recursive)
1411
1464
  */
1412
1465
  function sanitizeValue(value, config, depth) {
1413
1466
  if (depth > config.maxNestingDepth) return "[MAX_DEPTH_EXCEEDED]";
1414
1467
  if (value === null || value === void 0) return value;
1415
- if (typeof value === "string") {
1416
- if (value.length > config.maxAttributeValueLength) return value.slice(0, config.maxAttributeValueLength) + "...";
1417
- return value;
1418
- }
1419
- if (typeof value === "number" || typeof value === "boolean") return value;
1468
+ const text = asString(value);
1469
+ if (text !== void 0) return text.length > config.maxAttributeValueLength ? text.slice(0, config.maxAttributeValueLength) + "..." : text;
1470
+ const scalar = asNumber(value) ?? asBoolean(value);
1471
+ if (scalar !== void 0) return scalar;
1420
1472
  if (Array.isArray(value)) return value.map((item) => sanitizeValue(item, config, depth + 1));
1421
- if (typeof value === "object") try {
1422
- JSON.stringify(value);
1473
+ const record = asRecord(value);
1474
+ if (record) try {
1475
+ JSON.stringify(record);
1423
1476
  const sanitized = {};
1424
- for (const key in value) if (Object.prototype.hasOwnProperty.call(value, key)) {
1425
- const nested = value[key];
1426
- sanitized[key] = typeof nested === "string" && config.sensitivePatterns.some((pattern) => pattern.test(key)) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
1427
- }
1477
+ for (const [key, nested] of Object.entries(record)) sanitized[key] = isSensitiveString(key, nested, config) ? "[REDACTED]" : sanitizeValue(nested, config, depth + 1);
1428
1478
  return sanitized;
1429
1479
  } catch {
1430
1480
  return "[CIRCULAR]";
1431
1481
  }
1432
- return `[${typeof value}]`;
1482
+ return `[${describeValue(value)}]`;
1433
1483
  }
1434
1484
  /**
1435
1485
  * Validate and sanitize an events event
@@ -1790,7 +1840,7 @@ function hashValue(value) {
1790
1840
  * @example Recommended: Configure subscribers in init(), use track() function
1791
1841
  * ```typescript
1792
1842
  * import { init, track } from 'autotel';
1793
- * import { PostHogSubscriber } from 'autotel-subscribers/posthog';
1843
+ * import { PostHogSubscriber } from 'autotel-posthog/subscriber';
1794
1844
  *
1795
1845
  * init({
1796
1846
  * service: 'my-app',
@@ -1813,7 +1863,7 @@ function hashValue(value) {
1813
1863
  * @example Override subscribers for specific Event instance
1814
1864
  * ```typescript
1815
1865
  * import { Event } from 'autotel/event';
1816
- * import { PostHogSubscriber } from 'autotel-subscribers/posthog';
1866
+ * import { PostHogSubscriber } from 'autotel-posthog/subscriber';
1817
1867
  *
1818
1868
  * // Override: use different subscribers for this instance
1819
1869
  * const event = new Event('job-application', {
@@ -1846,7 +1896,7 @@ var Event = class {
1846
1896
  * @example Recommended: Use track() with init()
1847
1897
  * ```typescript
1848
1898
  * import { init, track } from 'autotel';
1849
- * import { PostHogSubscriber } from 'autotel-subscribers/posthog';
1899
+ * import { PostHogSubscriber } from 'autotel-posthog/subscriber';
1850
1900
  *
1851
1901
  * init({
1852
1902
  * service: 'checkout',
@@ -1866,7 +1916,7 @@ var Event = class {
1866
1916
  * @example Override subscribers for this instance
1867
1917
  * ```typescript
1868
1918
  * import { Event } from 'autotel/event';
1869
- * import { PostHogSubscriber } from 'autotel-subscribers/posthog';
1919
+ * import { PostHogSubscriber } from 'autotel-posthog/subscriber';
1870
1920
  *
1871
1921
  * // Override: use different subscribers for this instance only
1872
1922
  * const event = new Event('checkout', {
@@ -1944,7 +1994,7 @@ var Event = class {
1944
1994
  if (traceState) {
1945
1995
  let traceStateStr = "";
1946
1996
  try {
1947
- if (typeof traceState.serialize === "function") traceStateStr = traceState.serialize();
1997
+ if (isFunction(traceState.serialize)) traceStateStr = traceState.serialize();
1948
1998
  } catch {}
1949
1999
  if (traceStateStr) autotelContext.trace_state = traceStateStr;
1950
2000
  }
@@ -1993,9 +2043,8 @@ var Event = class {
1993
2043
  const transform = enrichConfig.transform?.[key];
1994
2044
  let transformedValue;
1995
2045
  if (transform === "hash") transformedValue = hashValue(value);
1996
- else if (transform === "plain" || !transform) transformedValue = value;
1997
- else if (typeof transform === "function") transformedValue = transform(value);
1998
- else transformedValue = value;
2046
+ else if (transform === void 0 || transform === "plain") transformedValue = value;
2047
+ else transformedValue = transform(value);
1999
2048
  const valueBytes = new TextEncoder().encode(transformedValue).length;
2000
2049
  if (byteCount + valueBytes > maxBytes) continue;
2001
2050
  const enrichedKey = `${prefix}${key}`;
@@ -2318,14 +2367,16 @@ var Event = class {
2318
2367
  stepNumber,
2319
2368
  attributes: enrichedAttributes
2320
2369
  }, "Funnel progression tracked");
2370
+ const stepAttributes = {
2371
+ ...enrichedAttributes,
2372
+ step_name: stepName
2373
+ };
2374
+ if (stepNumber !== void 0) stepAttributes.step_number = stepNumber;
2375
+ const stepAsStatus = stepName;
2321
2376
  this.collector?.recordFunnelStep({
2322
2377
  funnel: funnelName,
2323
- status: stepName,
2324
- attributes: {
2325
- ...enrichedAttributes,
2326
- step_name: stepName,
2327
- ...stepNumber === void 0 ? {} : { step_number: stepNumber }
2328
- },
2378
+ status: stepAsStatus,
2379
+ attributes: stepAttributes,
2329
2380
  service: this.serviceName,
2330
2381
  timestamp: Date.now()
2331
2382
  });
@@ -2333,10 +2384,9 @@ var Event = class {
2333
2384
  const autotelContext = this.buildAutotelContext();
2334
2385
  const finalAttributes = this.enrichFromBaggage(enrichedAttributes);
2335
2386
  this.notifySubscribers(async (subscriber) => {
2336
- await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName, stepName, {
2387
+ await (subscriber.trackFunnelProgression ? subscriber.trackFunnelProgression(funnelName, stepName, stepNumber, finalAttributes, { autotel: autotelContext }) : subscriber.trackFunnelStep(funnelName, stepAsStatus, {
2337
2388
  ...finalAttributes,
2338
- step_name: stepName,
2339
- ...stepNumber === void 0 ? {} : { step_number: stepNumber }
2389
+ ...stepAttributes
2340
2390
  }, { autotel: autotelContext }));
2341
2391
  });
2342
2392
  }
@@ -2360,11 +2410,17 @@ var Event = class {
2360
2410
  */
2361
2411
  trackBatch(events) {
2362
2412
  for (const event of events) {
2363
- const filteredAttributes = event.attributes ? Object.fromEntries(Object.entries(event.attributes).filter(([, v]) => v !== void 0 && v !== null)) : void 0;
2413
+ const filteredAttributes = event.attributes ? definedAttributes(event.attributes) : void 0;
2364
2414
  this.trackEvent(event.name, filteredAttributes);
2365
2415
  }
2366
2416
  }
2367
2417
  };
2418
+ /** The attributes with the entries that carry nothing left out. */
2419
+ function definedAttributes(input) {
2420
+ const defined = {};
2421
+ for (const [key, value] of Object.entries(input)) if (value !== void 0 && value !== null) defined[key] = value;
2422
+ return defined;
2423
+ }
2368
2424
  /**
2369
2425
  * Global events instances (singleton pattern)
2370
2426
  */
@@ -2410,24 +2466,21 @@ const UNREACHABLE_ENDPOINT_CODES = /* @__PURE__ */ new Set([
2410
2466
  "ENOTFOUND",
2411
2467
  "EAI_AGAIN"
2412
2468
  ]);
2413
- function errorCode(error) {
2414
- if (typeof error === "object" && error !== null && "code" in error) {
2415
- const code = error.code;
2416
- if (typeof code === "string") return code;
2417
- }
2469
+ function errorCode(cause) {
2470
+ return asString(readProperty(cause, "code"));
2418
2471
  }
2419
2472
  /**
2420
2473
  * True when the error (or every error it wraps) is an unreachable-endpoint
2421
2474
  * failure. Traverses `AggregateError.errors` and the `cause` chain, since the
2422
2475
  * SDK often wraps the underlying network error.
2423
2476
  */
2424
- function isUnreachableEndpointError(error, depth = 0) {
2425
- if (depth > 5 || error === null || typeof error !== "object") return false;
2426
- if (error instanceof AggregateError) return error.errors.length > 0 && error.errors.every((e) => isUnreachableEndpointError(e, depth + 1));
2427
- const code = errorCode(error);
2477
+ function isUnreachableEndpointError(cause, depth = 0) {
2478
+ if (depth > 5 || asRecord(cause) === void 0) return false;
2479
+ if (cause instanceof AggregateError) return cause.errors.length > 0 && cause.errors.every((e) => isUnreachableEndpointError(e, depth + 1));
2480
+ const code = errorCode(cause);
2428
2481
  if (code && UNREACHABLE_ENDPOINT_CODES.has(code)) return true;
2429
- const cause = error.cause;
2430
- return cause !== void 0 && cause !== error ? isUnreachableEndpointError(cause, depth + 1) : false;
2482
+ const wrapped = readProperty(cause, "cause");
2483
+ return wrapped !== void 0 && wrapped !== cause ? isUnreachableEndpointError(wrapped, depth + 1) : false;
2431
2484
  }
2432
2485
  /**
2433
2486
  * Flush all pending telemetry
@@ -2528,7 +2581,7 @@ async function shutdown() {
2528
2581
  uninstallProcessHandlers();
2529
2582
  await _closeEmbeddedDevtools();
2530
2583
  const eventsQueue = getEventQueue();
2531
- if (eventsQueue && typeof eventsQueue.cleanup === "function") eventsQueue.cleanup();
2584
+ if (isFunction(eventsQueue?.cleanup)) eventsQueue.cleanup();
2532
2585
  resetEvents();
2533
2586
  resetMetrics();
2534
2587
  resetEventQueue();
@@ -2808,14 +2861,17 @@ function detectHostname() {
2808
2861
  function getInstrumentationNames(instrumentations) {
2809
2862
  const names = /* @__PURE__ */ new Set();
2810
2863
  if (!instrumentations) return names;
2811
- for (const instrumentation of instrumentations) if (instrumentation && typeof instrumentation === "object") names.add(instrumentation.constructor.name);
2864
+ for (const instrumentation of instrumentations) {
2865
+ const className = asFunction(readProperty(instrumentation, "constructor"))?.name;
2866
+ if (className) names.add(className);
2867
+ }
2812
2868
  return names;
2813
2869
  }
2814
2870
  /**
2815
2871
  * Map common instrumentation class names to their package names
2816
2872
  * Used to disable auto-instrumentations when user provides manual configs
2817
2873
  */
2818
- const INSTRUMENTATION_CLASS_TO_PACKAGE = {
2874
+ const INSTRUMENTATION_CLASS_TO_PACKAGE = new Map(Object.entries({
2819
2875
  HttpInstrumentation: "@opentelemetry/instrumentation-http",
2820
2876
  HttpsInstrumentation: "@opentelemetry/instrumentation-http",
2821
2877
  ExpressInstrumentation: "@opentelemetry/instrumentation-express",
@@ -2834,7 +2890,7 @@ const INSTRUMENTATION_CLASS_TO_PACKAGE = {
2834
2890
  PgInstrumentation: "@opentelemetry/instrumentation-pg",
2835
2891
  MySQLInstrumentation: "@opentelemetry/instrumentation-mysql",
2836
2892
  MySQL2Instrumentation: "@opentelemetry/instrumentation-mysql2"
2837
- };
2893
+ }));
2838
2894
  /**
2839
2895
  * Detect if we're running in ESM mode
2840
2896
  */
@@ -2887,7 +2943,7 @@ function getAutoInstrumentations(integrations, manualInstrumentationNames = /* @
2887
2943
  const getNodeAutoInstrumentations = _autoInstrumentationsLoader ? _autoInstrumentationsLoader() : loadNodeAutoInstrumentations();
2888
2944
  const exclusionConfig = {};
2889
2945
  for (const className of manualInstrumentationNames) {
2890
- const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE[className];
2946
+ const packageName = INSTRUMENTATION_CLASS_TO_PACKAGE.get(className);
2891
2947
  if (packageName) exclusionConfig[packageName] = { enabled: false };
2892
2948
  }
2893
2949
  if (integrations === true) {
@@ -2919,17 +2975,6 @@ function getAutoInstrumentations(integrations, manualInstrumentationNames = /* @
2919
2975
  * Replaces initInstrumentation() and separate events config.
2920
2976
  */
2921
2977
  /**
2922
- * Silent logger (no-op) - used as default when user doesn't provide one.
2923
- * Internal autotel logs are silent by default to avoid spam.
2924
- * Users can import { autotelLogger } from 'autotel/logger' to create their own.
2925
- */
2926
- const silentLogger = {
2927
- info: () => {},
2928
- warn: () => {},
2929
- error: () => {},
2930
- debug: () => {}
2931
- };
2932
- /**
2933
2978
  * Adapts an Autotel Sampler to the OTel SDK Sampler interface.
2934
2979
  */
2935
2980
  function toOtelSampler(sampler) {
@@ -2942,10 +2987,9 @@ function toOtelSampler(sampler) {
2942
2987
  };
2943
2988
  const shouldTrace = sampler.shouldSample(samplingContext);
2944
2989
  const rate = sampler.sampleRate?.(samplingContext);
2945
- return {
2946
- decision: shouldTrace ? SamplingDecision.RECORD_AND_SAMPLED : SamplingDecision.NOT_RECORD,
2947
- ...shouldTrace && rate !== void 0 && rate > 1 ? { attributes: { [AUTOTEL_SAMPLING_RATE]: rate } } : {}
2948
- };
2990
+ const result = { decision: shouldTrace ? SamplingDecision.RECORD_AND_SAMPLED : SamplingDecision.NOT_RECORD };
2991
+ if (shouldTrace && rate !== void 0 && rate > 1) result.attributes = { [AUTOTEL_SAMPLING_RATE]: rate };
2992
+ return result;
2949
2993
  },
2950
2994
  toString() {
2951
2995
  return `AutotelSamplerAdapter`;
@@ -2962,16 +3006,10 @@ let validationConfig = null;
2962
3006
  let eventsConfig = null;
2963
3007
  let _stringRedactor = null;
2964
3008
  function acceptsStringRedactor(subscriber) {
2965
- return typeof subscriber === "object" && subscriber !== null && "setStringRedactor" in subscriber && typeof subscriber.setStringRedactor === "function";
3009
+ return isFunction(readProperty(subscriber, "setStringRedactor")) ? subscriber : void 0;
2966
3010
  }
2967
3011
  let _optionalRequire = safeRequire;
2968
3012
  let _devtoolsClose = null;
2969
- const LOG_LEVELS = {
2970
- debug: 0,
2971
- info: 1,
2972
- warn: 2,
2973
- error: 3
2974
- };
2975
3013
  /**
2976
3014
  * Lock the logger to prevent further `init()` calls.
2977
3015
  * Use this when framework plugins set up instrumentation and you want
@@ -2986,28 +3024,6 @@ function lockLogger() {
2986
3024
  function isLoggerLocked() {
2987
3025
  return locked;
2988
3026
  }
2989
- function createSilentLogger() {
2990
- return {
2991
- info: () => {},
2992
- warn: () => {},
2993
- error: () => {},
2994
- debug: () => {}
2995
- };
2996
- }
2997
- function wrapLogger(base, silent, minLevel) {
2998
- if (silent) return createSilentLogger();
2999
- const threshold = LOG_LEVELS[minLevel];
3000
- const wrap = (fn, level) => {
3001
- if (LOG_LEVELS[level] < threshold) return (() => {});
3002
- return ((...args) => fn(...args));
3003
- };
3004
- return {
3005
- debug: wrap(base.debug, "debug"),
3006
- info: wrap(base.info, "info"),
3007
- warn: wrap(base.warn, "warn"),
3008
- error: wrap(base.error, "error")
3009
- };
3010
- }
3011
3027
  /**
3012
3028
  * Initialize autotel - Write Once, Observe Everywhere
3013
3029
  *
@@ -3021,7 +3037,7 @@ function wrapLogger(base, silent, minLevel) {
3021
3037
  *
3022
3038
  * @example With events (observe in PostHog, Mixpanel, etc.)
3023
3039
  * ```typescript
3024
- * import { PostHogSubscriber } from 'autotel-subscribers/posthog';
3040
+ * import { PostHogSubscriber } from 'autotel-posthog/subscriber';
3025
3041
  *
3026
3042
  * init({
3027
3043
  * service: 'my-app',
@@ -3175,9 +3191,7 @@ function init(cfg) {
3175
3191
  spanProcessors = spanProcessors.map((processor) => new AttributeRedactingProcessor(processor, { redactor }));
3176
3192
  }
3177
3193
  if (mergedConfig.attributeRedactor) _stringRedactor = createStringRedactor(mergedConfig.attributeRedactor);
3178
- if (_stringRedactor && mergedConfig.subscribers) {
3179
- for (const subscriber of mergedConfig.subscribers) if (acceptsStringRedactor(subscriber)) subscriber.setStringRedactor(_stringRedactor);
3180
- }
3194
+ if (_stringRedactor && mergedConfig.subscribers) for (const subscriber of mergedConfig.subscribers) acceptsStringRedactor(subscriber)?.setStringRedactor(_stringRedactor);
3181
3195
  if (mergedConfig.spanNameNormalizer && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new SpanNameNormalizingProcessor(processor, { normalizer: mergedConfig.spanNameNormalizer }));
3182
3196
  if (mergedConfig.policies) {
3183
3197
  if (typeof mergedConfig.policies === "string") watchPolicyFile(mergedConfig.policies);
@@ -3186,6 +3200,7 @@ function init(cfg) {
3186
3200
  mergedConfig.spanFilter = userSpanFilter ? (span) => userSpanFilter(span) && policySpanFilter(span) : policySpanFilter;
3187
3201
  }
3188
3202
  if (mergedConfig.spanFilter && spanProcessors.length > 0) spanProcessors = spanProcessors.map((processor) => new FilteringSpanProcessor(processor, { filter: mergedConfig.spanFilter }));
3203
+ if (mergedConfig.spanEnrichers && mergedConfig.spanEnrichers.length > 0) spanProcessors.unshift(...mergedConfig.spanEnrichers);
3189
3204
  const metricReaders = [];
3190
3205
  if (configuredMetricReaders && configuredMetricReaders.length > 0) metricReaders.push(...configuredMetricReaders);
3191
3206
  else if (metricsEnabled) for (const destination of otlpDestinations) {
@@ -3196,11 +3211,10 @@ function init(cfg) {
3196
3211
  });
3197
3212
  const exportIntervalMillis = readMillisEnv("OTEL_METRIC_EXPORT_INTERVAL");
3198
3213
  const exportTimeoutMillis = readMillisEnv("OTEL_METRIC_EXPORT_TIMEOUT");
3199
- metricReaders.push(new PeriodicExportingMetricReader({
3200
- exporter: metricExporter,
3201
- ...exportIntervalMillis === void 0 ? {} : { exportIntervalMillis },
3202
- ...exportTimeoutMillis === void 0 ? {} : { exportTimeoutMillis }
3203
- }));
3214
+ const readerOptions = { exporter: metricExporter };
3215
+ if (exportIntervalMillis !== void 0) readerOptions.exportIntervalMillis = exportIntervalMillis;
3216
+ if (exportTimeoutMillis !== void 0) readerOptions.exportTimeoutMillis = exportTimeoutMillis;
3217
+ metricReaders.push(new PeriodicExportingMetricReader(readerOptions));
3204
3218
  }
3205
3219
  let logRecordProcessors;
3206
3220
  if (configuredLogRecordProcessors && configuredLogRecordProcessors.length > 0) logRecordProcessors = [...configuredLogRecordProcessors];
@@ -3258,11 +3272,10 @@ function init(cfg) {
3258
3272
  const traceloop = _optionalRequire("@traceloop/node-server-sdk");
3259
3273
  if (traceloop) {
3260
3274
  const initOptions = { ...mergedConfig.openllmetry.options };
3261
- try {
3262
- initOptions.tracerProvider = sdk.getTracerProvider();
3263
- } catch {}
3275
+ const getTracerProvider = asFunction(readProperty(sdk, "getTracerProvider"));
3276
+ if (getTracerProvider) initOptions.tracerProvider = getTracerProvider.call(sdk);
3264
3277
  if (configuredSpanExporters?.[0]) initOptions.exporter = configuredSpanExporters[0];
3265
- if (typeof traceloop.initialize === "function") {
3278
+ if (isFunction(traceloop.initialize)) {
3266
3279
  traceloop.initialize(initOptions);
3267
3280
  logger.info({}, "[autotel] OpenLLMetry initialized successfully");
3268
3281
  } else logger.warn({}, "[autotel] OpenLLMetry initialize function not found. Check @traceloop/node-server-sdk version.");
@@ -3337,4 +3350,4 @@ function getSdk() {
3337
3350
  }
3338
3351
 
3339
3352
  //#endregion
3340
- export { BaggageSpanProcessor as A, setCorrelationId as C, getActiveContextWithBaggage as D, defineBaggageSchema as E, getContextStorage as O, runWithCorrelationId as S, createTraceContext as T, CORRELATION_ID_BAGGAGE_KEY as _, isInitialized as a, getCorrelationStorage as b, flush as c, getEvents as d, resetEvents as f, track as g, getEventQueue as h, init as i, createStringRedactor as k, shutdown as l, runInOperationContext as m, getLogger as n, isLoggerLocked as o, getOperationContext as p, getSdk as r, lockLogger as s, getConfig as t, Event as u, generateCorrelationId as v, setCorrelationIdInBaggage as w, getOrCreateCorrelationId as x, getCorrelationId as y };
3353
+ export { createStringRedactor as A, setCorrelationId as C, getActiveContextWithBaggage as D, defineBaggageSchema as E, getContextStorage as O, runWithCorrelationId as S, createTraceContext as T, CORRELATION_ID_BAGGAGE_KEY as _, isInitialized as a, getCorrelationStorage as b, flush as c, getEvents as d, resetEvents as f, track as g, getEventQueue as h, init as i, BaggageSpanProcessor as j, hasExplicitSpanStatus as k, shutdown as l, runInOperationContext as m, getLogger as n, isLoggerLocked as o, getOperationContext as p, getSdk as r, lockLogger as s, getConfig as t, Event as u, generateCorrelationId as v, setCorrelationIdInBaggage as w, getOrCreateCorrelationId as x, getCorrelationId as y };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_node_require = require('./node-require-PFqDihze.cjs');
3
- const require_init = require('./init-BnxHAi2M.cjs');
2
+ const require_init = require('./init-D4m5rCmD.cjs');
3
+ const require_node_require = require('./node-require-EifOMikz.cjs');
4
4
  const require_tail_sampling_processor = require('./tail-sampling-processor.cjs');
5
5
  let _opentelemetry_sdk_node = require("@opentelemetry/sdk-node");
6
6
  let _opentelemetry_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
@@ -1,5 +1,5 @@
1
- import { n as safeRequire, t as requireModule } from "./node-require-vROmTeJ8.js";
2
- import { n as getLogger } from "./init-BxfZ3Vbw.js";
1
+ import { n as getLogger } from "./init-JtX-KKz_.js";
2
+ import { n as safeRequire, t as requireModule } from "./node-require-DSPjaw_l.js";
3
3
  import { TailSamplingSpanProcessor } from "./tail-sampling-processor.js";
4
4
  import { NodeSDK } from "@opentelemetry/sdk-node";
5
5
  import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";