feat: add PostHog telemetry events for SSO, App Connection, Secret Rotation V2, and Gateway#5731
Conversation
…tation V2, and Gateway - Add new PostHogEventTypes: SSOConfigured, AppConnectionCreated, AppConnectionDeleted, SecretRotationV2Created, SecretRotationV2Deleted, SecretRotationV2Executed, GatewayCreated - Add corresponding TypeScript type definitions for each event - Instrument SAML/OIDC/LDAP routers with SSO telemetry on create and update - Instrument app-connection-endpoints with create/delete telemetry - Instrument secret-rotation-v2-endpoints with create/delete/execute telemetry - Instrument gateway router exchange-cert handler with creation telemetry - All events follow existing fire-and-forget pattern Co-Authored-By: arsh <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile SummaryThis PR adds PostHog telemetry instrumentation to four previously untracked feature areas — SSO (SAML/OIDC/LDAP), App Connections, Secret Rotation V2, and Gateway — following the existing fire-and-forget pattern used throughout the codebase. All previous review feedback has been addressed: Key observations:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 5d21b7c |
… remove redundant orgId, rename gatewayId Co-Authored-By: arsh <[email protected]>
…Exchanged, remove SAML update guard Co-Authored-By: arsh <[email protected]>
|
All Greptile comments have been addressed in commits 2da6f50 and d2c6829:
|
…n telemetry events Co-Authored-By: arsh <[email protected]>
|
Addressed the latest Greptile comment in commit 8fdada8: |
…ecuted events Co-Authored-By: arsh <[email protected]>
|
Addressed in 2ff8945 — |
…ation enum for type property Co-Authored-By: arsh <[email protected]>
|
Addressed in f0940de:
|
Co-Authored-By: arsh <[email protected]>
…or handling Co-Authored-By: arsh <[email protected]>
Context
Adds PostHog telemetry events for four feature areas that previously had no usage tracking:
SSO Configured) — tracks SAML, OIDC, and LDAP config creation and updates, withproviderandactionpropertiesApp Connection Created/App Connection Deleted) — tracks connection lifecycle withapp(typed asAppConnectionenum) andmethodpropertiesSecret Rotation V2 Created/Deleted/Executed) — tracks rotation lifecycle withtype(typed asSecretRotationenum),projectId,environment, andsecretPathGateway Cert Exchanged) — tracks gateway certificate exchange via theexchange-certendpointAll events follow the existing fire-and-forget pattern (
void ... .catch((err) => logger.error(...))). All events passorganizationIdat the top level (sourced fromreq.permission.orgId) for proper org-level grouping in PostHog.Updates since last revision
Addressed all review feedback (Devin Review + Greptile + human reviewer) across multiple rounds:
.catch(() => {})blocks with.catch((err) => logger.error(err, "..."))across all 6 router files (12 catch blocks) so telemetry failures are logged instead of silently swallowedimport { logger } from "@app/lib/logger"to the 4 files that didn't already have it (gateway-router, oidc-router, secret-rotation-v2-endpoints, app-connection-endpoints)organizationId: req.permission.orgIdto all three Secret Rotation V2 events for proper org-level PostHog groupingorgIdfrompropertiesacross SSO, App Connection, and Gateway events (org association is handled by the top-levelorganizationIdfield)gatewayIdtocertificateSerialNumberin the Gateway event to clarify it holds a TLS cert serial number, not a DB gateway IDGatewayCreatedtoGatewayCertExchangedsinceexchange-certfires on both first-time provisioning and cert renewalsif (authProvider)guard on SAML update handler — now always fires telemetry withauthProvider ?? "saml"fallback, consistent with LDAP/OIDC update handlersappproperty type fromstringtoAppConnectionenum inTAppConnectionCreatedEventandTAppConnectionDeletedEventfor stronger typingenvironmentandsecretPathtoSecretRotationV2DeletedandSecretRotationV2Executedevents (sourced fromsecretRotation.environment.slugandsecretRotation.folder.path) for consistency with the Created eventreq.permission.orgIdinstead ofreq.body.organizationIdto prevent spoofed org attributiontypeproperty in all three Secret Rotation V2 event types fromstringtoSecretRotationenum for compile-time safetytelemetry-types.tsto satisfysimple-import-sort/importslint ruleItems for human reviewer attention
certificateSerialNumber: The DB gateway ID is not returned byexchangeAllocatedRelayAddress. If correlating telemetry events with DB records is important, the service would need to be updated to also return the gateway ID.authProvideris not in the PATCH body, the telemetry event uses"saml"as the provider value. Verify this default is acceptable.method as stringcast inapp-connection-endpoints.ts: The genericmethodparameter is cast tostringfor the telemetry properties type. This is safe but worth a glance.secretRotation.environment.slugandsecretRotation.folder.pathare used — verify these are always populated on the object returned bydeleteSecretRotationandrotateSecretRotation.Steps to verify the change
telemetry-types.tsare correctly typed (includingAppConnectionandSecretRotationenum usage)organizationId: req.permission.orgIdat the top level (not insideproperties, and not fromreq.body).catch()blocks uselogger.errorwith a descriptive messagenpx tsc --noEmitinbackend/to confirm no type errorsType
Checklist
type(scope): short descriptionLink to Devin session: https://app.devin.ai/sessions/ff644e7024c8430f847cc431a8ef22b0
Requested by: @0xArshdeep