Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(telemetry): suppress PostHog person creation for anonymous public secret shares
Devin AI325e462f27cc
diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.tsindex a1bc0c5e29..d9005f50af 100644--- a/backend/src/server/routes/v1/secret-sharing-router.ts+++ b/backend/src/server/routes/v1/secret-sharing-router.ts@@ -164,6 +164,12 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>await server.services.telemetry.sendPostHogEvents({event: PostHogEventTypes.SharedSecretViewed,distinctId: req.permission?.id ? getTelemetryDistinctId(req) : `anonymous-${req.params.id}`,+ // Suppress person-record creation for unauthenticated viewers — the+ // `anonymous-<shareId>` distinctId is synthesised per share and has+ // no continuity with any real user or identity, so creating a+ // PostHog person for it inflates the person count without adding+ // any analytical value.+ anonymous: !req.permission?.id,organizationId: sharedSecret.orgId ?? undefined,properties: {sharedSecretId: req.params.id,@@ -233,6 +239,12 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>await server.services.telemetry.sendPostHogEvents({event: PostHogEventTypes.SecretShared,distinctId: `anonymous-${sharedSecret.id}`,+ // The public share endpoint is unauthenticated and the distinctId+ // is unique per share, so creating a PostHog person for each share+ // would inflate the person count by one record per share forever.+ // Suppress person-record creation while still emitting the event+ // so usage volume, funnels, and breakdowns continue to work.+ anonymous: true,properties: {accessType: SecretSharingAccessType.Anyone,expiresAt: sharedSecret.expiresAt.toISOString(),diff --git a/backend/src/services/telemetry/telemetry-service.ts b/backend/src/services/telemetry/telemetry-service.tsindex f11510fb0f..5b6e0ca17e 100644--- a/backend/src/services/telemetry/telemetry-service.ts+++ b/backend/src/services/telemetry/telemetry-service.ts@@ -290,10 +290,18 @@ To opt into telemetry, you can set "TELEMETRY_ENABLED=true" within the environmelogger.error(error, "Failed to identify PostHog organization");});}+ // When `anonymous` is set, we still record the event but instruct+ // PostHog not to create or update a person record for the synthesised+ // distinctId. This prevents per-request distinctIds (e.g. the+ // `anonymous-<shareId>` keys used by unauthenticated public secret+ // shares) from inflating the person count while preserving event+ // counts, funnels, and breakdowns.+ const properties = event.anonymous ? { ...event.properties, $process_person_profile: false } : event.properties;+postHog.capture({event: event.event,distinctId: event.distinctId,- properties: event.properties,+ properties,...(event.organizationId ? { groups: { organization: event.organizationId } } : {})});}diff --git a/backend/src/services/telemetry/telemetry-types.ts b/backend/src/services/telemetry/telemetry-types.tsindex 78ddf6ac98..4ba3c04a8e 100644--- a/backend/src/services/telemetry/telemetry-types.ts+++ b/backend/src/services/telemetry/telemetry-types.ts@@ -889,7 +889,21 @@ export type THoneyTokenTriggeredEvent = {};};-export type TPostHogEvent = { distinctId: string; organizationId?: string; organizationName?: string } & (+export type TPostHogEvent = {+ distinctId: string;+ organizationId?: string;+ organizationName?: string;+ /**+ * When true, the event is captured without creating or updating a PostHog+ * person record (`$process_person_profile: false`). Use for events fired+ * from unauthenticated, single-shot interactions where the distinctId is+ * synthesised per-request (e.g. anonymous public secret shares) and there+ * is no real user/identity to attribute the event to. The event itself is+ * still recorded so funnels and breakdowns continue to work — only the+ * person record is suppressed.+ */+ anonymous?: boolean;+} & (| TSecretModifiedEvent| TAdminInitEvent| TUserSignedUpEvent