@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.
- package/automatic-delivery.cjs +271 -0
- package/batch-sender.cjs +164 -0
- package/bounded-number.cjs +34 -0
- package/browser-breadcrumbs.cjs +346 -136
- package/capture-support.cjs +100 -0
- package/client-options.cjs +292 -0
- package/client-report.cjs +232 -0
- package/client.cjs +447 -0
- package/console-arguments.cjs +151 -0
- package/console-capture.cjs +194 -0
- package/core.cjs +35 -2984
- package/delivery-health.cjs +133 -0
- package/error-causes.cjs +130 -0
- package/error-details.cjs +124 -0
- package/error-issue.cjs +187 -0
- package/event-clone.cjs +55 -0
- package/event-metadata.cjs +40 -0
- package/event-pipeline.cjs +325 -0
- package/event-queue.cjs +306 -0
- package/event-store.cjs +237 -0
- package/event-validation.cjs +159 -0
- package/examples/agent-timeline.cjs +57 -46
- package/examples/agent-timeline.mjs +41 -35
- package/examples/index.mjs +122 -94
- package/examples/readme-example.cjs +36 -27
- package/examples/readme-example.mjs +21 -17
- package/examples/real-user-smoke.cjs +41 -32
- package/examples/real-user-smoke.mjs +26 -22
- package/exception-chain.cjs +205 -0
- package/index.d.ts +144 -1076
- package/index.js +1 -1
- package/issue-breadcrumbs.cjs +143 -0
- package/issue-diagnostics.cjs +94 -582
- package/issue-evidence.cjs +256 -0
- package/issue-exception.cjs +268 -0
- package/issue-stack-frames.cjs +220 -0
- package/issue-stack-text.cjs +101 -0
- package/issue-stack.cjs +188 -225
- package/issue-text.cjs +72 -0
- package/log-context.cjs +87 -67
- package/metric-validation.cjs +95 -0
- package/network-milestone.cjs +155 -0
- package/null-value.cjs +4 -0
- package/opentelemetry-bridge.cjs +330 -0
- package/opentelemetry-context.cjs +245 -0
- package/opentelemetry-exceptions.cjs +69 -0
- package/opentelemetry-keys.cjs +183 -0
- package/opentelemetry-span.cjs +286 -0
- package/opentelemetry-summary.cjs +213 -0
- package/opentelemetry-time.cjs +131 -0
- package/opentelemetry.cjs +99 -1068
- package/package.json +64 -1
- package/pino-destination.cjs +108 -0
- package/pino-record.cjs +237 -0
- package/product-action.cjs +163 -0
- package/provided-breadcrumbs.cjs +117 -0
- package/random-hex.cjs +29 -0
- package/react-native.js +1 -1
- package/recording-transport.cjs +68 -0
- package/release-artifacts-build.cjs +263 -84
- package/release-artifacts-common.js +347 -66
- package/release-artifacts-debug-id.js +178 -0
- package/release-artifacts-inspect.js +213 -0
- package/release-artifacts-issue-event.js +99 -0
- package/release-artifacts-manifest-artifact.js +107 -0
- package/release-artifacts-manifest.js +77 -0
- package/release-artifacts-mappings.js +265 -0
- package/release-artifacts-prepare.js +297 -0
- package/release-artifacts-source-context.js +210 -0
- package/release-artifacts-symbolication.js +272 -421
- package/release-artifacts-upload-files.js +122 -0
- package/release-artifacts-upload-request.js +246 -0
- package/release-artifacts-upload.js +155 -300
- package/release-artifacts-urls.js +49 -0
- package/release-artifacts.js +189 -662
- package/retry-delay.cjs +32 -0
- package/sdk-error.cjs +36 -0
- package/span-validation.cjs +191 -0
- package/stored-events.cjs +243 -0
- package/support-ticket.cjs +232 -122
- package/telemetry-context.cjs +343 -251
- package/trace-context.cjs +376 -179
- package/transport-error.cjs +23 -0
- package/types/client.d.ts +67 -0
- package/types/delivery.d.ts +125 -0
- package/types/issues.d.ts +249 -0
- package/types/logging.d.ts +175 -0
- package/types/opentelemetry.d.ts +205 -0
- package/types/product.d.ts +128 -0
- package/types/recording-transport.d.ts +15 -0
- package/types/sdk-error.d.ts +9 -0
- package/types/telemetry.d.ts +171 -0
- package/types/trace-context.d.ts +110 -0
- package/types/transport-error.d.ts +10 -0
- package/utf8.cjs +37 -0
- package/validation.cjs +327 -0
- package/vite-release-artifacts-config.cjs +120 -0
- package/vite-release-artifacts.cjs +199 -99
- package/vite-release-artifacts.d.cts +65 -40
- package/vite-release-artifacts.d.ts +65 -40
- package/vite-release-artifacts.js +2 -2
- package/winston-info.cjs +205 -0
- package/winston.cjs +189 -290
package/index.js
CHANGED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { SdkError } = require("./sdk-error.cjs");
|
|
4
|
+
const { boundedText, optionalText, requireMachineName } = require("./issue-text.cjs");
|
|
5
|
+
const { optionalEntry, rejectUnknownKeys, requireObject, requireTimestamp } = require("./validation.cjs");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import { IssueBreadcrumb, IssueBreadcrumbDataValue, IssueBreadcrumbLevel } from "./index.cjs"
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const MAX_ISSUE_BREADCRUMBS = 64;
|
|
12
|
+
const MIN_ISSUE_BREADCRUMBS = 1;
|
|
13
|
+
const MAX_BREADCRUMB_MESSAGE_LENGTH = 512;
|
|
14
|
+
const MAX_BREADCRUMB_DATA_FIELDS = 8;
|
|
15
|
+
const MAX_BREADCRUMB_DATA_STRING_LENGTH = 256;
|
|
16
|
+
const DATA_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
|
|
17
|
+
const BREADCRUMB_KEYS = new Set(["timestamp", "type", "category", "level", "message", "data"]);
|
|
18
|
+
/** @type {ReadonlyMap<string, IssueBreadcrumbLevel>} */
|
|
19
|
+
const BREADCRUMB_LEVEL_ALIASES = new Map([
|
|
20
|
+
["trace", "debug"],
|
|
21
|
+
["debug", "debug"],
|
|
22
|
+
["info", "info"],
|
|
23
|
+
["log", "info"],
|
|
24
|
+
["warn", "warning"],
|
|
25
|
+
["warning", "warning"],
|
|
26
|
+
["error", "error"],
|
|
27
|
+
["fatal", "critical"],
|
|
28
|
+
["critical", "critical"]
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {unknown} value
|
|
33
|
+
* @returns {IssueBreadcrumbLevel | undefined}
|
|
34
|
+
*/
|
|
35
|
+
function optionalBreadcrumbLevel(value) {
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const normalized = typeof value === "string" ? BREADCRUMB_LEVEL_ALIASES.get(value) : undefined;
|
|
40
|
+
if (normalized === undefined) {
|
|
41
|
+
throw new SdkError(
|
|
42
|
+
"validation_error",
|
|
43
|
+
`issue breadcrumb level must be one of: ${[...BREADCRUMB_LEVEL_ALIASES.keys()].join(", ")}`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
return normalized;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} key
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
function requireDataKey(key) {
|
|
54
|
+
if (!DATA_KEY_PATTERN.test(key)) {
|
|
55
|
+
throw new SdkError("validation_error", `issue breadcrumb data key must match ${DATA_KEY_PATTERN}`);
|
|
56
|
+
}
|
|
57
|
+
return key;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {string} key
|
|
62
|
+
* @param {unknown} value
|
|
63
|
+
* @returns {IssueBreadcrumbDataValue}
|
|
64
|
+
*/
|
|
65
|
+
function breadcrumbDataValue(key, value) {
|
|
66
|
+
if (typeof value === "string") {
|
|
67
|
+
return boundedText(`issue breadcrumb data value for ${key}`, value, MAX_BREADCRUMB_DATA_STRING_LENGTH);
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === "number") {
|
|
70
|
+
if (!Number.isFinite(value)) {
|
|
71
|
+
throw new SdkError("validation_error", `issue breadcrumb data value for ${key} must be finite`);
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "boolean" || value === null) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
throw new SdkError(
|
|
79
|
+
"validation_error",
|
|
80
|
+
`issue breadcrumb data value for ${key} must be a string, number, boolean, or null`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {unknown} data
|
|
86
|
+
* @returns {Record<string, IssueBreadcrumbDataValue> | undefined}
|
|
87
|
+
*/
|
|
88
|
+
function validateBreadcrumbData(data) {
|
|
89
|
+
if (data === undefined) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
/** @type {readonly (readonly [string, unknown])[]} */
|
|
93
|
+
const entries = Object.entries(requireObject("issue breadcrumb data", data));
|
|
94
|
+
if (entries.length > MAX_BREADCRUMB_DATA_FIELDS) {
|
|
95
|
+
throw new SdkError(
|
|
96
|
+
"validation_error",
|
|
97
|
+
`issue breadcrumb data must contain at most ${MAX_BREADCRUMB_DATA_FIELDS} fields`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return Object.fromEntries(entries.map(([key, value]) => [requireDataKey(key), breadcrumbDataValue(key, value)]));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {unknown} breadcrumb
|
|
105
|
+
* @param {unknown} [defaultTimestamp]
|
|
106
|
+
* @returns {IssueBreadcrumb}
|
|
107
|
+
*/
|
|
108
|
+
function validateIssueBreadcrumb(breadcrumb, defaultTimestamp) {
|
|
109
|
+
const source = requireObject("issue breadcrumb", breadcrumb);
|
|
110
|
+
rejectUnknownKeys("issue breadcrumb", source, BREADCRUMB_KEYS);
|
|
111
|
+
const timestamp = requireTimestamp(source["timestamp"] ?? defaultTimestamp);
|
|
112
|
+
const category = requireMachineName("issue breadcrumb category", source["category"]);
|
|
113
|
+
const type = source["type"] === undefined ? undefined : requireMachineName("issue breadcrumb type", source["type"]);
|
|
114
|
+
const level = optionalBreadcrumbLevel(source["level"]);
|
|
115
|
+
const message = optionalText("issue breadcrumb message", source["message"], MAX_BREADCRUMB_MESSAGE_LENGTH);
|
|
116
|
+
const data = validateBreadcrumbData(source["data"]);
|
|
117
|
+
return {
|
|
118
|
+
timestamp,
|
|
119
|
+
...optionalEntry("type", type),
|
|
120
|
+
category,
|
|
121
|
+
...optionalEntry("level", level),
|
|
122
|
+
...optionalEntry("message", message),
|
|
123
|
+
...optionalEntry("data", data)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {unknown} breadcrumbs
|
|
129
|
+
* @returns {IssueBreadcrumb[] | undefined}
|
|
130
|
+
*/
|
|
131
|
+
function validateIssueBreadcrumbs(breadcrumbs) {
|
|
132
|
+
if (breadcrumbs === undefined) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
if (!Array.isArray(breadcrumbs) || breadcrumbs.length < MIN_ISSUE_BREADCRUMBS || breadcrumbs.length > MAX_ISSUE_BREADCRUMBS) {
|
|
136
|
+
throw new SdkError("validation_error", `issue breadcrumbs must contain 1-${MAX_ISSUE_BREADCRUMBS} entries`);
|
|
137
|
+
}
|
|
138
|
+
/** @type {readonly unknown[]} */
|
|
139
|
+
const list = breadcrumbs;
|
|
140
|
+
return list.map((breadcrumb) => validateIssueBreadcrumb(breadcrumb));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = { MAX_ISSUE_BREADCRUMBS, validateIssueBreadcrumb, validateIssueBreadcrumbs };
|