Fix table_quickstart_opened event to track control group (#39986)

* Fix table_quickstart_opened event to track control group

Previously, the control group was excluded from exposure tracking because
activeQuickstartVariant filtered out CONTROL variants. This prevented
establishing a baseline for A/B test analysis.

Changes:
- Add shouldTrackExposure variable to separate tracking from rendering logic
- Track all variants including control when conditions are met
- Add explicit type narrowing for TypeScript safety
- Update comment to document control as valid variant

The event now fires for all users in the experiment (including control)
when viewing NewTab on projects < 7 days old in table editor mode.

* Update apps/studio/components/layouts/Tabs/NewTab.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Sean OliverandCopilot authored and GitHub committed 2025-10-29 13:38:45 -06:00
1 parent 5ac87590ce
commit c52e8b53aa
1 file changed
+10 -4
+10 -4
View File
@@ -81,7 +81,7 @@ export function NewTab() {
/**
* Returns:
* - `QuickstartVariant`: user variation (`ai`, `templates`, `assistant`)
* - `QuickstartVariant`: user variation (`control`, `ai`, `templates`, `assistant`)
* - `false`: user not yet bucketed or not targeted for experiment
* - `undefined`: PostHog still loading
*/
@@ -102,14 +102,20 @@ export function NewTab() {
? tableQuickstartVariant
: null
const shouldTrackExposure =
editor !== 'sql' &&
isNewProject &&
tableQuickstartVariant !== false &&
tableQuickstartVariant !== undefined
useEffect(() => {
if (activeQuickstartVariant && !hasTrackedExposure.current) {
if (shouldTrackExposure && !hasTrackedExposure.current) {
hasTrackedExposure.current = true
track('table_quickstart_opened', {
variant: activeQuickstartVariant,
variant: tableQuickstartVariant,
})
}
}, [activeQuickstartVariant, track])
}, [shouldTrackExposure, tableQuickstartVariant, track])
const handleOpenAssistant = () => {
if (isCreatingChat) return