feat: add PostHog telemetry events for secrets management features#5730
feat: add PostHog telemetry events for secrets management features#57300xArshdeep merged 13 commits intomainfrom
Conversation
Add 8 new PostHog event types for tracking adoption and usage of: - Secret folder creation - Secret import creation - Secret sharing (create + view) - Webhook creation - PIT rollback performed - Secret reminder creation - Environment creation 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 for 8 previously un-tracked secrets management actions: Key implementation details:
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 05db8b2 |
Co-Authored-By: arsh <[email protected]>
…public view tracking Co-Authored-By: arsh <[email protected]>
…eptile review Co-Authored-By: arsh <[email protected]>
Co-Authored-By: arsh <[email protected]>
|
Addressed latest Greptile comment in 8bbaba4: Updated both |
… safety Co-Authored-By: arsh <[email protected]>
…anizationId optional Co-Authored-By: arsh <[email protected]>
|
Addressed latest Greptile comment (SecretShared not tracked for
|
…uthy check Co-Authored-By: arsh <[email protected]>
…retViewed properties Co-Authored-By: arsh <[email protected]>
Co-Authored-By: arsh <[email protected]>
…endpoint - Add SecretReminderCreated telemetry to secret-reminder-router.ts POST handler covering one-time reminders (via nextReminderDate) and recurring reminders - Add SecretFolderCreated telemetry to PIT /batch/commit endpoint for bulk folder creation - Update TSecretReminderCreatedEvent type: add isOneTime flag, make reminderRepeatDays optional, remove redundant location fields - Update TSecretFolderCreatedEvent type: make folderId/folderPath optional, add folderName for PIT commit context - Update v4 secret-router to match new type shape Co-Authored-By: arsh <[email protected]>
Co-Authored-By: arsh <[email protected]>
Co-Authored-By: arsh <[email protected]>
Context
Adds PostHog telemetry tracking for 8 secrets management features that previously had audit log coverage but no product analytics instrumentation. These events were identified from a gap analysis of the secrets management surface area, filtered to only high-signal, user-initiated actions.
New events:
Secret Folder Createdv2/secret-folder-router,ee/v1/pit-router(/batch/commit)Secret Import Createdv2/secret-import-routerSecret Sharedv1/secret-sharing-routerShared Secret Viewedv1/secret-sharing-routerSecret Rollback Performedee/v1/pit-routerWebhook Createdv1/webhook-routerSecret Reminder Createdv4/secret-router,v1/reminder-routers/secret-reminder-routerEnvironment Createdv1/project-env-routerAll events follow the existing pattern: fire after the audit log call, using
getTelemetryDistinctId(req)andreq.permission.orgId.Updates since last revision
Addressed reviewer feedback from @carlosmonastyrski:
SecretReminderCreatednow covers one-time reminders. Added telemetry to the dedicated reminder router (secret-reminder-router.ts), which handles reminders set vianextReminderDate. The event includes anisOneTimeboolean to distinguish one-time vs. recurring reminders. The> 0guard in the v4 secret-router remains correct for that endpoint (recurring reminders only).SecretFolderCreatednow fires from PIT/batch/commit. The commit endpoint creates folders in bulk but previously had no folder telemetry. Events now fire viaPromise.allfor each folder inchanges.folders.create.TSecretReminderCreatedEventtype updated.reminderRepeatDaysis now optional (one-time reminders don't have it);isOneTimeflag added; redundantprojectId/environment/secretPathremoved (available viasecretIdlookup).TSecretFolderCreatedEventtype updated.folderId/folderPathmade optional,folderNameadded — the PIT commit endpoint doesn't return created folder IDs.Previous rounds addressed Greptile review feedback:
SharedSecretViewedfires for public (no-org) secrets. Moved telemetry outside theif (sharedSecret.orgId)guard;organizationIduses?? undefinedfor the null case.SecretReminderCreatedPATCH guard tightened. Uses!== undefined && !== nullso it only fires when the client explicitly includessecretReminderRepeatDays.organizationIdnaming follows the newer convention fromTSecretRequestCreatedEvent/TSecretRequestDeletedEvent.WebhookTypeandSecretSharingAccessTypeenum precision.typeproperty usesWebhookTypeinstead ofstring;accessTypeusesSecretSharingAccessTypewith a cast for the DB value.SecretSharedtracked onPOST /publicendpoint. Unauthenticated shared-secret creation now emits telemetry withanonymous-${sharedSecret.id}asdistinctIdand noorganizationId.SecretReminderCreated> 0guard added. Prevents the event from firing whensecretReminderRepeatDaysis0, matching the service layer's truthy check that actually creates the reminder.organizationIdfrom event properties. The top-levelorganizationIdfield onTPostHogEventalready drivespostHog.groupIdentify; the duplicate insidepropertieswas unnecessary.Steps to verify the change
npm run type:check— no new errors introduced)sendPostHogEventscall is placed after the correspondingcreateAuditLogcalltelemetry-types.tsmatch what's passed in route handlersItems for reviewer attention
SecretReminderCreatedfires on both create (POST) and update (PATCH) inv4/secret-router.ts. The guard checks> 0and!== undefined && !== null, but it cannot diff against the previous reminder value sinceupdateSecretRawreturns the already-updated secret. Re-sending the same reminder value alongside other changes will still fire the event.SharedSecretViewedusesanonymous-${req.params.id}asdistinctIdfor unauthenticated viewers. This creates anonymous PostHog profiles keyed by shared secret ID.sharedSecret.accessType as SecretSharingAccessType— type cast from the DB string value. If the DB contains a value outside the enum, this would silently pass at runtime./batch/committracks folder creation but not secret creation. Carlos's comment mentioned both resources — verify whetherSecretCreatedtelemetry is also needed forchanges.secrets.createin this endpoint.TSecretFolderCreatedEventhas all optional identifier fields (folderPath,folderId,folderName). The folder router sendsfolderPath+folderId; the PIT commit endpoint sendsfolderName. No call sends all three. Verify this is acceptable vs. requiring at least one.Type
Checklist
type(scope): short descriptionLink to Devin session: https://app.devin.ai/sessions/bfcfbd16cf444133b7a4cbdfdbd815aa
Requested by: @0xArshdeep