@logbrew/sdk 0.1.37 → 0.1.39

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 (103) hide show
  1. package/automatic-delivery.cjs +271 -0
  2. package/batch-sender.cjs +164 -0
  3. package/bounded-number.cjs +34 -0
  4. package/browser-breadcrumbs.cjs +346 -136
  5. package/capture-support.cjs +100 -0
  6. package/client-options.cjs +292 -0
  7. package/client-report.cjs +232 -0
  8. package/client.cjs +447 -0
  9. package/console-arguments.cjs +151 -0
  10. package/console-capture.cjs +194 -0
  11. package/core.cjs +35 -2984
  12. package/delivery-health.cjs +133 -0
  13. package/error-causes.cjs +130 -0
  14. package/error-details.cjs +124 -0
  15. package/error-issue.cjs +187 -0
  16. package/event-clone.cjs +55 -0
  17. package/event-metadata.cjs +40 -0
  18. package/event-pipeline.cjs +325 -0
  19. package/event-queue.cjs +306 -0
  20. package/event-store.cjs +237 -0
  21. package/event-validation.cjs +159 -0
  22. package/examples/agent-timeline.cjs +57 -46
  23. package/examples/agent-timeline.mjs +41 -35
  24. package/examples/index.mjs +122 -94
  25. package/examples/readme-example.cjs +36 -27
  26. package/examples/readme-example.mjs +21 -17
  27. package/examples/real-user-smoke.cjs +41 -32
  28. package/examples/real-user-smoke.mjs +26 -22
  29. package/exception-chain.cjs +205 -0
  30. package/index.d.ts +144 -1076
  31. package/index.js +1 -1
  32. package/issue-breadcrumbs.cjs +143 -0
  33. package/issue-diagnostics.cjs +94 -582
  34. package/issue-evidence.cjs +256 -0
  35. package/issue-exception.cjs +268 -0
  36. package/issue-stack-frames.cjs +220 -0
  37. package/issue-stack-text.cjs +101 -0
  38. package/issue-stack.cjs +188 -225
  39. package/issue-text.cjs +72 -0
  40. package/log-context.cjs +87 -67
  41. package/metric-validation.cjs +95 -0
  42. package/network-milestone.cjs +155 -0
  43. package/null-value.cjs +4 -0
  44. package/opentelemetry-bridge.cjs +330 -0
  45. package/opentelemetry-context.cjs +245 -0
  46. package/opentelemetry-exceptions.cjs +69 -0
  47. package/opentelemetry-keys.cjs +183 -0
  48. package/opentelemetry-span.cjs +286 -0
  49. package/opentelemetry-summary.cjs +213 -0
  50. package/opentelemetry-time.cjs +131 -0
  51. package/opentelemetry.cjs +99 -1068
  52. package/package.json +64 -1
  53. package/pino-destination.cjs +108 -0
  54. package/pino-record.cjs +237 -0
  55. package/product-action.cjs +163 -0
  56. package/provided-breadcrumbs.cjs +117 -0
  57. package/random-hex.cjs +29 -0
  58. package/react-native.js +1 -1
  59. package/recording-transport.cjs +68 -0
  60. package/release-artifacts-build.cjs +263 -84
  61. package/release-artifacts-common.js +347 -66
  62. package/release-artifacts-debug-id.js +178 -0
  63. package/release-artifacts-inspect.js +213 -0
  64. package/release-artifacts-issue-event.js +99 -0
  65. package/release-artifacts-manifest-artifact.js +107 -0
  66. package/release-artifacts-manifest.js +77 -0
  67. package/release-artifacts-mappings.js +265 -0
  68. package/release-artifacts-prepare.js +297 -0
  69. package/release-artifacts-source-context.js +210 -0
  70. package/release-artifacts-symbolication.js +272 -421
  71. package/release-artifacts-upload-files.js +122 -0
  72. package/release-artifacts-upload-request.js +246 -0
  73. package/release-artifacts-upload.js +155 -300
  74. package/release-artifacts-urls.js +49 -0
  75. package/release-artifacts.js +189 -662
  76. package/retry-delay.cjs +32 -0
  77. package/sdk-error.cjs +36 -0
  78. package/span-validation.cjs +191 -0
  79. package/stored-events.cjs +243 -0
  80. package/support-ticket.cjs +232 -122
  81. package/telemetry-context.cjs +343 -251
  82. package/trace-context.cjs +376 -179
  83. package/transport-error.cjs +23 -0
  84. package/types/client.d.ts +67 -0
  85. package/types/delivery.d.ts +125 -0
  86. package/types/issues.d.ts +249 -0
  87. package/types/logging.d.ts +175 -0
  88. package/types/opentelemetry.d.ts +205 -0
  89. package/types/product.d.ts +128 -0
  90. package/types/recording-transport.d.ts +15 -0
  91. package/types/sdk-error.d.ts +9 -0
  92. package/types/telemetry.d.ts +171 -0
  93. package/types/trace-context.d.ts +110 -0
  94. package/types/transport-error.d.ts +10 -0
  95. package/utf8.cjs +37 -0
  96. package/validation.cjs +327 -0
  97. package/vite-release-artifacts-config.cjs +120 -0
  98. package/vite-release-artifacts.cjs +199 -99
  99. package/vite-release-artifacts.d.cts +65 -40
  100. package/vite-release-artifacts.d.ts +65 -40
  101. package/vite-release-artifacts.js +2 -2
  102. package/winston-info.cjs +205 -0
  103. package/winston.cjs +189 -290
@@ -0,0 +1,131 @@
1
+ const { isList } = require("./validation.cjs");
2
+
3
+ /**
4
+ * @typedef {Readonly<Record<string, unknown>>} ReadableSpan
5
+ */
6
+
7
+ const HR_TIME_PARTS = 2;
8
+ const MS_PER_SECOND = 1000;
9
+ const NANOS_PER_MS = 1_000_000;
10
+ const MIN_HR_TIME_PART = 0;
11
+
12
+ /**
13
+ * @param {unknown} value
14
+ * @returns {value is number}
15
+ */
16
+ function isFiniteNumber(value) {
17
+ return typeof value === "number" && Number.isFinite(value);
18
+ }
19
+
20
+ /**
21
+ * @param {unknown} value
22
+ * @returns {number | undefined}
23
+ */
24
+ function openTelemetryTimeMs(value) {
25
+ if (isList(value) && value.length >= HR_TIME_PARTS) {
26
+ const [seconds, nanos] = value;
27
+ if (isFiniteNumber(seconds) && isFiniteNumber(nanos)) {
28
+ return seconds * MS_PER_SECOND + nanos / NANOS_PER_MS;
29
+ }
30
+ }
31
+ if (isFiniteNumber(value)) {
32
+ return value;
33
+ }
34
+ if (value instanceof Date && !Number.isNaN(value.valueOf())) {
35
+ return value.valueOf();
36
+ }
37
+ return undefined;
38
+ }
39
+
40
+ /**
41
+ * @param {unknown} value
42
+ * @returns {number | undefined}
43
+ */
44
+ function openTelemetryDurationMs(value) {
45
+ if (!isList(value) || value.length < HR_TIME_PARTS) {
46
+ return undefined;
47
+ }
48
+ const [seconds, nanos] = value;
49
+ if (
50
+ !isFiniteNumber(seconds)
51
+ || !isFiniteNumber(nanos)
52
+ || seconds < MIN_HR_TIME_PART
53
+ || nanos < MIN_HR_TIME_PART
54
+ ) {
55
+ return undefined;
56
+ }
57
+ return seconds * MS_PER_SECOND + nanos / NANOS_PER_MS;
58
+ }
59
+
60
+ /**
61
+ * @param {unknown} value
62
+ * @returns {string | undefined}
63
+ */
64
+ function timestampFromOpenTelemetryTime(value) {
65
+ const milliseconds = openTelemetryTimeMs(value);
66
+ if (milliseconds === undefined) {
67
+ return undefined;
68
+ }
69
+ const date = new Date(milliseconds);
70
+ return Number.isNaN(date.valueOf()) ? undefined : date.toISOString();
71
+ }
72
+
73
+ /**
74
+ * @param {(() => unknown) | undefined} fallbackTimestamp
75
+ * @returns {unknown}
76
+ */
77
+ function fallbackTimestampValue(fallbackTimestamp) {
78
+ return fallbackTimestamp === undefined ? new Date().toISOString() : fallbackTimestamp();
79
+ }
80
+
81
+ /**
82
+ * @param {ReadableSpan} span
83
+ * @returns {number | undefined}
84
+ */
85
+ function durationMsFromOpenTelemetryReadableSpan(span) {
86
+ const durationMs = openTelemetryDurationMs(span["duration"]);
87
+ if (durationMs !== undefined) {
88
+ return durationMs;
89
+ }
90
+ const startMs = openTelemetryTimeMs(span["startTime"]);
91
+ const endMs = openTelemetryTimeMs(span["endTime"]);
92
+ if (startMs !== undefined && endMs !== undefined && endMs >= startMs) {
93
+ return endMs - startMs;
94
+ }
95
+ return undefined;
96
+ }
97
+
98
+ /**
99
+ * @param {ReadableSpan} span
100
+ * @param {number | undefined} startMs
101
+ * @param {number | undefined} durationMs
102
+ * @returns {number | undefined}
103
+ */
104
+ function endMsFromOpenTelemetryReadableSpan(span, startMs, durationMs) {
105
+ const endMs = openTelemetryTimeMs(span["endTime"]);
106
+ if (endMs !== undefined) {
107
+ return endMs;
108
+ }
109
+ if (startMs !== undefined && durationMs !== undefined) {
110
+ return startMs + durationMs;
111
+ }
112
+ return undefined;
113
+ }
114
+
115
+ /**
116
+ * @param {ReadableSpan} span
117
+ * @param {(() => unknown) | undefined} fallbackTimestamp
118
+ * @returns {unknown}
119
+ */
120
+ function timestampFromOpenTelemetryReadableSpan(span, fallbackTimestamp) {
121
+ return timestampFromOpenTelemetryTime(span["startTime"]) ?? fallbackTimestampValue(fallbackTimestamp);
122
+ }
123
+
124
+ module.exports = {
125
+ durationMsFromOpenTelemetryReadableSpan,
126
+ endMsFromOpenTelemetryReadableSpan,
127
+ fallbackTimestampValue,
128
+ openTelemetryTimeMs,
129
+ timestampFromOpenTelemetryReadableSpan,
130
+ timestampFromOpenTelemetryTime
131
+ };