Skip to content

: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.

feat(error-tracking): add context and stack trace to alert tickets (#119423)

James Gill142e2ddb7298
diff --git a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts
index 6f757fc79245..d40a56e6195c 100644
--- a/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts
+++ b/frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts
@@ -20,6 +20,44 @@ import {
export const errorTrackingIssueLinkHogTemplate = (medium: string): string =>
`{project.url}/error-tracking/fingerprint/{replaceAll(replaceAll(encodeURLComponent(event.properties.fingerprint), '(', '%28'), ')', '%29')}?timestamp={event.properties.exception_timestamp}&utm_source=alert&utm_campaign=error_tracking_alert&utm_medium=${medium}`
+const errorTrackingTicketCode = (value: string): string =>
+ `concat('\`', replaceAll(replaceAll(replaceAll(${value}, '\`', '\\''), '\\n', ' '), '\\r', ' '), '\`')`
+
+const errorTrackingTicketLine = (
+ label: string,
+ value: string,
+ condition = `notEmpty(${value})`,
+ formatted = errorTrackingTicketCode(value)
+): string => `{${condition} ? concat('\\n- ${label}: ', ${formatted}) : ''}`
+
+const errorTrackingTicketMessage = (message: string): string =>
+ `{notEmpty(${message}) ? concat('\`\`\`\\n', replaceAll(${message}, '\`', '\\''), '\\n\`\`\`') : ''}\n`
+const ERROR_TRACKING_SESSION_REPLAY_URL =
+ "concat(project.url, '/replay/', encodeURLComponent(event.properties.$session_id))"
+
+// Same shape as the Linear, GitHub and GitLab template defaults in nodejs/src/cdp/templates/error-tracking-ticket.ts,
+// but built from the issue name and description. When the event is too large for Kafka, the producer drops
+// exception_props (products/error_tracking/backend/temporal/lifecycle/side_effects.py), so $exception_types
+// and $exception_values are missing. The name and description still arrive, so the title still renders.
+const ERROR_TRACKING_TICKET_TITLE =
+ "{substring(replaceAll(notEmpty(event.properties.description) ? concat(event.properties.name, ': ', event.properties.description) : event.properties.name, '\\n', ' '), 1, 120)}"
+
+const ERROR_TRACKING_TICKET_DESCRIPTION = [
+ errorTrackingTicketMessage('event.properties.description'),
+ errorTrackingTicketLine(
+ 'Browser',
+ "trim(concat(event.properties.$browser, ' ', event.properties.$browser_version))"
+ ),
+ errorTrackingTicketLine('OS', "trim(concat(event.properties.$os, ' ', event.properties.$os_version))"),
+ errorTrackingTicketLine('Release', 'event.properties.$exception_release.version'),
+ errorTrackingTicketLine(
+ 'Session replay',
+ ERROR_TRACKING_SESSION_REPLAY_URL,
+ "notEmpty(event.properties.$session_id) and (empty(event.properties.$recording_status) or has(['active', 'sampled', 'buffering'], event.properties.$recording_status))",
+ ERROR_TRACKING_SESSION_REPLAY_URL
+ ),
+].join('')
+
// PagerDuty has no high, medium or low severity, so the issue severity maps onto its scale.
// The template sends error for an issue without a severity.
const ERROR_TRACKING_PAGERDUTY_SEVERITY =
@@ -1221,10 +1259,10 @@ export const HOG_FUNCTION_SUB_TEMPLATES: Record<HogFunctionSubTemplateIdType, Ho
description: 'Create an issue in Linear when an issue is created.',
inputs: {
title: {
- value: '{event.properties.name}',
+ value: ERROR_TRACKING_TICKET_TITLE,
},
description: {
- value: '{event.properties.description}',
+ value: ERROR_TRACKING_TICKET_DESCRIPTION,
},
posthog_issue_id: {
value: '{event.distinct_id}',
@@ -1241,10 +1279,10 @@ export const HOG_FUNCTION_SUB_TEMPLATES: Record<HogFunctionSubTemplateIdType, Ho
description: 'Create an issue in GitHub when an issue is created.',
inputs: {
title: {
- value: '{event.properties.name}',
+ value: ERROR_TRACKING_TICKET_TITLE,
},
description: {
- value: '{event.properties.description}',
+ value: ERROR_TRACKING_TICKET_DESCRIPTION,
},
posthog_issue_id: {
value: '{event.distinct_id}',
@@ -1261,10 +1299,10 @@ export const HOG_FUNCTION_SUB_TEMPLATES: Record<HogFunctionSubTemplateIdType, Ho
description: 'Create an issue in GitLab when an issue is created.',
inputs: {
title: {
- value: '{event.properties.name}',
+ value: ERROR_TRACKING_TICKET_TITLE,
},
description: {
- value: '{event.properties.description}',
+ value: ERROR_TRACKING_TICKET_DESCRIPTION,
},
posthog_issue_id: {
value: '{event.distinct_id}',
diff --git a/nodejs/src/cdp/templates/_destinations/github/github.template.test.ts b/nodejs/src/cdp/templates/_destinations/github/github.template.test.ts
index 40c385866233..8435fc59abb9 100644
--- a/nodejs/src/cdp/templates/_destinations/github/github.template.test.ts
+++ b/nodejs/src/cdp/templates/_destinations/github/github.template.test.ts
@@ -36,4 +36,154 @@ describe('github template', () => {
expect(body.body).toContain(`[View in PostHog](`)
expect(body.body).toContain(expectedLinkPart)
})
+
+ const appFrame = (name: string): Record<string, any> => ({
+ source: `src/${name}.ts`,
+ line: 1,
+ resolved_name: name,
+ resolved: true,
+ in_app: true,
+ })
+ const minifiedFrame = { source: 'main.3f9a.js', line: 1, mangled_name: 't.e', resolved: false, in_app: true }
+
+ it.each<[string, Record<string, any>, string, string]>([
+ [
+ 'adds the context lines and the resolved in-app frames, crash site first, with no secrets',
+ {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid Date\nvalue: `abc` @octocat [link](https://evil.example)'],
+ $exception_list: [
+ {
+ stacktrace: {
+ frames: [
+ {
+ source: 'node_modules/react-dom.js',
+ line: 10,
+ resolved_name: 'commit',
+ resolved: true,
+ in_app: false,
+ },
+ {
+ source: 'https://user:[email protected]',
+ line: 2,
+ resolved_name: '[email protected]',
+ resolved: true,
+ in_app: true,
+ },
+ {
+ source: 'https://example.com/reset-password/3f2b8c1e-9d4a-4e7b-8a6c-0d1e2f3a4b5c',
+ line: 1,
+ column: 20,
+ resolved_name: 'onSubmit',
+ resolved: true,
+ in_app: true,
+ },
+ {
+ source: '/home/bob/app.py',
+ line: 7,
+ resolved_name: 'handler_EXAMPLE0123456789',
+ resolved: true,
+ in_app: true,
+ },
+ {
+ source: '/Users/alice/projects/shop/src/resetPasswordToken_ABCDEF0123456789abcdef0123456789.ts',
+ line: 3,
+ resolved_name: 'handleCheckoutSubmitButtonClickEvent',
+ resolved: true,
+ in_app: true,
+ code_variables: { password: 'hunter2' },
+ context: { line: { number: 3, line: 'const apiKey = "sk_live_example"' } },
+ },
+ minifiedFrame,
+ {
+ source: 'https://app.example.com/static/js/src/checkout.ts?token=secret#frag',
+ line: 42,
+ resolved_name: 'parse`Date`',
+ resolved: true,
+ in_app: true,
+ },
+ ],
+ },
+ },
+ ],
+ $current_url: 'https://example.com/reset?token=secret#access_token=abc',
+ $browser: 'Chrome',
+ $browser_version: 129,
+ $os: 'Mac OS X',
+ $os_version: '10.15.7\n\n[link](https://evil.example)',
+ $exception_release: { version: '1.4.2' },
+ $session_id: 'session/1',
+ $recording_status: 'active',
+ },
+ 'RangeError: Invalid Date value: `abc` @octocat [link](https://evil.example)',
+ '```\nInvalid Date\nvalue: \'abc\' @octocat [link](https://evil.example)\n```\n\n- Browser: `Chrome 129`\n- OS: `Mac OS X 10.15.7 [link](https://evil.example)`\n- Release: `1.4.2`\n- Session replay: https://us.posthog.com/projects/1/replay/session%2F1\n\n```\n File "checkout.ts", line: 42, in: [redacted]\n File "[redacted]", line: 3, in: handleCheckoutSubmitButtonClickEvent\n File "app.py", line: 7, in: [redacted]\n File "[redacted]", line: 1, in: onSubmit\n File "[redacted]", line: 2, in: [redacted]\n```',
+ ],
+ [
+ 'leaves out missing lines, replay when recording was off, and a trace with no resolved frame',
+ {
+ $exception_types: ['RangeError'],
+ $exception_values: [''],
+ $exception_list: [{ stacktrace: { frames: [minifiedFrame] } }],
+ $browser: 'Chrome',
+ $session_id: 'session-1',
+ $recording_status: 'disabled',
+ },
+ 'RangeError',
+ '\n\n- Browser: `Chrome`',
+ ],
+ [
+ 'shows at most 5 frames',
+ {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid Date'],
+ $exception_list: [{ stacktrace: { frames: ['a', 'b', 'c', 'd', 'e', 'f', 'g'].map(appFrame) } }],
+ },
+ 'RangeError: Invalid Date',
+ '```\nInvalid Date\n```\n\n\n```\n File "g.ts", line: 1, in: g\n File "f.ts", line: 1, in: f\n File "e.ts", line: 1, in: e\n File "d.ts", line: 1, in: d\n File "c.ts", line: 1, in: c\n```',
+ ],
+ [
+ 'reads only the last 50 frames of a deep stack',
+ {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid Date'],
+ $exception_list: [{ stacktrace: { frames: [appFrame('a'), ...Array(50).fill(minifiedFrame)] } }],
+ },
+ 'RangeError: Invalid Date',
+ '```\nInvalid Date\n```\n',
+ ],
+ [
+ 'leaves out the trace of a stack over 2000 frames',
+ {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid Date'],
+ $exception_list: [{ stacktrace: { frames: [...Array(2000).fill(minifiedFrame), appFrame('a')] } }],
+ },
+ 'RangeError: Invalid Date',
+ '```\nInvalid Date\n```\n',
+ ],
+ ])('%s', async (_name, properties, expectedTitle, expectedDescription) => {
+ const { title: _title, description: _description, ...inputs } = baseInputs
+ const response = await tester.invoke(inputs, { event: { properties } })
+
+ expect(response.error).toBeUndefined()
+ const body = parseJSON((response.invocation.queueParameters as any).body)
+ expect(body.title).toEqual(expectedTitle)
+ for (const secret of [
+ 'token=',
+ 'access_token',
+ 'alice',
+ 'bob',
+ 'EXAMPLE0123',
+ 'hunter2',
+ 'sk_live',
+ 'password@',
+ '3f2b8c1e',
+ 'ABCDEF0123',
+ ]) {
+ expect(JSON.stringify(body)).not.toContain(secret)
+ }
+ expect(body.body).toEqual(
+ `${expectedDescription}\n\n[View in PostHog](https://us.posthog.com/projects/1/error-tracking/issue-uuid)`
+ )
+ })
})
diff --git a/nodejs/src/cdp/templates/_destinations/github/github.template.ts b/nodejs/src/cdp/templates/_destinations/github/github.template.ts
index b4468e1915d3..06625e27b373 100644
--- a/nodejs/src/cdp/templates/_destinations/github/github.template.ts
+++ b/nodejs/src/cdp/templates/_destinations/github/github.template.ts
@@ -1,5 +1,8 @@
import { HogFunctionTemplate } from '~/cdp/types'
+import { ERROR_TRACKING_TICKET_DESCRIPTION, ERROR_TRACKING_TICKET_TITLE } from '../../error-tracking-ticket'
+import { hogErrorTrackingStacktraceFn } from '../../hog-helpers'
+
export const template: HogFunctionTemplate = {
status: 'stable',
free: false,
@@ -10,7 +13,9 @@ export const template: HogFunctionTemplate = {
icon_url: '/static/services/github.png',
category: ['Error tracking'],
code_language: 'hog',
- code: `let owner := inputs.github_installation.account.name
+ code: `${hogErrorTrackingStacktraceFn}
+
+let owner := inputs.github_installation.account.name
let repo := inputs.repository
if (not owner) {
@@ -35,7 +40,7 @@ let payload := {
},
'body': {
'title': inputs.title,
- 'body': f'{inputs.description}\n\n[View in PostHog]({posthog_issue_url})'
+ 'body': f'{inputs.description}{errorTrackingStacktrace(event.properties.$exception_list)}\n\n[View in PostHog]({posthog_issue_url})'
}
}
@@ -70,7 +75,7 @@ if (res.status < 200 or res.status >= 300) {
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_types[1]}',
+ default: ERROR_TRACKING_TICKET_TITLE,
},
{
key: 'description',
@@ -79,7 +84,7 @@ if (res.status < 200 or res.status >= 300) {
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_values[1]}',
+ default: ERROR_TRACKING_TICKET_DESCRIPTION,
},
{
key: 'posthog_issue_id',
diff --git a/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.test.ts b/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.test.ts
new file mode 100644
index 000000000000..0f23d592e00a
--- /dev/null
+++ b/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.test.ts
@@ -0,0 +1,50 @@
+import { parseJSON } from '../../../../common/utils/json-parse'
+import { TemplateTester } from '../../test/test-helpers'
+import { template } from './gitlab.template'
+
+describe('gitlab template', () => {
+ const tester = new TemplateTester(template)
+
+ beforeEach(async () => {
+ await tester.beforeEach()
+ })
+
+ it('puts the title in a code span and adds the stack trace and the PostHog link after the description', async () => {
+ const response = await tester.invoke(
+ {
+ gitlab_project: { access_token: 'token', hostname: 'https://gitlab.com', project_id: 1 },
+ posthog_issue_id: 'issue-uuid',
+ },
+ {
+ event: {
+ properties: {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid `Date` @admin https://example.com'],
+ $exception_list: [
+ {
+ stacktrace: {
+ frames: [
+ {
+ source: 'src/checkout.ts',
+ line: 42,
+ resolved_name: 'parseDate',
+ resolved: true,
+ in_app: true,
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ }
+ )
+
+ expect(response.error).toBeUndefined()
+ const body = parseJSON((response.invocation.queueParameters as any).body)
+ expect(body.title).toEqual("`RangeError: Invalid 'Date' @admin https://example.com`")
+ expect(body.description).toEqual(
+ '```\nInvalid \'Date\' @admin https://example.com\n```\n\n\n```\n File "checkout.ts", line: 42, in: parseDate\n```\n\n[View in PostHog](https://us.posthog.com/projects/1/error-tracking/issue-uuid)'
+ )
+ })
+})
diff --git a/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.ts b/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.ts
index 1257373608ba..7201bfe7f1a0 100644
--- a/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.ts
+++ b/nodejs/src/cdp/templates/_destinations/gitlab/gitlab.template.ts
@@ -1,5 +1,8 @@
import { HogFunctionTemplate } from '~/cdp/types'
+import { ERROR_TRACKING_TICKET_DESCRIPTION, ERROR_TRACKING_TICKET_TITLE } from '../../error-tracking-ticket'
+import { hogErrorTrackingStacktraceFn } from '../../hog-helpers'
+
export const template: HogFunctionTemplate = {
status: 'stable',
free: false,
@@ -10,10 +13,15 @@ export const template: HogFunctionTemplate = {
icon_url: '/static/services/gitlab.png',
category: ['Error tracking'],
code_language: 'hog',
- code: `let posthog_issue_url := inputs.posthog_issue_url
+ code: `${hogErrorTrackingStacktraceFn}
+
+let posthog_issue_url := inputs.posthog_issue_url
if (empty(posthog_issue_url)) {
posthog_issue_url := f'{project.url}/error-tracking/{inputs.posthog_issue_id}'
}
+// GitLab links @mentions and URLs in an issue title, and notifies each mentioned user. Client-sent text
+// in a code span stays plain text.
+let title := notEmpty(inputs.title) ? concat('\`', replaceAll(replaceAll(inputs.title, '\`', '\\''), '\\n', ' '), '\`') : inputs.title
let payload := {
'method': 'POST',
'headers': {
@@ -21,8 +29,8 @@ let payload := {
'Content-Type': 'application/json'
},
'body': {
- 'title': inputs.title,
- 'description': f'{inputs.description}\n\n[View in PostHog]({posthog_issue_url})'
+ 'title': title,
+ 'description': f'{inputs.description}{errorTrackingStacktrace(event.properties.$exception_list)}\n\n[View in PostHog]({posthog_issue_url})'
}
}
@@ -47,7 +55,7 @@ if (res.status < 200 or res.status >= 300) {
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_types[1]}',
+ default: ERROR_TRACKING_TICKET_TITLE,
},
{
key: 'description',
@@ -56,7 +64,7 @@ if (res.status < 200 or res.status >= 300) {
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_values[1]}',
+ default: ERROR_TRACKING_TICKET_DESCRIPTION,
},
{
key: 'posthog_issue_id',
diff --git a/nodejs/src/cdp/templates/_destinations/linear/linear.template.test.ts b/nodejs/src/cdp/templates/_destinations/linear/linear.template.test.ts
index 4a89870cdf49..0f5220679790 100644
--- a/nodejs/src/cdp/templates/_destinations/linear/linear.template.test.ts
+++ b/nodejs/src/cdp/templates/_destinations/linear/linear.template.test.ts
@@ -1,3 +1,4 @@
+import { parseJSON } from '../../../../common/utils/json-parse'
import { TemplateTester } from '../../test/test-helpers'
import { template } from './linear.template'
@@ -41,4 +42,41 @@ describe('linear template', () => {
expect(attachmentBody).toContain('attachmentCreate')
expect(attachmentBody).toContain(expectedLinkPart)
})
+
+ it('builds the title and description from the event properties, with the stack trace', async () => {
+ const { title: _title, description: _description, ...inputs } = baseInputs
+ const response = await tester.invoke(inputs, {
+ event: {
+ properties: {
+ $exception_types: ['RangeError'],
+ $exception_values: ['Invalid Date'],
+ $current_url: 'https://example.com/reset?token=secret',
+ $session_id: 'session-1',
+ $exception_list: [
+ {
+ stacktrace: {
+ frames: [
+ {
+ source: 'src/checkout.ts',
+ line: 42,
+ resolved_name: 'parseDate',
+ resolved: true,
+ in_app: true,
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ })
+
+ expect(response.error).toBeUndefined()
+ const mutation = parseJSON((response.invocation.queueParameters as any).body).query
+ expect(mutation).toContain('title: "RangeError: Invalid Date"')
+ expect(mutation).not.toContain('token=secret')
+ expect(mutation).toContain(
+ 'description: "```\\nInvalid Date\\n```\\n\\n- Session replay: https://us.posthog.com/projects/1/replay/session-1\\n\\n```\\n File \\"checkout.ts\\", line: 42, in: parseDate\\n```"'
+ )
+ })
})
diff --git a/nodejs/src/cdp/templates/_destinations/linear/linear.template.ts b/nodejs/src/cdp/templates/_destinations/linear/linear.template.ts
index 590b4ba0af66..4b352de1d92f 100644
--- a/nodejs/src/cdp/templates/_destinations/linear/linear.template.ts
+++ b/nodejs/src/cdp/templates/_destinations/linear/linear.template.ts
@@ -1,5 +1,8 @@
import { HogFunctionTemplate } from '~/cdp/types'
+import { ERROR_TRACKING_TICKET_DESCRIPTION, ERROR_TRACKING_TICKET_TITLE } from '../../error-tracking-ticket'
+import { hogErrorTrackingStacktraceFn } from '../../hog-helpers'
+
export const template: HogFunctionTemplate = {
status: 'stable',
free: false,
@@ -10,7 +13,9 @@ export const template: HogFunctionTemplate = {
icon_url: '/static/services/linear.png',
category: ['Error tracking'],
code_language: 'hog',
- code: `fun query(mutation) {
+ code: `${hogErrorTrackingStacktraceFn}
+
+fun query(mutation) {
return fetch('https://api.linear.app/graphql', {
'body': {
'query': mutation,
@@ -23,7 +28,9 @@ export const template: HogFunctionTemplate = {
})
}
-let issue_mutation := f'mutation IssueCreate \\{ issueCreate(input: \\{ title: {jsonStringify(inputs.title)} description: {jsonStringify(inputs.description)} teamId: "{inputs.team}" }) \\{ success issue \\{ identifier } } }';
+let description := concat(inputs.description, errorTrackingStacktrace(event.properties.$exception_list));
+
+let issue_mutation := f'mutation IssueCreate \\{ issueCreate(input: \\{ title: {jsonStringify(inputs.title)} description: {jsonStringify(description)} teamId: "{inputs.team}" }) \\{ success issue \\{ identifier } } }';
let issue_response := query(issue_mutation);
@@ -67,7 +74,7 @@ query(attachment_mutation);`,
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_types[1]}',
+ default: ERROR_TRACKING_TICKET_TITLE,
},
{
key: 'description',
@@ -76,7 +83,7 @@ query(attachment_mutation);`,
secret: false,
hidden: false,
required: true,
- default: '{event.properties.$exception_values[1]}',
+ default: ERROR_TRACKING_TICKET_DESCRIPTION,
},
{
key: 'posthog_issue_id',
diff --git a/nodejs/src/cdp/templates/error-tracking-ticket.ts b/nodejs/src/cdp/templates/error-tracking-ticket.ts
new file mode 100644
index 000000000000..440a00527038
--- /dev/null
+++ b/nodejs/src/cdp/templates/error-tracking-ticket.ts
@@ -0,0 +1,35 @@
+const EXCEPTION_TYPE = 'event.properties.$exception_types[1]'
+const EXCEPTION_MESSAGE = 'event.properties.$exception_values[1]'
+
+const ticketCode = (value: string): string =>
+ `concat('\`', replaceAll(replaceAll(replaceAll(${value}, '\`', '\\''), '\\n', ' '), '\\r', ' '), '\`')`
+
+const ticketLine = (
+ label: string,
+ value: string,
+ condition = `notEmpty(${value})`,
+ formatted = ticketCode(value)
+): string => `{${condition} ? concat('\\n- ${label}: ', ${formatted}) : ''}`
+
+const ticketMessage = (message: string): string =>
+ `{notEmpty(${message}) ? concat('\`\`\`\\n', replaceAll(${message}, '\`', '\\''), '\\n\`\`\`') : ''}\n`
+const SESSION_REPLAY_URL = "concat(project.url, '/replay/', encodeURLComponent(event.properties.$session_id))"
+
+// Keep in step with the tracker entries in frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts
+// and with products/error_tracking/skills/authoring-error-tracking-alerts/references/block-templates.md.
+export const ERROR_TRACKING_TICKET_TITLE = `{substring(replaceAll(notEmpty(${EXCEPTION_MESSAGE}) ? concat(${EXCEPTION_TYPE}, ': ', ${EXCEPTION_MESSAGE}) : ${EXCEPTION_TYPE}, '\\n', ' '), 1, 120)}`
+
+// A Markdown list because GitLab joins consecutive plain lines into one paragraph. Values sit in code so
+// that client-sent text cannot render links, images or @mentions in the tracker.
+export const ERROR_TRACKING_TICKET_DESCRIPTION = [
+ ticketMessage(EXCEPTION_MESSAGE),
+ ticketLine('Browser', "trim(concat(event.properties.$browser, ' ', event.properties.$browser_version))"),
+ ticketLine('OS', "trim(concat(event.properties.$os, ' ', event.properties.$os_version))"),
+ ticketLine('Release', 'event.properties.$exception_release.version'),
+ ticketLine(
+ 'Session replay',
+ SESSION_REPLAY_URL,
+ "notEmpty(event.properties.$session_id) and (empty(event.properties.$recording_status) or has(['active', 'sampled', 'buffering'], event.properties.$recording_status))",
+ SESSION_REPLAY_URL
+ ),
+].join('')
diff --git a/nodejs/src/cdp/templates/hog-helpers.ts b/nodejs/src/cdp/templates/hog-helpers.ts
index b2a95c773815..4568bbb44048 100644
--- a/nodejs/src/cdp/templates/hog-helpers.ts
+++ b/nodejs/src/cdp/templates/hog-helpers.ts
@@ -11,3 +11,79 @@
export const hogApiErrorMessageFn = `fun apiErrorMessage(response) {
return response.body.error ?? response.body.detail ?? response.body
}`
+
+// Ticket trackers sit outside PostHog's access controls, and a GitHub or GitLab repository can be
+// public, so a frame line carries only a file name, the line and the function name. Cymbal marks a JS
+// frame without a source map as resolved, and an inline script's source is the page URL, which can end
+// in a token. So a file name shows only when it looks like a source file, and a function name only when
+// it uses identifier characters. Anything else, or any name that holds a UUID or a key-shaped run of
+// letters and digits, becomes [redacted]. The function
+// never reads code_variables or source context, which can hold user data or secrets.
+// Each frames[i] read makes the VM measure the whole array. To stay inside the execution time limit, the
+// loop reads at most the last 50 frames and skips stacks over 2000 frames. The try block keeps a bad trace
+// from losing the ticket.
+export const hogErrorTrackingStacktraceFn = `fun errorTrackingHasSecret(text) {
+ if (match(text, '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}')) {
+ return true
+ }
+ let parts := text
+ for (let separator in ['_', '-', '.', '$', ':', '<', '>', '(', ')', '#', ',', '[', ']', ' ', '+', '=']) {
+ parts := replaceAll(parts, separator, '/')
+ }
+ for (let part in splitByString('/', parts)) {
+ if (length(part) >= 16 and match(part, '[0-9]')) {
+ return true
+ }
+ }
+ return false
+}
+
+fun errorTrackingFunctionName(name) {
+ let text := toString(name)
+ if (not match(text, '^[]A-Za-z0-9_$.:<>()#,[ -]{1,100}$') or errorTrackingHasSecret(text)) {
+ return '[redacted]'
+ }
+ return text
+}
+
+fun errorTrackingFileName(source) {
+ let path := splitByString('#', splitByString('?', replaceAll(toString(source), '\\\\', '/'))[1])[1]
+ let parts := splitByString('/', path)
+ let name := parts[length(parts)]
+ if (not match(name, '^[A-Za-z0-9_.-]{1,64}[.](js|mjs|cjs|jsx|ts|tsx|mts|cts|vue|svelte|py|rb|php|go|java|kt|kts|scala|rs|swift|dart|ex|exs|erl|cs|c|cc|cpp|h|hpp|m|mm|lua)$')) {
+ return '[redacted]'
+ }
+ return errorTrackingHasSecret(name) ? '[redacted]' : name
+}
+
+fun errorTrackingStacktrace(exceptionList) {
+ try {
+ let frames := exceptionList[1].stacktrace.frames
+ let last := length(frames)
+ if (empty(frames) or last > 2000) {
+ return ''
+ }
+ let lines := []
+ let first := last > 50 ? last - 49 : 1
+ for (let i := last; i >= first and length(lines) < 5; i := i - 1) {
+ let frame := frames[i]
+ if (frame.resolved and frame.in_app) {
+ let line := concat(' File "', notEmpty(frame.source) ? errorTrackingFileName(frame.source) : 'unknown', '"')
+ if (notEmpty(frame.line)) {
+ line := concat(line, ', line: ', frame.line)
+ }
+ let name := frame.resolved_name ?? frame.mangled_name
+ if (notEmpty(name)) {
+ line := concat(line, ', in: ', errorTrackingFunctionName(name))
+ }
+ lines := arrayPushBack(lines, replaceAll(substring(line, 1, 200), '\`', '\\''))
+ }
+ }
+ if (empty(lines)) {
+ return ''
+ }
+ return concat('\\n\\n\`\`\`\\n', arrayStringConcat(lines, '\\n'), '\\n\`\`\`')
+ } catch (error) {
+ return ''
+ }
+}`
diff --git a/nodejs/tests/fixtures/hog-bytecode/523e5b228e241236628e4af29e8931699f92eb5a9a5ca8f7cf9f1bfbeed60602.json b/nodejs/tests/fixtures/hog-bytecode/523e5b228e241236628e4af29e8931699f92eb5a9a5ca8f7cf9f1bfbeed60602.json
new file mode 100644
index 000000000000..591a82b1c35f
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/523e5b228e241236628e4af29e8931699f92eb5a9a5ca8f7cf9f1bfbeed60602.json
@@ -0,0 +1 @@
+["_H",1,52,"errorTrackingHasSecret",1,0,171,36,0,32,"[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}",2,"match",2,40,2,29,38,36,0,32,"_",32,"-",32,".",32,"$",32,":",32,"<",32,">",32,"(",32,")",32,"#",32,",",32,"[",32,"]",32," ",32,"+",32,"=",43,16,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,27,36,3,36,4,45,37,6,36,1,36,6,32,"/",2,"replaceAll",3,37,1,36,4,33,1,6,37,4,39,-34,35,35,35,35,35,32,"/",36,1,2,"splitByString",2,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,33,16,36,6,2,"length",1,14,36,6,32,"[0-9]",2,"match",2,3,2,40,2,29,38,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,30,38,35,53,0,52,"errorTrackingFunctionName",1,1,30,36,0,2,"toString",1,36,1,32,"^[]A-Za-z0-9_$.:<>()#,[ -]{1,100}$",2,"match",2,5,36,1,55,0,54,1,4,2,40,3,32,"[redacted]",38,36,1,38,35,53,1,true,0,52,"errorTrackingFileName",1,1,74,32,"#",32,"?",36,0,2,"toString",1,32,"\\",32,"/",2,"replaceAll",3,2,"splitByString",2,33,1,45,2,"splitByString",2,33,1,45,32,"/",36,1,2,"splitByString",2,36,2,36,2,2,"length",1,45,36,3,32,"^[A-Za-z0-9_.-]{1,64}[.](js|mjs|cjs|jsx|ts|tsx|mts|cts|vue|svelte|py|rb|php|go|java|kt|kts|scala|rs|swift|dart|ex|exs|erl|cs|c|cc|cpp|h|hpp|m|mm|lua)$",2,"match",2,5,40,3,32,"[redacted]",38,36,3,55,0,54,1,40,4,32,"[redacted]",39,2,36,3,38,35,35,35,53,1,true,0,52,"errorTrackingStacktrace",1,2,267,50,247,36,0,33,1,45,32,"stacktrace",45,32,"frames",45,36,1,2,"length",1,36,1,2,"empty",1,33,2000,36,2,13,4,2,40,3,32,"",38,43,0,33,50,36,2,13,40,7,33,49,36,2,7,39,2,33,1,36,2,36,4,36,5,14,33,5,36,3,2,"length",1,15,3,2,40,143,36,1,36,5,45,36,6,32,"resolved",45,36,6,32,"in_app",45,3,2,40,114,32," File \"",36,6,32,"source",45,2,"notEmpty",1,40,11,36,6,32,"source",45,55,0,54,1,39,2,32,"unknown",32,"\"",2,"concat",3,36,6,32,"line",45,2,"notEmpty",1,40,14,36,7,32,", line: ",36,6,32,"line",45,2,"concat",3,37,7,36,6,32,"resolved_name",45,47,6,35,36,6,32,"mangled_name",45,36,8,2,"notEmpty",1,40,15,36,7,32,", in: ",36,8,55,1,54,1,2,"concat",3,37,7,36,3,36,7,33,1,33,200,2,"substring",3,32,"`",32,"'",2,"replaceAll",3,2,"arrayPushBack",2,37,3,35,35,35,33,1,36,5,7,37,5,39,-160,35,36,3,2,"empty",1,40,3,32,"",38,32,"\n\n```\n",36,3,32,"\n",2,"arrayStringConcat",2,32,"\n```",2,"concat",3,38,35,35,35,35,51,39,17,36,1,32,"type",45,36,1,32,"",38,35,39,2,35,49,35,35,31,38,53,2,true,2,true,1,52,"query",1,0,43,32,"https://api.linear.app/graphql",32,"body",32,"query",36,0,42,1,32,"method",32,"POST",32,"headers",32,"Authorization",32,"Bearer ",32,"access_token",32,"linear_workspace",32,"inputs",1,3,2,"concat",2,32,"Content-Type",32,"application/json",42,2,42,3,2,"fetch",2,38,53,0,32,"description",32,"inputs",1,2,32,"$exception_list",32,"properties",32,"event",1,3,36,3,54,1,2,"concat",2,32,"mutation IssueCreate { issueCreate(input: { title: ",32,"title",32,"inputs",1,2,2,"jsonStringify",1,32," description: ",36,5,2,"jsonStringify",1,32," teamId: \"",32,"team",32,"inputs",1,2,32,"\" }) { success issue { identifier } } }",2,"concat",7,36,6,36,4,54,1,33,200,36,7,32,"status",45,12,40,21,32,"Failed to post create issue in Linear: ",36,7,32,"status",45,32,": ",36,7,32,"body",45,2,"concat",4,2,"Error",1,49,36,7,32,"body",45,32,"data",45,32,"issueCreate",45,32,"issue",45,32,"identifier",45,32,"posthog_issue_url",32,"inputs",1,2,36,9,2,"empty",1,40,19,32,"url",32,"project",1,2,32,"/error-tracking/",32,"posthog_issue_id",32,"inputs",1,2,2,"concat",3,37,9,32,"mutation AttachmentCreate { attachmentCreate(input: { issueId: \"",36,8,32,"\", title: \"PostHog issue\", url: \"",36,9,32,"\" }) { success } }",2,"concat",5,36,10,36,4,54,1,35,35,35,35,35,35,35,35,35,57,57,57]
diff --git a/nodejs/tests/fixtures/hog-bytecode/6c020417b65be63551bf6669879d8aab2843e704c57e69ff4de55b765505ab15.json b/nodejs/tests/fixtures/hog-bytecode/6c020417b65be63551bf6669879d8aab2843e704c57e69ff4de55b765505ab15.json
new file mode 100644
index 000000000000..96b2ad5dc047
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/6c020417b65be63551bf6669879d8aab2843e704c57e69ff4de55b765505ab15.json
@@ -0,0 +1 @@
+["_H",1,32,"https://gitlab.com",38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/b677d8c9f140f01834fbce8225b0eff79427112c45428adcc99c0a904bc7b0be.json b/nodejs/tests/fixtures/hog-bytecode/b677d8c9f140f01834fbce8225b0eff79427112c45428adcc99c0a904bc7b0be.json
new file mode 100644
index 000000000000..143911833da6
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/b677d8c9f140f01834fbce8225b0eff79427112c45428adcc99c0a904bc7b0be.json
@@ -0,0 +1 @@
+["_H",1,32,"$exception_values",32,"properties",32,"event",1,3,33,1,45,2,"notEmpty",1,40,29,32,"$exception_types",32,"properties",32,"event",1,3,33,1,45,32,": ",32,"$exception_values",32,"properties",32,"event",1,3,33,1,45,2,"concat",3,39,11,32,"$exception_types",32,"properties",32,"event",1,3,33,1,45,32,"\n",32," ",2,"replaceAll",3,33,1,33,120,2,"substring",3,38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/b7184987afc0d383a606c2bfb9a0db16520f3159d337af2e1c239ec551a8e3e7.json b/nodejs/tests/fixtures/hog-bytecode/b7184987afc0d383a606c2bfb9a0db16520f3159d337af2e1c239ec551a8e3e7.json
new file mode 100644
index 000000000000..5ede34724046
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/b7184987afc0d383a606c2bfb9a0db16520f3159d337af2e1c239ec551a8e3e7.json
@@ -0,0 +1 @@
+["_H",1,52,"errorTrackingHasSecret",1,0,171,36,0,32,"[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}",2,"match",2,40,2,29,38,36,0,32,"_",32,"-",32,".",32,"$",32,":",32,"<",32,">",32,"(",32,")",32,"#",32,",",32,"[",32,"]",32," ",32,"+",32,"=",43,16,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,27,36,3,36,4,45,37,6,36,1,36,6,32,"/",2,"replaceAll",3,37,1,36,4,33,1,6,37,4,39,-34,35,35,35,35,35,32,"/",36,1,2,"splitByString",2,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,33,16,36,6,2,"length",1,14,36,6,32,"[0-9]",2,"match",2,3,2,40,2,29,38,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,30,38,35,53,0,52,"errorTrackingFunctionName",1,1,30,36,0,2,"toString",1,36,1,32,"^[]A-Za-z0-9_$.:<>()#,[ -]{1,100}$",2,"match",2,5,36,1,55,0,54,1,4,2,40,3,32,"[redacted]",38,36,1,38,35,53,1,true,0,52,"errorTrackingFileName",1,1,74,32,"#",32,"?",36,0,2,"toString",1,32,"\\",32,"/",2,"replaceAll",3,2,"splitByString",2,33,1,45,2,"splitByString",2,33,1,45,32,"/",36,1,2,"splitByString",2,36,2,36,2,2,"length",1,45,36,3,32,"^[A-Za-z0-9_.-]{1,64}[.](js|mjs|cjs|jsx|ts|tsx|mts|cts|vue|svelte|py|rb|php|go|java|kt|kts|scala|rs|swift|dart|ex|exs|erl|cs|c|cc|cpp|h|hpp|m|mm|lua)$",2,"match",2,5,40,3,32,"[redacted]",38,36,3,55,0,54,1,40,4,32,"[redacted]",39,2,36,3,38,35,35,35,53,1,true,0,52,"errorTrackingStacktrace",1,2,267,50,247,36,0,33,1,45,32,"stacktrace",45,32,"frames",45,36,1,2,"length",1,36,1,2,"empty",1,33,2000,36,2,13,4,2,40,3,32,"",38,43,0,33,50,36,2,13,40,7,33,49,36,2,7,39,2,33,1,36,2,36,4,36,5,14,33,5,36,3,2,"length",1,15,3,2,40,143,36,1,36,5,45,36,6,32,"resolved",45,36,6,32,"in_app",45,3,2,40,114,32," File \"",36,6,32,"source",45,2,"notEmpty",1,40,11,36,6,32,"source",45,55,0,54,1,39,2,32,"unknown",32,"\"",2,"concat",3,36,6,32,"line",45,2,"notEmpty",1,40,14,36,7,32,", line: ",36,6,32,"line",45,2,"concat",3,37,7,36,6,32,"resolved_name",45,47,6,35,36,6,32,"mangled_name",45,36,8,2,"notEmpty",1,40,15,36,7,32,", in: ",36,8,55,1,54,1,2,"concat",3,37,7,36,3,36,7,33,1,33,200,2,"substring",3,32,"`",32,"'",2,"replaceAll",3,2,"arrayPushBack",2,37,3,35,35,35,33,1,36,5,7,37,5,39,-160,35,36,3,2,"empty",1,40,3,32,"",38,32,"\n\n```\n",36,3,32,"\n",2,"arrayStringConcat",2,32,"\n```",2,"concat",3,38,35,35,35,35,51,39,17,36,1,32,"type",45,36,1,32,"",38,35,39,2,35,49,35,35,31,38,53,2,true,2,true,1,32,"name",32,"account",32,"github_installation",32,"inputs",1,4,32,"repository",32,"inputs",1,2,36,4,5,40,6,32,"Owner is required",2,"Error",1,49,36,5,5,40,6,32,"Repository is required",2,"Error",1,49,32,"posthog_issue_url",32,"inputs",1,2,36,6,2,"empty",1,40,19,32,"url",32,"project",1,2,32,"/error-tracking/",32,"posthog_issue_id",32,"inputs",1,2,2,"concat",3,37,6,32,"method",32,"POST",32,"headers",32,"Authorization",32,"Bearer ",32,"access_token",32,"github_installation",32,"inputs",1,3,2,"concat",2,32,"Accept",32,"application/vnd.github+json",32,"Content-Type",32,"application/json",32,"User-Agent",32,"PostHog Github App",42,4,32,"body",32,"title",32,"title",32,"inputs",1,2,32,"body",32,"description",32,"inputs",1,2,32,"$exception_list",32,"properties",32,"event",1,3,36,3,54,1,32,"\n\n[View in PostHog](",36,6,32,")",2,"concat",5,42,2,42,3,32,"https://api.github.com/repos/",36,4,32,"/",36,5,32,"/issues",2,"concat",5,36,7,2,"fetch",2,33,200,36,8,32,"status",45,15,33,300,36,8,32,"status",45,14,4,2,40,21,32,"Failed to create GitHub issue: ",36,8,32,"status",45,32,": ",36,8,32,"body",45,2,"concat",4,2,"Error",1,49,35,35,35,35,35,35,57,57,57]
diff --git a/nodejs/tests/fixtures/hog-bytecode/c8a004454801fd26a37575e4c4c73dcef1652e1fffa39bd04d2b0ba4439ddc70.json b/nodejs/tests/fixtures/hog-bytecode/c8a004454801fd26a37575e4c4c73dcef1652e1fffa39bd04d2b0ba4439ddc70.json
new file mode 100644
index 000000000000..fb3e0ef36c4a
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/c8a004454801fd26a37575e4c4c73dcef1652e1fffa39bd04d2b0ba4439ddc70.json
@@ -0,0 +1 @@
+["_H",1,32,"$exception_values",32,"properties",32,"event",1,3,33,1,45,2,"notEmpty",1,40,27,32,"```\n",32,"$exception_values",32,"properties",32,"event",1,3,33,1,45,32,"`",32,"'",2,"replaceAll",3,32,"\n```",2,"concat",3,39,2,32,"",32,"\n",32,"$browser",32,"properties",32,"event",1,3,32," ",32,"$browser_version",32,"properties",32,"event",1,3,2,"concat",3,2,"trim",1,2,"notEmpty",1,40,59,32,"\n- Browser: ",32,"`",32,"$browser",32,"properties",32,"event",1,3,32," ",32,"$browser_version",32,"properties",32,"event",1,3,2,"concat",3,2,"trim",1,32,"`",32,"'",2,"replaceAll",3,32,"\n",32," ",2,"replaceAll",3,32,"\r",32," ",2,"replaceAll",3,32,"`",2,"concat",3,2,"concat",2,39,2,32,"",32,"$os",32,"properties",32,"event",1,3,32," ",32,"$os_version",32,"properties",32,"event",1,3,2,"concat",3,2,"trim",1,2,"notEmpty",1,40,59,32,"\n- OS: ",32,"`",32,"$os",32,"properties",32,"event",1,3,32," ",32,"$os_version",32,"properties",32,"event",1,3,2,"concat",3,2,"trim",1,32,"`",32,"'",2,"replaceAll",3,32,"\n",32," ",2,"replaceAll",3,32,"\r",32," ",2,"replaceAll",3,32,"`",2,"concat",3,2,"concat",2,39,2,32,"",32,"version",32,"$exception_release",32,"properties",32,"event",1,4,2,"notEmpty",1,40,45,32,"\n- Release: ",32,"`",32,"version",32,"$exception_release",32,"properties",32,"event",1,4,32,"`",32,"'",2,"replaceAll",3,32,"\n",32," ",2,"replaceAll",3,32,"\r",32," ",2,"replaceAll",3,32,"`",2,"concat",3,2,"concat",2,39,2,32,"",32,"$session_id",32,"properties",32,"event",1,3,2,"notEmpty",1,32,"$recording_status",32,"properties",32,"event",1,3,2,"empty",1,32,"active",32,"sampled",32,"buffering",43,3,32,"$recording_status",32,"properties",32,"event",1,3,2,"has",2,4,2,3,2,40,29,32,"\n- Session replay: ",32,"url",32,"project",1,2,32,"/replay/",32,"$session_id",32,"properties",32,"event",1,3,2,"encodeURLComponent",1,2,"concat",3,2,"concat",2,39,2,32,"",2,"concat",6,38]
diff --git a/nodejs/tests/fixtures/hog-bytecode/e0b819125ebd7672afb373b20b41bd89b6e5cf4f5d628c9c0282c357add29a49.json b/nodejs/tests/fixtures/hog-bytecode/e0b819125ebd7672afb373b20b41bd89b6e5cf4f5d628c9c0282c357add29a49.json
new file mode 100644
index 000000000000..688e16753a8b
--- /dev/null
+++ b/nodejs/tests/fixtures/hog-bytecode/e0b819125ebd7672afb373b20b41bd89b6e5cf4f5d628c9c0282c357add29a49.json
@@ -0,0 +1 @@
+["_H",1,52,"errorTrackingHasSecret",1,0,171,36,0,32,"[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}",2,"match",2,40,2,29,38,36,0,32,"_",32,"-",32,".",32,"$",32,":",32,"<",32,">",32,"(",32,")",32,"#",32,",",32,"[",32,"]",32," ",32,"+",32,"=",43,16,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,27,36,3,36,4,45,37,6,36,1,36,6,32,"/",2,"replaceAll",3,37,1,36,4,33,1,6,37,4,39,-34,35,35,35,35,35,32,"/",36,1,2,"splitByString",2,36,2,2,"values",1,33,1,36,3,2,"length",1,31,36,5,36,4,16,40,37,36,3,36,4,45,37,6,33,16,36,6,2,"length",1,14,36,6,32,"[0-9]",2,"match",2,3,2,40,2,29,38,36,4,33,1,6,37,4,39,-44,35,35,35,35,35,30,38,35,53,0,52,"errorTrackingFunctionName",1,1,30,36,0,2,"toString",1,36,1,32,"^[]A-Za-z0-9_$.:<>()#,[ -]{1,100}$",2,"match",2,5,36,1,55,0,54,1,4,2,40,3,32,"[redacted]",38,36,1,38,35,53,1,true,0,52,"errorTrackingFileName",1,1,74,32,"#",32,"?",36,0,2,"toString",1,32,"\\",32,"/",2,"replaceAll",3,2,"splitByString",2,33,1,45,2,"splitByString",2,33,1,45,32,"/",36,1,2,"splitByString",2,36,2,36,2,2,"length",1,45,36,3,32,"^[A-Za-z0-9_.-]{1,64}[.](js|mjs|cjs|jsx|ts|tsx|mts|cts|vue|svelte|py|rb|php|go|java|kt|kts|scala|rs|swift|dart|ex|exs|erl|cs|c|cc|cpp|h|hpp|m|mm|lua)$",2,"match",2,5,40,3,32,"[redacted]",38,36,3,55,0,54,1,40,4,32,"[redacted]",39,2,36,3,38,35,35,35,53,1,true,0,52,"errorTrackingStacktrace",1,2,267,50,247,36,0,33,1,45,32,"stacktrace",45,32,"frames",45,36,1,2,"length",1,36,1,2,"empty",1,33,2000,36,2,13,4,2,40,3,32,"",38,43,0,33,50,36,2,13,40,7,33,49,36,2,7,39,2,33,1,36,2,36,4,36,5,14,33,5,36,3,2,"length",1,15,3,2,40,143,36,1,36,5,45,36,6,32,"resolved",45,36,6,32,"in_app",45,3,2,40,114,32," File \"",36,6,32,"source",45,2,"notEmpty",1,40,11,36,6,32,"source",45,55,0,54,1,39,2,32,"unknown",32,"\"",2,"concat",3,36,6,32,"line",45,2,"notEmpty",1,40,14,36,7,32,", line: ",36,6,32,"line",45,2,"concat",3,37,7,36,6,32,"resolved_name",45,47,6,35,36,6,32,"mangled_name",45,36,8,2,"notEmpty",1,40,15,36,7,32,", in: ",36,8,55,1,54,1,2,"concat",3,37,7,36,3,36,7,33,1,33,200,2,"substring",3,32,"`",32,"'",2,"replaceAll",3,2,"arrayPushBack",2,37,3,35,35,35,33,1,36,5,7,37,5,39,-160,35,36,3,2,"empty",1,40,3,32,"",38,32,"\n\n```\n",36,3,32,"\n",2,"arrayStringConcat",2,32,"\n```",2,"concat",3,38,35,35,35,35,51,39,17,36,1,32,"type",45,36,1,32,"",38,35,39,2,35,49,35,35,31,38,53,2,true,2,true,1,32,"posthog_issue_url",32,"inputs",1,2,36,4,2,"empty",1,40,19,32,"url",32,"project",1,2,32,"/error-tracking/",32,"posthog_issue_id",32,"inputs",1,2,2,"concat",3,37,4,32,"title",32,"inputs",1,2,2,"notEmpty",1,40,29,32,"`",32,"title",32,"inputs",1,2,32,"`",32,"'",2,"replaceAll",3,32,"\n",32," ",2,"replaceAll",3,32,"`",2,"concat",3,39,6,32,"title",32,"inputs",1,2,32,"method",32,"POST",32,"headers",32,"PRIVATE-TOKEN",32,"access_token",32,"gitlab_project",32,"inputs",1,3,32,"Content-Type",32,"application/json",42,2,32,"body",32,"title",36,5,32,"description",32,"description",32,"inputs",1,2,32,"$exception_list",32,"properties",32,"event",1,3,36,3,54,1,32,"\n\n[View in PostHog](",36,4,32,")",2,"concat",5,42,2,42,3,32,"hostname",32,"gitlab_project",32,"inputs",1,3,32,"/api/v4/projects/",32,"project_id",32,"gitlab_project",32,"inputs",1,3,32,"/issues",2,"concat",4,36,6,2,"fetch",2,33,200,36,7,32,"status",45,15,33,300,36,7,32,"status",45,14,4,2,40,21,32,"Failed to create GitLab issue: ",36,7,32,"status",45,32,": ",36,7,32,"body",45,2,"concat",4,2,"Error",1,49,35,35,35,35,35,57,57,57]
diff --git a/products/error_tracking/skills/authoring-error-tracking-alerts/references/block-templates.md b/products/error_tracking/skills/authoring-error-tracking-alerts/references/block-templates.md
index 84600210f107..bac46ebca4ec 100644
--- a/products/error_tracking/skills/authoring-error-tracking-alerts/references/block-templates.md
+++ b/products/error_tracking/skills/authoring-error-tracking-alerts/references/block-templates.md
@@ -107,14 +107,25 @@ time against the live event — leave the curly-braced segments as-is.
These integrations file a tracking issue rather than post a message. Use the same `inputs` shape across
all three:
-```json
+````json
"inputs": {
- "title": { "value": "{event.properties.name}" },
- "description": { "value": "{event.properties.description}" },
+ "title": { "value": "{substring(replaceAll(notEmpty(event.properties.description) ? concat(event.properties.name, ': ', event.properties.description) : event.properties.name, '\\n', ' '), 1, 120)}" },
+ "description": { "value": "{notEmpty(event.properties.description) ? concat('```\\n', replaceAll(event.properties.description, '`', '\\''), '\\n```') : ''}\n{notEmpty(trim(concat(event.properties.$browser, ' ', event.properties.$browser_version))) ? concat('\\n- Browser: ', concat('`', replaceAll(replaceAll(replaceAll(trim(concat(event.properties.$browser, ' ', event.properties.$browser_version)), '`', '\\''), '\\n', ' '), '\\r', ' '), '`')) : ''}{notEmpty(trim(concat(event.properties.$os, ' ', event.properties.$os_version))) ? concat('\\n- OS: ', concat('`', replaceAll(replaceAll(replaceAll(trim(concat(event.properties.$os, ' ', event.properties.$os_version)), '`', '\\''), '\\n', ' '), '\\r', ' '), '`')) : ''}{notEmpty(event.properties.$exception_release.version) ? concat('\\n- Release: ', concat('`', replaceAll(replaceAll(replaceAll(event.properties.$exception_release.version, '`', '\\''), '\\n', ' '), '\\r', ' '), '`')) : ''}{notEmpty(event.properties.$session_id) and (empty(event.properties.$recording_status) or has(['active', 'sampled', 'buffering'], event.properties.$recording_status)) ? concat('\\n- Session replay: ', concat(project.url, '/replay/', encodeURLComponent(event.properties.$session_id))) : ''}" },
"posthog_issue_id": { "value": "{event.distinct_id}" },
"posthog_issue_url": { "value": "{project.url}/error-tracking/fingerprint/{encodeURLComponent(event.properties.fingerprint)}?timestamp={event.properties.exception_timestamp}&utm_source=alert&utm_campaign=error_tracking_alert&utm_medium=linear" }
}
-```
+````
+
+The title reads as the exception type and message, for example `RangeError: Invalid Date`, on one line, cut at 120 characters.
+The description is the message, then a Markdown list of the browser, OS, release and a session replay link.
+The destination code then adds up to 5 resolved in-app stack frames as a code block, so the inputs do not carry the trace.
+Each frame shows only the file name, the line and the function name.
+A file name that does not look like a source file, a function name with characters outside an identifier set, or any name that holds a UUID or looks like a key or token, becomes `[redacted]`.
+The message sits in a code block and the browser, OS and release values sit in inline code, so client-sent text cannot render links, images or @mentions.
+Do not add the page URL, request data, local variables or source lines to these inputs. Trackers sit outside PostHog's access controls and a repository can be public, so these values can expose tokens and user data.
+Each list line is left out when the event has no value for it, and the replay line is left out when replay was not recording.
+Keep the list form: GitLab joins plain consecutive lines into one paragraph.
+`_spiking` events carry no exception properties, so on them only the message would render.
Set `utm_medium` to the destination (`linear`, `github`, `gitlab`). `posthog_issue_url` is the merge-stable deep link embedded in the external issue; when omitted, the destination falls back to building a link from `posthog_issue_id`.