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/README.md
CHANGED
|
@@ -113,7 +113,7 @@ try {
|
|
|
113
113
|
await processarNota(nota);
|
|
114
114
|
} catch (error) {
|
|
115
115
|
Hobots.captureException(error, {
|
|
116
|
-
|
|
116
|
+
type: 'error',
|
|
117
117
|
tags: { cliente: 'acme' },
|
|
118
118
|
fingerprint: ['sefaz-timeout'], // agrupa manualmente; sem isso o servidor agrupa pelo stack
|
|
119
119
|
});
|
|
@@ -123,9 +123,9 @@ try {
|
|
|
123
123
|
Hobots.captureMessage('Lote processado com sucesso', 'success');
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
-
Ambas retornam o `event_id` (ou `undefined` se não inicializado). O hint aceita `
|
|
126
|
+
Ambas retornam o `event_id` (ou `undefined` se não inicializado). O hint aceita `type`, `tags`, `extra` e `fingerprint`. Erros **não tratados** são capturados e flushados automaticamente antes do processo sair — desligue com `captureUnhandled: false`. Os eventos aparecem agrupados em issues no módulo **Issues** do app.
|
|
127
127
|
|
|
128
|
-
`
|
|
128
|
+
`EventType = 'fatal' | 'error' | 'warning' | 'success'`. Não há `'info'`/`'debug'`: narração não abre issue — para isso existem o log da execução e as breadcrumbs. Use `'success'` para reportar itens concluídos com êxito — contam como eventos, mas **não** viram issue nem disparam alertas.
|
|
129
129
|
|
|
130
130
|
### Breadcrumbs
|
|
131
131
|
|
package/dist/index.cjs
CHANGED
|
@@ -161,7 +161,7 @@ function scrubSecrets(text) {
|
|
|
161
161
|
|
|
162
162
|
// src/utils.ts
|
|
163
163
|
var SDK_NAME = "hobots";
|
|
164
|
-
var SDK_VERSION = true ? "2.0.
|
|
164
|
+
var SDK_VERSION = true ? "2.0.1" : "0.0.0-dev";
|
|
165
165
|
function isNode() {
|
|
166
166
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
167
167
|
}
|
|
@@ -291,34 +291,34 @@ function safeString(value) {
|
|
|
291
291
|
}
|
|
292
292
|
return String(value);
|
|
293
293
|
}
|
|
294
|
-
function eventFromException(error,
|
|
295
|
-
let
|
|
294
|
+
function eventFromException(error, type = "error") {
|
|
295
|
+
let exceptionType;
|
|
296
296
|
let value;
|
|
297
297
|
let frames = [];
|
|
298
298
|
if (error instanceof Error) {
|
|
299
|
-
|
|
299
|
+
exceptionType = error.name || "Error";
|
|
300
300
|
value = scrubSecrets(error.message);
|
|
301
301
|
frames = parseStacktrace(error.stack);
|
|
302
302
|
} else {
|
|
303
|
-
|
|
303
|
+
exceptionType = "NonError";
|
|
304
304
|
value = scrubSecrets(safeString(error));
|
|
305
305
|
}
|
|
306
306
|
return {
|
|
307
307
|
event_id: uuid4(),
|
|
308
308
|
timestamp: nowISO(),
|
|
309
|
-
|
|
309
|
+
type,
|
|
310
310
|
exception: {
|
|
311
|
-
type,
|
|
311
|
+
type: exceptionType,
|
|
312
312
|
value,
|
|
313
313
|
...frames.length > 0 ? { stacktrace: { frames } } : {}
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
function eventFromMessage(message,
|
|
317
|
+
function eventFromMessage(message, type = "warning") {
|
|
318
318
|
return {
|
|
319
319
|
event_id: uuid4(),
|
|
320
320
|
timestamp: nowISO(),
|
|
321
|
-
|
|
321
|
+
type,
|
|
322
322
|
message: scrubSecrets(message)
|
|
323
323
|
};
|
|
324
324
|
}
|
|
@@ -481,10 +481,10 @@ var Client = class {
|
|
|
481
481
|
return `Client { baseUrl: '${this.#config.baseUrl}' }`;
|
|
482
482
|
}
|
|
483
483
|
captureException(error, hint, scope2) {
|
|
484
|
-
return this.captureEvent(eventFromException(error, hint?.
|
|
484
|
+
return this.captureEvent(eventFromException(error, hint?.type ?? "error"), hint, scope2);
|
|
485
485
|
}
|
|
486
|
-
captureMessage(message,
|
|
487
|
-
return this.captureEvent(eventFromMessage(message,
|
|
486
|
+
captureMessage(message, type, hint, scope2) {
|
|
487
|
+
return this.captureEvent(eventFromMessage(message, type), hint, scope2);
|
|
488
488
|
}
|
|
489
489
|
captureEvent(event, hint, scope2) {
|
|
490
490
|
const sampleRate = this.options.sampleRate ?? 1;
|
|
@@ -506,7 +506,7 @@ var Client = class {
|
|
|
506
506
|
const extra = { ...scope2.extra, ...event.extra, ...hint?.extra };
|
|
507
507
|
return {
|
|
508
508
|
...event,
|
|
509
|
-
|
|
509
|
+
type: hint?.type ?? event.type ?? scope2.type ?? "error",
|
|
510
510
|
release: event.release ?? this.options.release,
|
|
511
511
|
environment: event.environment ?? this.options.environment ?? "production",
|
|
512
512
|
tags: Object.keys(tags).length > 0 ? tags : void 0,
|
|
@@ -624,7 +624,7 @@ function installGlobalHandlers(client2, getScope) {
|
|
|
624
624
|
process.on(
|
|
625
625
|
"uncaughtException",
|
|
626
626
|
markInternal((error) => {
|
|
627
|
-
client2.captureException(error, {
|
|
627
|
+
client2.captureException(error, { type: "fatal", tags: { mechanism: "uncaughtException" } }, getScope());
|
|
628
628
|
void client2.flush(2e3).then(async () => {
|
|
629
629
|
if (externalListenerCount("uncaughtException") === 0) {
|
|
630
630
|
await awaitEmergencyTasks(EMERGENCY_REPORT_CAP_MS);
|
|
@@ -637,7 +637,7 @@ function installGlobalHandlers(client2, getScope) {
|
|
|
637
637
|
process.on(
|
|
638
638
|
"unhandledRejection",
|
|
639
639
|
markInternal((reason) => {
|
|
640
|
-
client2.captureException(reason, {
|
|
640
|
+
client2.captureException(reason, { type: "error", tags: { mechanism: "unhandledRejection" } }, getScope());
|
|
641
641
|
void client2.flush(2e3);
|
|
642
642
|
})
|
|
643
643
|
);
|
|
@@ -668,7 +668,7 @@ var Scope = class _Scope {
|
|
|
668
668
|
user;
|
|
669
669
|
contexts = {};
|
|
670
670
|
extra = {};
|
|
671
|
-
|
|
671
|
+
type;
|
|
672
672
|
fingerprint;
|
|
673
673
|
breadcrumbs = [];
|
|
674
674
|
setTag(key, value) {
|
|
@@ -699,8 +699,8 @@ var Scope = class _Scope {
|
|
|
699
699
|
Object.assign(this.extra, extras);
|
|
700
700
|
return this;
|
|
701
701
|
}
|
|
702
|
-
|
|
703
|
-
this.
|
|
702
|
+
setType(type) {
|
|
703
|
+
this.type = type;
|
|
704
704
|
return this;
|
|
705
705
|
}
|
|
706
706
|
setFingerprint(fingerprint) {
|
|
@@ -724,7 +724,7 @@ var Scope = class _Scope {
|
|
|
724
724
|
next.user = this.user ? { ...this.user } : void 0;
|
|
725
725
|
next.contexts = Object.fromEntries(Object.entries(this.contexts).map(([k, v]) => [k, { ...v }]));
|
|
726
726
|
next.extra = { ...this.extra };
|
|
727
|
-
next.
|
|
727
|
+
next.type = this.type;
|
|
728
728
|
next.fingerprint = this.fingerprint ? [...this.fingerprint] : void 0;
|
|
729
729
|
next.breadcrumbs = [...this.breadcrumbs];
|
|
730
730
|
return next;
|
|
@@ -2084,10 +2084,10 @@ function init(options) {
|
|
|
2084
2084
|
function getClient() {
|
|
2085
2085
|
return client;
|
|
2086
2086
|
}
|
|
2087
|
-
function toRunLogLevel(
|
|
2088
|
-
return
|
|
2087
|
+
function toRunLogLevel(type) {
|
|
2088
|
+
return type === "fatal" ? "error" : type;
|
|
2089
2089
|
}
|
|
2090
|
-
function forwardAttachment(attachment, message,
|
|
2090
|
+
function forwardAttachment(attachment, message, type) {
|
|
2091
2091
|
const attach = currentRunAttach();
|
|
2092
2092
|
if (!attach) {
|
|
2093
2093
|
client?.logger.warn("attachment descartado \u2014 s\xF3 \xE9 suportado dentro de uma execu\xE7\xE3o de task (register/start)");
|
|
@@ -2096,7 +2096,7 @@ function forwardAttachment(attachment, message, level) {
|
|
|
2096
2096
|
const withMeta = typeof attachment === "object" && "image" in attachment ? attachment : { image: attachment };
|
|
2097
2097
|
void attach(withMeta.image, {
|
|
2098
2098
|
message,
|
|
2099
|
-
level: toRunLogLevel(
|
|
2099
|
+
level: toRunLogLevel(type),
|
|
2100
2100
|
caption: withMeta.caption,
|
|
2101
2101
|
contentType: withMeta.contentType
|
|
2102
2102
|
});
|
|
@@ -2104,15 +2104,15 @@ function forwardAttachment(attachment, message, level) {
|
|
|
2104
2104
|
function captureException(error, hint) {
|
|
2105
2105
|
if (hint?.attachment) {
|
|
2106
2106
|
const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
2107
|
-
forwardAttachment(hint.attachment, message, hint.
|
|
2107
|
+
forwardAttachment(hint.attachment, message, hint.type ?? "error");
|
|
2108
2108
|
}
|
|
2109
2109
|
return client?.captureException(error, hint, scope);
|
|
2110
2110
|
}
|
|
2111
|
-
function captureMessage(message,
|
|
2111
|
+
function captureMessage(message, type = "warning", hint) {
|
|
2112
2112
|
if (hint?.attachment) {
|
|
2113
|
-
forwardAttachment(hint.attachment, message, hint.
|
|
2113
|
+
forwardAttachment(hint.attachment, message, hint.type ?? type);
|
|
2114
2114
|
}
|
|
2115
|
-
return client?.captureMessage(message,
|
|
2115
|
+
return client?.captureMessage(message, type, hint, scope);
|
|
2116
2116
|
}
|
|
2117
2117
|
function addBreadcrumb(crumb) {
|
|
2118
2118
|
scope.addBreadcrumb(crumb, client?.options.maxBreadcrumbs ?? DEFAULT_MAX_BREADCRUMBS);
|