hobots 1.7.6 → 1.8.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 +5 -25
- package/dist/index.cjs +3 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -19
- package/dist/index.d.ts +2 -19
- package/dist/index.js +3 -73
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +1 -17
- package/dist/protocol.d.ts +1 -17
- package/docs/README.md +3 -3
- package/docs/api-reference.md +0 -22
- package/docs/concepts.md +9 -33
- package/docs/getting-started.md +1 -1
- package/docs/protocol.md +1 -2
- package/docs/{monitor.md → telemetry.md} +3 -25
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload,
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData } from './protocol.cjs';
|
|
2
2
|
export { AgentInfo, Envelope, EnvelopeItem, ExceptionData, PollRequest, PollResponse, RunDescriptor, RunError, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
@@ -58,7 +58,6 @@ declare class Client {
|
|
|
58
58
|
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
59
59
|
private prepareEvent;
|
|
60
60
|
sendTransaction(payload: TransactionPayload): void;
|
|
61
|
-
sendCheckIn(payload: CheckInPayload): void;
|
|
62
61
|
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
63
62
|
flush(timeoutMs?: number): Promise<boolean>;
|
|
64
63
|
close(timeoutMs?: number): Promise<boolean>;
|
|
@@ -232,18 +231,6 @@ interface CaptureHint {
|
|
|
232
231
|
fingerprint?: string[];
|
|
233
232
|
}
|
|
234
233
|
|
|
235
|
-
interface CheckInOptions {
|
|
236
|
-
monitorSlug: string;
|
|
237
|
-
status: CheckInStatus;
|
|
238
|
-
/** Reutilize o id retornado pelo check-in 'in_progress' para fechar a execução */
|
|
239
|
-
checkInId?: string;
|
|
240
|
-
durationMs?: number;
|
|
241
|
-
/** Expressão cron — cria/atualiza o monitor automaticamente no servidor */
|
|
242
|
-
schedule?: string;
|
|
243
|
-
timezone?: string;
|
|
244
|
-
}
|
|
245
|
-
type WithMonitorOptions = Pick<CheckInOptions, 'schedule' | 'timezone'>;
|
|
246
|
-
|
|
247
234
|
/** Inicializa o SDK. Chame uma vez, o mais cedo possível no programa. */
|
|
248
235
|
declare function init(options: InitOptions): void;
|
|
249
236
|
declare function getClient(): Client | undefined;
|
|
@@ -261,10 +248,6 @@ declare function setExtra(key: string, value: unknown): void;
|
|
|
261
248
|
declare function withScope<T>(callback: (scope: Scope) => T): T;
|
|
262
249
|
/** Inicia uma transaction de performance. Chame .finish() para enviá-la. */
|
|
263
250
|
declare function startTransaction(name: string, op?: string): Transaction;
|
|
264
|
-
/** Check-in manual de um monitor cron. Retorna o check_in_id para fechar a execução depois. */
|
|
265
|
-
declare function checkIn(options: CheckInOptions): string | undefined;
|
|
266
|
-
/** Envolve um job monitorado: envia in_progress → ok/error com duração e captura a exceção em caso de falha. */
|
|
267
|
-
declare function withMonitor<T>(monitorSlug: string, fn: () => T | Promise<T>, options?: WithMonitorOptions): Promise<T>;
|
|
268
251
|
/** Aguarda o envio de tudo que está na fila (até timeoutMs). */
|
|
269
252
|
declare function flush(timeoutMs?: number): Promise<boolean>;
|
|
270
253
|
/** Registra o handler de uma task (o task_slug configurado no formulário do app, em Configurações → Formulários). */
|
|
@@ -284,4 +267,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
284
267
|
|
|
285
268
|
declare function scrubSecrets(text: string): string;
|
|
286
269
|
|
|
287
|
-
export { Breadcrumb, type BreadcrumbInput, type CaptureHint,
|
|
270
|
+
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity, 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,4 +1,4 @@
|
|
|
1
|
-
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload,
|
|
1
|
+
import { Breadcrumb, EventUser, Severity, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData } from './protocol.js';
|
|
2
2
|
export { AgentInfo, Envelope, EnvelopeItem, ExceptionData, PollRequest, PollResponse, RunDescriptor, RunError, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
3
3
|
|
|
4
4
|
/** API oficial da Hobots — o SDK sempre fala com ela em produção. */
|
|
@@ -58,7 +58,6 @@ declare class Client {
|
|
|
58
58
|
captureEvent(event: EventPayload, hint: CaptureHint | undefined, scope: Scope): string;
|
|
59
59
|
private prepareEvent;
|
|
60
60
|
sendTransaction(payload: TransactionPayload): void;
|
|
61
|
-
sendCheckIn(payload: CheckInPayload): void;
|
|
62
61
|
sendHeartbeat(payload: HeartbeatPayload): void;
|
|
63
62
|
flush(timeoutMs?: number): Promise<boolean>;
|
|
64
63
|
close(timeoutMs?: number): Promise<boolean>;
|
|
@@ -232,18 +231,6 @@ interface CaptureHint {
|
|
|
232
231
|
fingerprint?: string[];
|
|
233
232
|
}
|
|
234
233
|
|
|
235
|
-
interface CheckInOptions {
|
|
236
|
-
monitorSlug: string;
|
|
237
|
-
status: CheckInStatus;
|
|
238
|
-
/** Reutilize o id retornado pelo check-in 'in_progress' para fechar a execução */
|
|
239
|
-
checkInId?: string;
|
|
240
|
-
durationMs?: number;
|
|
241
|
-
/** Expressão cron — cria/atualiza o monitor automaticamente no servidor */
|
|
242
|
-
schedule?: string;
|
|
243
|
-
timezone?: string;
|
|
244
|
-
}
|
|
245
|
-
type WithMonitorOptions = Pick<CheckInOptions, 'schedule' | 'timezone'>;
|
|
246
|
-
|
|
247
234
|
/** Inicializa o SDK. Chame uma vez, o mais cedo possível no programa. */
|
|
248
235
|
declare function init(options: InitOptions): void;
|
|
249
236
|
declare function getClient(): Client | undefined;
|
|
@@ -261,10 +248,6 @@ declare function setExtra(key: string, value: unknown): void;
|
|
|
261
248
|
declare function withScope<T>(callback: (scope: Scope) => T): T;
|
|
262
249
|
/** Inicia uma transaction de performance. Chame .finish() para enviá-la. */
|
|
263
250
|
declare function startTransaction(name: string, op?: string): Transaction;
|
|
264
|
-
/** Check-in manual de um monitor cron. Retorna o check_in_id para fechar a execução depois. */
|
|
265
|
-
declare function checkIn(options: CheckInOptions): string | undefined;
|
|
266
|
-
/** Envolve um job monitorado: envia in_progress → ok/error com duração e captura a exceção em caso de falha. */
|
|
267
|
-
declare function withMonitor<T>(monitorSlug: string, fn: () => T | Promise<T>, options?: WithMonitorOptions): Promise<T>;
|
|
268
251
|
/** Aguarda o envio de tudo que está na fila (até timeoutMs). */
|
|
269
252
|
declare function flush(timeoutMs?: number): Promise<boolean>;
|
|
270
253
|
/** Registra o handler de uma task (o task_slug configurado no formulário do app, em Configurações → Formulários). */
|
|
@@ -284,4 +267,4 @@ declare function close(timeoutMs?: number): Promise<boolean>;
|
|
|
284
267
|
|
|
285
268
|
declare function scrubSecrets(text: string): string;
|
|
286
269
|
|
|
287
|
-
export { Breadcrumb, type BreadcrumbInput, type CaptureHint,
|
|
270
|
+
export { Breadcrumb, type BreadcrumbInput, type CaptureHint, Client, DEFAULT_BASE_URL, EventPayload, EventUser, type HeartbeatOptions, HeartbeatPayload, type InitOptions, type RunContext, RunLogLevel, Scope, Severity, 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 ? "1.
|
|
106
|
+
var SDK_VERSION = true ? "1.8.0" : "0.0.0-dev";
|
|
107
107
|
function isNode() {
|
|
108
108
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
109
109
|
}
|
|
@@ -457,16 +457,6 @@ var Client = class {
|
|
|
457
457
|
}
|
|
458
458
|
});
|
|
459
459
|
}
|
|
460
|
-
sendCheckIn(payload) {
|
|
461
|
-
this.transport.enqueue({
|
|
462
|
-
type: "check_in",
|
|
463
|
-
payload: {
|
|
464
|
-
...payload,
|
|
465
|
-
release: payload.release ?? this.options.release,
|
|
466
|
-
environment: payload.environment ?? this.options.environment ?? "production"
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
460
|
sendHeartbeat(payload) {
|
|
471
461
|
this.transport.enqueue({
|
|
472
462
|
type: "heartbeat",
|
|
@@ -831,34 +821,6 @@ var Transaction = class {
|
|
|
831
821
|
}
|
|
832
822
|
};
|
|
833
823
|
|
|
834
|
-
// src/checkin.ts
|
|
835
|
-
function sendCheckIn(client2, options) {
|
|
836
|
-
const checkInId = options.checkInId ?? uuid4();
|
|
837
|
-
client2.sendCheckIn({
|
|
838
|
-
check_in_id: checkInId,
|
|
839
|
-
monitor_slug: options.monitorSlug,
|
|
840
|
-
status: options.status,
|
|
841
|
-
duration_ms: options.durationMs,
|
|
842
|
-
schedule: options.schedule,
|
|
843
|
-
timezone: options.timezone
|
|
844
|
-
});
|
|
845
|
-
return checkInId;
|
|
846
|
-
}
|
|
847
|
-
async function withMonitorImpl(client2, captureError, monitorSlug, fn, options) {
|
|
848
|
-
const base = { monitorSlug, schedule: options?.schedule, timezone: options?.timezone };
|
|
849
|
-
const checkInId = sendCheckIn(client2, { ...base, status: "in_progress" });
|
|
850
|
-
const startedAt = Date.now();
|
|
851
|
-
try {
|
|
852
|
-
const result = await fn();
|
|
853
|
-
sendCheckIn(client2, { ...base, status: "ok", checkInId, durationMs: Date.now() - startedAt });
|
|
854
|
-
return result;
|
|
855
|
-
} catch (error) {
|
|
856
|
-
sendCheckIn(client2, { ...base, status: "error", checkInId, durationMs: Date.now() - startedAt });
|
|
857
|
-
captureError(error);
|
|
858
|
-
throw error;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
824
|
// src/tasks/api.ts
|
|
863
825
|
var POLL_TIMEOUT_MS = 3e4;
|
|
864
826
|
var UPDATE_TIMEOUT_MS = 1e4;
|
|
@@ -996,7 +958,6 @@ var DEFAULT_CANCEL_CHECK_INTERVAL_MS = 5e3;
|
|
|
996
958
|
var MIN_CANCEL_CHECK_INTERVAL_MS = 1e3;
|
|
997
959
|
var MAX_CANCEL_CHECK_INTERVAL_MS = 15e3;
|
|
998
960
|
var MAX_LOG_MESSAGE_CHARS = 1e4;
|
|
999
|
-
var MAX_LOGS_PER_RUN = 500;
|
|
1000
961
|
var MAX_LOGS_PER_PATCH = 100;
|
|
1001
962
|
var FLUSH_AT_BUFFERED = 20;
|
|
1002
963
|
var RunReporter = class {
|
|
@@ -1032,8 +993,6 @@ var RunReporter = class {
|
|
|
1032
993
|
}
|
|
1033
994
|
context;
|
|
1034
995
|
buffer = [];
|
|
1035
|
-
loggedCount = 0;
|
|
1036
|
-
droppedCount = 0;
|
|
1037
996
|
dead = false;
|
|
1038
997
|
chain = Promise.resolve();
|
|
1039
998
|
pendingUpdates = 0;
|
|
@@ -1080,11 +1039,6 @@ var RunReporter = class {
|
|
|
1080
1039
|
push(level, message, alreadyScrubbed = false) {
|
|
1081
1040
|
if (this.dead) return;
|
|
1082
1041
|
const scrubbed = alreadyScrubbed ? message : scrubSecrets(message);
|
|
1083
|
-
if (this.loggedCount >= MAX_LOGS_PER_RUN) {
|
|
1084
|
-
this.droppedCount++;
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
|
-
this.loggedCount++;
|
|
1088
1042
|
this.buffer.push({ ts: nowISO(), level, message: truncate(scrubbed, MAX_LOG_MESSAGE_CHARS) });
|
|
1089
1043
|
if (this.buffer.length >= FLUSH_AT_BUFFERED) {
|
|
1090
1044
|
this.flushLogs();
|
|
@@ -1107,16 +1061,7 @@ var RunReporter = class {
|
|
|
1107
1061
|
}
|
|
1108
1062
|
}
|
|
1109
1063
|
takeLogs() {
|
|
1110
|
-
|
|
1111
|
-
if (this.droppedCount > 0) {
|
|
1112
|
-
logs.push({
|
|
1113
|
-
ts: nowISO(),
|
|
1114
|
-
level: "warning",
|
|
1115
|
-
message: `${this.droppedCount} logs descartados (limite de ${MAX_LOGS_PER_RUN} por execu\xE7\xE3o)`
|
|
1116
|
-
});
|
|
1117
|
-
this.droppedCount = 0;
|
|
1118
|
-
}
|
|
1119
|
-
return logs;
|
|
1064
|
+
return this.buffer.splice(0, this.buffer.length);
|
|
1120
1065
|
}
|
|
1121
1066
|
/** Flush incremental: envia o buffer como status 'running' (em chunks). */
|
|
1122
1067
|
flushLogs() {
|
|
@@ -1404,7 +1349,7 @@ var TaskAgent = class {
|
|
|
1404
1349
|
{
|
|
1405
1350
|
agent: {
|
|
1406
1351
|
// identidade canônica do agente no painel — o mesmo instanceId do
|
|
1407
|
-
// heartbeat
|
|
1352
|
+
// heartbeat da Telemetria, então os dois canais convergem em um agente
|
|
1408
1353
|
instance_id: this.instanceId,
|
|
1409
1354
|
version: SDK_VERSION,
|
|
1410
1355
|
host: hostname(),
|
|
@@ -1606,19 +1551,6 @@ function startTransaction(name, op) {
|
|
|
1606
1551
|
const sampled = rate >= 1 || Math.random() < rate;
|
|
1607
1552
|
return new Transaction(client, name, op, sampled);
|
|
1608
1553
|
}
|
|
1609
|
-
function checkIn(options) {
|
|
1610
|
-
return client ? sendCheckIn(client, options) : void 0;
|
|
1611
|
-
}
|
|
1612
|
-
async function withMonitor(monitorSlug, fn, options) {
|
|
1613
|
-
if (!client) return fn();
|
|
1614
|
-
return withMonitorImpl(
|
|
1615
|
-
client,
|
|
1616
|
-
(error) => captureException(error, { tags: { monitor: monitorSlug } }),
|
|
1617
|
-
monitorSlug,
|
|
1618
|
-
fn,
|
|
1619
|
-
options
|
|
1620
|
-
);
|
|
1621
|
-
}
|
|
1622
1554
|
function flush(timeoutMs) {
|
|
1623
1555
|
return client ? client.flush(timeoutMs) : Promise.resolve(true);
|
|
1624
1556
|
}
|
|
@@ -1659,7 +1591,6 @@ export {
|
|
|
1659
1591
|
addBreadcrumb,
|
|
1660
1592
|
captureException,
|
|
1661
1593
|
captureMessage,
|
|
1662
|
-
checkIn,
|
|
1663
1594
|
close,
|
|
1664
1595
|
flush,
|
|
1665
1596
|
getClient,
|
|
@@ -1674,7 +1605,6 @@ export {
|
|
|
1674
1605
|
start,
|
|
1675
1606
|
startTransaction,
|
|
1676
1607
|
stop,
|
|
1677
|
-
withMonitor,
|
|
1678
1608
|
withScope
|
|
1679
1609
|
};
|
|
1680
1610
|
//# sourceMappingURL=index.js.map
|