mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 15:27:27 +00:00
patch getDistinctId
This commit is contained in:
@@ -8,12 +8,12 @@ import {
|
|||||||
getTelemetryEnabled,
|
getTelemetryEnabled,
|
||||||
} from "../config";
|
} from "../config";
|
||||||
import {
|
import {
|
||||||
|
Identity,
|
||||||
ServiceTokenData,
|
ServiceTokenData,
|
||||||
User,
|
User
|
||||||
} from "../models";
|
} from "../models";
|
||||||
import {
|
import {
|
||||||
AccountNotFoundError,
|
AccountNotFoundError,
|
||||||
BadRequestError,
|
|
||||||
} from "../utils/errors";
|
} from "../utils/errors";
|
||||||
|
|
||||||
class Telemetry {
|
class Telemetry {
|
||||||
@@ -52,6 +52,7 @@ class Telemetry {
|
|||||||
}: {
|
}: {
|
||||||
authData: AuthData;
|
authData: AuthData;
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
let distinctId = "";
|
let distinctId = "";
|
||||||
if (authData.authPayload instanceof User) {
|
if (authData.authPayload instanceof User) {
|
||||||
distinctId = authData.authPayload.email;
|
distinctId = authData.authPayload.email;
|
||||||
@@ -61,12 +62,12 @@ class Telemetry {
|
|||||||
if (!user) throw AccountNotFoundError();
|
if (!user) throw AccountNotFoundError();
|
||||||
distinctId = user.email;
|
distinctId = user.email;
|
||||||
}
|
}
|
||||||
|
} else if (authData.authPayload instanceof Identity) {
|
||||||
|
distinctId = `identity-${authData.authPayload._id.toString()}`
|
||||||
|
} else {
|
||||||
|
distinctId = "unknown-auth-data"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distinctId === "") throw BadRequestError({
|
|
||||||
message: "Failed to obtain distinct id for logging telemetry",
|
|
||||||
});
|
|
||||||
|
|
||||||
return distinctId;
|
return distinctId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user