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