Repository navigation
[HDX-5837] Expose alert tags as a webhook template variable #3492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@hyperdx/common-utils': minor | ||
| '@hyperdx/api': minor | ||
| '@hyperdx/app': minor | ||
| --- | ||
|
|
||
| feat: Expose alert tags to Generic and incident.io webhook bodies as `{{tags}}` (comma-separated, or iterate with `{{#each tags}}`), and include them in the default incident.io body's `metadata.tags`, so one shared webhook can route alerts by owning team |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,13 +101,15 @@ export const buildWebhookTemplateVariables = (message: Message) => | |
| note: escapeJsonString(message.note ?? ''), | ||
| sourceQuery: escapeJsonString(message.sourceQuery ?? ''), | ||
| status: escapeJsonString(message.status ?? ''), | ||
| // An array so `{{tags}}` renders comma-joined and `{{#each tags}}` works. | ||
| tags: (message.tags ?? []).map(escapeJsonString), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — Comma-joined
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| teamId: escapeJsonString(message.teamId ?? ''), | ||
| threshold: message.threshold, | ||
| thresholdMax: message.thresholdMax, | ||
| value: message.value, | ||
| }) satisfies Record< | ||
| WebhookTemplateVariable, | ||
| string | number | undefined | Record<string, string> | ||
| string | number | undefined | string[] | Record<string, string> | ||
| >; | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — No test checks that an alert's tags reach the dispatched message
Add a case to the
renderWithWebhooksuite inpackages/api/src/tasks/checkAlerts/__tests__/renderAlertTemplate.int.test.ts: givebase.alertsome tags and assertdispatched[0].message.tagsequals them, plus a case for an alert with no tags that expects[]. Today the new unit test only feeds a hand-builtMessageintobuildWebhookTemplateVariables. If this line were deleted, every test would still pass and the customer's original bug ("tags": "") would come back.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond