@se-studio/contentful-cms 2.0.0 → 2.0.2
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/CHANGELOG.md +12 -0
- package/dist/cli/program.d.ts.map +1 -1
- package/dist/cli/program.js +9 -27
- package/dist/cli/program.js.map +1 -1
- package/dist/cli/runner.d.ts.map +1 -1
- package/dist/cli/runner.js +3 -0
- package/dist/cli/runner.js.map +1 -1
- package/dist/generated/hosted-guide.d.ts +1 -1
- package/dist/generated/hosted-guide.d.ts.map +1 -1
- package/dist/generated/hosted-guide.js +1 -1
- package/dist/generated/hosted-guide.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/hosted/index.d.ts +2 -1
- package/dist/hosted/index.d.ts.map +1 -1
- package/dist/hosted/index.js +1 -0
- package/dist/hosted/index.js.map +1 -1
- package/dist/hosted/next/routes/mcp.d.ts.map +1 -1
- package/dist/hosted/next/routes/mcp.js +14 -1
- package/dist/hosted/next/routes/mcp.js.map +1 -1
- package/dist/hosted/oauth/auth.d.ts +4 -2
- package/dist/hosted/oauth/auth.d.ts.map +1 -1
- package/dist/hosted/oauth/auth.js +6 -4
- package/dist/hosted/oauth/auth.js.map +1 -1
- package/dist/hosted/oauth/handlers.d.ts.map +1 -1
- package/dist/hosted/oauth/handlers.js +16 -0
- package/dist/hosted/oauth/handlers.js.map +1 -1
- package/dist/hosted/oauth/log.d.ts +7 -0
- package/dist/hosted/oauth/log.d.ts.map +1 -0
- package/dist/hosted/oauth/log.js +36 -0
- package/dist/hosted/oauth/log.js.map +1 -0
- package/dist/telemetry/axiom.d.ts +22 -0
- package/dist/telemetry/axiom.d.ts.map +1 -0
- package/dist/telemetry/axiom.js +41 -0
- package/dist/telemetry/axiom.js.map +1 -0
- package/dist/telemetry/composite.d.ts +9 -0
- package/dist/telemetry/composite.d.ts.map +1 -0
- package/dist/telemetry/composite.js +16 -0
- package/dist/telemetry/composite.js.map +1 -0
- package/dist/telemetry/enrich.d.ts +11 -0
- package/dist/telemetry/enrich.d.ts.map +1 -0
- package/dist/telemetry/enrich.js +23 -0
- package/dist/telemetry/enrich.js.map +1 -0
- package/dist/telemetry/factory.d.ts +8 -0
- package/dist/telemetry/factory.d.ts.map +1 -0
- package/dist/telemetry/factory.js +44 -0
- package/dist/telemetry/factory.js.map +1 -0
- package/dist/telemetry/index.d.ts +6 -7
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +6 -9
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/noop.d.ts +7 -0
- package/dist/telemetry/noop.d.ts.map +1 -0
- package/dist/telemetry/noop.js +6 -0
- package/dist/telemetry/noop.js.map +1 -0
- package/dist/telemetry/record.d.ts +12 -0
- package/dist/telemetry/record.d.ts.map +1 -0
- package/dist/telemetry/record.js +55 -0
- package/dist/telemetry/record.js.map +1 -0
- package/dist/telemetry/types.d.ts +15 -3
- package/dist/telemetry/types.d.ts.map +1 -1
- package/docs/FUNCTIONAL_SPEC.md +6 -1
- package/docs/TELEMETRY_AXIOM.md +74 -0
- package/docs/mcp/hosted-guide.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** OAuth/auth diagnostics for hosted cms-edit — failures always log; verbose with LOG_CMS_OAUTH=1. */
|
|
2
|
+
function writeOauthLog(line) {
|
|
3
|
+
process.stderr.write(`${line}\n`);
|
|
4
|
+
}
|
|
5
|
+
export function isOauthLoggingVerbose() {
|
|
6
|
+
const value = process.env['LOG_CMS_OAUTH'];
|
|
7
|
+
return value === '1' || value === 'true';
|
|
8
|
+
}
|
|
9
|
+
export function oauthLogVerbose(event, details) {
|
|
10
|
+
if (!isOauthLoggingVerbose())
|
|
11
|
+
return;
|
|
12
|
+
writeOauthLog(`[cms-edit:oauth] ${event}${details ? ` ${JSON.stringify(details)}` : ''}`);
|
|
13
|
+
}
|
|
14
|
+
/** Always emitted for auth failures — visible in Vercel runtime logs. */
|
|
15
|
+
export function oauthLogAuthFailure(route, reason, details) {
|
|
16
|
+
writeOauthLog(`[cms-edit:oauth] auth_failure route=${route} reason=${reason}${details ? ` ${JSON.stringify(details)}` : ''}`);
|
|
17
|
+
}
|
|
18
|
+
export function patValidationFailureReason(message) {
|
|
19
|
+
if (message.includes('does not have access to the configured Contentful space')) {
|
|
20
|
+
return 'space_access_denied';
|
|
21
|
+
}
|
|
22
|
+
if (message.includes('Invalid Contentful management token')) {
|
|
23
|
+
return 'invalid_contentful_token';
|
|
24
|
+
}
|
|
25
|
+
if (message.includes('Contentful management token is required')) {
|
|
26
|
+
return 'missing_contentful_token';
|
|
27
|
+
}
|
|
28
|
+
if (message.includes('Contentful API error')) {
|
|
29
|
+
return 'contentful_api_error';
|
|
30
|
+
}
|
|
31
|
+
if (message.includes('Contentful space check failed')) {
|
|
32
|
+
return 'space_check_failed';
|
|
33
|
+
}
|
|
34
|
+
return 'pat_validation_failed';
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/hosted/oauth/log.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,OAAiC;IAC9E,IAAI,CAAC,qBAAqB,EAAE;QAAE,OAAO;IACrC,aAAa,CAAC,oBAAoB,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,MAAc,EACd,OAAiC;IAEjC,aAAa,CACX,uCAAuC,KAAK,WAAW,MAAM,GAC3D,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAC5C,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,IAAI,OAAO,CAAC,QAAQ,CAAC,yDAAyD,CAAC,EAAE,CAAC;QAChF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,qCAAqC,CAAC,EAAE,CAAC;QAC5D,OAAO,0BAA0B,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,yCAAyC,CAAC,EAAE,CAAC;QAChE,OAAO,0BAA0B,CAAC;IACpC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC7C,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QACtD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TelemetryEvent, TelemetryWriter } from './types.js';
|
|
2
|
+
export interface AxiomTelemetryWriterOptions {
|
|
3
|
+
token?: string;
|
|
4
|
+
dataset?: string;
|
|
5
|
+
domain?: string;
|
|
6
|
+
fetchFn?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Buffers telemetry events and POSTs them to Axiom ingest on flush.
|
|
10
|
+
* Errors are silently swallowed so telemetry never affects CLI behaviour.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AxiomTelemetryWriter implements TelemetryWriter {
|
|
13
|
+
private readonly buffer;
|
|
14
|
+
private readonly token;
|
|
15
|
+
private readonly dataset;
|
|
16
|
+
private readonly domain;
|
|
17
|
+
private readonly fetchFn;
|
|
18
|
+
constructor(options?: AxiomTelemetryWriterOptions);
|
|
19
|
+
record(event: TelemetryEvent): void;
|
|
20
|
+
flush(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=axiom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiom.d.ts","sourceRoot":"","sources":["../../src/telemetry/axiom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,OAAO,GAAE,2BAAgC;IAOrD,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAK7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAiB7B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffers telemetry events and POSTs them to Axiom ingest on flush.
|
|
3
|
+
* Errors are silently swallowed so telemetry never affects CLI behaviour.
|
|
4
|
+
*/
|
|
5
|
+
export class AxiomTelemetryWriter {
|
|
6
|
+
buffer = [];
|
|
7
|
+
token;
|
|
8
|
+
dataset;
|
|
9
|
+
domain;
|
|
10
|
+
fetchFn;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.token = options.token ?? process.env['AXIOM_TOKEN'] ?? '';
|
|
13
|
+
this.dataset = options.dataset ?? process.env['AXIOM_DATASET'] ?? '';
|
|
14
|
+
this.domain = options.domain ?? process.env['AXIOM_DOMAIN'] ?? 'api.axiom.co';
|
|
15
|
+
this.fetchFn = options.fetchFn ?? fetch;
|
|
16
|
+
}
|
|
17
|
+
record(event) {
|
|
18
|
+
if (!this.token || !this.dataset)
|
|
19
|
+
return;
|
|
20
|
+
this.buffer.push(event);
|
|
21
|
+
}
|
|
22
|
+
async flush() {
|
|
23
|
+
if (!this.token || !this.dataset || this.buffer.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
const events = this.buffer.splice(0);
|
|
26
|
+
try {
|
|
27
|
+
await this.fetchFn(`https://${this.domain}/v1/ingest/${this.dataset}`, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
Authorization: `Bearer ${this.token}`,
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify(events),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Intentionally swallowed — telemetry must not break the CLI
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=axiom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiom.js","sourceRoot":"","sources":["../../src/telemetry/axiom.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACd,MAAM,GAAqB,EAAE,CAAC;IAC9B,KAAK,CAAS;IACd,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,OAAO,CAAe;IAEvC,YAAY,UAAuC,EAAE;QACnD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC;QAC9E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAqB;QAC1B,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAErE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,cAAc,IAAI,CAAC,OAAO,EAAE,EAAE;gBACrE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;oBACrC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;aAC7B,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,6DAA6D;QAC/D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TelemetryEvent, TelemetryWriter } from './types.js';
|
|
2
|
+
/** Fans out events to multiple writers and flushes them in parallel. */
|
|
3
|
+
export declare class CompositeTelemetryWriter implements TelemetryWriter {
|
|
4
|
+
private readonly writers;
|
|
5
|
+
constructor(writers: TelemetryWriter[]);
|
|
6
|
+
record(event: TelemetryEvent): void;
|
|
7
|
+
flush(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=composite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite.d.ts","sourceRoot":"","sources":["../../src/telemetry/composite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,wEAAwE;AACxE,qBAAa,wBAAyB,YAAW,eAAe;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,eAAe,EAAE;IAEvD,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAM7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Fans out events to multiple writers and flushes them in parallel. */
|
|
2
|
+
export class CompositeTelemetryWriter {
|
|
3
|
+
writers;
|
|
4
|
+
constructor(writers) {
|
|
5
|
+
this.writers = writers;
|
|
6
|
+
}
|
|
7
|
+
record(event) {
|
|
8
|
+
for (const writer of this.writers) {
|
|
9
|
+
writer.record(event);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
async flush() {
|
|
13
|
+
await Promise.all(this.writers.map((writer) => writer.flush?.() ?? Promise.resolve()));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=composite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite.js","sourceRoot":"","sources":["../../src/telemetry/composite.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,MAAM,OAAO,wBAAwB;IACN;IAA7B,YAA6B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAE3D,MAAM,CAAC,KAAqB;QAC1B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TelemetryEvent } from './types.js';
|
|
2
|
+
export type TelemetryMode = TelemetryEvent['mode'];
|
|
3
|
+
export declare function isHostedMcpMode(): boolean;
|
|
4
|
+
export declare function getTelemetryMode(): TelemetryMode;
|
|
5
|
+
export declare function getTelemetryProjectKey(): string | undefined;
|
|
6
|
+
type TelemetryEventInput = Omit<TelemetryEvent, 'event_id' | 'cms_edit_version' | 'mode' | 'node_version' | 'platform' | 'project_key'> & {
|
|
7
|
+
project_key?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function enrichTelemetryEvent(event: TelemetryEventInput): TelemetryEvent;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=enrich.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrich.d.ts","sourceRoot":"","sources":["../../src/telemetry/enrich.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AAEnD,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAG3D;AAED,KAAK,mBAAmB,GAAG,IAAI,CAC7B,cAAc,EACd,UAAU,GAAG,kBAAkB,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,GAAG,aAAa,CACvF,GAAG;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAU/E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CMS_EDIT_VERSION } from '../version.js';
|
|
2
|
+
export function isHostedMcpMode() {
|
|
3
|
+
return process.env['VERCEL'] === '1' || process.env['CMS_EDIT_HOSTED'] === '1';
|
|
4
|
+
}
|
|
5
|
+
export function getTelemetryMode() {
|
|
6
|
+
return isHostedMcpMode() ? 'hosted-mcp' : 'cli';
|
|
7
|
+
}
|
|
8
|
+
export function getTelemetryProjectKey() {
|
|
9
|
+
const key = process.env['CMS_EDIT_PROJECT_KEY']?.trim();
|
|
10
|
+
return key || undefined;
|
|
11
|
+
}
|
|
12
|
+
export function enrichTelemetryEvent(event) {
|
|
13
|
+
return {
|
|
14
|
+
...event,
|
|
15
|
+
event_id: crypto.randomUUID(),
|
|
16
|
+
cms_edit_version: CMS_EDIT_VERSION,
|
|
17
|
+
mode: getTelemetryMode(),
|
|
18
|
+
project_key: event.project_key ?? getTelemetryProjectKey(),
|
|
19
|
+
node_version: process.version,
|
|
20
|
+
platform: process.platform,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=enrich.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrich.js","sourceRoot":"","sources":["../../src/telemetry/enrich.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,KAAK,GAAG,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,eAAe,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,GAAG,IAAI,SAAS,CAAC;AAC1B,CAAC;AASD,MAAM,UAAU,oBAAoB,CAAC,KAA0B;IAC7D,OAAO;QACL,GAAG,KAAK;QACR,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE;QAC7B,gBAAgB,EAAE,gBAAgB;QAClC,IAAI,EAAE,gBAAgB,EAAE;QACxB,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,sBAAsB,EAAE;QAC1D,YAAY,EAAE,OAAO,CAAC,OAAO;QAC7B,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TelemetryWriter } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the default telemetry writer for this environment.
|
|
4
|
+
* Opt in with CMS_EDIT_TELEMETRY=1; opt out with CMS_EDIT_TELEMETRY=0.
|
|
5
|
+
* Hosted (Vercel): Axiom only when configured. Local: file log.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTelemetryWriter(): TelemetryWriter;
|
|
8
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/telemetry/factory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAgBlD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CA4BvD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AxiomTelemetryWriter } from './axiom.js';
|
|
2
|
+
import { CompositeTelemetryWriter } from './composite.js';
|
|
3
|
+
import { isHostedMcpMode } from './enrich.js';
|
|
4
|
+
import { LocalFileTelemetryWriter } from './local.js';
|
|
5
|
+
import { NoOpTelemetryWriter } from './noop.js';
|
|
6
|
+
function isTelemetryExplicitlyDisabled() {
|
|
7
|
+
const value = process.env['CMS_EDIT_TELEMETRY'];
|
|
8
|
+
return value === '0' || value === 'false';
|
|
9
|
+
}
|
|
10
|
+
function isTelemetryExplicitlyEnabled() {
|
|
11
|
+
const value = process.env['CMS_EDIT_TELEMETRY'];
|
|
12
|
+
return value === '1' || value === 'true';
|
|
13
|
+
}
|
|
14
|
+
function hasAxiomConfig() {
|
|
15
|
+
return Boolean(process.env['AXIOM_TOKEN']?.trim() && process.env['AXIOM_DATASET']?.trim());
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the default telemetry writer for this environment.
|
|
19
|
+
* Opt in with CMS_EDIT_TELEMETRY=1; opt out with CMS_EDIT_TELEMETRY=0.
|
|
20
|
+
* Hosted (Vercel): Axiom only when configured. Local: file log.
|
|
21
|
+
*/
|
|
22
|
+
export function createTelemetryWriter() {
|
|
23
|
+
if (isTelemetryExplicitlyDisabled()) {
|
|
24
|
+
return new NoOpTelemetryWriter();
|
|
25
|
+
}
|
|
26
|
+
if (!isTelemetryExplicitlyEnabled()) {
|
|
27
|
+
return new NoOpTelemetryWriter();
|
|
28
|
+
}
|
|
29
|
+
const writers = [];
|
|
30
|
+
if (!isHostedMcpMode()) {
|
|
31
|
+
writers.push(new LocalFileTelemetryWriter());
|
|
32
|
+
}
|
|
33
|
+
if (hasAxiomConfig()) {
|
|
34
|
+
writers.push(new AxiomTelemetryWriter());
|
|
35
|
+
}
|
|
36
|
+
if (writers.length === 0) {
|
|
37
|
+
return new NoOpTelemetryWriter();
|
|
38
|
+
}
|
|
39
|
+
if (writers.length === 1) {
|
|
40
|
+
return writers[0];
|
|
41
|
+
}
|
|
42
|
+
return new CompositeTelemetryWriter(writers);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/telemetry/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGhD,SAAS,6BAA6B;IACpC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAChD,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,OAAO,CAAC;AAC5C,CAAC;AAED,SAAS,4BAA4B;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAChD,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7F,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,6BAA6B,EAAE,EAAE,CAAC;QACpC,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,4BAA4B,EAAE,EAAE,CAAC;QACpC,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,cAAc,EAAE,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export { AxiomTelemetryWriter } from './axiom.js';
|
|
2
|
+
export { CompositeTelemetryWriter } from './composite.js';
|
|
3
|
+
export { enrichTelemetryEvent, getTelemetryMode, isHostedMcpMode } from './enrich.js';
|
|
4
|
+
export { createTelemetryWriter } from './factory.js';
|
|
2
5
|
export { LocalFileTelemetryWriter } from './local.js';
|
|
6
|
+
export { NoOpTelemetryWriter } from './noop.js';
|
|
7
|
+
export { beginTelemetryCommand, flushTelemetry, getTelemetryWriter, recordOAuthTelemetryFailure, recordTelemetryOutcome, resetTelemetryStateForTests, } from './record.js';
|
|
3
8
|
export type { TelemetryEvent, TelemetryWriter } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Returns the default telemetry writer for this environment.
|
|
6
|
-
* Currently always returns a LocalFileTelemetryWriter.
|
|
7
|
-
* Swap this factory to switch to a remote sink in the future.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createTelemetryWriter(): TelemetryWriter;
|
|
10
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
export { AxiomTelemetryWriter } from './axiom.js';
|
|
2
|
+
export { CompositeTelemetryWriter } from './composite.js';
|
|
3
|
+
export { enrichTelemetryEvent, getTelemetryMode, isHostedMcpMode } from './enrich.js';
|
|
4
|
+
export { createTelemetryWriter } from './factory.js';
|
|
2
5
|
export { LocalFileTelemetryWriter } from './local.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Currently always returns a LocalFileTelemetryWriter.
|
|
6
|
-
* Swap this factory to switch to a remote sink in the future.
|
|
7
|
-
*/
|
|
8
|
-
export function createTelemetryWriter() {
|
|
9
|
-
return new LocalFileTelemetryWriter();
|
|
10
|
-
}
|
|
6
|
+
export { NoOpTelemetryWriter } from './noop.js';
|
|
7
|
+
export { beginTelemetryCommand, flushTelemetry, getTelemetryWriter, recordOAuthTelemetryFailure, recordTelemetryOutcome, resetTelemetryStateForTests, } from './record.js';
|
|
11
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TelemetryEvent, TelemetryWriter } from './types.js';
|
|
2
|
+
/** Discards events when telemetry is disabled. */
|
|
3
|
+
export declare class NoOpTelemetryWriter implements TelemetryWriter {
|
|
4
|
+
record(_event: TelemetryEvent): void;
|
|
5
|
+
flush(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/telemetry/noop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,kDAAkD;AAClD,qBAAa,mBAAoB,YAAW,eAAe;IACzD,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAE9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/telemetry/noop.ts"],"names":[],"mappings":"AAEA,kDAAkD;AAClD,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,MAAsB,IAAS,CAAC;IAEvC,KAAK,CAAC,KAAK,KAAmB,CAAC;CAChC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TelemetryWriter } from './types.js';
|
|
2
|
+
export declare function getTelemetryWriter(): TelemetryWriter;
|
|
3
|
+
/** @internal Test helper — resets module singleton state. */
|
|
4
|
+
export declare function resetTelemetryStateForTests(): void;
|
|
5
|
+
export declare function beginTelemetryCommand(cmd: string, sub?: string): void;
|
|
6
|
+
export declare function recordTelemetryOutcome(outcome: 'success' | 'error' | 'exit', opts?: {
|
|
7
|
+
exitCode?: number;
|
|
8
|
+
errorName?: string;
|
|
9
|
+
}): void;
|
|
10
|
+
export declare function recordOAuthTelemetryFailure(route: string, reason: string): void;
|
|
11
|
+
export declare function flushTelemetry(): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/telemetry/record.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AASlD,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD;AAED,6DAA6D;AAC7D,wBAAgB,2BAA2B,IAAI,IAAI,CAMlD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAKrE;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,EACrC,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GACnD,IAAI,CAeN;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAW/E;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { enrichTelemetryEvent } from './enrich.js';
|
|
2
|
+
import { createTelemetryWriter } from './factory.js';
|
|
3
|
+
let writerInstance;
|
|
4
|
+
let command;
|
|
5
|
+
let subcommand;
|
|
6
|
+
let startMs;
|
|
7
|
+
let recorded = false;
|
|
8
|
+
export function getTelemetryWriter() {
|
|
9
|
+
if (!writerInstance) {
|
|
10
|
+
writerInstance = createTelemetryWriter();
|
|
11
|
+
}
|
|
12
|
+
return writerInstance;
|
|
13
|
+
}
|
|
14
|
+
/** @internal Test helper — resets module singleton state. */
|
|
15
|
+
export function resetTelemetryStateForTests() {
|
|
16
|
+
writerInstance = undefined;
|
|
17
|
+
command = undefined;
|
|
18
|
+
subcommand = undefined;
|
|
19
|
+
startMs = undefined;
|
|
20
|
+
recorded = false;
|
|
21
|
+
}
|
|
22
|
+
export function beginTelemetryCommand(cmd, sub) {
|
|
23
|
+
command = cmd;
|
|
24
|
+
subcommand = sub;
|
|
25
|
+
startMs = Date.now();
|
|
26
|
+
recorded = false;
|
|
27
|
+
}
|
|
28
|
+
export function recordTelemetryOutcome(outcome, opts = {}) {
|
|
29
|
+
if (recorded || !command)
|
|
30
|
+
return;
|
|
31
|
+
recorded = true;
|
|
32
|
+
getTelemetryWriter().record(enrichTelemetryEvent({
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
command,
|
|
35
|
+
subcommand,
|
|
36
|
+
outcome,
|
|
37
|
+
exit_code: opts.exitCode,
|
|
38
|
+
error_name: opts.errorName,
|
|
39
|
+
duration_ms: startMs !== undefined ? Date.now() - startMs : 0,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
export function recordOAuthTelemetryFailure(route, reason) {
|
|
43
|
+
getTelemetryWriter().record(enrichTelemetryEvent({
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
command: 'oauth',
|
|
46
|
+
subcommand: route,
|
|
47
|
+
outcome: 'error',
|
|
48
|
+
error_name: reason,
|
|
49
|
+
duration_ms: 0,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
export async function flushTelemetry() {
|
|
53
|
+
await getTelemetryWriter().flush?.();
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/telemetry/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,IAAI,cAA2C,CAAC;AAEhD,IAAI,OAA2B,CAAC;AAChC,IAAI,UAA8B,CAAC;AACnC,IAAI,OAA2B,CAAC;AAChC,IAAI,QAAQ,GAAG,KAAK,CAAC;AAErB,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,qBAAqB,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,2BAA2B;IACzC,cAAc,GAAG,SAAS,CAAC;IAC3B,OAAO,GAAG,SAAS,CAAC;IACpB,UAAU,GAAG,SAAS,CAAC;IACvB,OAAO,GAAG,SAAS,CAAC;IACpB,QAAQ,GAAG,KAAK,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAE,GAAY;IAC7D,OAAO,GAAG,GAAG,CAAC;IACd,UAAU,GAAG,GAAG,CAAC;IACjB,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACrB,QAAQ,GAAG,KAAK,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAqC,EACrC,OAAkD,EAAE;IAEpD,IAAI,QAAQ,IAAI,CAAC,OAAO;QAAE,OAAO;IACjC,QAAQ,GAAG,IAAI,CAAC;IAEhB,kBAAkB,EAAE,CAAC,MAAM,CACzB,oBAAoB,CAAC;QACnB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO;QACP,UAAU;QACV,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,QAAQ;QACxB,UAAU,EAAE,IAAI,CAAC,SAAS;QAC1B,WAAW,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KAC9D,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAAa,EAAE,MAAc;IACvE,kBAAkB,EAAE,CAAC,MAAM,CACzB,oBAAoB,CAAC;QACnB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,MAAM;QAClB,WAAW,EAAE,CAAC;KACf,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,MAAM,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
* No PII is stored: no slugs, entry IDs, field values, query text, or replacement strings.
|
|
4
4
|
*/
|
|
5
5
|
export interface TelemetryEvent {
|
|
6
|
+
/** Stable id for deduplication in downstream analytics. */
|
|
7
|
+
event_id: string;
|
|
6
8
|
/** ISO 8601 timestamp of when the command completed. */
|
|
7
9
|
timestamp: string;
|
|
8
|
-
/** Top-level command name (e.g. "rtf", "open", "save"). */
|
|
10
|
+
/** Top-level command name (e.g. "rtf", "open", "save", "oauth"). */
|
|
9
11
|
command: string;
|
|
10
|
-
/** Subcommand name when applicable (e.g. "replace", "embed", "
|
|
12
|
+
/** Subcommand name when applicable (e.g. "replace", "embed", "link-contentful"). */
|
|
11
13
|
subcommand?: string;
|
|
12
14
|
/** Whether the command succeeded, errored, or exited (process.exit called). */
|
|
13
15
|
outcome: 'success' | 'error' | 'exit';
|
|
14
16
|
/** Process exit code (populated for 'exit' outcome). */
|
|
15
17
|
exit_code?: number;
|
|
16
|
-
/** Error constructor name
|
|
18
|
+
/** Error constructor name or stable reason code — NOT the message, to avoid logging PII. */
|
|
17
19
|
error_name?: string;
|
|
18
20
|
/** Wall-clock duration from command start to completion in milliseconds. */
|
|
19
21
|
duration_ms: number;
|
|
22
|
+
/** cms-edit package version. */
|
|
23
|
+
cms_edit_version: string;
|
|
24
|
+
/** Invocation context. */
|
|
25
|
+
mode: 'cli' | 'hosted-mcp';
|
|
26
|
+
/** Deployment aggregate key (CMS_EDIT_PROJECT_KEY); never user id or email. */
|
|
27
|
+
project_key?: string;
|
|
28
|
+
/** Node.js runtime version. */
|
|
29
|
+
node_version: string;
|
|
30
|
+
/** process.platform value. */
|
|
31
|
+
platform: string;
|
|
20
32
|
}
|
|
21
33
|
/**
|
|
22
34
|
* Abstraction for telemetry sinks. Swap out LocalFileTelemetryWriter for a remote
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACtC,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,0BAA0B;IAC1B,IAAI,EAAE,KAAK,GAAG,YAAY,CAAC;IAC3B,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
|
package/docs/FUNCTIONAL_SPEC.md
CHANGED
|
@@ -289,7 +289,12 @@ When `devBaseUrl` is configured, the tool can capture screenshots of components
|
|
|
289
289
|
|
|
290
290
|
## 13. Telemetry
|
|
291
291
|
|
|
292
|
-
The tool emits telemetry events recording the command name, outcome (success
|
|
292
|
+
Opt in with `CMS_EDIT_TELEMETRY=1` (opt out with `0`). The tool emits telemetry events recording the command name, outcome (`success`, `error`, or `exit`), duration, package version, and deployment `project_key`. No user ids, emails, slugs, field values, entry IDs, query text, or error messages are included.
|
|
293
|
+
|
|
294
|
+
- **Local CLI:** newline-delimited JSON at `~/.contentful-cms/telemetry.log`
|
|
295
|
+
- **Hosted (Vercel):** batched ingest to Axiom when `AXIOM_TOKEN` and `AXIOM_DATASET` are set
|
|
296
|
+
|
|
297
|
+
See [TELEMETRY_AXIOM.md](./TELEMETRY_AXIOM.md) for env vars, schema, and example queries.
|
|
293
298
|
|
|
294
299
|
---
|
|
295
300
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# cms-edit telemetry (Axiom)
|
|
2
|
+
|
|
3
|
+
Hosted cms-edit deployments can emit aggregate usage telemetry to [Axiom](https://axiom.co). Events contain command names, outcomes, and durations only — no user ids, emails, slugs, entry ids, or error messages.
|
|
4
|
+
|
|
5
|
+
## Enable on Vercel
|
|
6
|
+
|
|
7
|
+
Set on each cms-edit host project (`se-website-2026-cms-edit-host`, `pedestal-cms-edit`, `headwater-cms-edit`, dev `cms-edit-host`):
|
|
8
|
+
|
|
9
|
+
| Variable | Value |
|
|
10
|
+
|----------|-------|
|
|
11
|
+
| `CMS_EDIT_TELEMETRY` | `1` |
|
|
12
|
+
| `AXIOM_TOKEN` | Axiom ingest token (sensitive) |
|
|
13
|
+
| `AXIOM_DATASET` | `cms-edit` |
|
|
14
|
+
| `AXIOM_DOMAIN` | Optional; default `api.axiom.co` |
|
|
15
|
+
| `CMS_EDIT_PROJECT_KEY` | Already required — used as `project_key` for aggregation |
|
|
16
|
+
|
|
17
|
+
Opt out: `CMS_EDIT_TELEMETRY=0`.
|
|
18
|
+
|
|
19
|
+
## Event schema
|
|
20
|
+
|
|
21
|
+
Each event is one JSON object:
|
|
22
|
+
|
|
23
|
+
| Field | Description |
|
|
24
|
+
|-------|-------------|
|
|
25
|
+
| `event_id` | UUID for deduplication |
|
|
26
|
+
| `timestamp` | ISO 8601 completion time |
|
|
27
|
+
| `command` | e.g. `open`, `save`, `oauth` |
|
|
28
|
+
| `subcommand` | Optional, e.g. `replace`, `link-contentful` |
|
|
29
|
+
| `outcome` | `success`, `error`, or `exit` |
|
|
30
|
+
| `exit_code` | When `outcome` is `exit` |
|
|
31
|
+
| `error_name` | Error class or stable reason code (never message text) |
|
|
32
|
+
| `duration_ms` | Wall-clock duration |
|
|
33
|
+
| `cms_edit_version` | Package version |
|
|
34
|
+
| `mode` | `hosted-mcp` on Vercel, `cli` locally |
|
|
35
|
+
| `project_key` | From `CMS_EDIT_PROJECT_KEY` |
|
|
36
|
+
| `node_version` | Node runtime |
|
|
37
|
+
| `platform` | `process.platform` |
|
|
38
|
+
|
|
39
|
+
OAuth connect failures emit `command: oauth`, `subcommand: link-contentful`, `error_name` set to a stable reason (`invalid_contentful_token`, `space_access_denied`, etc.).
|
|
40
|
+
|
|
41
|
+
## Local development
|
|
42
|
+
|
|
43
|
+
With `CMS_EDIT_TELEMETRY=1` and no Axiom env vars, events append to `~/.contentful-cms/telemetry.log` as NDJSON.
|
|
44
|
+
|
|
45
|
+
## Example Axiom queries
|
|
46
|
+
|
|
47
|
+
**Commands per project (last 24h):**
|
|
48
|
+
|
|
49
|
+
```apl
|
|
50
|
+
['cms-edit']
|
|
51
|
+
| where _time > ago(24h)
|
|
52
|
+
| summarize count() by project_key, command, outcome
|
|
53
|
+
| order by count_ desc
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**OAuth failures by reason:**
|
|
57
|
+
|
|
58
|
+
```apl
|
|
59
|
+
['cms-edit']
|
|
60
|
+
| where command == "oauth" and outcome == "error"
|
|
61
|
+
| summarize count() by project_key, error_name
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**p95 duration by command:**
|
|
65
|
+
|
|
66
|
+
```apl
|
|
67
|
+
['cms-edit']
|
|
68
|
+
| where outcome == "success"
|
|
69
|
+
| summarize percentile(duration_ms, 95) by project_key, command
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Flow
|
|
73
|
+
|
|
74
|
+
MCP request → `runCmsEditArgs` → Commander hooks record outcome → `flush()` POSTs buffered events before the HTTP response returns. OAuth `link-contentful` failures record and flush in the route handler.
|
package/docs/mcp/hosted-guide.md
CHANGED
|
@@ -177,7 +177,7 @@ Asset search and media-by-filename list **require** the index. Template/taxonomy
|
|
|
177
177
|
|
|
178
178
|
| Problem | What to do |
|
|
179
179
|
|---------|------------|
|
|
180
|
-
| **401 / connection failed** | Claude → Settings → Integrations → Connect again; complete Contentful sign-in |
|
|
180
|
+
| **401 / connection failed** | Claude → Settings → Integrations → Connect again; complete Contentful sign-in. On Vercel, search runtime logs for `[cms-edit:oauth] auth_failure` (always logged). Set `LOG_CMS_OAUTH=1` for connect success traces. |
|
|
181
181
|
| **No cms_edit tool** | Confirm the integration is connected under Settings → Integrations |
|
|
182
182
|
| **No active session** | Do not pass `--space` on hosted. Check `/api/health` — `redis` must be ok. MCP uses `_mcp` session automatically. Manual session: `["--session", "name", "open", "--page-slug", "/"]`. Fallback: `["read", "<entry-id>", "--id"]` |
|
|
183
183
|
| **Wrong space** | Your Contentful account must have access to this deployment's space |
|