hydrate alert evidence from clickhouse
This commit is contained in:
parent
cd0a1dd9e5
commit
c0b5b6dbeb
10 changed files with 701 additions and 62 deletions
21
services/api/src/alert-context.ts
Normal file
21
services/api/src/alert-context.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const alertContextTraceIdSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(256)
|
||||
.regex(/^[A-Za-z0-9][A-Za-z0-9:_./-]*$/);
|
||||
|
||||
export const isAlertContextPath = (pathname: string): boolean => {
|
||||
return /^\/flow\/alerts\/[^/]+\/context$/.test(pathname);
|
||||
};
|
||||
|
||||
export const parseAlertContextTraceIdPath = (pathname: string): string | null => {
|
||||
if (!isAlertContextPath(pathname)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const encodedTraceId = pathname.slice("/flow/alerts/".length, -"/context".length);
|
||||
return alertContextTraceIdSchema.parse(decodeURIComponent(encodedTraceId));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue