Files
supabase/packages
claude[bot]andClaude 4893c396db fix(studio): split cron_job_cleanup dialog-open from enable to stop double-counting (#48348)
<!-- ccr-slack-attribution -->
_Requested by **Pam Chia** · [Slack
thread](https://supabase.slack.com/archives/C076KTY11DF/p1785115156767339?thread_ts=1785115156.767339&cid=C076KTY11DF)_

## What kind of change does this PR introduce?

Bug fix (telemetry).

## What is the current behavior?

Clicking the header "Enable cleanup" button fires
`cron_job_cleanup_enable_button_clicked` when it merely OPENS the
confirmation dialog (`origin: 'header'`), and fires it AGAIN when the
dialog is confirmed (`origin: 'dialog'` + `retentionInterval`). So every
successful enable logs the event twice, and a naive
`count(cron_job_cleanup_enable_button_clicked)` roughly doubles the true
number of cleanups enabled. The dual-fire was introduced in #48200.

## What is the new behavior?

Opening the dialog fires a new `cron_job_cleanup_dialog_opened` event,
and `cron_job_cleanup_enable_button_clicked` fires only on confirm —
when cleanup is actually scheduled. Each event now maps 1:1 to a
distinct user action.

**How:**
- Added `cron_job_cleanup_dialog_opened` to the shared telemetry catalog
(`packages/common/telemetry-constants.ts`).
- Removed the now-redundant `origin` property from
`cron_job_cleanup_enable_button_clicked` (the two events encode what
`origin` used to); kept `retentionInterval`.
- Updated the emit sites in
`apps/studio/components/interfaces/Integrations/CronJobs/CronJobsTab.EnableCleanupButton.tsx`:
the header open now sends `cron_job_cleanup_dialog_opened`; the dialog
confirm sends `cron_job_cleanup_enable_button_clicked` with just
`retentionInterval`.

## Additional context

`origin` already technically separated the two paths
(`count(origin='dialog')` gave the true number), but splitting into two
named events removes the footgun of anyone aggregating the raw event.

Note for reviewers: I kept the existing event key
`cron_job_cleanup_enable_button_clicked` for the confirm path rather
than renaming it to something like `cron_job_cleanup_enabled` — happy to
rename if preferred, but keeping the key avoids churn on such a new
event.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Analytics**
* Improved tracking for the cron job cleanup flow by distinguishing when
the cleanup confirmation dialog is opened from when cleanup is enabled.
* Updated event details to more accurately reflect the cleanup
scheduling and confirmation steps.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-27 23:29:36 +08:00
..