@theholocron/observability 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Newton Koumantzelis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # `@theholocron/observability`
2
+
3
+ <!-- holocron:description -->
4
+
5
+ Logging, error tracking, and analytics — one interface, swappable backends.
6
+ <!-- /holocron:description -->
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pnpm add @theholocron/observability
12
+ ```
13
+
14
+ Then add the peer dependencies for the subpaths you use — they are all
15
+ optional:
16
+
17
+ | Subpath | Peers |
18
+ | -------------------------------------- | -------------------------------------- |
19
+ | `@theholocron/observability/core` | none |
20
+ | `@theholocron/observability/logger` | `pino`, `pino-pretty`, `@axiomhq/pino` |
21
+ | `@theholocron/observability/errors` | `@sentry/node` |
22
+ | `@theholocron/observability/analytics` | `posthog-node` |
23
+
24
+ ## Usage
25
+
26
+ Application modules depend on the interfaces from `/core`, never a concrete
27
+ adapter:
28
+
29
+ ```typescript
30
+ import type { Logger, ErrorSink } from "@theholocron/observability/core";
31
+
32
+ export function deploy(deps: { logger: Logger; errors: ErrorSink }) {
33
+ deps.logger.info({ target: "production" }, "deploying");
34
+ }
35
+ ```
36
+
37
+ The process entry point wires the adapters and is the only place that reads
38
+ credentials:
39
+
40
+ ```typescript
41
+ import { createLogger } from "@theholocron/observability/logger";
42
+ import { NoopErrorSink } from "@theholocron/observability/core";
43
+ import { SentrySink } from "@theholocron/observability/errors";
44
+
45
+ const { logger, runId } = createLogger({ level: "info" });
46
+
47
+ const errors = process.env.SENTRY_DSN ? new SentrySink() : new NoopErrorSink();
48
+ errors.init({
49
+ dsn: process.env.SENTRY_DSN ?? "",
50
+ release: "my-app@1.0.0",
51
+ environment: process.env.CI ? "ci" : "local",
52
+ tags: { runId },
53
+ });
54
+
55
+ deploy({ logger, errors });
56
+ ```
57
+
58
+ For the browser, an edge runtime, or React Native, import
59
+ `@theholocron/observability/core` (zero dependencies) and use `ConsoleLogger`
60
+ from `/logger` in place of Pino.
61
+
62
+ See the [documentation](https://docs.theholocron.dev/observability/) for the
63
+ full API.
64
+
65
+ ## Development
66
+
67
+ <!-- holocron:development -->
68
+
69
+ ```bash
70
+ pnpm install # install deps
71
+ pnpm build # tsdown → dist/
72
+ pnpm test # vitest
73
+ pnpm typecheck # tsc --noEmit
74
+ pnpm lint # eslint
75
+ ```
76
+
77
+ <!-- /holocron:development -->
78
+
79
+ ## Releases
80
+
81
+ <!-- holocron:releases -->
82
+
83
+ Releases are automated via [semantic-release](https://semantic-release.gitbook.io) on push to `main`. See [CHANGELOG.md](CHANGELOG.md) for the release history.
84
+
85
+ <!-- /holocron:releases -->
@@ -0,0 +1,3 @@
1
+ import { i as NoopAnalyticsSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
2
+ import { t as PostHogSink } from "./posthog-sink-BvVIQrGy.mjs";
3
+ export { type AnalyticsSink, NoopAnalyticsSink, PostHogSink };
@@ -0,0 +1,3 @@
1
+ import { t as NoopAnalyticsSink } from "./sinks-scWbkOMp.mjs";
2
+ import { t as PostHogSink } from "./posthog-sink-ClNks-Le.mjs";
3
+ export { NoopAnalyticsSink, PostHogSink };
@@ -0,0 +1,33 @@
1
+ //#region src/core/redact.d.ts
2
+ /**
3
+ * Two redaction layers, both zero-dependency:
4
+ *
5
+ * 1. **Field-path redaction** ({@link REDACTED_PATHS} / {@link redactOptions}) —
6
+ * Pino's `redact` option. Strips known-sensitive keys from every log line in
7
+ * Pino's serialisation layer, before any transport sees it.
8
+ * 2. **Token-shape scrubbing** ({@link redact} / {@link redactObject}) — a
9
+ * regex over the serialised string that matches a token shape *anywhere*,
10
+ * even in a value the caller controls. Used by the Sentry `beforeSend` hook
11
+ * and the analytics `capture()` path.
12
+ */
13
+ /**
14
+ * Sensitive field paths stripped from every log line. Paths use Pino's
15
+ * redaction syntax: dotted access, `[*]` wildcards for arrays, and
16
+ * bracket-quoted keys for names that are not valid identifiers.
17
+ *
18
+ * @see https://getpino.io/#/docs/redaction
19
+ */
20
+ declare const REDACTED_PATHS: readonly string[];
21
+ /** Replacement string Pino writes in place of a redacted value. */
22
+ declare const REDACT_CENSOR = "[Redacted]";
23
+ /** Ready-to-use Pino `redact` option. */
24
+ declare const redactOptions: {
25
+ readonly paths: readonly string[];
26
+ readonly censor: "[Redacted]";
27
+ };
28
+ /** Replace token-shaped substrings in a string with `[REDACTED]`. */
29
+ declare function redact(raw: string): string;
30
+ /** Deep-scrub every string in an object by round-tripping through {@link redact}. */
31
+ declare function redactObject<T>(value: T): T;
32
+ //#endregion
33
+ export { redactOptions as a, redactObject as i, REDACT_CENSOR as n, redact as r, REDACTED_PATHS as t };
@@ -0,0 +1,4 @@
1
+ import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
2
+ import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-UDRkgXWQ.mjs";
3
+ import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-jXa8qbEx.mjs";
4
+ export { type AnalyticsSink, type CommandSpan, type ErrorSink, LOG_LEVELS, type LogEnv, type LogLevel, type Logger, NoopAnalyticsSink, NoopErrorSink, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
package/dist/core.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { t as LOG_LEVELS } from "./logger--ic6Hr3c.mjs";
2
+ import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-BMWG62k9.mjs";
3
+ import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-scWbkOMp.mjs";
4
+ export { LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, REDACTED_PATHS, REDACT_CENSOR, redact, redactObject, redactOptions };
@@ -0,0 +1,287 @@
1
+ import { t as LOG_LEVELS } from "./logger--ic6Hr3c.mjs";
2
+ import { a as redactOptions } from "./redact-BMWG62k9.mjs";
3
+ import { randomUUID } from "node:crypto";
4
+ import pino from "pino";
5
+ //#region src/logger/console.ts
6
+ const RANK = {
7
+ debug: 10,
8
+ info: 20,
9
+ warn: 30,
10
+ error: 40
11
+ };
12
+ const SINK = {
13
+ debug: (...a) => console.debug(...a),
14
+ info: (...a) => console.info(...a),
15
+ warn: (...a) => console.warn(...a),
16
+ error: (...a) => console.error(...a)
17
+ };
18
+ /**
19
+ * A zero-dependency {@link Logger} over the platform `console` — no Pino, no
20
+ * worker thread, no transports. Use it in the browser, an edge runtime, or
21
+ * React Native, or anywhere the Pino weight is not worth it. Structured calls
22
+ * are emitted as `(message, contextObject)`; `child()` bindings are merged into
23
+ * every line's context.
24
+ *
25
+ * There is no Axiom shipping here — that is a Node-transport concern. A
26
+ * `ConsoleLogger` is for local visibility only.
27
+ */
28
+ var ConsoleLogger = class ConsoleLogger {
29
+ #level;
30
+ #bindings;
31
+ constructor(options = {}) {
32
+ this.#level = RANK[options.level ?? "info"];
33
+ this.#bindings = options.bindings ?? {};
34
+ }
35
+ debug(objOrMsg, msg) {
36
+ this.#emit("debug", objOrMsg, msg);
37
+ }
38
+ info(objOrMsg, msg) {
39
+ this.#emit("info", objOrMsg, msg);
40
+ }
41
+ warn(objOrMsg, msg) {
42
+ this.#emit("warn", objOrMsg, msg);
43
+ }
44
+ error(objOrMsg, msg) {
45
+ this.#emit("error", objOrMsg, msg);
46
+ }
47
+ child(bindings) {
48
+ return new ConsoleLogger({
49
+ level: Object.keys(RANK).find((l) => RANK[l] === this.#level),
50
+ bindings: {
51
+ ...this.#bindings,
52
+ ...bindings
53
+ }
54
+ });
55
+ }
56
+ #emit(level, objOrMsg, msg) {
57
+ if (RANK[level] < this.#level) return;
58
+ if (typeof objOrMsg === "string") {
59
+ if (Object.keys(this.#bindings).length) SINK[level](objOrMsg, this.#bindings);
60
+ else SINK[level](objOrMsg);
61
+ return;
62
+ }
63
+ const ctx = {
64
+ ...this.#bindings,
65
+ ...objOrMsg
66
+ };
67
+ if (msg) SINK[level](msg, ctx);
68
+ else SINK[level](ctx);
69
+ }
70
+ };
71
+ //#endregion
72
+ //#region src/logger/context.ts
73
+ /**
74
+ * A fresh correlation id for one invocation. Every log line from a single run
75
+ * carries this `runId`, so a whole run can be pulled back out of Axiom with
76
+ * one query.
77
+ */
78
+ function generateRunId() {
79
+ return randomUUID();
80
+ }
81
+ /**
82
+ * True when running inside CI. GitHub Actions (and most other providers) set
83
+ * `CI=true`; we also accept any other non-empty, non-`false` value.
84
+ */
85
+ function isCI(env = process.env) {
86
+ const ci = env.CI;
87
+ if (!ci) return false;
88
+ return ci !== "false" && ci !== "0";
89
+ }
90
+ /** `"ci"` inside CI, otherwise `"local"` — bound on every root logger. */
91
+ function detectEnv(env = process.env) {
92
+ return isCI(env) ? "ci" : "local";
93
+ }
94
+ /** Narrow an arbitrary string to a {@link LogLevel}, or `undefined`. */
95
+ function parseLogLevel(value) {
96
+ return value && LOG_LEVELS.includes(value) ? value : void 0;
97
+ }
98
+ /**
99
+ * Resolve the effective log level in priority order:
100
+ *
101
+ * 1. `explicit` — an already-resolved level (a CLI flag, a config field)
102
+ * passed by the caller.
103
+ * 2. `HOLOCRON_LOG_LEVEL` env var.
104
+ * 3. `"info"` default.
105
+ *
106
+ * An unrecognised value at any tier is ignored and resolution falls through.
107
+ */
108
+ function resolveLevel(explicit, env = process.env) {
109
+ return explicit ?? parseLogLevel(env.HOLOCRON_LOG_LEVEL) ?? "info";
110
+ }
111
+ /** True when the Axiom transport must be suppressed via `HOLOCRON_TELEMETRY=false`. */
112
+ function isTelemetryDisabled(env = process.env) {
113
+ return env.HOLOCRON_TELEMETRY === "false";
114
+ }
115
+ /**
116
+ * Resolve Axiom credentials from the environment — the canonical fallback
117
+ * chain from ADR-0007. `createLogger` calls this when no explicit
118
+ * `config.axiom` is supplied, so every consumer gets Axiom activation from env
119
+ * vars alone. Credentials are read here and only here — never from a config
120
+ * file.
121
+ *
122
+ * Returns `undefined` unless BOTH a token and a dataset are present.
123
+ *
124
+ * | Value | Primary | Fallback |
125
+ * | -------- | ------------------------ | --------------- |
126
+ * | token | `HOLOCRON_AXIOM_TOKEN` | `AXIOM_TOKEN` |
127
+ * | dataset | `HOLOCRON_AXIOM_DATASET` | `AXIOM_DATASET` |
128
+ */
129
+ function resolveAxiomFromEnv(env = process.env) {
130
+ const token = env.HOLOCRON_AXIOM_TOKEN ?? env.AXIOM_TOKEN;
131
+ const dataset = env.HOLOCRON_AXIOM_DATASET ?? env.AXIOM_DATASET;
132
+ return token && dataset ? {
133
+ token,
134
+ dataset
135
+ } : void 0;
136
+ }
137
+ //#endregion
138
+ //#region src/logger/transports.ts
139
+ const prettyTarget = (level) => ({
140
+ target: "pino-pretty",
141
+ level,
142
+ options: {
143
+ colorize: true,
144
+ translateTime: "SYS:HH:MM:ss",
145
+ ignore: "pid,hostname"
146
+ }
147
+ });
148
+ const stdoutJsonTarget = (level) => ({
149
+ target: "pino/file",
150
+ level,
151
+ options: { destination: 1 }
152
+ });
153
+ const axiomTarget = (level, axiom) => ({
154
+ target: "@axiomhq/pino",
155
+ level,
156
+ options: {
157
+ dataset: axiom.dataset,
158
+ token: axiom.token
159
+ }
160
+ });
161
+ /**
162
+ * Build the Pino `transport` option for the current environment.
163
+ *
164
+ * | Environment | Output |
165
+ * | -------------------------- | --------------------------------------------------- |
166
+ * | Local, TTY, no Axiom | `pino-pretty` only |
167
+ * | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
168
+ * | Local, TTY, with Axiom | `pino-pretty` + Axiom |
169
+ * | CI, with Axiom | NDJSON to stdout + Axiom |
170
+ *
171
+ * The Axiom transport is dropped entirely when `telemetryDisabled` is set,
172
+ * regardless of whether credentials were supplied. Every transport runs on
173
+ * the same resolved `level` — there is no Axiom-only gate.
174
+ *
175
+ * Returning `undefined` lets `createLogger` fall back to a plain
176
+ * `pino({ ... })` with no worker thread — the cheapest path, and exactly
177
+ * what CI wants.
178
+ */
179
+ function buildTransport(input) {
180
+ const { level, axiom, ci, tty, telemetryDisabled } = input;
181
+ const pretty = !ci && tty;
182
+ const targets = [];
183
+ if (pretty) targets.push(prettyTarget(level));
184
+ if (axiom && !telemetryDisabled) targets.push(axiomTarget(level, axiom));
185
+ if (targets.length === 0) return void 0;
186
+ if (!pretty) targets.unshift(stdoutJsonTarget(level));
187
+ if (targets.length === 1) return targets[0];
188
+ return { targets };
189
+ }
190
+ //#endregion
191
+ //#region src/logger/pino.ts
192
+ /**
193
+ * The Pino-backed {@link Logger}. Nothing outside this package should name it —
194
+ * construct loggers with `createLogger`. It is a thin pass-through to a Pino
195
+ * instance; the interface overloads mirror Pino's own, so each method is a
196
+ * single delegated call.
197
+ */
198
+ var PinoLogger = class PinoLogger {
199
+ #pino;
200
+ constructor(instance) {
201
+ this.#pino = instance;
202
+ }
203
+ debug(objOrMsg, msg) {
204
+ this.#emit("debug", objOrMsg, msg);
205
+ }
206
+ info(objOrMsg, msg) {
207
+ this.#emit("info", objOrMsg, msg);
208
+ }
209
+ warn(objOrMsg, msg) {
210
+ this.#emit("warn", objOrMsg, msg);
211
+ }
212
+ error(objOrMsg, msg) {
213
+ this.#emit("error", objOrMsg, msg);
214
+ }
215
+ child(bindings) {
216
+ return new PinoLogger(this.#pino.child(bindings));
217
+ }
218
+ #emit(level, objOrMsg, msg) {
219
+ if (typeof objOrMsg === "string") this.#pino[level](objOrMsg);
220
+ else this.#pino[level](objOrMsg, msg);
221
+ }
222
+ };
223
+ /**
224
+ * Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
225
+ * line, ISO timestamps, sensitive-field redaction, and — unless a capture
226
+ * `destination` is in play — the environment-appropriate transport from
227
+ * {@link buildTransport}.
228
+ */
229
+ function buildPinoOptions(input) {
230
+ const options = {
231
+ level: input.level,
232
+ base: input.base,
233
+ timestamp: pino.stdTimeFunctions.isoTime,
234
+ redact: {
235
+ paths: [...redactOptions.paths],
236
+ censor: redactOptions.censor
237
+ }
238
+ };
239
+ if (input.destination) return options;
240
+ const transport = buildTransport(input);
241
+ if (transport) options.transport = transport;
242
+ return options;
243
+ }
244
+ /**
245
+ * Construct the underlying Pino instance. Writes to `destination` when one is
246
+ * supplied (tests), otherwise to the transports {@link buildPinoOptions} wired.
247
+ */
248
+ function createPinoInstance(input) {
249
+ const options = buildPinoOptions(input);
250
+ return input.destination ? pino(options, input.destination) : pino(options);
251
+ }
252
+ //#endregion
253
+ //#region src/logger/create.ts
254
+ /**
255
+ * The single entry point for building a Pino-backed logger. Generates a
256
+ * `runId`, detects the environment, resolves the level, wires the right
257
+ * transports, and returns a ready {@link Logger}.
258
+ *
259
+ * ```ts
260
+ * const { logger, runId } = createLogger({ level, axiom });
261
+ * const log = logger.child({ command: "sync-github", repo });
262
+ * log.info({ branch }, "opening PR");
263
+ * ```
264
+ *
265
+ * For a browser / edge / React Native context, construct a `ConsoleLogger`
266
+ * directly instead — it needs no `createLogger`.
267
+ */
268
+ function createLogger(config = {}) {
269
+ const runId = generateRunId();
270
+ const env = detectEnv();
271
+ return {
272
+ logger: new PinoLogger(createPinoInstance({
273
+ level: resolveLevel(config.level),
274
+ axiom: config.axiom ?? resolveAxiomFromEnv(),
275
+ ci: isCI(),
276
+ tty: Boolean(process.stdout.isTTY),
277
+ telemetryDisabled: isTelemetryDisabled(),
278
+ base: {
279
+ runId,
280
+ env
281
+ }
282
+ })),
283
+ runId
284
+ };
285
+ }
286
+ //#endregion
287
+ 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 };
@@ -0,0 +1,3 @@
1
+ import { a as NoopErrorSink, n as CommandSpan, r as ErrorSink } from "./sinks-CSEolKcN.mjs";
2
+ import { n as scrubError, t as SentrySink } from "./sentry-sink-Dk0H3MG5.mjs";
3
+ export { type CommandSpan, type ErrorSink, NoopErrorSink, SentrySink, scrubError };
@@ -0,0 +1,3 @@
1
+ import { n as NoopErrorSink } from "./sinks-scWbkOMp.mjs";
2
+ import { n as scrubError, t as SentrySink } from "./sentry-sink-BOuueung.mjs";
3
+ export { NoopErrorSink, SentrySink, scrubError };
@@ -0,0 +1,7 @@
1
+ import { a as NoopErrorSink, i as NoopAnalyticsSink, n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
2
+ import { t as PostHogSink } from "./posthog-sink-BvVIQrGy.mjs";
3
+ import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-UDRkgXWQ.mjs";
4
+ import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./core-jXa8qbEx.mjs";
5
+ import { n as scrubError, t as SentrySink } from "./sentry-sink-Dk0H3MG5.mjs";
6
+ import { _ as buildTransport, a as CreateLoggerResult, c as detectEnv, d as isTelemetryDisabled, f as parseLogLevel, g as BuildTransportInput, h as AxiomTransportConfig, i as createPinoInstance, l as generateRunId, m as resolveLevel, n as PinoLogger, o as LoggerConfig, p as resolveAxiomFromEnv, r as buildPinoOptions, s as createLogger, t as CreatePinoInstanceInput, u as isCI, v as ConsoleLogger } from "./pino-TxwJ9Q2h.mjs";
7
+ 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, 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 ADDED
@@ -0,0 +1,8 @@
1
+ import { t as LOG_LEVELS } from "./logger--ic6Hr3c.mjs";
2
+ import { a as redactOptions, i as redactObject, n as REDACT_CENSOR, r as redact, t as REDACTED_PATHS } from "./redact-BMWG62k9.mjs";
3
+ import { n as NoopErrorSink, t as NoopAnalyticsSink } from "./sinks-scWbkOMp.mjs";
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-D9zLARVf.mjs";
6
+ import { n as scrubError, t as SentrySink } from "./sentry-sink-BOuueung.mjs";
7
+ import { t as PostHogSink } from "./posthog-sink-ClNks-Le.mjs";
8
+ export { ConsoleLogger, LOG_LEVELS, NoopAnalyticsSink, NoopErrorSink, PinoLogger, PostHogSink, REDACTED_PATHS, REDACT_CENSOR, SentrySink, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, redact, redactObject, redactOptions, resolveAxiomFromEnv, resolveLevel, scrubError };
@@ -0,0 +1,10 @@
1
+ //#region src/core/logger.ts
2
+ /** The four levels, in ascending severity — useful for validation. */
3
+ const LOG_LEVELS = [
4
+ "debug",
5
+ "info",
6
+ "warn",
7
+ "error"
8
+ ];
9
+ //#endregion
10
+ export { LOG_LEVELS as t };
@@ -0,0 +1,37 @@
1
+ //#region src/core/logger.d.ts
2
+ /**
3
+ * The logging surface every consumer depends on.
4
+ *
5
+ * Call sites import `Logger` — never Pino directly. The concrete implementation
6
+ * ({@link PinoLogger}, or the zero-dep `ConsoleLogger`) is hidden behind this
7
+ * interface so the logging library can be swapped without touching a single
8
+ * call site.
9
+ *
10
+ * The overloads mirror Pino's native API: pass a context object first for
11
+ * structured logging (`log.info({ repo }, "sync complete")`) or a bare string
12
+ * for a simple line (`log.info("sync complete")`).
13
+ */
14
+ interface Logger {
15
+ debug(obj: Record<string, unknown>, msg?: string): void;
16
+ debug(msg: string): void;
17
+ info(obj: Record<string, unknown>, msg?: string): void;
18
+ info(msg: string): void;
19
+ warn(obj: Record<string, unknown>, msg?: string): void;
20
+ warn(msg: string): void;
21
+ error(obj: Record<string, unknown>, msg?: string): void;
22
+ error(msg: string): void;
23
+ /**
24
+ * Derive a child logger that inherits every binding from its parent and
25
+ * adds its own. Used to attach per-module context (`module`, `repo`, …)
26
+ * without threading extra fields through every call.
27
+ */
28
+ child(bindings: Record<string, unknown>): Logger;
29
+ }
30
+ /** Log levels, ordered least to most severe. */
31
+ type LogLevel = "debug" | "info" | "warn" | "error";
32
+ /** The four levels, in ascending severity — useful for validation. */
33
+ declare const LOG_LEVELS: readonly LogLevel[];
34
+ /** Runtime environment a logger was constructed in. */
35
+ type LogEnv = "ci" | "local";
36
+ //#endregion
37
+ export { Logger as i, LogEnv as n, LogLevel as r, LOG_LEVELS as t };
@@ -0,0 +1,3 @@
1
+ import { i as Logger, n as LogEnv, r as LogLevel, t as LOG_LEVELS } from "./logger-UDRkgXWQ.mjs";
2
+ import { _ as buildTransport, a as CreateLoggerResult, c as detectEnv, d as isTelemetryDisabled, f as parseLogLevel, g as BuildTransportInput, h as AxiomTransportConfig, i as createPinoInstance, l as generateRunId, m as resolveLevel, n as PinoLogger, o as LoggerConfig, p as resolveAxiomFromEnv, r as buildPinoOptions, s as createLogger, t as CreatePinoInstanceInput, u as isCI, v as ConsoleLogger } from "./pino-TxwJ9Q2h.mjs";
3
+ 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 };
@@ -0,0 +1,3 @@
1
+ import { t as LOG_LEVELS } from "./logger--ic6Hr3c.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-D9zLARVf.mjs";
3
+ export { ConsoleLogger, LOG_LEVELS, PinoLogger, buildPinoOptions, buildTransport, createLogger, createPinoInstance, detectEnv, generateRunId, isCI, isTelemetryDisabled, parseLogLevel, resolveAxiomFromEnv, resolveLevel };
@@ -0,0 +1,211 @@
1
+ import { i as Logger$1, n as LogEnv, r as LogLevel } from "./logger-UDRkgXWQ.mjs";
2
+ import { DestinationStream, Logger, LoggerOptions, TransportMultiOptions, TransportSingleOptions } from "pino";
3
+ //#region src/logger/console.d.ts
4
+ /**
5
+ * A zero-dependency {@link Logger} over the platform `console` — no Pino, no
6
+ * worker thread, no transports. Use it in the browser, an edge runtime, or
7
+ * React Native, or anywhere the Pino weight is not worth it. Structured calls
8
+ * are emitted as `(message, contextObject)`; `child()` bindings are merged into
9
+ * every line's context.
10
+ *
11
+ * There is no Axiom shipping here — that is a Node-transport concern. A
12
+ * `ConsoleLogger` is for local visibility only.
13
+ */
14
+ declare class ConsoleLogger implements Logger$1 {
15
+ #private;
16
+ constructor(options?: {
17
+ level?: LogLevel;
18
+ bindings?: Record<string, unknown>;
19
+ });
20
+ debug(obj: Record<string, unknown>, msg?: string): void;
21
+ debug(msg: string): void;
22
+ info(obj: Record<string, unknown>, msg?: string): void;
23
+ info(msg: string): void;
24
+ warn(obj: Record<string, unknown>, msg?: string): void;
25
+ warn(msg: string): void;
26
+ error(obj: Record<string, unknown>, msg?: string): void;
27
+ error(msg: string): void;
28
+ child(bindings: Record<string, unknown>): Logger$1;
29
+ }
30
+ //#endregion
31
+ //#region src/logger/transports.d.ts
32
+ /** Axiom credentials. The token comes from env vars or the OS keyring — never
33
+ * a committed config file; the dataset name may come from config. */
34
+ interface AxiomTransportConfig {
35
+ dataset: string;
36
+ token: string;
37
+ }
38
+ interface BuildTransportInput {
39
+ /** Resolved log level — applied uniformly to every transport. */
40
+ level: LogLevel;
41
+ /** Axiom credentials. When absent, no Axiom transport is wired. */
42
+ axiom?: AxiomTransportConfig;
43
+ /** `true` inside CI — suppresses pino-pretty. */
44
+ ci: boolean;
45
+ /** `process.stdout.isTTY` — pino-pretty only makes sense on a TTY. */
46
+ tty: boolean;
47
+ /** `true` when `HOLOCRON_TELEMETRY=false` — suppresses the Axiom transport only. */
48
+ telemetryDisabled: boolean;
49
+ }
50
+ /**
51
+ * Build the Pino `transport` option for the current environment.
52
+ *
53
+ * | Environment | Output |
54
+ * | -------------------------- | --------------------------------------------------- |
55
+ * | Local, TTY, no Axiom | `pino-pretty` only |
56
+ * | CI, no Axiom | `undefined` — Pino's default NDJSON to stdout |
57
+ * | Local, TTY, with Axiom | `pino-pretty` + Axiom |
58
+ * | CI, with Axiom | NDJSON to stdout + Axiom |
59
+ *
60
+ * The Axiom transport is dropped entirely when `telemetryDisabled` is set,
61
+ * regardless of whether credentials were supplied. Every transport runs on
62
+ * the same resolved `level` — there is no Axiom-only gate.
63
+ *
64
+ * Returning `undefined` lets `createLogger` fall back to a plain
65
+ * `pino({ ... })` with no worker thread — the cheapest path, and exactly
66
+ * what CI wants.
67
+ */
68
+ declare function buildTransport(input: BuildTransportInput): TransportSingleOptions | TransportMultiOptions | undefined;
69
+ //#endregion
70
+ //#region src/logger/context.d.ts
71
+ /**
72
+ * A fresh correlation id for one invocation. Every log line from a single run
73
+ * carries this `runId`, so a whole run can be pulled back out of Axiom with
74
+ * one query.
75
+ */
76
+ declare function generateRunId(): string;
77
+ /**
78
+ * True when running inside CI. GitHub Actions (and most other providers) set
79
+ * `CI=true`; we also accept any other non-empty, non-`false` value.
80
+ */
81
+ declare function isCI(env?: NodeJS.ProcessEnv): boolean;
82
+ /** `"ci"` inside CI, otherwise `"local"` — bound on every root logger. */
83
+ declare function detectEnv(env?: NodeJS.ProcessEnv): LogEnv;
84
+ /** Narrow an arbitrary string to a {@link LogLevel}, or `undefined`. */
85
+ declare function parseLogLevel(value: string | undefined): LogLevel | undefined;
86
+ /**
87
+ * Resolve the effective log level in priority order:
88
+ *
89
+ * 1. `explicit` — an already-resolved level (a CLI flag, a config field)
90
+ * passed by the caller.
91
+ * 2. `HOLOCRON_LOG_LEVEL` env var.
92
+ * 3. `"info"` default.
93
+ *
94
+ * An unrecognised value at any tier is ignored and resolution falls through.
95
+ */
96
+ declare function resolveLevel(explicit?: LogLevel, env?: NodeJS.ProcessEnv): LogLevel;
97
+ /** True when the Axiom transport must be suppressed via `HOLOCRON_TELEMETRY=false`. */
98
+ declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
99
+ /**
100
+ * Resolve Axiom credentials from the environment — the canonical fallback
101
+ * chain from ADR-0007. `createLogger` calls this when no explicit
102
+ * `config.axiom` is supplied, so every consumer gets Axiom activation from env
103
+ * vars alone. Credentials are read here and only here — never from a config
104
+ * file.
105
+ *
106
+ * Returns `undefined` unless BOTH a token and a dataset are present.
107
+ *
108
+ * | Value | Primary | Fallback |
109
+ * | -------- | ------------------------ | --------------- |
110
+ * | token | `HOLOCRON_AXIOM_TOKEN` | `AXIOM_TOKEN` |
111
+ * | dataset | `HOLOCRON_AXIOM_DATASET` | `AXIOM_DATASET` |
112
+ */
113
+ declare function resolveAxiomFromEnv(env?: NodeJS.ProcessEnv): AxiomTransportConfig | undefined;
114
+ //#endregion
115
+ //#region src/logger/create.d.ts
116
+ interface LoggerConfig {
117
+ /**
118
+ * Explicit level — the highest-priority source. The caller passes the
119
+ * resolved `--verbose` / `--quiet` flag or a config field here. Falls
120
+ * through to `HOLOCRON_LOG_LEVEL`, then `"info"`.
121
+ */
122
+ level?: LogLevel;
123
+ /**
124
+ * Axiom credentials. Resolved from env vars by default
125
+ * (`HOLOCRON_AXIOM_TOKEN` / `AXIOM_TOKEN` + `HOLOCRON_AXIOM_DATASET` /
126
+ * `AXIOM_DATASET`). Pass this only to override — e.g. to pair an OS-keyring
127
+ * token with a config-file dataset. The **token** must never come from a
128
+ * committed config file. The transport is also skipped entirely when
129
+ * `HOLOCRON_TELEMETRY=false`.
130
+ */
131
+ axiom?: AxiomTransportConfig;
132
+ }
133
+ interface CreateLoggerResult {
134
+ /** The logger to thread through modules via `child()`. */
135
+ logger: Logger$1;
136
+ /**
137
+ * Correlation id bound to every line this logger (and its children) emit.
138
+ * Surface it to the user (e.g. on `--debug`) so they can pull the run out
139
+ * of Axiom.
140
+ */
141
+ runId: string;
142
+ }
143
+ /**
144
+ * The single entry point for building a Pino-backed logger. Generates a
145
+ * `runId`, detects the environment, resolves the level, wires the right
146
+ * transports, and returns a ready {@link Logger}.
147
+ *
148
+ * ```ts
149
+ * const { logger, runId } = createLogger({ level, axiom });
150
+ * const log = logger.child({ command: "sync-github", repo });
151
+ * log.info({ branch }, "opening PR");
152
+ * ```
153
+ *
154
+ * For a browser / edge / React Native context, construct a `ConsoleLogger`
155
+ * directly instead — it needs no `createLogger`.
156
+ */
157
+ declare function createLogger(config?: LoggerConfig): CreateLoggerResult;
158
+ //#endregion
159
+ //#region src/logger/pino.d.ts
160
+ /**
161
+ * The Pino-backed {@link Logger}. Nothing outside this package should name it —
162
+ * construct loggers with `createLogger`. It is a thin pass-through to a Pino
163
+ * instance; the interface overloads mirror Pino's own, so each method is a
164
+ * single delegated call.
165
+ */
166
+ declare class PinoLogger implements Logger$1 {
167
+ #private;
168
+ constructor(instance: Logger);
169
+ debug(obj: Record<string, unknown>, msg?: string): void;
170
+ debug(msg: string): void;
171
+ info(obj: Record<string, unknown>, msg?: string): void;
172
+ info(msg: string): void;
173
+ warn(obj: Record<string, unknown>, msg?: string): void;
174
+ warn(msg: string): void;
175
+ error(obj: Record<string, unknown>, msg?: string): void;
176
+ error(msg: string): void;
177
+ child(bindings: Record<string, unknown>): Logger$1;
178
+ }
179
+ interface CreatePinoInstanceInput {
180
+ /** Resolved log level. */
181
+ level: LogLevel;
182
+ /** Axiom credentials, if the transport should be wired. */
183
+ axiom?: AxiomTransportConfig;
184
+ /** `true` inside CI. */
185
+ ci: boolean;
186
+ /** `process.stdout.isTTY`. */
187
+ tty: boolean;
188
+ /** `true` when `HOLOCRON_TELEMETRY=false`. */
189
+ telemetryDisabled: boolean;
190
+ /** Bindings written on every line — `runId` and `env`. */
191
+ base: Record<string, unknown>;
192
+ /**
193
+ * Write here instead of configuring transports. Used by tests to capture
194
+ * output synchronously; never set in production.
195
+ */
196
+ destination?: DestinationStream;
197
+ }
198
+ /**
199
+ * Assemble the Pino `LoggerOptions`: resolved level, `runId` / `env` on every
200
+ * line, ISO timestamps, sensitive-field redaction, and — unless a capture
201
+ * `destination` is in play — the environment-appropriate transport from
202
+ * {@link buildTransport}.
203
+ */
204
+ declare function buildPinoOptions(input: CreatePinoInstanceInput): LoggerOptions;
205
+ /**
206
+ * Construct the underlying Pino instance. Writes to `destination` when one is
207
+ * supplied (tests), otherwise to the transports {@link buildPinoOptions} wired.
208
+ */
209
+ declare function createPinoInstance(input: CreatePinoInstanceInput): Logger;
210
+ //#endregion
211
+ export { buildTransport as _, CreateLoggerResult as a, detectEnv as c, isTelemetryDisabled as d, parseLogLevel as f, BuildTransportInput as g, AxiomTransportConfig as h, createPinoInstance as i, generateRunId as l, resolveLevel as m, PinoLogger as n, LoggerConfig as o, resolveAxiomFromEnv as p, buildPinoOptions as r, createLogger as s, CreatePinoInstanceInput as t, isCI as u, ConsoleLogger as v };
@@ -0,0 +1,14 @@
1
+ import { t as AnalyticsSink } from "./sinks-CSEolKcN.mjs";
2
+ //#region src/analytics/posthog-sink.d.ts
3
+ declare class PostHogSink implements AnalyticsSink {
4
+ #private;
5
+ constructor(config: {
6
+ key: string;
7
+ host: string;
8
+ });
9
+ identify(distinctId: string, props: Record<string, unknown>): void;
10
+ capture(distinctId: string, event: string, props: Record<string, unknown>): void;
11
+ shutdown(): Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { PostHogSink as t };
@@ -0,0 +1,38 @@
1
+ import { PostHog } from "posthog-node";
2
+ //#region src/analytics/posthog-sink.ts
3
+ /**
4
+ * `PostHogSink` — the **only** `posthog-node` call site. A portable
5
+ * `AnalyticsSink` adapter: usage, adoption, retention. It reads no environment
6
+ * and ships no credentials — the constructor takes a resolved `key` + `host`;
7
+ * the caller owns the env chain and any fallback. An empty `key` is the
8
+ * caller's signal to install a `NoopAnalyticsSink` instead — it is never
9
+ * passed here.
10
+ *
11
+ * `posthog-node` is an optional peer dependency. For a browser / React Native
12
+ * context use `posthog-js` / `posthog-react-native` behind the same
13
+ * {@link AnalyticsSink} interface.
14
+ */
15
+ var PostHogSink = class {
16
+ #client;
17
+ constructor(config) {
18
+ this.#client = new PostHog(config.key, { host: config.host });
19
+ }
20
+ identify(distinctId, props) {
21
+ this.#client.identify({
22
+ distinctId,
23
+ properties: props
24
+ });
25
+ }
26
+ capture(distinctId, event, props) {
27
+ this.#client.capture({
28
+ distinctId,
29
+ event,
30
+ properties: props
31
+ });
32
+ }
33
+ async shutdown() {
34
+ await this.#client.shutdown();
35
+ }
36
+ };
37
+ //#endregion
38
+ export { PostHogSink as t };
@@ -0,0 +1,50 @@
1
+ //#region src/core/redact.ts
2
+ /**
3
+ * Two redaction layers, both zero-dependency:
4
+ *
5
+ * 1. **Field-path redaction** ({@link REDACTED_PATHS} / {@link redactOptions}) —
6
+ * Pino's `redact` option. Strips known-sensitive keys from every log line in
7
+ * Pino's serialisation layer, before any transport sees it.
8
+ * 2. **Token-shape scrubbing** ({@link redact} / {@link redactObject}) — a
9
+ * regex over the serialised string that matches a token shape *anywhere*,
10
+ * even in a value the caller controls. Used by the Sentry `beforeSend` hook
11
+ * and the analytics `capture()` path.
12
+ */
13
+ /**
14
+ * Sensitive field paths stripped from every log line. Paths use Pino's
15
+ * redaction syntax: dotted access, `[*]` wildcards for arrays, and
16
+ * bracket-quoted keys for names that are not valid identifiers.
17
+ *
18
+ * @see https://getpino.io/#/docs/redaction
19
+ */
20
+ const REDACTED_PATHS = [
21
+ "token",
22
+ "secret",
23
+ "password",
24
+ "apiKey",
25
+ "secrets[*].value",
26
+ "headers.authorization",
27
+ "headers[\"x-api-key\"]",
28
+ "*.token",
29
+ "*.secret",
30
+ "*.password",
31
+ "*.apiKey"
32
+ ];
33
+ /** Replacement string Pino writes in place of a redacted value. */
34
+ const REDACT_CENSOR = "[Redacted]";
35
+ /** Ready-to-use Pino `redact` option. */
36
+ const redactOptions = {
37
+ paths: [...REDACTED_PATHS],
38
+ censor: REDACT_CENSOR
39
+ };
40
+ const TOKEN_RE = /\b(ghp_|ghs_|glpat-|xoxb-|xoxp-|npm_|sk-|[A-Z][A-Z0-9_]{2,}_TOKEN[=\s])[^\s"]*/g;
41
+ /** Replace token-shaped substrings in a string with `[REDACTED]`. */
42
+ function redact(raw) {
43
+ return raw.replace(TOKEN_RE, "[REDACTED]");
44
+ }
45
+ /** Deep-scrub every string in an object by round-tripping through {@link redact}. */
46
+ function redactObject(value) {
47
+ return JSON.parse(redact(JSON.stringify(value)));
48
+ }
49
+ //#endregion
50
+ export { redactOptions as a, redactObject as i, REDACT_CENSOR as n, redact as r, REDACTED_PATHS as t };
@@ -0,0 +1,43 @@
1
+ import { i as redactObject } from "./redact-BMWG62k9.mjs";
2
+ import * as Sentry from "@sentry/node";
3
+ //#region src/errors/sentry-sink.ts
4
+ /** `beforeSend` — token-shaped strings never leave the process. */
5
+ function scrubError(event, _hint) {
6
+ return redactObject(event);
7
+ }
8
+ var SentrySink = class {
9
+ init(ctx) {
10
+ Sentry.init({
11
+ dsn: ctx.dsn,
12
+ release: ctx.release,
13
+ environment: ctx.environment,
14
+ tracesSampleRate: 1,
15
+ beforeSend: scrubError
16
+ });
17
+ Sentry.startSession();
18
+ for (const [key, value] of Object.entries(ctx.tags)) Sentry.setTag(key, value);
19
+ }
20
+ startSpan(name) {
21
+ Sentry.setTag("command", name);
22
+ const span = Sentry.startInactiveSpan({
23
+ name,
24
+ op: "holocron.command",
25
+ forceTransaction: true
26
+ });
27
+ return {
28
+ setStatus: (ok) => span.setStatus({ code: ok ? 1 : 2 }),
29
+ end: () => span.end()
30
+ };
31
+ }
32
+ captureException(err) {
33
+ Sentry.captureException(err);
34
+ }
35
+ endSession() {
36
+ Sentry.endSession();
37
+ }
38
+ async flush() {
39
+ await Sentry.close(2e3);
40
+ }
41
+ };
42
+ //#endregion
43
+ export { scrubError as n, SentrySink as t };
@@ -0,0 +1,19 @@
1
+ import { n as CommandSpan, r as ErrorSink } from "./sinks-CSEolKcN.mjs";
2
+ import { ErrorEvent, EventHint } from "@sentry/node";
3
+ //#region src/errors/sentry-sink.d.ts
4
+ /** `beforeSend` — token-shaped strings never leave the process. */
5
+ declare function scrubError(event: ErrorEvent, _hint: EventHint): ErrorEvent;
6
+ declare class SentrySink implements ErrorSink {
7
+ init(ctx: {
8
+ dsn: string;
9
+ release: string;
10
+ environment: "ci" | "local";
11
+ tags: Record<string, string>;
12
+ }): void;
13
+ startSpan(name: string): CommandSpan;
14
+ captureException(err: unknown): void;
15
+ endSession(): void;
16
+ flush(): Promise<void>;
17
+ }
18
+ //#endregion
19
+ export { scrubError as n, SentrySink as t };
@@ -0,0 +1,54 @@
1
+ //#region src/core/sinks.d.ts
2
+ /**
3
+ * Telemetry sink interfaces — the seam between an application's telemetry
4
+ * orchestration and the vendor SDKs. No `@sentry/node` / `posthog-node` import
5
+ * lives outside `@theholocron/observability/errors` / `.../analytics`; every
6
+ * other module talks to these interfaces, so a vendor swap (or a
7
+ * {@link NoopErrorSink} for tests / opt-out) is one file. Same shape as
8
+ * {@link Logger}.
9
+ */
10
+ /** A running command span — `undefined` when the error sink is off. */
11
+ interface CommandSpan {
12
+ setStatus(ok: boolean): void;
13
+ end(): void;
14
+ }
15
+ /** Error tracking + performance (Sentry). */
16
+ interface ErrorSink {
17
+ init(ctx: {
18
+ dsn: string;
19
+ release: string;
20
+ environment: "ci" | "local";
21
+ tags: Record<string, string>;
22
+ }): void;
23
+ /** Start a command span. Returns `undefined` for a no-op sink. */
24
+ startSpan(name: string): CommandSpan | undefined;
25
+ captureException(err: unknown): void;
26
+ endSession(): void;
27
+ flush(): Promise<void>;
28
+ }
29
+ /** Product analytics — usage, adoption, retention (PostHog). */
30
+ interface AnalyticsSink {
31
+ identify(distinctId: string, props: Record<string, unknown>): void;
32
+ capture(distinctId: string, event: string, props: Record<string, unknown>): void;
33
+ shutdown(): Promise<void>;
34
+ }
35
+ /**
36
+ * The disabled path made explicit — one shared no-op instead of a scatter of
37
+ * `if (!enabled) return` guards. Install it when telemetry is opted out or no
38
+ * credentials resolve.
39
+ */
40
+ declare class NoopErrorSink implements ErrorSink {
41
+ init(): void;
42
+ startSpan(): CommandSpan | undefined;
43
+ captureException(): void;
44
+ endSession(): void;
45
+ flush(): Promise<void>;
46
+ }
47
+ /** @see NoopErrorSink */
48
+ declare class NoopAnalyticsSink implements AnalyticsSink {
49
+ identify(): void;
50
+ capture(): void;
51
+ shutdown(): Promise<void>;
52
+ }
53
+ //#endregion
54
+ export { NoopErrorSink as a, NoopAnalyticsSink as i, CommandSpan as n, ErrorSink as r, AnalyticsSink as t };
@@ -0,0 +1,21 @@
1
+ //#region src/core/sinks.ts
2
+ /**
3
+ * The disabled path made explicit — one shared no-op instead of a scatter of
4
+ * `if (!enabled) return` guards. Install it when telemetry is opted out or no
5
+ * credentials resolve.
6
+ */
7
+ var NoopErrorSink = class {
8
+ init() {}
9
+ startSpan() {}
10
+ captureException() {}
11
+ endSession() {}
12
+ async flush() {}
13
+ };
14
+ /** @see NoopErrorSink */
15
+ var NoopAnalyticsSink = class {
16
+ identify() {}
17
+ capture() {}
18
+ async shutdown() {}
19
+ };
20
+ //#endregion
21
+ export { NoopErrorSink as n, NoopAnalyticsSink as t };
package/package.json ADDED
@@ -0,0 +1,142 @@
1
+ {
2
+ "name": "@theholocron/observability",
3
+ "version": "0.1.0",
4
+ "description": "Logging, error tracking, and analytics — one interface, swappable backends.",
5
+ "keywords": [
6
+ "observability",
7
+ "telemetry",
8
+ "logging",
9
+ "logger",
10
+ "pino",
11
+ "sentry",
12
+ "posthog",
13
+ "structured-logging",
14
+ "theholocron",
15
+ "typescript"
16
+ ],
17
+ "homepage": "https://docs.theholocron.dev/observability/",
18
+ "bugs": "https://github.com/theholocron/observability/issues",
19
+ "repository": "theholocron/observability",
20
+ "license": "MIT",
21
+ "author": "Newton Koumantzelis",
22
+ "sideEffects": false,
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.mts",
27
+ "import": "./dist/index.mjs",
28
+ "default": "./dist/index.mjs"
29
+ },
30
+ "./core": {
31
+ "types": "./dist/core.d.mts",
32
+ "import": "./dist/core.mjs",
33
+ "default": "./dist/core.mjs"
34
+ },
35
+ "./logger": {
36
+ "types": "./dist/logger.d.mts",
37
+ "import": "./dist/logger.mjs",
38
+ "default": "./dist/logger.mjs"
39
+ },
40
+ "./errors": {
41
+ "types": "./dist/errors.d.mts",
42
+ "import": "./dist/errors.mjs",
43
+ "default": "./dist/errors.mjs"
44
+ },
45
+ "./analytics": {
46
+ "types": "./dist/analytics.d.mts",
47
+ "import": "./dist/analytics.mjs",
48
+ "default": "./dist/analytics.mjs"
49
+ }
50
+ },
51
+ "files": [
52
+ "dist"
53
+ ],
54
+ "devDependencies": {
55
+ "@astrojs/starlight": "^0.42.0",
56
+ "@axiomhq/pino": "^2.0.0",
57
+ "@commitlint/cli": "^21.2.1",
58
+ "@commitlint/types": "^21.2.0",
59
+ "@eslint/js": "^10.0.0",
60
+ "@semantic-release/changelog": "^7.0.0",
61
+ "@semantic-release/exec": "^7.1.0",
62
+ "@semantic-release/git": "^11.0.1",
63
+ "@semantic-release/github": "^12.0.9",
64
+ "@sentry/node": "^10.70.0",
65
+ "@theholocron/astro-config": "^8.2.0",
66
+ "@theholocron/cli": "^4.14.1",
67
+ "@theholocron/commitlint-config": "^8.2.0",
68
+ "@theholocron/docs-theme": "^1.3.0",
69
+ "@theholocron/eslint-config": "^8.2.0",
70
+ "@theholocron/holocron-config": "^8.2.0",
71
+ "@theholocron/holocron-plugin-github": "^4.14.1",
72
+ "@theholocron/lint-staged-config": "^8.2.0",
73
+ "@theholocron/prettier-config": "^8.2.0",
74
+ "@theholocron/semantic-release-config": "^8.2.0",
75
+ "@theholocron/skills": "^1.3.2",
76
+ "@theholocron/tsconfig": "^8.2.0",
77
+ "@theholocron/tsdown-config": "^8.2.0",
78
+ "@theholocron/vitest-config": "^8.2.0",
79
+ "@types/node": "^26.1.2",
80
+ "@vitest/coverage-v8": "^4.1.10",
81
+ "astro": "^7.1.5",
82
+ "conventional-changelog-conventionalcommits": "^10.2.1",
83
+ "eslint": "^10.8.0",
84
+ "eslint-plugin-n": "^18.2.2",
85
+ "eslint-plugin-simple-import-sort": "^14.0.0",
86
+ "globals": "^17.8.0",
87
+ "husky": "^9.1.7",
88
+ "knip": "^6.29.0",
89
+ "lint-staged": "^16.2.6",
90
+ "pino": "^10.3.1",
91
+ "pino-pretty": "^13.1.3",
92
+ "posthog-node": "^5.51.6",
93
+ "prettier": "^3.6.2",
94
+ "semantic-release": "^25.0.8",
95
+ "sort-package-json": "^4.0.0",
96
+ "tsdown": "^0.23.0",
97
+ "typescript": "^5.9.3",
98
+ "typescript-eslint": "^8.65.0",
99
+ "vitest": "^4.1.10"
100
+ },
101
+ "peerDependencies": {
102
+ "@axiomhq/pino": ">=2",
103
+ "@sentry/node": ">=10",
104
+ "pino": ">=10",
105
+ "pino-pretty": ">=13",
106
+ "posthog-node": ">=5"
107
+ },
108
+ "peerDependenciesMeta": {
109
+ "@axiomhq/pino": {
110
+ "optional": true
111
+ },
112
+ "@sentry/node": {
113
+ "optional": true
114
+ },
115
+ "pino": {
116
+ "optional": true
117
+ },
118
+ "pino-pretty": {
119
+ "optional": true
120
+ },
121
+ "posthog-node": {
122
+ "optional": true
123
+ }
124
+ },
125
+ "engines": {
126
+ "node": ">=22.0.0"
127
+ },
128
+ "publishConfig": {
129
+ "access": "public"
130
+ },
131
+ "releases": "https://github.com/theholocron/observability/releases",
132
+ "wiki": "https://github.com/theholocron/observability/wiki",
133
+ "scripts": {
134
+ "audit": "knip",
135
+ "build": "tsdown",
136
+ "lint": "eslint .",
137
+ "release": "semantic-release",
138
+ "test": "vitest run",
139
+ "test:coverage": "vitest run --coverage",
140
+ "typecheck": "tsc --noEmit"
141
+ }
142
+ }