@geonosis/observability 1.0.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 +202 -0
- package/README.md +333 -0
- package/bin/geonosis-observability.mjs +4 -0
- package/dist/chunk-2ZTQU3OO.js +161 -0
- package/dist/chunk-EJS3A3ZV.js +82 -0
- package/dist/chunk-UFR2R2VM.js +141 -0
- package/dist/health/index.d.ts +63 -0
- package/dist/health/index.js +89 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +145 -0
- package/dist/observability-cli.js +229 -0
- package/dist/ports-Ct5eq-HS.d.ts +116 -0
- package/dist/posthog/index.d.ts +58 -0
- package/dist/posthog/index.js +7 -0
- package/package.json +63 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Result } from 'better-result';
|
|
2
|
+
import { b as SinkFailure, E as ErrorSink, A as Attributes } from '../ports-Ct5eq-HS.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The PostHog adapter.
|
|
6
|
+
*
|
|
7
|
+
* `posthog-node` is never imported here. The consumer passes a factory that builds a client for one
|
|
8
|
+
* batch — which is during.day's own shape (`new PostHog(key, { host, flushAt: events.length,
|
|
9
|
+
* flushInterval: 0 })`, every event pushed, then `shutdown()`) — and it keeps this package at zero
|
|
10
|
+
* runtime dependencies, keeps the key and the host out of it entirely, and makes the whole adapter
|
|
11
|
+
* drivable against a stub server without a network.
|
|
12
|
+
*
|
|
13
|
+
* `flushInterval: 0` in that line is load-bearing and belongs in the consumer's factory: there is no
|
|
14
|
+
* long-lived process in workerd to run a background timer in, and a timer left running is an
|
|
15
|
+
* isolate that will not shut down.
|
|
16
|
+
*/
|
|
17
|
+
type PostHogLike = {
|
|
18
|
+
captureException: (error: unknown, distinctId?: string, properties?: Record<string, unknown>, uuid?: string) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The ONLY place `posthog-node` tells anyone a batch did not land. Measured against 5.50.0:
|
|
21
|
+
* `shutdown()` resolves over a server that answered 500 and over a port nobody is listening on,
|
|
22
|
+
* and the failure arrives here instead. during.day's sink awaits `shutdown()` and returns
|
|
23
|
+
* `events.length`, so it reports "5 sent" having sent none.
|
|
24
|
+
*/
|
|
25
|
+
on: (event: 'error', handler: (error: unknown) => void) => unknown;
|
|
26
|
+
shutdown: () => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
type FlushHandle = {
|
|
29
|
+
/** How many reports this handle will send. Read it BEFORE awaiting; the buffer is already taken. */
|
|
30
|
+
readonly pending: number;
|
|
31
|
+
/** The promise a host hands to `waitUntil`. It resolves, always — a report is never the failure. */
|
|
32
|
+
readonly promise: Promise<Result<void, SinkFailure>>;
|
|
33
|
+
};
|
|
34
|
+
type PostHogSink = ErrorSink & {
|
|
35
|
+
/**
|
|
36
|
+
* Take what is buffered and start sending it. `ctx.waitUntil(sink.flushable().promise)` is the
|
|
37
|
+
* whole workerd story: the response is not held for the flush, the isolate is not killed before it
|
|
38
|
+
* lands, and `pending` lets a caller skip the call entirely when there is nothing to send.
|
|
39
|
+
*/
|
|
40
|
+
flushable: () => FlushHandle;
|
|
41
|
+
};
|
|
42
|
+
type PostHogSinkOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* The group key the tenant is filed under. `organization` is during.day's, and it is a DEFAULT,
|
|
45
|
+
* never a fact: an adapter that hardcoded one repo's group key could not be shared.
|
|
46
|
+
*/
|
|
47
|
+
groupName?: string;
|
|
48
|
+
/** Who the report is attributed to. Default: the actor, else the tenant, else the service. */
|
|
49
|
+
identityOf?: (attributes: Attributes) => string;
|
|
50
|
+
/**
|
|
51
|
+
* A client for ONE batch, sized to it. during.day's line, verbatim:
|
|
52
|
+
* `(size) => new PostHog(key, { host, flushAt: size, flushInterval: 0 })`.
|
|
53
|
+
*/
|
|
54
|
+
newClient: (batchSize: number) => PostHogLike;
|
|
55
|
+
};
|
|
56
|
+
declare const createPostHogSink: ({ groupName, identityOf, newClient, }: PostHogSinkOptions) => PostHogSink;
|
|
57
|
+
|
|
58
|
+
export { type FlushHandle, type PostHogLike, type PostHogSink, type PostHogSinkOptions, createPostHogSink };
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geonosis/observability",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Ports whose answer can say failed: an ErrorSink and a Tracer returning Result, one attribute vocabulary (tenant as a group id, never a person), a memory sink, envelope-id dedupe, a PostHog adapter, a tiered health registry, and a probe that plants an error and names the trace id it arrived as.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"observability",
|
|
7
|
+
"error-tracking",
|
|
8
|
+
"health-check",
|
|
9
|
+
"posthog",
|
|
10
|
+
"tracing",
|
|
11
|
+
"result",
|
|
12
|
+
"workers"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/microcompanies/geonosis/tree/main/packages/observability",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/microcompanies/geonosis.git",
|
|
18
|
+
"directory": "packages/observability"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./dist/index.js",
|
|
25
|
+
"./health": "./dist/health/index.js",
|
|
26
|
+
"./posthog": "./dist/posthog/index.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"bin",
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"better-result": "^3.0.0",
|
|
34
|
+
"posthog-node": ">=5.49.0",
|
|
35
|
+
"zod": "^4.0.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"posthog-node": {
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
"zod": {
|
|
42
|
+
"optional": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"better-result": "3.0.1",
|
|
47
|
+
"posthog-node": "5.50.0",
|
|
48
|
+
"zod": "^4.0.0"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=22"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
},
|
|
56
|
+
"bin": {
|
|
57
|
+
"geonosis-observability": "bin/geonosis-observability.mjs"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsup",
|
|
61
|
+
"typecheck": "tsc --noEmit"
|
|
62
|
+
}
|
|
63
|
+
}
|