mirror of
https://github.com/Infisical/infisical.git
synced 2026-05-02 03:02:03 -04:00
Correct service token telemetry depending on creating entity
This commit is contained in:
@@ -157,7 +157,7 @@ const getAuthSTDPayload = async ({
|
||||
}, {
|
||||
new: true
|
||||
})
|
||||
.select('+encryptedKey +iv +tag').populate('user');
|
||||
.select('+encryptedKey +iv +tag').populate('user serviceAccount');
|
||||
|
||||
if (!serviceTokenData) throw ServiceTokenDataNotFoundError({ message: 'Failed to find service token data' });
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ import {
|
||||
} from '../config';
|
||||
import {
|
||||
IUser,
|
||||
User,
|
||||
IServiceAccount,
|
||||
ServiceAccount,
|
||||
IServiceTokenData
|
||||
} from '../models';
|
||||
import {
|
||||
@@ -56,7 +58,7 @@ class Telemetry {
|
||||
}: {
|
||||
user?: IUser;
|
||||
serviceAccount?: IServiceAccount;
|
||||
serviceTokenData?: IServiceTokenData;
|
||||
serviceTokenData?: any; // TODO: fix (it's ServiceTokenData with user populated)
|
||||
}) => {
|
||||
let distinctId = '';
|
||||
|
||||
@@ -65,11 +67,13 @@ class Telemetry {
|
||||
}
|
||||
|
||||
if (serviceAccount) {
|
||||
distinctId = `sa.${serviceAccount._id}`;
|
||||
distinctId = `sa.${serviceAccount._id.toString()}`;
|
||||
}
|
||||
|
||||
if (serviceTokenData) {
|
||||
distinctId = `st.${serviceTokenData._id}`;
|
||||
|
||||
if (serviceTokenData?.user && serviceTokenData?.user instanceof User) {
|
||||
distinctId = serviceTokenData.user.email;
|
||||
} else if (serviceTokenData?.serviceAccount && serviceTokenData?.serviceAccount instanceof ServiceAccount) {
|
||||
distinctId = `sa.${serviceTokenData.serviceAccount._id.toString()}`;
|
||||
}
|
||||
|
||||
if (distinctId === '') {
|
||||
|
||||
Reference in New Issue
Block a user