diff --git a/backend/src/server/routes/v3/secret-router.ts b/backend/src/server/routes/v3/secret-router.ts index c17d03b06..5c5890a6b 100644 --- a/backend/src/server/routes/v3/secret-router.ts +++ b/backend/src/server/routes/v3/secret-router.ts @@ -13,12 +13,12 @@ import { EventType } from "@app/ee/services/audit-log/audit-log-types"; import { CommitType } from "@app/ee/services/secret-approval-request/secret-approval-request-types"; import { BadRequestError } from "@app/lib/errors"; import { removeTrailingSlash } from "@app/lib/fn"; +import { getUserAgentType } from "@app/server/plugins/audit-log"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { ActorType, AuthMode } from "@app/services/auth/auth-type"; import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types"; import { secretRawSchema } from "../sanitizedSchemas"; -import { getUserAgentType } from "@app/server/plugins/audit-log"; const getDistinctId = (req: FastifyRequest) => { if (req.auth.actor === ActorType.USER) { @@ -108,7 +108,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => { workspaceId, environment, secretPath: req.query.secretPath, - channel: getUserAgentType(req.headers["user-agent"]), + channel: getUserAgentType(req.headers["user-agent"]), ...req.auditLogInfo } }); @@ -470,14 +470,16 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => { } }); + // TODO: Move to telemetry plugin let shouldRecordK8Event = false; - if (req.authData.userAgent == "k8-operator") { + if (req.headers["user-agent"] === "k8-operator") { const randomNumber = Math.random(); if (randomNumber > 0.95) { shouldRecordK8Event = true; } } - const shouldCapture = req.authData.userAgent !== "k8-operator" || shouldRecordK8Event; + + const shouldCapture = req.headers["user-agent"] !== "k8-operator" || shouldRecordK8Event; const approximateNumberTotalSecrets = secrets.length * 20; if (shouldCapture) { server.services.telemetry.sendPostHogEvents({