@logbrew/sdk 0.1.38 → 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 (90) 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 +30 -2810
  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-exception.cjs +13 -8
  33. package/metric-validation.cjs +95 -0
  34. package/network-milestone.cjs +155 -0
  35. package/null-value.cjs +4 -0
  36. package/opentelemetry-bridge.cjs +330 -0
  37. package/opentelemetry-context.cjs +245 -0
  38. package/opentelemetry-exceptions.cjs +69 -0
  39. package/opentelemetry-keys.cjs +183 -0
  40. package/opentelemetry-span.cjs +286 -0
  41. package/opentelemetry-summary.cjs +213 -0
  42. package/opentelemetry-time.cjs +131 -0
  43. package/opentelemetry.cjs +99 -1068
  44. package/package.json +55 -1
  45. package/pino-destination.cjs +108 -0
  46. package/pino-record.cjs +237 -0
  47. package/product-action.cjs +163 -0
  48. package/provided-breadcrumbs.cjs +117 -0
  49. package/random-hex.cjs +29 -0
  50. package/react-native.js +1 -1
  51. package/recording-transport.cjs +68 -0
  52. package/release-artifacts-build.cjs +263 -84
  53. package/release-artifacts-common.js +347 -66
  54. package/release-artifacts-debug-id.js +178 -0
  55. package/release-artifacts-inspect.js +213 -0
  56. package/release-artifacts-issue-event.js +99 -0
  57. package/release-artifacts-manifest-artifact.js +107 -0
  58. package/release-artifacts-manifest.js +77 -0
  59. package/release-artifacts-mappings.js +265 -0
  60. package/release-artifacts-prepare.js +297 -0
  61. package/release-artifacts-source-context.js +210 -0
  62. package/release-artifacts-symbolication.js +272 -421
  63. package/release-artifacts-upload-files.js +122 -0
  64. package/release-artifacts-upload-request.js +246 -0
  65. package/release-artifacts-upload.js +155 -300
  66. package/release-artifacts-urls.js +49 -0
  67. package/release-artifacts.js +189 -662
  68. package/retry-delay.cjs +32 -0
  69. package/span-validation.cjs +191 -0
  70. package/stored-events.cjs +243 -0
  71. package/types/client.d.ts +67 -0
  72. package/types/delivery.d.ts +125 -0
  73. package/types/issues.d.ts +249 -0
  74. package/types/logging.d.ts +175 -0
  75. package/types/opentelemetry.d.ts +205 -0
  76. package/types/product.d.ts +128 -0
  77. package/types/recording-transport.d.ts +15 -0
  78. package/types/sdk-error.d.ts +9 -0
  79. package/types/telemetry.d.ts +171 -0
  80. package/types/trace-context.d.ts +110 -0
  81. package/types/transport-error.d.ts +10 -0
  82. package/utf8.cjs +37 -0
  83. package/validation.cjs +49 -1
  84. package/vite-release-artifacts-config.cjs +120 -0
  85. package/vite-release-artifacts.cjs +199 -99
  86. package/vite-release-artifacts.d.cts +65 -40
  87. package/vite-release-artifacts.d.ts +65 -40
  88. package/vite-release-artifacts.js +2 -2
  89. package/winston-info.cjs +205 -0
  90. package/winston.cjs +189 -289
@@ -0,0 +1,205 @@
1
+ const { errorCauseType, errorDetails, isObjectLike, safeProperty } = require("./error-details.cjs");
2
+ const { javascriptStackEvidence } = require("./issue-stack.cjs");
3
+ const { optionalEntry } = require("./validation.cjs");
4
+
5
+ /**
6
+ * @import {
7
+ * IssueException,
8
+ * IssueExceptionChain,
9
+ * IssueExceptionChainEntry,
10
+ * IssueExceptionMechanism,
11
+ * IssueExceptionMessageState,
12
+ * IssueExceptionRelationship
13
+ * } from "./index.cjs"
14
+ * @import { ErrorDetails } from "./error-details.cjs"
15
+ * @import { StackEvidence } from "./issue-stack.cjs"
16
+ * @import { DeepReadonly } from "./validation.cjs"
17
+ * @typedef {DeepReadonly<{
18
+ * details: ErrorDetails,
19
+ * exception: IssueException | undefined,
20
+ * stackEvidence: StackEvidence,
21
+ * debugIdMap: unknown
22
+ * }>} ReportedException
23
+ * @typedef {Readonly<{ parentId?: number, relationship: IssueExceptionRelationship }>} ChainLink
24
+ */
25
+
26
+ const MAX_CHAIN_ENTRIES = 8;
27
+ const ROOT_ID = 0;
28
+ const NO_FRAMES = 0;
29
+ const WHITESPACE_PATTERN = /\s+/gu;
30
+
31
+ /**
32
+ * @param {unknown} value
33
+ * @returns {{ messageState: IssueExceptionMessageState }}
34
+ */
35
+ function exceptionMessageEvidence(value) {
36
+ if (typeof value !== "string" || value.replaceAll(WHITESPACE_PATTERN, " ").trim() === "") {
37
+ return { messageState: "not_captured" };
38
+ }
39
+ return { messageState: "redacted" };
40
+ }
41
+
42
+ /**
43
+ * @param {IssueExceptionRelationship} relationship
44
+ * @returns {IssueExceptionMechanism}
45
+ */
46
+ function childMechanism(relationship) {
47
+ return {
48
+ type: relationship === "aggregate_member" ? "javascript.aggregate_member" : "javascript.cause",
49
+
50
+ handled: true
51
+ };
52
+ }
53
+
54
+ /**
55
+ * @param {number} frameCount
56
+ * @param {boolean} truncated
57
+ * @returns {IssueExceptionChainEntry["stackFramesState"]}
58
+ */
59
+ function stackFramesState(frameCount, truncated) {
60
+ if (frameCount === NO_FRAMES) {
61
+ return "not_captured";
62
+ }
63
+ return truncated ? "truncated" : "captured";
64
+ }
65
+
66
+ class ExceptionChainCollector {
67
+ /**
68
+ * @param {unknown} debugIdMap
69
+ */
70
+ constructor(debugIdMap) {
71
+ /** @type {DeepReadonly<IssueExceptionChainEntry>[]} */
72
+ this.entries = [];
73
+ /** @type {Set<object>} */
74
+ this.seen = new Set();
75
+ this.truncated = false;
76
+ this.debugIdMap = debugIdMap;
77
+ }
78
+
79
+ /**
80
+ * @param {unknown} value
81
+ * @param {ChainLink} link
82
+ * @param {ReportedException} [known]
83
+ * @returns {number | undefined}
84
+ */
85
+ appendNode(value, link, known) {
86
+ if (this.entries.length >= MAX_CHAIN_ENTRIES) {
87
+ this.truncated = true;
88
+ return undefined;
89
+ }
90
+ const details = known?.details ?? errorDetails(value);
91
+ const stackEvidence = known?.stackEvidence ?? javascriptStackEvidence(details.stack, this.debugIdMap);
92
+ const mechanism = known?.exception?.mechanism ?? childMechanism(link.relationship);
93
+ const messageEvidence = exceptionMessageEvidence(details.message);
94
+ const id = this.entries.length;
95
+ this.entries.push({
96
+ id,
97
+ ...optionalEntry("parentId", link.parentId),
98
+ relationship: link.relationship,
99
+ type: known?.exception?.type ?? errorCauseType(value),
100
+ ...messageEvidence,
101
+ mechanism,
102
+ ...optionalEntry("stackFrames", stackEvidence.frames.length === NO_FRAMES ? undefined : stackEvidence.frames),
103
+ stackFramesState: stackFramesState(stackEvidence.frames.length, stackEvidence.truncated)
104
+ });
105
+ return id;
106
+ }
107
+
108
+ /**
109
+ * @param {unknown} value
110
+ * @returns {boolean}
111
+ */
112
+ markSeen(value) {
113
+ if (!isObjectLike(value)) {
114
+ return true;
115
+ }
116
+ if (this.seen.has(value)) {
117
+ this.truncated = true;
118
+ return false;
119
+ }
120
+ this.seen.add(value);
121
+ return true;
122
+ }
123
+
124
+ /**
125
+ * @param {unknown} value
126
+ * @param {number} parentId
127
+ * @param {IssueExceptionRelationship} relationship
128
+ * @returns {void}
129
+ */
130
+ collectChild(value, parentId, relationship) {
131
+ if (this.entries.length >= MAX_CHAIN_ENTRIES) {
132
+ this.truncated = true;
133
+ return;
134
+ }
135
+ if (!this.markSeen(value)) {
136
+ return;
137
+ }
138
+ const id = this.appendNode(value, { parentId, relationship });
139
+ if (id !== undefined) {
140
+ this.collectChildren(value, id);
141
+ }
142
+ }
143
+
144
+ /**
145
+ * @param {unknown} value
146
+ * @param {number} parentId
147
+ * @returns {void}
148
+ */
149
+ collectChildren(value, parentId) {
150
+ if (!isObjectLike(value)) {
151
+ return;
152
+ }
153
+ this.collectCause(value, parentId);
154
+ this.collectAggregateMembers(value, parentId);
155
+ }
156
+
157
+ /**
158
+ * @param {object} value
159
+ * @param {number} parentId
160
+ * @returns {void}
161
+ */
162
+ collectCause(value, parentId) {
163
+ const cause = safeProperty(value, "cause");
164
+ if (cause.available && cause.value !== undefined && cause.value !== null) {
165
+ this.collectChild(cause.value, parentId, "cause");
166
+ } else if (!cause.available) {
167
+ this.truncated = true;
168
+ }
169
+ }
170
+
171
+ /**
172
+ * @param {object} value
173
+ * @param {number} parentId
174
+ * @returns {void}
175
+ */
176
+ collectAggregateMembers(value, parentId) {
177
+ const errors = safeProperty(value, "errors");
178
+ if (!errors.available) {
179
+ this.truncated = true;
180
+ } else if (Array.isArray(errors.value)) {
181
+ /** @type {readonly unknown[]} */
182
+ const children = errors.value;
183
+ for (const child of children) {
184
+ this.collectChild(child, parentId, "aggregate_member");
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * @param {unknown} error
192
+ * @param {ReportedException} reported
193
+ * @returns {DeepReadonly<IssueExceptionChain>}
194
+ */
195
+ function createJavaScriptExceptionChain(error, reported) {
196
+ const collector = new ExceptionChainCollector(reported.debugIdMap);
197
+ if (isObjectLike(error)) {
198
+ collector.seen.add(error);
199
+ }
200
+ collector.appendNode(error, { relationship: "reported" }, reported);
201
+ collector.collectChildren(error, ROOT_ID);
202
+ return { entries: collector.entries, truncated: collector.truncated };
203
+ }
204
+
205
+ module.exports = { createJavaScriptExceptionChain };