mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Skip event logs in CI
Some checks failed
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Test / docker (push) Has been cancelled
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests / build (latest) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
Dev Environment Test / test (push) Has been cancelled
Run setup tests / test (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Some checks failed
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Test / docker (push) Has been cancelled
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Runs E2E API Tests / build (latest) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
Dev Environment Test / test (push) Has been cancelled
Run setup tests / test (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
This commit is contained in:
parent
6353baa486
commit
0fc6839751
@ -2,6 +2,7 @@ import withPostHog from "@/analytics";
|
||||
import { prismaClient } from "@/prisma-client";
|
||||
import { runAsynchronouslyAndWaitUntil } from "@/utils/vercel";
|
||||
import { urlSchema, yupMixed, yupObject, yupString } from "@stackframe/stack-shared/dist/schema-fields";
|
||||
import { getEnvVariable, getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env";
|
||||
import { StackAssertionError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
||||
import { HTTP_METHODS } from "@stackframe/stack-shared/dist/utils/http";
|
||||
import { filterUndefined, typedKeys } from "@stackframe/stack-shared/dist/utils/objects";
|
||||
@ -165,25 +166,27 @@ export async function logEvent<T extends EventType[]>(
|
||||
});
|
||||
|
||||
// log event in PostHog
|
||||
await withPostHog(async posthog => {
|
||||
const distinctId = typeof data === "object" && data && "userId" in data ? (data.userId as string) : `backend-anon-${generateUuid()}`;
|
||||
for (const eventType of allEventTypes) {
|
||||
const postHogEventName = `stack_${eventType.id.replace(/^\$/, "system_").replace(/-/g, "_")}`;
|
||||
posthog.capture({
|
||||
event: postHogEventName,
|
||||
distinctId,
|
||||
groups: filterUndefined({
|
||||
projectId: typeof data === "object" && data && "projectId" in data ? (typeof data.projectId === "string" ? data.projectId : throwErr("Project ID is not a string for some reason?", { data })) : undefined,
|
||||
}),
|
||||
timestamp: timeRange.end,
|
||||
properties: {
|
||||
data,
|
||||
is_wide: isWide,
|
||||
event_started_at: timeRange.start,
|
||||
event_ended_at: timeRange.end,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
if (getNodeEnvironment().includes("production") && !getEnvVariable("CI", "")) {
|
||||
await withPostHog(async posthog => {
|
||||
const distinctId = typeof data === "object" && data && "userId" in data ? (data.userId as string) : `backend-anon-${generateUuid()}`;
|
||||
for (const eventType of allEventTypes) {
|
||||
const postHogEventName = `stack_${eventType.id.replace(/^\$/, "system_").replace(/-/g, "_")}`;
|
||||
posthog.capture({
|
||||
event: postHogEventName,
|
||||
distinctId,
|
||||
groups: filterUndefined({
|
||||
projectId: typeof data === "object" && data && "projectId" in data ? (typeof data.projectId === "string" ? data.projectId : throwErr("Project ID is not a string for some reason?", { data })) : undefined,
|
||||
}),
|
||||
timestamp: timeRange.end,
|
||||
properties: {
|
||||
data,
|
||||
is_wide: isWide,
|
||||
event_started_at: timeRange.start,
|
||||
event_ended_at: timeRange.end,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
})());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user