@theholocron/observability 0.6.1-alpha.1 → 0.7.0-alpha.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/dist/analytics.d.mts +2 -2
- package/dist/analytics.mjs +2 -2
- package/dist/{core-jXa8qbEx.d.mts → core-DDpFbotv.d.mts} +2 -2
- package/dist/core.d.mts +3 -3
- package/dist/core.mjs +3 -3
- package/dist/{create-BLYkMD-k.mjs → create-BVlZq5Qa.mjs} +8 -25
- package/dist/{create-CEY3e4NQ.d.mts → create-X1v3LWjb.d.mts} +6 -5
- package/dist/errors.d.mts +2 -2
- package/dist/errors.mjs +2 -2
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +6 -6
- package/dist/{logger-DIvYoEp9.mjs → logger-BqELCAzg.mjs} +5 -2
- package/dist/{logger-CxGXigv1.d.mts → logger-DC6M2rL_.d.mts} +15 -4
- package/dist/logger.d.mts +3 -3
- package/dist/logger.mjs +2 -2
- package/dist/{pino-Dx8yblcl.d.mts → pino-DIfQGY7z.d.mts} +12 -15
- package/dist/{posthog-sink-ClNks-Le.mjs → posthog-sink-BUvWHuIC.mjs} +4 -2
- package/dist/{posthog-sink-BvVIQrGy.d.mts → posthog-sink-D4aRF3P2.d.mts} +4 -3
- package/dist/{redact-BMWG62k9.mjs → redact-DCKZnDDa.mjs} +3 -2
- package/dist/{sentry-sink-Dk0H3MG5.d.mts → sentry-sink-C1E3tOl-.d.mts} +5 -3
- package/dist/{sentry-sink-BOuueung.mjs → sentry-sink-QWpfJGg_.mjs} +6 -3
- package/dist/{sinks-scWbkOMp.mjs → sinks-Dz8Kxoha.mjs} +8 -2
- package/dist/{sinks-CSEolKcN.d.mts → sinks-v2TCQsCp.d.mts} +16 -2
- package/dist/testing.d.mts +8 -16
- package/dist/testing.mjs +5 -9
- package/package.json +17 -14
package/dist/analytics.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as NoopAnalyticsSink, t as AnalyticsSink } from "./sinks-
|
|
2
|
-
import { t as PostHogSink } from "./posthog-sink-
|
|
1
|
+
import { i as NoopAnalyticsSink, t as AnalyticsSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
|
+
import { t as PostHogSink } from "./posthog-sink-D4aRF3P2.mjs";
|
|
3
3
|
export { type AnalyticsSink, NoopAnalyticsSink, PostHogSink };
|
package/dist/analytics.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as NoopAnalyticsSink } from "./sinks-
|
|
2
|
-
import { t as PostHogSink } from "./posthog-sink-
|
|
1
|
+
import { t as NoopAnalyticsSink } from "./sinks-Dz8Kxoha.mjs";
|
|
2
|
+
import { t as PostHogSink } from "./posthog-sink-BUvWHuIC.mjs";
|
|
3
3
|
export { NoopAnalyticsSink, PostHogSink };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/redact.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Two redaction layers, both zero-dependency:
|
|
4
3
|
*
|
|
@@ -22,12 +21,13 @@ declare const REDACTED_PATHS: readonly string[];
|
|
|
22
21
|
declare const REDACT_CENSOR = "[Redacted]";
|
|
23
22
|
/** Ready-to-use Pino `redact` option. */
|
|
24
23
|
declare const redactOptions: {
|
|
24
|
+
/** The field paths to redact, a copy of {@link REDACTED_PATHS}. */
|
|
25
25
|
readonly paths: readonly string[];
|
|
26
|
+
/** The string written in place of each redacted value, {@link REDACT_CENSOR}. */
|
|
26
27
|
readonly censor: "[Redacted]";
|
|
27
28
|
};
|
|
28
29
|
/** Replace token-shaped substrings in a string with `[REDACTED]`. */
|
|
29
30
|
declare function redact(raw: string): string;
|
|
30
31
|
/** Deep-scrub every string in an object by round-tripping through {@link redact}. */
|
|
31
32
|
declare function redactObject<T>(value: T): T;
|
|
32
|
-
//#endregion
|
|
33
33
|
export { redactOptions as a, redactObject as i, REDACT_CENSOR as n, redact as r, REDACTED_PATHS as t };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-
|
|
2
|
-
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
3
|
-
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-
|
|
1
|
+
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
|
+
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-DC6M2rL_.mjs";
|
|
3
|
+
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-DDpFbotv.mjs";
|
|
4
4
|
export { type AnalyticsSink, type CommandSpan, type ErrorSink, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, NoopAnalyticsSink, NoopErrorSink, NoopLogger, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-
|
|
2
|
-
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-
|
|
3
|
-
import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-
|
|
1
|
+
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-BqELCAzg.mjs";
|
|
2
|
+
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-DCKZnDDa.mjs";
|
|
3
|
+
import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-Dz8Kxoha.mjs";
|
|
4
4
|
export { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, NoopLogger, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { t as LOG_LEVELS } from "./logger-
|
|
2
|
-
import { a as redactOptions } from "./redact-
|
|
1
|
+
import { t as LOG_LEVELS } from "./logger-BqELCAzg.mjs";
|
|
2
|
+
import { a as redactOptions } from "./redact-DCKZnDDa.mjs";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { detectEnvironment as detectEnv, isCI } from "@theholocron/env-utils/lookup";
|
|
4
5
|
import pino from "pino";
|
|
5
|
-
|
|
6
|
+
// src/logger/console.ts
|
|
6
7
|
const RANK = {
|
|
7
8
|
debug: 10,
|
|
8
9
|
info: 20,
|
|
@@ -71,8 +72,7 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
71
72
|
else SINK[level](ctx);
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
-
//#region src/logger/context.ts
|
|
75
|
+
// src/logger/context.ts
|
|
76
76
|
/**
|
|
77
77
|
* A fresh correlation id for one invocation. Every log line from a single run
|
|
78
78
|
* carries this `runId`, so a whole run can be pulled back out of Axiom with
|
|
@@ -81,19 +81,6 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
81
81
|
function generateRunId() {
|
|
82
82
|
return randomUUID();
|
|
83
83
|
}
|
|
84
|
-
/**
|
|
85
|
-
* True when running inside CI. GitHub Actions (and most other providers) set
|
|
86
|
-
* `CI=true`; we also accept any other non-empty, non-`false` value.
|
|
87
|
-
*/
|
|
88
|
-
function isCI(env = process.env) {
|
|
89
|
-
const ci = env.CI;
|
|
90
|
-
if (!ci) return false;
|
|
91
|
-
return ci !== "false" && ci !== "0";
|
|
92
|
-
}
|
|
93
|
-
/** `"ci"` inside CI, otherwise `"local"` — bound on every root logger. */
|
|
94
|
-
function detectEnv(env = process.env) {
|
|
95
|
-
return isCI(env) ? "ci" : "local";
|
|
96
|
-
}
|
|
97
84
|
/** Narrow an arbitrary string to a {@link LogLevel}, or `undefined`. */
|
|
98
85
|
function parseLogLevel(value) {
|
|
99
86
|
return value && LOG_LEVELS.includes(value) ? value : void 0;
|
|
@@ -137,8 +124,7 @@ function resolveAxiomFromEnv(env = process.env) {
|
|
|
137
124
|
dataset
|
|
138
125
|
} : void 0;
|
|
139
126
|
}
|
|
140
|
-
|
|
141
|
-
//#region src/logger/transports.ts
|
|
127
|
+
// src/logger/transports.ts
|
|
142
128
|
const prettyTarget = (level) => ({
|
|
143
129
|
target: "pino-pretty",
|
|
144
130
|
level,
|
|
@@ -197,8 +183,7 @@ function buildTransport(input) {
|
|
|
197
183
|
if (targets.length === 1) return targets[0];
|
|
198
184
|
return { targets };
|
|
199
185
|
}
|
|
200
|
-
|
|
201
|
-
//#region src/logger/pino.ts
|
|
186
|
+
// src/logger/pino.ts
|
|
202
187
|
/**
|
|
203
188
|
* The Pino-backed {@link Logger}. Nothing outside this package should name it —
|
|
204
189
|
* construct loggers with `createLogger`. It is a thin pass-through to a Pino
|
|
@@ -288,8 +273,7 @@ function createPinoInstance(input) {
|
|
|
288
273
|
if (input.consoleOutput === false && !options.transport) return pino(options, nullDestination());
|
|
289
274
|
return pino(options);
|
|
290
275
|
}
|
|
291
|
-
|
|
292
|
-
//#region src/logger/create.ts
|
|
276
|
+
// src/logger/create.ts
|
|
293
277
|
/**
|
|
294
278
|
* The single entry point for building a Pino-backed logger. Generates a
|
|
295
279
|
* `runId`, detects the environment, resolves the level, wires the right
|
|
@@ -323,5 +307,4 @@ function createLogger(config = {}) {
|
|
|
323
307
|
runId
|
|
324
308
|
};
|
|
325
309
|
}
|
|
326
|
-
//#endregion
|
|
327
310
|
export { buildTransport as a, isCI as c, resolveAxiomFromEnv as d, resolveLevel as f, createPinoInstance as i, isTelemetryDisabled as l, PinoLogger as n, detectEnv as o, ConsoleLogger as p, buildPinoOptions as r, generateRunId as s, createLogger as t, parseLogLevel as u };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { i as Logger$1, r as LogLevel } from "./logger-
|
|
1
|
+
import { i as Logger$1, r as LogLevel } from "./logger-DC6M2rL_.mjs";
|
|
2
2
|
import { TransportMultiOptions, TransportSingleOptions } from "pino";
|
|
3
|
-
//#region src/logger/transports.d.ts
|
|
4
3
|
/** Axiom credentials. The token comes from env vars or the OS keyring — never
|
|
5
4
|
* a committed config file; the dataset name may come from config. */
|
|
6
5
|
interface AxiomTransportConfig {
|
|
6
|
+
/** The Axiom dataset the lines are sent to. */
|
|
7
7
|
dataset: string;
|
|
8
|
+
/** The Axiom API token. */
|
|
8
9
|
token: string;
|
|
9
10
|
}
|
|
11
|
+
/** Inputs for {@link buildTransport}. */
|
|
10
12
|
interface BuildTransportInput {
|
|
11
13
|
/** Resolved log level — applied uniformly to every transport. */
|
|
12
14
|
level: LogLevel;
|
|
@@ -55,8 +57,7 @@ interface BuildTransportInput {
|
|
|
55
57
|
* target, untouched by the override.
|
|
56
58
|
*/
|
|
57
59
|
declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
|
|
58
|
-
|
|
59
|
-
//#region src/logger/create.d.ts
|
|
60
|
+
/** Options for {@link createLogger}. */
|
|
60
61
|
interface LoggerConfig {
|
|
61
62
|
/**
|
|
62
63
|
* Explicit level — the highest-priority source. The caller passes the
|
|
@@ -83,6 +84,7 @@ interface LoggerConfig {
|
|
|
83
84
|
*/
|
|
84
85
|
consoleOutput?: boolean;
|
|
85
86
|
}
|
|
87
|
+
/** What {@link createLogger} returns. */
|
|
86
88
|
interface CreateLoggerResult {
|
|
87
89
|
/** The logger to thread through modules via `child()`. */
|
|
88
90
|
logger: Logger$1;
|
|
@@ -108,5 +110,4 @@ interface CreateLoggerResult {
|
|
|
108
110
|
* directly instead — it needs no `createLogger`.
|
|
109
111
|
*/
|
|
110
112
|
declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
|
|
111
|
-
//#endregion
|
|
112
113
|
export { BuildTransportInput as a, AxiomTransportConfig as i, LoggerConfig as n, buildTransport as o, createLogger as r, CreateLoggerResult as t };
|
package/dist/errors.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as NoopErrorSink, n as CommandSpan, r as ErrorSink } from "./sinks-
|
|
2
|
-
import { n as scrubError, t as SentrySink } from "./sentry-sink-
|
|
1
|
+
import { a as NoopErrorSink, n as CommandSpan, r as ErrorSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
|
+
import { n as scrubError, t as SentrySink } from "./sentry-sink-C1E3tOl-.mjs";
|
|
3
3
|
export { type CommandSpan, type ErrorSink, NoopErrorSink, SentrySink, scrubError };
|
package/dist/errors.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as NoopErrorSink } from "./sinks-
|
|
2
|
-
import { n as scrubError, t as SentrySink } from "./sentry-sink-
|
|
1
|
+
import { n as NoopErrorSink } from "./sinks-Dz8Kxoha.mjs";
|
|
2
|
+
import { n as scrubError, t as SentrySink } from "./sentry-sink-QWpfJGg_.mjs";
|
|
3
3
|
export { NoopErrorSink, SentrySink, scrubError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-
|
|
2
|
-
import { t as PostHogSink } from "./posthog-sink-
|
|
3
|
-
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
4
|
-
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-
|
|
5
|
-
import { n as scrubError, t as SentrySink } from "./sentry-sink-
|
|
6
|
-
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-
|
|
7
|
-
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-
|
|
1
|
+
import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
|
+
import { t as PostHogSink } from "./posthog-sink-D4aRF3P2.mjs";
|
|
3
|
+
import { a as NoopLogger, i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-DC6M2rL_.mjs";
|
|
4
|
+
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-DDpFbotv.mjs";
|
|
5
|
+
import { n as scrubError, t as SentrySink } from "./sentry-sink-C1E3tOl-.mjs";
|
|
6
|
+
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-DIfQGY7z.mjs";
|
|
7
|
+
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-X1v3LWjb.mjs";
|
|
8
8
|
export { type AnalyticsSink, type AxiomTransportConfig, type BuildTransportInput, type CommandSpan, ConsoleLogger, type CreateLoggerResult, type CreatePinoInstanceInput, type ErrorSink, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, type LoggerConfig, NoopAnalyticsSink, NoopErrorSink, NoopLogger, PinoLogger, PostHogSink, REDACTED_PATHS, REDACT_CENSOR, SentrySink, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, redact, redactObject, redactOptions, resolveAxiomFromEnv, resolveLevel, scrubError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-
|
|
2
|
-
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-
|
|
3
|
-
import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-
|
|
1
|
+
import { n as NoopLogger, t as LOG_LEVELS } from "./logger-BqELCAzg.mjs";
|
|
2
|
+
import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-DCKZnDDa.mjs";
|
|
3
|
+
import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-Dz8Kxoha.mjs";
|
|
4
4
|
import "./core.mjs";
|
|
5
|
-
import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-
|
|
6
|
-
import { n as scrubError, t as SentrySink } from "./sentry-sink-
|
|
7
|
-
import { t as PostHogSink } from "./posthog-sink-
|
|
5
|
+
import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-BVlZq5Qa.mjs";
|
|
6
|
+
import { n as scrubError, t as SentrySink } from "./sentry-sink-QWpfJGg_.mjs";
|
|
7
|
+
import { t as PostHogSink } from "./posthog-sink-BUvWHuIC.mjs";
|
|
8
8
|
export { ConsoleLogger, LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, NoopLogger, PinoLogger, PostHogSink, REDACTED_PATHS, REDACT_CENSOR, SentrySink, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, redact, redactObject, redactOptions, resolveAxiomFromEnv, resolveLevel, scrubError };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/logger.ts
|
|
2
2
|
/** The four levels, in ascending severity — useful for validation. */
|
|
3
3
|
const LOG_LEVELS = [
|
|
4
4
|
"debug",
|
|
@@ -18,9 +18,13 @@ const LOG_LEVELS = [
|
|
|
18
18
|
* instead of discarding them) live in `@theholocron/observability/testing`.
|
|
19
19
|
*/
|
|
20
20
|
var NoopLogger = class {
|
|
21
|
+
/** Discards the line. */
|
|
21
22
|
debug(_objOrMsg, _msg) {}
|
|
23
|
+
/** Discards the line. */
|
|
22
24
|
info(_objOrMsg, _msg) {}
|
|
25
|
+
/** Discards the line. */
|
|
23
26
|
warn(_objOrMsg, _msg) {}
|
|
27
|
+
/** Discards the line. */
|
|
24
28
|
error(_objOrMsg, _msg) {}
|
|
25
29
|
child(_bindings) {
|
|
26
30
|
return this;
|
|
@@ -29,5 +33,4 @@ var NoopLogger = class {
|
|
|
29
33
|
return Promise.resolve();
|
|
30
34
|
}
|
|
31
35
|
};
|
|
32
|
-
//#endregion
|
|
33
36
|
export { NoopLogger as n, LOG_LEVELS as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/logger.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The logging surface every consumer depends on.
|
|
4
3
|
*
|
|
@@ -12,12 +11,16 @@
|
|
|
12
11
|
* for a simple line (`log.info("sync complete")`).
|
|
13
12
|
*/
|
|
14
13
|
interface Logger {
|
|
14
|
+
/** Logs a verbose line, either a context object with an optional message or a bare string. */
|
|
15
15
|
debug(obj: Record<string, unknown>, msg?: string): void;
|
|
16
16
|
debug(msg: string): void;
|
|
17
|
+
/** Logs a routine progress line, either a context object with an optional message or a bare string. */
|
|
17
18
|
info(obj: Record<string, unknown>, msg?: string): void;
|
|
18
19
|
info(msg: string): void;
|
|
20
|
+
/** Logs a recoverable problem, either a context object with an optional message or a bare string. */
|
|
19
21
|
warn(obj: Record<string, unknown>, msg?: string): void;
|
|
20
22
|
warn(msg: string): void;
|
|
23
|
+
/** Logs a failure, either a context object with an optional message or a bare string. */
|
|
21
24
|
error(obj: Record<string, unknown>, msg?: string): void;
|
|
22
25
|
error(msg: string): void;
|
|
23
26
|
/**
|
|
@@ -44,8 +47,13 @@ interface Logger {
|
|
|
44
47
|
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
45
48
|
/** The four levels, in ascending severity — useful for validation. */
|
|
46
49
|
declare const LOG_LEVELS: readonly LogLevel[];
|
|
47
|
-
/**
|
|
48
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Runtime environment a logger was constructed in: `local` (a laptop), `development` (a development instance), `ci`,
|
|
52
|
+
* `test` (a deployed pre-production instance) or `production`. It is bound on every line as `env`, so one Axiom dataset can hold all of them and a query filters by it.
|
|
53
|
+
* Detection lives in `@theholocron/env-utils` (`detectEnvironment`); this union is written out here because `/core`
|
|
54
|
+
* has no dependencies, and a type test keeps it equal to env-utils' `Environment`.
|
|
55
|
+
*/
|
|
56
|
+
type LogEnv = "local" | "development" | "ci" | "test" | "production";
|
|
49
57
|
/**
|
|
50
58
|
* The disabled-logging path made explicit — one shared no-op instead of a
|
|
51
59
|
* scatter of `if (!enabled) return` guards at every call site. Symmetric with
|
|
@@ -58,12 +66,15 @@ type LogEnv = "ci" | "local";
|
|
|
58
66
|
* instead of discarding them) live in `@theholocron/observability/testing`.
|
|
59
67
|
*/
|
|
60
68
|
declare class NoopLogger implements Logger {
|
|
69
|
+
/** Discards the line. */
|
|
61
70
|
debug(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
71
|
+
/** Discards the line. */
|
|
62
72
|
info(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
73
|
+
/** Discards the line. */
|
|
63
74
|
warn(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
75
|
+
/** Discards the line. */
|
|
64
76
|
error(_objOrMsg?: Record<string, unknown> | string, _msg?: string): void;
|
|
65
77
|
child(_bindings?: Record<string, unknown>): Logger;
|
|
66
78
|
flush(): Promise<void>;
|
|
67
79
|
}
|
|
68
|
-
//#endregion
|
|
69
80
|
export { NoopLogger as a, Logger as i, LogEnv as n, LogLevel as r, LOG_LEVELS as t };
|
package/dist/logger.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-
|
|
2
|
-
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-
|
|
3
|
-
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-
|
|
1
|
+
import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-DC6M2rL_.mjs";
|
|
2
|
+
import { a as detectEnv, c as isTelemetryDisabled, d as resolveLevel, f as ConsoleLogger, i as createPinoInstance, l as parseLogLevel, n as PinoLogger, o as generateRunId, r as buildPinoOptions, s as isCI, t as CreatePinoInstanceInput, u as resolveAxiomFromEnv } from "./pino-DIfQGY7z.mjs";
|
|
3
|
+
import { a as BuildTransportInput, i as AxiomTransportConfig, n as LoggerConfig, o as buildTransport, r as createLogger, t as CreateLoggerResult } from "./create-X1v3LWjb.mjs";
|
|
4
4
|
export { type AxiomTransportConfig, type BuildTransportInput, ConsoleLogger, type CreateLoggerResult, type CreatePinoInstanceInput, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, type LoggerConfig, PinoLogger, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
|
package/dist/logger.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as LOG_LEVELS } from "./logger-
|
|
2
|
-
import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-
|
|
1
|
+
import { t as LOG_LEVELS } from "./logger-BqELCAzg.mjs";
|
|
2
|
+
import { a as buildTransport, c as isCI, d as resolveAxiomFromEnv, f as resolveLevel, i as createPinoInstance, l as isTelemetryDisabled, n as PinoLogger, o as detectEnv, p as ConsoleLogger, r as buildPinoOptions, s as generateRunId, t as createLogger, u as parseLogLevel } from "./create-BVlZq5Qa.mjs";
|
|
3
3
|
export { ConsoleLogger, LOG_LEVELS, PinoLogger, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as Logger$1,
|
|
2
|
-
import { i as AxiomTransportConfig } from "./create-
|
|
1
|
+
import { i as Logger$1, r as LogLevel } from "./logger-DC6M2rL_.mjs";
|
|
2
|
+
import { i as AxiomTransportConfig } from "./create-X1v3LWjb.mjs";
|
|
3
|
+
import { detectEnvironment as detectEnv, isCI } from "@theholocron/env-utils/lookup";
|
|
3
4
|
import { DestinationStream, Logger, LoggerOptions } from "pino";
|
|
4
|
-
//#region src/logger/console.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A zero-dependency {@link Logger} over the platform `console` — no Pino, no
|
|
7
7
|
* worker thread, no transports. Use it in the browser, an edge runtime, or
|
|
@@ -18,32 +18,27 @@ declare class ConsoleLogger implements Logger$1 {
|
|
|
18
18
|
level?: LogLevel;
|
|
19
19
|
bindings?: Record<string, unknown>;
|
|
20
20
|
});
|
|
21
|
+
/** Logs at `debug` level through `console.debug`. */
|
|
21
22
|
debug(obj: Record<string, unknown>, msg?: string): void;
|
|
22
23
|
debug(msg: string): void;
|
|
24
|
+
/** Logs at `info` level through `console.info`. */
|
|
23
25
|
info(obj: Record<string, unknown>, msg?: string): void;
|
|
24
26
|
info(msg: string): void;
|
|
27
|
+
/** Logs at `warn` level through `console.warn`. */
|
|
25
28
|
warn(obj: Record<string, unknown>, msg?: string): void;
|
|
26
29
|
warn(msg: string): void;
|
|
30
|
+
/** Logs at `error` level through `console.error`. */
|
|
27
31
|
error(obj: Record<string, unknown>, msg?: string): void;
|
|
28
32
|
error(msg: string): void;
|
|
29
33
|
child(bindings: Record<string, unknown>): Logger$1;
|
|
30
34
|
flush(): Promise<void>;
|
|
31
35
|
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/logger/context.d.ts
|
|
34
36
|
/**
|
|
35
37
|
* A fresh correlation id for one invocation. Every log line from a single run
|
|
36
38
|
* carries this `runId`, so a whole run can be pulled back out of Axiom with
|
|
37
39
|
* one query.
|
|
38
40
|
*/
|
|
39
41
|
declare function generateRunId(): string;
|
|
40
|
-
/**
|
|
41
|
-
* True when running inside CI. GitHub Actions (and most other providers) set
|
|
42
|
-
* `CI=true`; we also accept any other non-empty, non-`false` value.
|
|
43
|
-
*/
|
|
44
|
-
declare function isCI(env?: NodeJS.ProcessEnv): boolean;
|
|
45
|
-
/** `"ci"` inside CI, otherwise `"local"` — bound on every root logger. */
|
|
46
|
-
declare function detectEnv(env?: NodeJS.ProcessEnv): LogEnv;
|
|
47
42
|
/** Narrow an arbitrary string to a {@link LogLevel}, or `undefined`. */
|
|
48
43
|
declare function parseLogLevel(value: string | undefined): LogLevel | undefined;
|
|
49
44
|
/**
|
|
@@ -74,8 +69,6 @@ declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
|
74
69
|
* | dataset | `HOLOCRON_AXIOM_DATASET` | `AXIOM_DATASET` |
|
|
75
70
|
*/
|
|
76
71
|
declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportConfig | undefined;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/logger/pino.d.ts
|
|
79
72
|
/**
|
|
80
73
|
* The Pino-backed {@link Logger}. Nothing outside this package should name it —
|
|
81
74
|
* construct loggers with `createLogger`. It is a thin pass-through to a Pino
|
|
@@ -85,12 +78,16 @@ declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportCon
|
|
|
85
78
|
declare class PinoLogger implements Logger$1 {
|
|
86
79
|
#private;
|
|
87
80
|
constructor(instance: Logger);
|
|
81
|
+
/** Logs at `debug` level. */
|
|
88
82
|
debug(obj: Record<string, unknown>, msg?: string): void;
|
|
89
83
|
debug(msg: string): void;
|
|
84
|
+
/** Logs at `info` level. */
|
|
90
85
|
info(obj: Record<string, unknown>, msg?: string): void;
|
|
91
86
|
info(msg: string): void;
|
|
87
|
+
/** Logs at `warn` level. */
|
|
92
88
|
warn(obj: Record<string, unknown>, msg?: string): void;
|
|
93
89
|
warn(msg: string): void;
|
|
90
|
+
/** Logs at `error` level. */
|
|
94
91
|
error(obj: Record<string, unknown>, msg?: string): void;
|
|
95
92
|
error(msg: string): void;
|
|
96
93
|
child(bindings: Record<string, unknown>): Logger$1;
|
|
@@ -102,6 +99,7 @@ declare class PinoLogger implements Logger$1 {
|
|
|
102
99
|
*/
|
|
103
100
|
flush(): Promise<void>;
|
|
104
101
|
}
|
|
102
|
+
/** Inputs for {@link createPinoInstance} and {@link buildPinoOptions}. */
|
|
105
103
|
interface CreatePinoInstanceInput {
|
|
106
104
|
/** Resolved log level. */
|
|
107
105
|
level: LogLevel;
|
|
@@ -142,5 +140,4 @@ declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions
|
|
|
142
140
|
* {@link buildPinoOptions} wired.
|
|
143
141
|
*/
|
|
144
142
|
declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
|
|
145
|
-
//#endregion
|
|
146
143
|
export { detectEnv as a, isTelemetryDisabled as c, resolveLevel as d, ConsoleLogger as f, createPinoInstance as i, parseLogLevel as l, PinoLogger as n, generateRunId as o, buildPinoOptions as r, isCI as s, CreatePinoInstanceInput as t, resolveAxiomFromEnv as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PostHog } from "posthog-node";
|
|
2
|
-
|
|
2
|
+
// src/analytics/posthog-sink.ts
|
|
3
3
|
/**
|
|
4
4
|
* `PostHogSink` — the **only** `posthog-node` call site. A portable
|
|
5
5
|
* `AnalyticsSink` adapter: usage, adoption, retention. It reads no environment
|
|
@@ -17,12 +17,14 @@ var PostHogSink = class {
|
|
|
17
17
|
constructor(config) {
|
|
18
18
|
this.#client = new PostHog(config.key, { host: config.host });
|
|
19
19
|
}
|
|
20
|
+
/** Associates `props` with the person identified by `distinctId`. */
|
|
20
21
|
identify(distinctId, props) {
|
|
21
22
|
this.#client.identify({
|
|
22
23
|
distinctId,
|
|
23
24
|
properties: props
|
|
24
25
|
});
|
|
25
26
|
}
|
|
27
|
+
/** Records the `event` for `distinctId` with the given `props`. */
|
|
26
28
|
capture(distinctId, event, props) {
|
|
27
29
|
this.#client.capture({
|
|
28
30
|
distinctId,
|
|
@@ -30,9 +32,9 @@ var PostHogSink = class {
|
|
|
30
32
|
properties: props
|
|
31
33
|
});
|
|
32
34
|
}
|
|
35
|
+
/** Flushes queued events and closes the PostHog client. */
|
|
33
36
|
async shutdown() {
|
|
34
37
|
await this.#client.shutdown();
|
|
35
38
|
}
|
|
36
39
|
};
|
|
37
|
-
//#endregion
|
|
38
40
|
export { PostHogSink as t };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { t as AnalyticsSink } from "./sinks-
|
|
2
|
-
//#region src/analytics/posthog-sink.d.ts
|
|
1
|
+
import { t as AnalyticsSink } from "./sinks-v2TCQsCp.mjs";
|
|
3
2
|
declare class PostHogSink implements AnalyticsSink {
|
|
4
3
|
#private;
|
|
5
4
|
constructor(config: {
|
|
6
5
|
key: string;
|
|
7
6
|
host: string;
|
|
8
7
|
});
|
|
8
|
+
/** Associates `props` with the person identified by `distinctId`. */
|
|
9
9
|
identify(distinctId: string, props: Record<string, unknown>): void;
|
|
10
|
+
/** Records the `event` for `distinctId` with the given `props`. */
|
|
10
11
|
capture(distinctId: string, event: string, props: Record<string, unknown>): void;
|
|
12
|
+
/** Flushes queued events and closes the PostHog client. */
|
|
11
13
|
shutdown(): Promise<void>;
|
|
12
14
|
}
|
|
13
|
-
//#endregion
|
|
14
15
|
export { PostHogSink as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/redact.ts
|
|
2
2
|
/**
|
|
3
3
|
* Two redaction layers, both zero-dependency:
|
|
4
4
|
*
|
|
@@ -34,7 +34,9 @@ const REDACTED_PATHS = [
|
|
|
34
34
|
const REDACT_CENSOR = "[Redacted]";
|
|
35
35
|
/** Ready-to-use Pino `redact` option. */
|
|
36
36
|
const redactOptions = {
|
|
37
|
+
/** The field paths to redact, a copy of {@link REDACTED_PATHS}. */
|
|
37
38
|
paths: [...REDACTED_PATHS],
|
|
39
|
+
/** The string written in place of each redacted value, {@link REDACT_CENSOR}. */
|
|
38
40
|
censor: REDACT_CENSOR
|
|
39
41
|
};
|
|
40
42
|
const TOKEN_RE = /\b(ghp_|ghs_|glpat-|xoxb-|xoxp-|npm_|sk-|[A-Z][A-Z0-9_]{2,}_TOKEN[=\s])[^\s"]*/g;
|
|
@@ -46,5 +48,4 @@ function redact(raw) {
|
|
|
46
48
|
function redactObject(value) {
|
|
47
49
|
return JSON.parse(redact(JSON.stringify(value)));
|
|
48
50
|
}
|
|
49
|
-
//#endregion
|
|
50
51
|
export { redactOptions as a, redactObject as i, REDACT_CENSOR as n, redact as r, REDACTED_PATHS as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as CommandSpan, r as ErrorSink } from "./sinks-
|
|
1
|
+
import { n as CommandSpan, r as ErrorSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
2
|
import { ErrorEvent, EventHint } from "@sentry/node";
|
|
3
|
-
//#region src/errors/sentry-sink.d.ts
|
|
4
3
|
/** `beforeSend` — token-shaped strings never leave the process. */
|
|
5
4
|
declare function scrubError(event: ErrorEvent, _hint: EventHint): ErrorEvent;
|
|
6
5
|
declare class SentrySink implements ErrorSink {
|
|
6
|
+
/** Initialises Sentry with the DSN, release and environment, starts a session and applies `ctx.tags`; events are scrubbed by {@link scrubError} and every trace is sampled. */
|
|
7
7
|
init(ctx: {
|
|
8
8
|
dsn: string;
|
|
9
9
|
release: string;
|
|
@@ -11,9 +11,11 @@ declare class SentrySink implements ErrorSink {
|
|
|
11
11
|
tags: Record<string, string>;
|
|
12
12
|
}): void;
|
|
13
13
|
startSpan(name: string): CommandSpan;
|
|
14
|
+
/** Reports `err` to Sentry. */
|
|
14
15
|
captureException(err: unknown): void;
|
|
16
|
+
/** Ends the Sentry session. */
|
|
15
17
|
endSession(): void;
|
|
18
|
+
/** Closes the Sentry client, waiting up to two seconds for pending events to send. */
|
|
16
19
|
flush(): Promise<void>;
|
|
17
20
|
}
|
|
18
|
-
//#endregion
|
|
19
21
|
export { scrubError as n, SentrySink as t };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { i as redactObject } from "./redact-
|
|
1
|
+
import { i as redactObject } from "./redact-DCKZnDDa.mjs";
|
|
2
2
|
import * as Sentry from "@sentry/node";
|
|
3
|
-
|
|
3
|
+
// src/errors/sentry-sink.ts
|
|
4
4
|
/** `beforeSend` — token-shaped strings never leave the process. */
|
|
5
5
|
function scrubError(event, _hint) {
|
|
6
6
|
return redactObject(event);
|
|
7
7
|
}
|
|
8
8
|
var SentrySink = class {
|
|
9
|
+
/** Initialises Sentry with the DSN, release and environment, starts a session and applies `ctx.tags`; events are scrubbed by {@link scrubError} and every trace is sampled. */
|
|
9
10
|
init(ctx) {
|
|
10
11
|
Sentry.init({
|
|
11
12
|
dsn: ctx.dsn,
|
|
@@ -29,15 +30,17 @@ var SentrySink = class {
|
|
|
29
30
|
end: () => span.end()
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
/** Reports `err` to Sentry. */
|
|
32
34
|
captureException(err) {
|
|
33
35
|
Sentry.captureException(err);
|
|
34
36
|
}
|
|
37
|
+
/** Ends the Sentry session. */
|
|
35
38
|
endSession() {
|
|
36
39
|
Sentry.endSession();
|
|
37
40
|
}
|
|
41
|
+
/** Closes the Sentry client, waiting up to two seconds for pending events to send. */
|
|
38
42
|
async flush() {
|
|
39
43
|
await Sentry.close(2e3);
|
|
40
44
|
}
|
|
41
45
|
};
|
|
42
|
-
//#endregion
|
|
43
46
|
export { scrubError as n, SentrySink as t };
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/sinks.ts
|
|
2
2
|
/**
|
|
3
3
|
* The disabled path made explicit — one shared no-op instead of a scatter of
|
|
4
4
|
* `if (!enabled) return` guards. Install it when telemetry is opted out or no
|
|
5
5
|
* credentials resolve.
|
|
6
6
|
*/
|
|
7
7
|
var NoopErrorSink = class {
|
|
8
|
+
/** Does nothing. */
|
|
8
9
|
init() {}
|
|
9
10
|
startSpan() {}
|
|
11
|
+
/** Does nothing. */
|
|
10
12
|
captureException() {}
|
|
13
|
+
/** Does nothing. */
|
|
11
14
|
endSession() {}
|
|
15
|
+
/** Resolves immediately. */
|
|
12
16
|
async flush() {}
|
|
13
17
|
};
|
|
14
18
|
/** @see NoopErrorSink */
|
|
15
19
|
var NoopAnalyticsSink = class {
|
|
20
|
+
/** Does nothing. */
|
|
16
21
|
identify() {}
|
|
22
|
+
/** Does nothing. */
|
|
17
23
|
capture() {}
|
|
24
|
+
/** Resolves immediately. */
|
|
18
25
|
async shutdown() {}
|
|
19
26
|
};
|
|
20
|
-
//#endregion
|
|
21
27
|
export { NoopErrorSink as n, NoopAnalyticsSink as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/sinks.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Telemetry sink interfaces — the seam between an application's telemetry
|
|
4
3
|
* orchestration and the vendor SDKs. No `@sentry/node` / `posthog-node` import
|
|
@@ -9,11 +8,14 @@
|
|
|
9
8
|
*/
|
|
10
9
|
/** A running command span — `undefined` when the error sink is off. */
|
|
11
10
|
interface CommandSpan {
|
|
11
|
+
/** Marks the span as succeeded (`true`) or failed (`false`). */
|
|
12
12
|
setStatus(ok: boolean): void;
|
|
13
|
+
/** Ends the span and records its duration. */
|
|
13
14
|
end(): void;
|
|
14
15
|
}
|
|
15
16
|
/** Error tracking + performance (Sentry). */
|
|
16
17
|
interface ErrorSink {
|
|
18
|
+
/** Initialises the tracker with the resolved DSN, release, environment and tags applied to every event. */
|
|
17
19
|
init(ctx: {
|
|
18
20
|
dsn: string;
|
|
19
21
|
release: string;
|
|
@@ -22,14 +24,20 @@ interface ErrorSink {
|
|
|
22
24
|
}): void;
|
|
23
25
|
/** Start a command span. Returns `undefined` for a no-op sink. */
|
|
24
26
|
startSpan(name: string): CommandSpan | undefined;
|
|
27
|
+
/** Reports an error (or any thrown value) to the tracker. */
|
|
25
28
|
captureException(err: unknown): void;
|
|
29
|
+
/** Ends the current session. */
|
|
26
30
|
endSession(): void;
|
|
31
|
+
/** Resolves once pending events have been sent, or the sink's timeout passes. */
|
|
27
32
|
flush(): Promise<void>;
|
|
28
33
|
}
|
|
29
34
|
/** Product analytics — usage, adoption, retention (PostHog). */
|
|
30
35
|
interface AnalyticsSink {
|
|
36
|
+
/** Associates `props` with the person identified by `distinctId`. */
|
|
31
37
|
identify(distinctId: string, props: Record<string, unknown>): void;
|
|
38
|
+
/** Records the `event` for `distinctId` with the given `props`. */
|
|
32
39
|
capture(distinctId: string, event: string, props: Record<string, unknown>): void;
|
|
40
|
+
/** Flushes queued events and shuts the client down. */
|
|
33
41
|
shutdown(): Promise<void>;
|
|
34
42
|
}
|
|
35
43
|
/**
|
|
@@ -38,17 +46,23 @@ interface AnalyticsSink {
|
|
|
38
46
|
* credentials resolve.
|
|
39
47
|
*/
|
|
40
48
|
declare class NoopErrorSink implements ErrorSink {
|
|
49
|
+
/** Does nothing. */
|
|
41
50
|
init(): void;
|
|
42
51
|
startSpan(): CommandSpan | undefined;
|
|
52
|
+
/** Does nothing. */
|
|
43
53
|
captureException(): void;
|
|
54
|
+
/** Does nothing. */
|
|
44
55
|
endSession(): void;
|
|
56
|
+
/** Resolves immediately. */
|
|
45
57
|
flush(): Promise<void>;
|
|
46
58
|
}
|
|
47
59
|
/** @see NoopErrorSink */
|
|
48
60
|
declare class NoopAnalyticsSink implements AnalyticsSink {
|
|
61
|
+
/** Does nothing. */
|
|
49
62
|
identify(): void;
|
|
63
|
+
/** Does nothing. */
|
|
50
64
|
capture(): void;
|
|
65
|
+
/** Resolves immediately. */
|
|
51
66
|
shutdown(): Promise<void>;
|
|
52
67
|
}
|
|
53
|
-
//#endregion
|
|
54
68
|
export { NoopErrorSink as a, NoopAnalyticsSink as i, CommandSpan as n, ErrorSink as r, AnalyticsSink as t };
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-
|
|
2
|
-
import { i as Logger } from "./logger-
|
|
3
|
-
import { r as createLogger } from "./create-
|
|
1
|
+
import { n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-v2TCQsCp.mjs";
|
|
2
|
+
import { i as Logger } from "./logger-DC6M2rL_.mjs";
|
|
3
|
+
import { r as createLogger } from "./create-X1v3LWjb.mjs";
|
|
4
4
|
import { Mock } from "vitest";
|
|
5
|
-
//#region src/testing/fake-analytics-sink.d.ts
|
|
6
5
|
/** An {@link AnalyticsSink} whose methods are spies. */
|
|
7
6
|
interface FakeAnalyticsSink extends AnalyticsSink {
|
|
8
7
|
identify: Mock;
|
|
@@ -19,9 +18,7 @@ interface FakeAnalyticsSink extends AnalyticsSink {
|
|
|
19
18
|
* expect(analytics.capture).toHaveBeenCalledWith("abc123", "deploy_triggered", { branch: "main" });
|
|
20
19
|
* ```
|
|
21
20
|
*/
|
|
22
|
-
declare function fakeAnalyticsSink(): FakeAnalyticsSink;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/testing/fake-error-sink.d.ts
|
|
21
|
+
export declare function fakeAnalyticsSink(): FakeAnalyticsSink;
|
|
25
22
|
/** A {@link CommandSpan} whose methods are spies. */
|
|
26
23
|
interface FakeSpan extends CommandSpan {
|
|
27
24
|
setStatus: Mock;
|
|
@@ -46,9 +43,7 @@ interface FakeErrorSink extends ErrorSink {
|
|
|
46
43
|
* expect(errors.captureException).not.toHaveBeenCalled();
|
|
47
44
|
* ```
|
|
48
45
|
*/
|
|
49
|
-
declare function fakeErrorSink(): FakeErrorSink;
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/testing/fake-logger.d.ts
|
|
46
|
+
export declare function fakeErrorSink(): FakeErrorSink;
|
|
52
47
|
/** A {@link Logger} whose level methods are spies; `child()` returns itself. */
|
|
53
48
|
interface FakeLogger extends Logger {
|
|
54
49
|
debug: Mock;
|
|
@@ -68,9 +63,7 @@ interface FakeLogger extends Logger {
|
|
|
68
63
|
* expect(log.info).toHaveBeenCalledWith(expect.objectContaining({ target: "production" }), "deploying");
|
|
69
64
|
* ```
|
|
70
65
|
*/
|
|
71
|
-
declare function fakeLogger(): FakeLogger;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/testing/silence-logger.d.ts
|
|
66
|
+
export declare function fakeLogger(): FakeLogger;
|
|
74
67
|
/**
|
|
75
68
|
* Replace `createLogger` in the `/logger` module with one that returns a
|
|
76
69
|
* {@link NoopLogger}, so code under test that builds a real Pino logger stops
|
|
@@ -91,10 +84,9 @@ declare function fakeLogger(): FakeLogger;
|
|
|
91
84
|
* });
|
|
92
85
|
* ```
|
|
93
86
|
*/
|
|
94
|
-
declare function silenceLogger<T extends {
|
|
87
|
+
export declare function silenceLogger<T extends {
|
|
95
88
|
createLogger: unknown;
|
|
96
89
|
}>(actual: T): Omit<T, "createLogger"> & {
|
|
97
90
|
createLogger: typeof createLogger;
|
|
98
91
|
};
|
|
99
|
-
|
|
100
|
-
export { type FakeAnalyticsSink, type FakeErrorSink, type FakeLogger, type FakeSpan, fakeAnalyticsSink, fakeErrorSink, fakeLogger, silenceLogger };
|
|
92
|
+
export type { FakeAnalyticsSink, FakeErrorSink, FakeLogger, FakeSpan };
|
package/dist/testing.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as NoopLogger } from "./logger-
|
|
1
|
+
import { n as NoopLogger } from "./logger-BqELCAzg.mjs";
|
|
2
2
|
import { vi } from "vitest";
|
|
3
|
-
|
|
3
|
+
// src/testing/fake-analytics-sink.ts
|
|
4
4
|
/**
|
|
5
5
|
* Build a spy {@link AnalyticsSink} for asserting what a unit under test
|
|
6
6
|
* reported. `shutdown()` resolves immediately.
|
|
@@ -18,8 +18,7 @@ function fakeAnalyticsSink() {
|
|
|
18
18
|
shutdown: vi.fn().mockResolvedValue(void 0)
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
//#region src/testing/fake-error-sink.ts
|
|
21
|
+
// src/testing/fake-error-sink.ts
|
|
23
22
|
/**
|
|
24
23
|
* Build a spy {@link ErrorSink} for asserting what a unit under test reported.
|
|
25
24
|
* `flush()` resolves immediately; `startSpan()` always returns the same spy
|
|
@@ -44,8 +43,7 @@ function fakeErrorSink() {
|
|
|
44
43
|
flush: vi.fn().mockResolvedValue(void 0)
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
//#region src/testing/fake-logger.ts
|
|
46
|
+
// src/testing/fake-logger.ts
|
|
49
47
|
/**
|
|
50
48
|
* Build a spy {@link Logger} for asserting what a unit under test logged.
|
|
51
49
|
* Pass it wherever a real `Logger` is expected.
|
|
@@ -67,8 +65,7 @@ function fakeLogger() {
|
|
|
67
65
|
};
|
|
68
66
|
return log;
|
|
69
67
|
}
|
|
70
|
-
|
|
71
|
-
//#region src/testing/silence-logger.ts
|
|
68
|
+
// src/testing/silence-logger.ts
|
|
72
69
|
const SILENT_RUN_ID = "00000000-0000-4000-8000-000000000000";
|
|
73
70
|
/**
|
|
74
71
|
* Replace `createLogger` in the `/logger` module with one that returns a
|
|
@@ -99,5 +96,4 @@ function silenceLogger(actual) {
|
|
|
99
96
|
})
|
|
100
97
|
};
|
|
101
98
|
}
|
|
102
|
-
//#endregion
|
|
103
99
|
export { fakeAnalyticsSink, fakeErrorSink, fakeLogger, silenceLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/observability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-alpha.1",
|
|
4
4
|
"description": "Logging, error tracking, and analytics — one interface, swappable backends.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,25 +58,28 @@
|
|
|
58
58
|
"files": [
|
|
59
59
|
"dist"
|
|
60
60
|
],
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@theholocron/env-utils": "^1.17.0-alpha.1"
|
|
63
|
+
},
|
|
61
64
|
"devDependencies": {
|
|
62
65
|
"@axiomhq/pino": "^2.0.0",
|
|
63
|
-
"@sentry/node": "^
|
|
64
|
-
"@theholocron/eslint-config": "^8.8.2",
|
|
65
|
-
"@theholocron/tsconfig": "^8.8.2",
|
|
66
|
-
"@theholocron/tsdown-config": "^8.8.2",
|
|
67
|
-
"@theholocron/vitest-config": "^8.8.2",
|
|
66
|
+
"@sentry/node": "^11.9.0",
|
|
68
67
|
"@types/node": "^26",
|
|
69
|
-
"@vitest/coverage-v8": "^
|
|
68
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
70
69
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
71
70
|
"eslint": "^10.8.1",
|
|
72
71
|
"eslint-plugin-n": "^18.3.0",
|
|
73
72
|
"globals": "^17.11.0",
|
|
74
73
|
"pino": "^10.3.1",
|
|
75
74
|
"pino-pretty": "^13.1.3",
|
|
76
|
-
"posthog-node": "^5.
|
|
77
|
-
"tsdown": "^0.
|
|
75
|
+
"posthog-node": "^5.57.2",
|
|
76
|
+
"tsdown": "^0.23.3",
|
|
78
77
|
"typescript": "^5.9.3",
|
|
79
|
-
"vitest": "^
|
|
78
|
+
"vitest": "^5.0.5",
|
|
79
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.8",
|
|
80
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.8",
|
|
81
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.8",
|
|
82
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.8"
|
|
80
83
|
},
|
|
81
84
|
"peerDependencies": {
|
|
82
85
|
"@axiomhq/pino": ">=2",
|
|
@@ -113,10 +116,10 @@
|
|
|
113
116
|
"access": "public"
|
|
114
117
|
},
|
|
115
118
|
"scripts": {
|
|
116
|
-
"
|
|
117
|
-
"
|
|
119
|
+
"build": "tsdown",
|
|
120
|
+
"lint:code": "eslint .",
|
|
121
|
+
"test:unit": "vitest run --coverage",
|
|
118
122
|
"test:watch": "vitest",
|
|
119
|
-
"
|
|
120
|
-
"verification.unitTests": "vitest run"
|
|
123
|
+
"typecheck": "tsc --noEmit"
|
|
121
124
|
}
|
|
122
125
|
}
|