@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.
- 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 +30 -2810
- 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-exception.cjs +13 -8
- 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 +55 -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/span-validation.cjs +191 -0
- package/stored-events.cjs +243 -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 +49 -1
- 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 -289
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const { isObjectLike, propertyOf } = require("./error-details.cjs");
|
|
2
|
+
const { MAX_ISSUE_BREADCRUMBS, validateIssueBreadcrumb } = require("./issue-diagnostics.cjs");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @import { IssueBreadcrumb } from "./index.cjs"
|
|
6
|
+
* @import { Callable, DeepReadonly } from "./validation.cjs"
|
|
7
|
+
* @typedef {readonly DeepReadonly<IssueBreadcrumb>[]} Breadcrumbs
|
|
8
|
+
* @typedef {Readonly<{ breadcrumbs: Breadcrumbs, truncated: boolean }>} BreadcrumbTrail
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const NO_BREADCRUMBS = 0;
|
|
12
|
+
/** @type {BreadcrumbTrail} */
|
|
13
|
+
const EMPTY_TRAIL = { breadcrumbs: [], truncated: false };
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {Callable | undefined} provider
|
|
17
|
+
* @param {unknown} receiver
|
|
18
|
+
* @returns {unknown}
|
|
19
|
+
*/
|
|
20
|
+
function callProvider(provider, receiver) {
|
|
21
|
+
try {
|
|
22
|
+
return provider === undefined ? undefined : Reflect.apply(provider, receiver, []);
|
|
23
|
+
} catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {unknown} breadcrumb
|
|
30
|
+
* @returns {IssueBreadcrumb | undefined}
|
|
31
|
+
*/
|
|
32
|
+
function validBreadcrumb(breadcrumb) {
|
|
33
|
+
try {
|
|
34
|
+
return validateIssueBreadcrumb(breadcrumb);
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {readonly unknown[]} entries
|
|
42
|
+
* @returns {BreadcrumbTrail}
|
|
43
|
+
*/
|
|
44
|
+
function validBreadcrumbs(entries) {
|
|
45
|
+
/** @type {IssueBreadcrumb[]} */
|
|
46
|
+
const breadcrumbs = [];
|
|
47
|
+
let truncated = false;
|
|
48
|
+
for (const entry of entries.slice(-MAX_ISSUE_BREADCRUMBS)) {
|
|
49
|
+
const breadcrumb = validBreadcrumb(entry);
|
|
50
|
+
if (breadcrumb === undefined) {
|
|
51
|
+
truncated = true;
|
|
52
|
+
} else {
|
|
53
|
+
breadcrumbs.push(breadcrumb);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { breadcrumbs, truncated };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {Callable | undefined} provider
|
|
61
|
+
* @param {unknown} receiver
|
|
62
|
+
* @returns {BreadcrumbTrail}
|
|
63
|
+
*/
|
|
64
|
+
function providedBreadcrumbs(provider, receiver) {
|
|
65
|
+
const provided = callProvider(provider, receiver);
|
|
66
|
+
const list = isObjectLike(provided) ? propertyOf(provided, "breadcrumbs") : undefined;
|
|
67
|
+
if (!Array.isArray(list)) {
|
|
68
|
+
return EMPTY_TRAIL;
|
|
69
|
+
}
|
|
70
|
+
/** @type {readonly unknown[]} */
|
|
71
|
+
const entries = list;
|
|
72
|
+
const flagged = propertyOf(provided, "truncated") === true || entries.length > MAX_ISSUE_BREADCRUMBS;
|
|
73
|
+
const validated = validBreadcrumbs(entries);
|
|
74
|
+
return { breadcrumbs: validated.breadcrumbs, truncated: flagged || validated.truncated };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {DeepReadonly<IssueBreadcrumb>} left
|
|
79
|
+
* @param {DeepReadonly<IssueBreadcrumb>} right
|
|
80
|
+
* @returns {number}
|
|
81
|
+
*/
|
|
82
|
+
function byTimestamp(left, right) {
|
|
83
|
+
return Date.parse(left.timestamp) - Date.parse(right.timestamp);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {Breadcrumbs} local
|
|
88
|
+
* @param {Breadcrumbs} provided
|
|
89
|
+
* @returns {Breadcrumbs}
|
|
90
|
+
*/
|
|
91
|
+
function mergedBreadcrumbs(local, provided) {
|
|
92
|
+
if (provided.length === NO_BREADCRUMBS) {
|
|
93
|
+
return local;
|
|
94
|
+
}
|
|
95
|
+
const merged = [...local, ...provided];
|
|
96
|
+
merged.sort(byTimestamp);
|
|
97
|
+
return merged;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Readonly<Record<string, unknown>>} attributes
|
|
102
|
+
* @param {BreadcrumbTrail} local
|
|
103
|
+
* @param {BreadcrumbTrail} provided
|
|
104
|
+
* @returns {Readonly<Record<string, unknown>>}
|
|
105
|
+
*/
|
|
106
|
+
function withIssueBreadcrumbs(attributes, local, provided) {
|
|
107
|
+
const merged = mergedBreadcrumbs(local.breadcrumbs, provided.breadcrumbs);
|
|
108
|
+
const breadcrumbs = merged.slice(-MAX_ISSUE_BREADCRUMBS);
|
|
109
|
+
const truncated = attributes["breadcrumbsTruncated"] === true || local.truncated
|
|
110
|
+
|| provided.truncated || merged.length > breadcrumbs.length;
|
|
111
|
+
if (breadcrumbs.length === NO_BREADCRUMBS) {
|
|
112
|
+
return attributes;
|
|
113
|
+
}
|
|
114
|
+
return { ...attributes, breadcrumbs, ...(truncated ? { breadcrumbsTruncated: true } : {}) };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = { providedBreadcrumbs, withIssueBreadcrumbs };
|
package/random-hex.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { propertyOf } = require("./error-details.cjs");
|
|
2
|
+
|
|
3
|
+
const BYTE_VALUES = 256;
|
|
4
|
+
const HEX_RADIX = 16;
|
|
5
|
+
const HEX_DIGITS_PER_BYTE = 2;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {number} byteLength
|
|
9
|
+
* @returns {Uint8Array}
|
|
10
|
+
*/
|
|
11
|
+
function randomBytes(byteLength) {
|
|
12
|
+
const bytes = new Uint8Array(byteLength);
|
|
13
|
+
const getRandomValues = propertyOf(propertyOf(globalThis, "crypto"), "getRandomValues");
|
|
14
|
+
if (typeof getRandomValues === "function") {
|
|
15
|
+
Reflect.apply(getRandomValues, propertyOf(globalThis, "crypto"), [bytes]);
|
|
16
|
+
return bytes;
|
|
17
|
+
}
|
|
18
|
+
return Uint8Array.from(bytes, () => Math.floor(Math.random() * BYTE_VALUES));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {number} byteLength
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
function randomHex(byteLength) {
|
|
26
|
+
return Array.from(randomBytes(byteLength), (byte) => byte.toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0")).join("");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = { randomHex };
|
package/react-native.js
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { NULL_VALUE } = require("./null-value.cjs");
|
|
2
|
+
const { retryAfterMsOrUndefined } = require("./sdk-error.cjs");
|
|
3
|
+
const { requireNonEmpty } = require("./validation.cjs");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @import { TransportResponse } from "./index.cjs"
|
|
7
|
+
* @typedef {{ statusCode: number, retryAfterMs?: number, errorCode?: string }} ScriptedResponse
|
|
8
|
+
* @typedef {ScriptedResponse | Error} ScriptedOutcome
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const ACCEPTED_STATUS_CODE = 202;
|
|
12
|
+
const SINGLE_ATTEMPT = 1;
|
|
13
|
+
const LAST_INDEX = -1;
|
|
14
|
+
const FIRST_INDEX = 0;
|
|
15
|
+
const SINGLE_RESPONSE = 1;
|
|
16
|
+
|
|
17
|
+
class RecordingTransport {
|
|
18
|
+
/**
|
|
19
|
+
* @param {readonly (Readonly<ScriptedResponse> | Readonly<Error>)[]} [scriptedResponses]
|
|
20
|
+
*/
|
|
21
|
+
constructor(scriptedResponses = [{ statusCode: ACCEPTED_STATUS_CODE }]) {
|
|
22
|
+
/** @type {ScriptedOutcome[]} */
|
|
23
|
+
this.scriptedResponses = [...scriptedResponses];
|
|
24
|
+
/** @type {string[]} */
|
|
25
|
+
this.sentBodies = [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @returns {RecordingTransport}
|
|
30
|
+
*/
|
|
31
|
+
static alwaysAccept() {
|
|
32
|
+
return new RecordingTransport([{ statusCode: ACCEPTED_STATUS_CODE }]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @returns {string | null}
|
|
37
|
+
*/
|
|
38
|
+
lastBody() {
|
|
39
|
+
return this.sentBodies.at(LAST_INDEX) ?? NULL_VALUE;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {unknown} apiKey
|
|
44
|
+
* @param {string} body
|
|
45
|
+
* @returns {Promise<TransportResponse>}
|
|
46
|
+
*/
|
|
47
|
+
async send(apiKey, body) {
|
|
48
|
+
requireNonEmpty("apiKey", apiKey);
|
|
49
|
+
this.sentBodies.push(body);
|
|
50
|
+
|
|
51
|
+
const [next = { statusCode: ACCEPTED_STATUS_CODE }] = this.scriptedResponses.splice(FIRST_INDEX, SINGLE_RESPONSE);
|
|
52
|
+
|
|
53
|
+
if (next instanceof Error) {
|
|
54
|
+
throw next;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const retryAfterMs = retryAfterMsOrUndefined(next.retryAfterMs);
|
|
58
|
+
return {
|
|
59
|
+
statusCode: next.statusCode,
|
|
60
|
+
|
|
61
|
+
attempts: SINGLE_ATTEMPT,
|
|
62
|
+
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
63
|
+
...(typeof next.errorCode === "string" ? { errorCode: next.errorCode } : {})
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { RecordingTransport };
|