mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +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 {
|
||||||
@@ -22,7 +22,7 @@ class Telemetry {
|
|||||||
*/
|
*/
|
||||||
static logTelemetryMessage = async () => {
|
static logTelemetryMessage = async () => {
|
||||||
|
|
||||||
if(!(await getTelemetryEnabled())){
|
if (!(await getTelemetryEnabled())) {
|
||||||
[
|
[
|
||||||
"To improve, Infisical collects telemetry data about general usage.",
|
"To improve, Infisical collects telemetry data about general usage.",
|
||||||
"This helps us understand how the product is doing and guide our product development to create the best possible platform; it also helps us demonstrate growth as we support Infisical as open-source software.",
|
"This helps us understand how the product is doing and guide our product development to create the best possible platform; it also helps us demonstrate growth as we support Infisical as open-source software.",
|
||||||
@@ -42,8 +42,8 @@ class Telemetry {
|
|||||||
postHogClient = new PostHog(await getPostHogProjectApiKey(), {
|
postHogClient = new PostHog(await getPostHogProjectApiKey(), {
|
||||||
host: await getPostHogHost(),
|
host: await getPostHogHost(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return postHogClient;
|
return postHogClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
@@ -59,14 +60,14 @@ class Telemetry {
|
|||||||
if (authData.authPayload.user) {
|
if (authData.authPayload.user) {
|
||||||
const user = await User.findById(authData.authPayload.user, "email");
|
const user = await User.findById(authData.authPayload.user, "email");
|
||||||
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