hobots 2.0.0 → 2.0.1
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/README.md +3 -3
- package/dist/index.cjs +27 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +12 -4
- package/dist/protocol.d.ts +12 -4
- package/docs/api-reference.md +7 -7
- package/docs/concepts.md +13 -11
- package/docs/tasks.md +1 -1
- package/docs/telemetry.md +3 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser,
|
|
2
|
-
export { Envelope, EnvelopeItem, ExceptionData, InstanceInfo, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
1
|
+
import { Breadcrumb, EventUser, EventType, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, RunItemStatus, RunAttachmentContentType } from './protocol.cjs';
|
|
2
|
+
export { BreadcrumbLevel, Envelope, EnvelopeItem, ExceptionData, InstanceInfo, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
/** Aceita tudo que o handler pode ter em mãos: bytes ou um caminho de arquivo (só Node). */
|
|
5
5
|
type AttachInput = Uint8Array | ArrayBuffer | string;
|
|
@@ -25,7 +25,7 @@ declare class Scope {
|
|
|
25
25
|
user?: EventUser;
|
|
26
26
|
contexts: Record<string, Record<string, unknown>>;
|
|
27
27
|
extra: Record<string, unknown>;
|
|
28
|
-
|
|
28
|
+
type?: EventType;
|
|
29
29
|
fingerprint?: string[];
|
|
30
30
|
breadcrumbs: Breadcrumb[];
|
|
31
31
|
setTag(key: string, value: string): this;
|
|
@@ -34,7 +34,7 @@ declare class Scope {
|
|
|
34
34
|
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
35
35
|
setExtra(key: string, value: unknown): this;
|
|
36
36
|
setExtras(extras: Record<string, unknown>): this;
|
|
37
|
-
|
|
37
|
+
setType(type: EventType): this;
|
|
38
38
|
setFingerprint(fingerprint: string[]): this;
|
|
39
39
|
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
40
40
|
clearBreadcrumbs(): this;
|
|
@@ -59,7 +59,7 @@ declare class Client {
|
|
|
59
59
|
/** Serialização explícita nunca inclui o secret. */
|
|
60
60
|
toJSON(): Record<string, unknown>;
|
|
61
61
|
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
62
|
-
captureMessage(message: string,
|
|
62
|
+
captureMessage(message: string, type: EventType, hint: CaptureHint | undefined, scope: Scope): string;
|
|
63
63
|
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
64
64
|
private prepareEvent;
|
|
65
65
|
sendTransaction(payload: TransactionPayload): void;
|
|
@@ -277,7 +277,7 @@ interface CaptureAttachment {
|
|
|
277
277
|
contentType?: RunAttachmentContentType;
|
|
278
278
|
}
|
|
279
279
|
interface CaptureHint {
|
|
280
|
-
|
|
280
|
+
type?: EventType;
|
|
281
281
|
tags?: Record<string, string>;
|
|
282
282
|
extra?: Record<string, unknown>;
|
|
283
283
|
fingerprint?: string[];
|
|
@@ -305,7 +305,7 @@ declare function getClient(): Client | undefined;
|
|
|
305
305
|
* como miniatura na linha de log da run correspondente ao erro.
|
|
306
306
|
*/
|
|
307
307
|
declare function captureException(error: unknown, hint?: CaptureHint): string | undefined;
|
|
308
|
-
declare function captureMessage(message: string,
|
|
308
|
+
declare function captureMessage(message: string, type?: EventType, hint?: CaptureHint): string | undefined;
|
|
309
309
|
/** Registra um breadcrumb — anexado aos próximos eventos como trilha do que aconteceu antes. */
|
|
310
310
|
declare function addBreadcrumb(crumb: BreadcrumbInput): void;
|
|
311
311
|
declare function setTag(key: string, value: string): void;
|
|
@@ -336,4 +336,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
336
336
|
|
|
337
337
|
declare function scrubSecrets(text: string): string;
|
|
338
338
|
|
|
339
|
-
export { type AttachInput, Breadcrumb, type BreadcrumbInput, type CaptureAttachment, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, Scope,
|
|
339
|
+
export { type AttachInput, Breadcrumb, type BreadcrumbInput, type CaptureAttachment, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventType, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, Scope, Step, StepData, type TaskHandler, type TasksOptions, Transaction, TransactionPayload, addBreadcrumb, captureException, captureMessage, close, flush, getClient, init, register, scrubSecrets, setContext, setExtra, setTag, setTags, setUser, start, startTransaction, stop, withScope };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser,
|
|
2
|
-
export { Envelope, EnvelopeItem, ExceptionData, InstanceInfo, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
1
|
+
import { Breadcrumb, EventUser, EventType, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, RunItemStatus, RunAttachmentContentType } from './protocol.js';
|
|
2
|
+
export { BreadcrumbLevel, Envelope, EnvelopeItem, ExceptionData, InstanceInfo, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
3
3
|
|
|
4
4
|
/** Aceita tudo que o handler pode ter em mãos: bytes ou um caminho de arquivo (só Node). */
|
|
5
5
|
type AttachInput = Uint8Array | ArrayBuffer | string;
|
|
@@ -25,7 +25,7 @@ declare class Scope {
|
|
|
25
25
|
user?: EventUser;
|
|
26
26
|
contexts: Record<string, Record<string, unknown>>;
|
|
27
27
|
extra: Record<string, unknown>;
|
|
28
|
-
|
|
28
|
+
type?: EventType;
|
|
29
29
|
fingerprint?: string[];
|
|
30
30
|
breadcrumbs: Breadcrumb[];
|
|
31
31
|
setTag(key: string, value: string): this;
|
|
@@ -34,7 +34,7 @@ declare class Scope {
|
|
|
34
34
|
setContext(name: string, context: Record<string, unknown> | null): this;
|
|
35
35
|
setExtra(key: string, value: unknown): this;
|
|
36
36
|
setExtras(extras: Record<string, unknown>): this;
|
|
37
|
-
|
|
37
|
+
setType(type: EventType): this;
|
|
38
38
|
setFingerprint(fingerprint: string[]): this;
|
|
39
39
|
addBreadcrumb(crumb: BreadcrumbInput, maxBreadcrumbs: number): this;
|
|
40
40
|
clearBreadcrumbs(): this;
|
|
@@ -59,7 +59,7 @@ declare class Client {
|
|
|
59
59
|
/** Serialização explícita nunca inclui o secret. */
|
|
60
60
|
toJSON(): Record<string, unknown>;
|
|
61
61
|
captureException(error: unknown, hint: CaptureHint | undefined, scope: Scope): string;
|
|
62
|
-
captureMessage(message: string,
|
|
62
|
+
captureMessage(message: string, type: EventType, hint: CaptureHint | undefined, scope: Scope): string;
|
|
63
63
|
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
64
64
|
private prepareEvent;
|
|
65
65
|
sendTransaction(payload: TransactionPayload): void;
|
|
@@ -277,7 +277,7 @@ interface CaptureAttachment {
|
|
|
277
277
|
contentType?: RunAttachmentContentType;
|
|
278
278
|
}
|
|
279
279
|
interface CaptureHint {
|
|
280
|
-
|
|
280
|
+
type?: EventType;
|
|
281
281
|
tags?: Record<string, string>;
|
|
282
282
|
extra?: Record<string, unknown>;
|
|
283
283
|
fingerprint?: string[];
|
|
@@ -305,7 +305,7 @@ declare function getClient(): Client | undefined;
|
|
|
305
305
|
* como miniatura na linha de log da run correspondente ao erro.
|
|
306
306
|
*/
|
|
307
307
|
declare function captureException(error: unknown, hint?: CaptureHint): string | undefined;
|
|
308
|
-
declare function captureMessage(message: string,
|
|
308
|
+
declare function captureMessage(message: string, type?: EventType, hint?: CaptureHint): string | undefined;
|
|
309
309
|
/** Registra um breadcrumb — anexado aos próximos eventos como trilha do que aconteceu antes. */
|
|
310
310
|
declare function addBreadcrumb(crumb: BreadcrumbInput): void;
|
|
311
311
|
declare function setTag(key: string, value: string): void;
|
|
@@ -336,4 +336,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
336
336
|
|
|
337
337
|
declare function scrubSecrets(text: string): string;
|
|
338
338
|
|
|
339
|
-
export { type AttachInput, Breadcrumb, type BreadcrumbInput, type CaptureAttachment, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, Scope,
|
|
339
|
+
export { type AttachInput, Breadcrumb, type BreadcrumbInput, type CaptureAttachment, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventType, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, Scope, Step, StepData, type TaskHandler, type TasksOptions, Transaction, TransactionPayload, addBreadcrumb, captureException, captureMessage, close, flush, getClient, init, register, scrubSecrets, setContext, setExtra, setTag, setTags, setUser, start, startTransaction, stop, withScope };
|
package/dist/index.js
CHANGED
|
@@ -103,7 +103,7 @@ function scrubSecrets(text) {
|
|
|
103
103
|
|
|
104
104
|
// src/utils.ts
|
|
105
105
|
var SDK_NAME = "hobots";
|
|
106
|
-
var SDK_VERSION = true ? "2.0.
|
|
106
|
+
var SDK_VERSION = true ? "2.0.1" : "0.0.0-dev";
|
|
107
107
|
function isNode() {
|
|
108
108
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
109
109
|
}
|
|
@@ -233,34 +233,34 @@ function safeString(value) {
|
|
|
233
233
|
}
|
|
234
234
|
return String(value);
|
|
235
235
|
}
|
|
236
|
-
function eventFromException(error,
|
|
237
|
-
let
|
|
236
|
+
function eventFromException(error, type = "error") {
|
|
237
|
+
let exceptionType;
|
|
238
238
|
let value;
|
|
239
239
|
let frames = [];
|
|
240
240
|
if (error instanceof Error) {
|
|
241
|
-
|
|
241
|
+
exceptionType = error.name || "Error";
|
|
242
242
|
value = scrubSecrets(error.message);
|
|
243
243
|
frames = parseStacktrace(error.stack);
|
|
244
244
|
} else {
|
|
245
|
-
|
|
245
|
+
exceptionType = "NonError";
|
|
246
246
|
value = scrubSecrets(safeString(error));
|
|
247
247
|
}
|
|
248
248
|
return {
|
|
249
249
|
event_id: uuid4(),
|
|
250
250
|
timestamp: nowISO(),
|
|
251
|
-
|
|
251
|
+
type,
|
|
252
252
|
exception: {
|
|
253
|
-
type,
|
|
253
|
+
type: exceptionType,
|
|
254
254
|
value,
|
|
255
255
|
...frames.length > 0 ? { stacktrace: { frames } } : {}
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
|
-
function eventFromMessage(message,
|
|
259
|
+
function eventFromMessage(message, type = "warning") {
|
|
260
260
|
return {
|
|
261
261
|
event_id: uuid4(),
|
|
262
262
|
timestamp: nowISO(),
|
|
263
|
-
|
|
263
|
+
type,
|
|
264
264
|
message: scrubSecrets(message)
|
|
265
265
|
};
|
|
266
266
|
}
|
|
@@ -423,10 +423,10 @@ var Client = class {
|
|
|
423
423
|
return `Client { baseUrl: '${this.#config.baseUrl}' }`;
|
|
424
424
|
}
|
|
425
425
|
captureException(error, hint, scope2) {
|
|
426
|
-
return this.captureEvent(eventFromException(error, hint?.
|
|
426
|
+
return this.captureEvent(eventFromException(error, hint?.type ?? "error"), hint, scope2);
|
|
427
427
|
}
|
|
428
|
-
captureMessage(message,
|
|
429
|
-
return this.captureEvent(eventFromMessage(message,
|
|
428
|
+
captureMessage(message, type, hint, scope2) {
|
|
429
|
+
return this.captureEvent(eventFromMessage(message, type), hint, scope2);
|
|
430
430
|
}
|
|
431
431
|
captureEvent(event, hint, scope2) {
|
|
432
432
|
const sampleRate = this.options.sampleRate ?? 1;
|
|
@@ -448,7 +448,7 @@ var Client = class {
|
|
|
448
448
|
const extra = { ...scope2.extra, ...event.extra, ...hint?.extra };
|
|
449
449
|
return {
|
|
450
450
|
...event,
|
|
451
|
-
|
|
451
|
+
type: hint?.type ?? event.type ?? scope2.type ?? "error",
|
|
452
452
|
release: event.release ?? this.options.release,
|
|
453
453
|
environment: event.environment ?? this.options.environment ?? "production",
|
|
454
454
|
tags: Object.keys(tags).length > 0 ? tags : void 0,
|
|
@@ -566,7 +566,7 @@ function installGlobalHandlers(client2, getScope) {
|
|
|
566
566
|
process.on(
|
|
567
567
|
"uncaughtException",
|
|
568
568
|
markInternal((error) => {
|
|
569
|
-
client2.captureException(error, {
|
|
569
|
+
client2.captureException(error, { type: "fatal", tags: { mechanism: "uncaughtException" } }, getScope());
|
|
570
570
|
void client2.flush(2e3).then(async () => {
|
|
571
571
|
if (externalListenerCount("uncaughtException") === 0) {
|
|
572
572
|
await awaitEmergencyTasks(EMERGENCY_REPORT_CAP_MS);
|
|
@@ -579,7 +579,7 @@ function installGlobalHandlers(client2, getScope) {
|
|
|
579
579
|
process.on(
|
|
580
580
|
"unhandledRejection",
|
|
581
581
|
markInternal((reason) => {
|
|
582
|
-
client2.captureException(reason, {
|
|
582
|
+
client2.captureException(reason, { type: "error", tags: { mechanism: "unhandledRejection" } }, getScope());
|
|
583
583
|
void client2.flush(2e3);
|
|
584
584
|
})
|
|
585
585
|
);
|
|
@@ -610,7 +610,7 @@ var Scope = class _Scope {
|
|
|
610
610
|
user;
|
|
611
611
|
contexts = {};
|
|
612
612
|
extra = {};
|
|
613
|
-
|
|
613
|
+
type;
|
|
614
614
|
fingerprint;
|
|
615
615
|
breadcrumbs = [];
|
|
616
616
|
setTag(key, value) {
|
|
@@ -641,8 +641,8 @@ var Scope = class _Scope {
|
|
|
641
641
|
Object.assign(this.extra, extras);
|
|
642
642
|
return this;
|
|
643
643
|
}
|
|
644
|
-
|
|
645
|
-
this.
|
|
644
|
+
setType(type) {
|
|
645
|
+
this.type = type;
|
|
646
646
|
return this;
|
|
647
647
|
}
|
|
648
648
|
setFingerprint(fingerprint) {
|
|
@@ -666,7 +666,7 @@ var Scope = class _Scope {
|
|
|
666
666
|
next.user = this.user ? { ...this.user } : void 0;
|
|
667
667
|
next.contexts = Object.fromEntries(Object.entries(this.contexts).map(([k, v]) => [k, { ...v }]));
|
|
668
668
|
next.extra = { ...this.extra };
|
|
669
|
-
next.
|
|
669
|
+
next.type = this.type;
|
|
670
670
|
next.fingerprint = this.fingerprint ? [...this.fingerprint] : void 0;
|
|
671
671
|
next.breadcrumbs = [...this.breadcrumbs];
|
|
672
672
|
return next;
|
|
@@ -2026,10 +2026,10 @@ function init(options) {
|
|
|
2026
2026
|
function getClient() {
|
|
2027
2027
|
return client;
|
|
2028
2028
|
}
|
|
2029
|
-
function toRunLogLevel(
|
|
2030
|
-
return
|
|
2029
|
+
function toRunLogLevel(type) {
|
|
2030
|
+
return type === "fatal" ? "error" : type;
|
|
2031
2031
|
}
|
|
2032
|
-
function forwardAttachment(attachment, message,
|
|
2032
|
+
function forwardAttachment(attachment, message, type) {
|
|
2033
2033
|
const attach = currentRunAttach();
|
|
2034
2034
|
if (!attach) {
|
|
2035
2035
|
client?.logger.warn("attachment descartado \u2014 s\xF3 \xE9 suportado dentro de uma execu\xE7\xE3o de task (register/start)");
|
|
@@ -2038,7 +2038,7 @@ function forwardAttachment(attachment, message, level) {
|
|
|
2038
2038
|
const withMeta = typeof attachment === "object" && "image" in attachment ? attachment : { image: attachment };
|
|
2039
2039
|
void attach(withMeta.image, {
|
|
2040
2040
|
message,
|
|
2041
|
-
level: toRunLogLevel(
|
|
2041
|
+
level: toRunLogLevel(type),
|
|
2042
2042
|
caption: withMeta.caption,
|
|
2043
2043
|
contentType: withMeta.contentType
|
|
2044
2044
|
});
|
|
@@ -2046,15 +2046,15 @@ function forwardAttachment(attachment, message, level) {
|
|
|
2046
2046
|
function captureException(error, hint) {
|
|
2047
2047
|
if (hint?.attachment) {
|
|
2048
2048
|
const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
2049
|
-
forwardAttachment(hint.attachment, message, hint.
|
|
2049
|
+
forwardAttachment(hint.attachment, message, hint.type ?? "error");
|
|
2050
2050
|
}
|
|
2051
2051
|
return client?.captureException(error, hint, scope);
|
|
2052
2052
|
}
|
|
2053
|
-
function captureMessage(message,
|
|
2053
|
+
function captureMessage(message, type = "warning", hint) {
|
|
2054
2054
|
if (hint?.attachment) {
|
|
2055
|
-
forwardAttachment(hint.attachment, message, hint.
|
|
2055
|
+
forwardAttachment(hint.attachment, message, hint.type ?? type);
|
|
2056
2056
|
}
|
|
2057
|
-
return client?.captureMessage(message,
|
|
2057
|
+
return client?.captureMessage(message, type, hint, scope);
|
|
2058
2058
|
}
|
|
2059
2059
|
function addBreadcrumb(crumb) {
|
|
2060
2060
|
scope.addBreadcrumb(crumb, client?.options.maxBreadcrumbs ?? DEFAULT_MAX_BREADCRUMBS);
|