fix(telemetry): added back email for telemetry when using service token

This commit is contained in:
Akhil Mohan
2024-02-22 17:09:33 +05:30
parent acfa89ba8b
commit be49de5f34
6 changed files with 31 additions and 7 deletions
@@ -27,7 +27,7 @@ export type TAuthMode =
}
| {
authMode: AuthMode.SERVICE_TOKEN;
serviceToken: TServiceTokens;
serviceToken: TServiceTokens & { createdByEmail: string };
actor: ActorType.SERVICE;
serviceTokenId: string;
}
@@ -28,7 +28,7 @@ const getDistinctId = (req: FastifyRequest) => {
return `identity-${req.auth.identityId}`;
}
if (req.auth.actor === ActorType.SERVICE) {
return `service-token-${req.auth.serviceToken.id}`;
return req.auth.serviceToken.createdByEmail || `service-token-${req.auth.serviceTokenId}`; // when user gets removed from system
}
return "unknown-auth-data";
};