:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(logs): rename the pattern body kind invalid_json to plaintext (#88637)
Jon McCalluma708620113dd
diff --git a/nodejs/src/logs/log-pattern-mask.test.ts b/nodejs/src/logs/log-pattern-mask.test.tsindex beeaa8f38db4..b722d000b149 100644--- a/nodejs/src/logs/log-pattern-mask.test.ts+++ b/nodejs/src/logs/log-pattern-mask.test.ts@@ -68,7 +68,7 @@ describe('log-pattern-mask', () => {const body = JSON.stringify({ message: 'x'.repeat(100) })const result = computeLogPattern(body, 20, NO_CAP)expect(result.inputCapped).toEqual(true)- expect(result.bodyKind).toEqual('invalid_json')+ expect(result.bodyKind).toEqual('plaintext')expect(result.pattern).toEqual(body.slice(0, 20))})@@ -88,7 +88,7 @@ describe('log-pattern-mask', () => {['json array', '[1,2]', 'json_object_or_array', JSON_ARRAY],['json string', '"quoted 7"', 'json_string', 'quoted <N>'],['json number primitive', '42', 'primitive', '<N>'],- ['prose body', 'plain text 3', 'invalid_json', 'plain text <N>'],+ ['prose body', 'plain text 3', 'plaintext', 'plain text <N>'],])('body kind %s', (_name, body, expectedKind, expectedPattern) => {const result = computeLogPattern(body, NO_CAP, NO_CAP)expect(result.bodyKind).toEqual(expectedKind)diff --git a/nodejs/src/logs/log-pattern-mask.ts b/nodejs/src/logs/log-pattern-mask.tsindex 8571a068c2e3..967115cf1fd5 100644--- a/nodejs/src/logs/log-pattern-mask.ts+++ b/nodejs/src/logs/log-pattern-mask.ts@@ -59,7 +59,7 @@ export function maskString(input: string): MaskResult {return { masked, ruleFires }}-export type PatternBodyKind = 'empty' | 'invalid_json' | 'json_object_or_array' | 'json_string' | 'primitive'+export type PatternBodyKind = 'empty' | 'plaintext' | 'json_object_or_array' | 'json_string' | 'primitive'export type LogPatternResult = {pattern: string@@ -104,7 +104,8 @@ export function computeLogPattern(const inputCapped = body.length > maxInputCharsconst cappedBody = inputCapped ? body.slice(0, maxInputChars) : bodyconst parsed = parseLogBodyForIngestion(cappedBody)- const bodyKind: PatternBodyKind = parsed.kind === 'json_primitive' ? 'primitive' : parsed.kind+ const bodyKind: PatternBodyKind =+ parsed.kind === 'json_primitive' ? 'primitive' : parsed.kind === 'invalid_json' ? 'plaintext' : parsed.kindlet maskInput: stringswitch (parsed.kind) {diff --git a/nodejs/src/logs/log-pattern-stage.test.ts b/nodejs/src/logs/log-pattern-stage.test.tsindex c81ff79b306c..93694d59bdd7 100644--- a/nodejs/src/logs/log-pattern-stage.test.ts+++ b/nodejs/src/logs/log-pattern-stage.test.ts@@ -55,7 +55,7 @@ describe('log-pattern-stage', () => {expect(records.map((r) => r.body)).toEqual(bodiesBefore)expect(await counterValues(logsPatternBodyKindCounter)).toEqual({empty: 1,- invalid_json: 2,+ plaintext: 2,json_object_or_array: 1,})expect(await counterValues(logsPatternRuleFiredCounter)).toEqual({ num: 1 })