mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 19:28:16 +00:00
Add telemetry for Infisical SSH
This commit is contained in:
@@ -5,9 +5,11 @@ import { SshCertType } from "@app/ee/services/ssh/ssh-certificate-authority-type
|
|||||||
import { SSH_CERTIFICATE_AUTHORITIES } from "@app/lib/api-docs";
|
import { SSH_CERTIFICATE_AUTHORITIES } from "@app/lib/api-docs";
|
||||||
import { ms } from "@app/lib/ms";
|
import { ms } from "@app/lib/ms";
|
||||||
import { writeLimit } from "@app/server/config/rateLimiter";
|
import { writeLimit } from "@app/server/config/rateLimiter";
|
||||||
|
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
|
||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
import { CertKeyAlgorithm } from "@app/services/certificate/certificate-types";
|
import { CertKeyAlgorithm } from "@app/services/certificate/certificate-types";
|
||||||
|
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
|
||||||
|
|
||||||
export const registerSshCertRouter = async (server: FastifyZodProvider) => {
|
export const registerSshCertRouter = async (server: FastifyZodProvider) => {
|
||||||
server.route({
|
server.route({
|
||||||
@@ -73,6 +75,16 @@ export const registerSshCertRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server.services.telemetry.sendPostHogEvents({
|
||||||
|
event: PostHogEventTypes.SignSshKey,
|
||||||
|
distinctId: getTelemetryDistinctId(req),
|
||||||
|
properties: {
|
||||||
|
certificateTemplateId: req.body.certificateTemplateId,
|
||||||
|
principals: req.body.principals,
|
||||||
|
...req.auditLogInfo
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
serialNumber,
|
serialNumber,
|
||||||
signedKey: signedPublicKey
|
signedKey: signedPublicKey
|
||||||
@@ -152,6 +164,16 @@ export const registerSshCertRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server.services.telemetry.sendPostHogEvents({
|
||||||
|
event: PostHogEventTypes.IssueSshCreds,
|
||||||
|
distinctId: getTelemetryDistinctId(req),
|
||||||
|
properties: {
|
||||||
|
certificateTemplateId: req.body.certificateTemplateId,
|
||||||
|
principals: req.body.principals,
|
||||||
|
...req.auditLogInfo
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
serialNumber,
|
serialNumber,
|
||||||
signedKey: signedPublicKey,
|
signedKey: signedPublicKey,
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ export enum PostHogEventTypes {
|
|||||||
UserOrgInvitation = "User Org Invitation",
|
UserOrgInvitation = "User Org Invitation",
|
||||||
TelemetryInstanceStats = "Self Hosted Instance Stats",
|
TelemetryInstanceStats = "Self Hosted Instance Stats",
|
||||||
SecretRequestCreated = "Secret Request Created",
|
SecretRequestCreated = "Secret Request Created",
|
||||||
SecretRequestDeleted = "Secret Request Deleted"
|
SecretRequestDeleted = "Secret Request Deleted",
|
||||||
|
SignSshKey = "Sign SSH Key",
|
||||||
|
IssueSshCreds = "Issue SSH Credentials"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TSecretModifiedEvent = {
|
export type TSecretModifiedEvent = {
|
||||||
@@ -139,6 +141,24 @@ export type TSecretRequestDeletedEvent = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TSignSshKeyEvent = {
|
||||||
|
event: PostHogEventTypes.SignSshKey;
|
||||||
|
properties: {
|
||||||
|
certificateTemplateId: string;
|
||||||
|
principals: string[];
|
||||||
|
userAgent?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TIssueSshCredsEvent = {
|
||||||
|
event: PostHogEventTypes.IssueSshCreds;
|
||||||
|
properties: {
|
||||||
|
certificateTemplateId: string;
|
||||||
|
principals: string[];
|
||||||
|
userAgent?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export type TPostHogEvent = { distinctId: string } & (
|
export type TPostHogEvent = { distinctId: string } & (
|
||||||
| TSecretModifiedEvent
|
| TSecretModifiedEvent
|
||||||
| TAdminInitEvent
|
| TAdminInitEvent
|
||||||
@@ -151,4 +171,6 @@ export type TPostHogEvent = { distinctId: string } & (
|
|||||||
| TTelemetryInstanceStatsEvent
|
| TTelemetryInstanceStatsEvent
|
||||||
| TSecretRequestCreatedEvent
|
| TSecretRequestCreatedEvent
|
||||||
| TSecretRequestDeletedEvent
|
| TSecretRequestDeletedEvent
|
||||||
|
| TSignSshKeyEvent
|
||||||
|
| TIssueSshCredsEvent
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user