feat(telemetry): added telemetry events for creation of integration,project,machine identity and user invitation to org

This commit is contained in:
Akhil Mohan
2024-02-23 13:19:16 +05:30
parent a231813f01
commit 76daa20d69
8 changed files with 148 additions and 18 deletions
+17
View File
@@ -0,0 +1,17 @@
import { FastifyRequest } from "fastify";
import { ActorType } from "@app/services/auth/auth-type";
// this is a unique id for sending posthog event
export const getTelemetryDistinctId = (req: FastifyRequest) => {
if (req.auth.actor === ActorType.USER) {
return req.auth.user.email;
}
if (req.auth.actor === ActorType.IDENTITY) {
return `identity-${req.auth.identityId}`;
}
if (req.auth.actor === ActorType.SERVICE) {
return `service-token-${req.auth.serviceToken.id}`;
}
return "unknown-auth-data";
};