Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: add PostHog telemetry events for SSO, App Connection, Secret Rotation V2, and Gateway

Devin AIce57d3bb6bfa
diff --git a/backend/src/ee/routes/v1/gateway-router.ts b/backend/src/ee/routes/v1/gateway-router.ts
index 40e9c15801..f20ade6c96 100644
--- a/backend/src/ee/routes/v1/gateway-router.ts
+++ b/backend/src/ee/routes/v1/gateway-router.ts
@@ -4,8 +4,10 @@ import { GatewaysSchema } from "@app/db/schemas";
import { isValidIp } from "@app/lib/ip";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { slugSchema } from "@app/server/lib/schemas";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
const SanitizedGatewaySchema = GatewaysSchema.pick({
id: true,
@@ -79,6 +81,20 @@ export const registerGatewayRouter = async (server: FastifyZodProvider) => {
relayAddress: req.body.relayAddress,
identityOrgAuthMethod: req.permission.authMethod
});
+
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.GatewayCreated,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: {
+ gatewayId: gatewayCertificates.serialNumber,
+ identityId: req.permission.id,
+ orgId: req.permission.orgId
+ }
+ })
+ .catch(() => {});
+
return gatewayCertificates;
}
});
diff --git a/backend/src/ee/routes/v1/ldap-router.ts b/backend/src/ee/routes/v1/ldap-router.ts
index 52a819be8e..46bb3089bf 100644
--- a/backend/src/ee/routes/v1/ldap-router.ts
+++ b/backend/src/ee/routes/v1/ldap-router.ts
@@ -22,9 +22,11 @@ import { getConfig } from "@app/lib/config/env";
import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { SanitizedLdapConfigSchema } from "@app/server/routes/sanitizedSchema/directory-config";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
export const registerLdapRouter = async (server: FastifyZodProvider) => {
const appCfg = getConfig();
@@ -222,6 +224,19 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
...req.body
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: "ldap",
+ action: "create"
+ }
+ })
+ .catch(() => {});
+
return ldap;
}
});
@@ -271,6 +286,19 @@ export const registerLdapRouter = async (server: FastifyZodProvider) => {
...req.body
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: "ldap",
+ action: "update"
+ }
+ })
+ .catch(() => {});
+
return ldap;
}
});
diff --git a/backend/src/ee/routes/v1/oidc-router.ts b/backend/src/ee/routes/v1/oidc-router.ts
index 59c05272d0..f900a61bf4 100644
--- a/backend/src/ee/routes/v1/oidc-router.ts
+++ b/backend/src/ee/routes/v1/oidc-router.ts
@@ -16,8 +16,10 @@ import { OIDCConfigurationType, OIDCJWTSignatureAlgorithm } from "@app/ee/servic
import { ApiDocsTags, OidcSSo } from "@app/lib/api-docs";
import { getConfig } from "@app/lib/config/env";
import { authRateLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
const SanitizedOidcConfigSchema = OidcConfigsSchema.pick({
id: true,
@@ -277,6 +279,20 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
actorOrgId: req.permission.orgId,
...req.body
});
+
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: "oidc",
+ action: "update"
+ }
+ })
+ .catch(() => {});
+
return oidc;
}
});
@@ -401,6 +417,20 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
actorOrgId: req.permission.orgId,
...req.body
});
+
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: "oidc",
+ action: "create"
+ }
+ })
+ .catch(() => {});
+
return oidc;
}
});
diff --git a/backend/src/ee/routes/v1/saml-router.ts b/backend/src/ee/routes/v1/saml-router.ts
index d0723799f5..140250c2e2 100644
--- a/backend/src/ee/routes/v1/saml-router.ts
+++ b/backend/src/ee/routes/v1/saml-router.ts
@@ -20,9 +20,11 @@ import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { AuthAttemptAuthMethod, AuthAttemptAuthResult, authAttemptCounter } from "@app/lib/telemetry/metrics";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { SanitizedSamlConfigSchema } from "@app/server/routes/sanitizedSchema/directory-config";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
type TSAMLConfig = {
callbackUrl: string;
@@ -367,7 +369,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
const { isActive, authProvider, issuer, entryPoint, cert, enableGroupSync } = req.body;
const { permission } = req;
- return server.services.saml.createSamlCfg({
+ const samlCfg = await server.services.saml.createSamlCfg({
isActive,
authProvider,
issuer,
@@ -380,6 +382,21 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
actorOrgId: permission.orgId,
orgId: req.body.organizationId
});
+
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: authProvider,
+ action: "create"
+ }
+ })
+ .catch(() => {});
+
+ return samlCfg;
}
});
@@ -418,7 +435,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
const { isActive, authProvider, issuer, entryPoint, cert, enableGroupSync } = req.body;
const { permission } = req;
- return server.services.saml.updateSamlCfg({
+ const samlCfg = await server.services.saml.updateSamlCfg({
isActive,
authProvider,
issuer,
@@ -431,6 +448,23 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
actorOrgId: permission.orgId,
orgId: req.body.organizationId
});
+
+ if (authProvider) {
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SSOConfigured,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.body.organizationId,
+ properties: {
+ orgId: req.body.organizationId,
+ provider: authProvider,
+ action: "update"
+ }
+ })
+ .catch(() => {});
+ }
+
+ return samlCfg;
}
});
};
diff --git a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-endpoints.ts b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-endpoints.ts
index 60bb32a60e..252513e453 100644
--- a/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-endpoints.ts
+++ b/backend/src/ee/routes/v2/secret-rotation-v2-routers/secret-rotation-v2-endpoints.ts
@@ -12,8 +12,10 @@ import {
import { ApiDocsTags, SecretRotations } from "@app/lib/api-docs";
import { startsWithVowel } from "@app/lib/fn";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
export const registerSecretRotationEndpoints = <
T extends TSecretRotationV2,
@@ -256,6 +258,20 @@ export const registerSecretRotationEndpoints = <
}
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SecretRotationV2Created,
+ distinctId: getTelemetryDistinctId(req),
+ properties: {
+ rotationId: secretRotation.id,
+ type,
+ projectId: secretRotation.projectId,
+ environment: req.body.environment,
+ secretPath: req.body.secretPath
+ }
+ })
+ .catch(() => {});
+
return { secretRotation };
}
});
@@ -359,6 +375,18 @@ export const registerSecretRotationEndpoints = <
}
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SecretRotationV2Deleted,
+ distinctId: getTelemetryDistinctId(req),
+ properties: {
+ rotationId,
+ type,
+ projectId: secretRotation.projectId
+ }
+ })
+ .catch(() => {});
+
return { secretRotation };
}
});
@@ -450,6 +478,18 @@ export const registerSecretRotationEndpoints = <
req.permission
)) as T;
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.SecretRotationV2Executed,
+ distinctId: getTelemetryDistinctId(req),
+ properties: {
+ rotationId,
+ type,
+ projectId: secretRotation.projectId
+ }
+ })
+ .catch(() => {});
+
return { secretRotation };
}
});
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
index 46bc358902..18bb5fd917 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
@@ -4,12 +4,14 @@ import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { ApiDocsTags, AppConnections } from "@app/lib/api-docs";
import { startsWithVowel } from "@app/lib/fn";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { APP_CONNECTION_NAME_MAP } from "@app/services/app-connection/app-connection-maps";
import { TAppConnection, TAppConnectionInput } from "@app/services/app-connection/app-connection-types";
import { TCreateAppConnectionCredentialRotationSchema } from "@app/services/app-connection/credential-rotation/app-connection-credential-rotation-types";
import { AuthMode } from "@app/services/auth/auth-type";
+import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
export const registerAppConnectionEndpoints = <T extends TAppConnection, I extends TAppConnectionInput>({
server,
@@ -321,6 +323,20 @@ export const registerAppConnectionEndpoints = <T extends TAppConnection, I exten
}
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.AppConnectionCreated,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: {
+ appConnectionId: appConnection.id,
+ app,
+ method: method as string,
+ orgId: req.permission.orgId
+ }
+ })
+ .catch(() => {});
+
return { appConnection };
}
});
@@ -431,6 +447,19 @@ export const registerAppConnectionEndpoints = <T extends TAppConnection, I exten
}
});
+ void server.services.telemetry
+ .sendPostHogEvents({
+ event: PostHogEventTypes.AppConnectionDeleted,
+ distinctId: getTelemetryDistinctId(req),
+ organizationId: req.permission.orgId,
+ properties: {
+ appConnectionId: connectionId,
+ app,
+ orgId: req.permission.orgId
+ }
+ })
+ .catch(() => {});
+
return { appConnection };
}
});
diff --git a/backend/src/services/telemetry/telemetry-types.ts b/backend/src/services/telemetry/telemetry-types.ts
index 1bfd34df2c..d56b5ddad7 100644
--- a/backend/src/services/telemetry/telemetry-types.ts
+++ b/backend/src/services/telemetry/telemetry-types.ts
@@ -66,7 +66,14 @@ export enum PostHogEventTypes {
DynamicSecretCreated = "Dynamic Secret Created",
DynamicSecretDeleted = "Dynamic Secret Deleted",
DynamicSecretLeaseCreated = "Dynamic Secret Lease Created",
- DynamicSecretLeaseRenewed = "Dynamic Secret Lease Renewed"
+ DynamicSecretLeaseRenewed = "Dynamic Secret Lease Renewed",
+ SSOConfigured = "SSO Configured",
+ AppConnectionCreated = "App Connection Created",
+ AppConnectionDeleted = "App Connection Deleted",
+ SecretRotationV2Created = "Secret Rotation V2 Created",
+ SecretRotationV2Deleted = "Secret Rotation V2 Deleted",
+ SecretRotationV2Executed = "Secret Rotation V2 Executed",
+ GatewayCreated = "Gateway Created"
}
export type TSecretModifiedEvent = {
@@ -544,6 +551,72 @@ export type TDynamicSecretLeaseRenewedEvent = {
};
};
+export type TSSOConfiguredEvent = {
+ event: PostHogEventTypes.SSOConfigured;
+ properties: {
+ orgId: string;
+ provider: string;
+ action: "create" | "update";
+ };
+};
+
+export type TAppConnectionCreatedEvent = {
+ event: PostHogEventTypes.AppConnectionCreated;
+ properties: {
+ appConnectionId: string;
+ app: string;
+ method: string;
+ orgId: string;
+ };
+};
+
+export type TAppConnectionDeletedEvent = {
+ event: PostHogEventTypes.AppConnectionDeleted;
+ properties: {
+ appConnectionId: string;
+ app: string;
+ orgId: string;
+ };
+};
+
+export type TSecretRotationV2CreatedEvent = {
+ event: PostHogEventTypes.SecretRotationV2Created;
+ properties: {
+ rotationId: string;
+ type: string;
+ projectId: string;
+ environment: string;
+ secretPath: string;
+ };
+};
+
+export type TSecretRotationV2DeletedEvent = {
+ event: PostHogEventTypes.SecretRotationV2Deleted;
+ properties: {
+ rotationId: string;
+ type: string;
+ projectId: string;
+ };
+};
+
+export type TSecretRotationV2ExecutedEvent = {
+ event: PostHogEventTypes.SecretRotationV2Executed;
+ properties: {
+ rotationId: string;
+ type: string;
+ projectId: string;
+ };
+};
+
+export type TGatewayCreatedEvent = {
+ event: PostHogEventTypes.GatewayCreated;
+ properties: {
+ gatewayId: string;
+ identityId: string;
+ orgId: string;
+ };
+};
+
export type TPostHogEvent = { distinctId: string; organizationId?: string; organizationName?: string } & (
| TSecretModifiedEvent
| TAdminInitEvent
@@ -588,4 +661,11 @@ export type TPostHogEvent = { distinctId: string; organizationId?: string; organ
| TDynamicSecretDeletedEvent
| TDynamicSecretLeaseCreatedEvent
| TDynamicSecretLeaseRenewedEvent
+ | TSSOConfiguredEvent
+ | TAppConnectionCreatedEvent
+ | TAppConnectionDeletedEvent
+ | TSecretRotationV2CreatedEvent
+ | TSecretRotationV2DeletedEvent
+ | TSecretRotationV2ExecutedEvent
+ | TGatewayCreatedEvent
);