hobots 1.7.6 → 1.8.0
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 +2 -55
- 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 +2 -55
- 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;
|
|
@@ -1404,7 +1366,7 @@ var TaskAgent = class {
|
|
|
1404
1366
|
{
|
|
1405
1367
|
agent: {
|
|
1406
1368
|
// identidade canônica do agente no painel — o mesmo instanceId do
|
|
1407
|
-
// heartbeat
|
|
1369
|
+
// heartbeat da Telemetria, então os dois canais convergem em um agente
|
|
1408
1370
|
instance_id: this.instanceId,
|
|
1409
1371
|
version: SDK_VERSION,
|
|
1410
1372
|
host: hostname(),
|
|
@@ -1606,19 +1568,6 @@ function startTransaction(name, op) {
|
|
|
1606
1568
|
const sampled = rate >= 1 || Math.random() < rate;
|
|
1607
1569
|
return new Transaction(client, name, op, sampled);
|
|
1608
1570
|
}
|
|
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
1571
|
function flush(timeoutMs) {
|
|
1623
1572
|
return client ? client.flush(timeoutMs) : Promise.resolve(true);
|
|
1624
1573
|
}
|
|
@@ -1659,7 +1608,6 @@ export {
|
|
|
1659
1608
|
addBreadcrumb,
|
|
1660
1609
|
captureException,
|
|
1661
1610
|
captureMessage,
|
|
1662
|
-
checkIn,
|
|
1663
1611
|
close,
|
|
1664
1612
|
flush,
|
|
1665
1613
|
getClient,
|
|
@@ -1674,7 +1622,6 @@ export {
|
|
|
1674
1622
|
start,
|
|
1675
1623
|
startTransaction,
|
|
1676
1624
|
stop,
|
|
1677
|
-
withMonitor,
|
|
1678
1625
|
withScope
|
|
1679
1626
|
};
|
|
1680
1627
|
//# sourceMappingURL=index.js.map
|