Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e31ce6d

Browse files
authored
feat: add feature preview events (supabase#31215)
1 parent 2f63366 commit e31ce6d

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ const FeaturePreviewModal = () => {
2222
const isNotReleased =
2323
selectedFeatureKey === 'supabase-ui-functions-assistant' && !enableFunctionsAssistant
2424

25-
// this modal can be triggered on other pages
26-
// Update local state when valtio state changes
27-
useEffect(() => {
28-
if (snap.selectedFeaturePreview !== '') {
29-
setSelectedFeatureKey(snap.selectedFeaturePreview)
30-
}
31-
}, [snap.selectedFeaturePreview])
32-
3325
const { flags, onUpdateFlag } = featurePreviewContext
3426
const selectedFeature = FEATURE_PREVIEWS.find((preview) => preview.key === selectedFeatureKey)
3527
const isSelectedFeatureEnabled = flags[selectedFeatureKey]
@@ -49,6 +41,20 @@ const FeaturePreviewModal = () => {
4941
snap.setSelectedFeaturePreview(FEATURE_PREVIEWS[0].key)
5042
}
5143

44+
// this modal can be triggered on other pages
45+
// Update local state when valtio state changes
46+
useEffect(() => {
47+
if (snap.selectedFeaturePreview !== '') {
48+
setSelectedFeatureKey(snap.selectedFeaturePreview)
49+
}
50+
}, [snap.selectedFeaturePreview])
51+
52+
useEffect(() => {
53+
if (snap.showFeaturePreviewModal) {
54+
sendEvent({ action: TelemetryActions.FEATURE_PREVIEWS_CLICKED })
55+
}
56+
}, [snap.showFeaturePreviewModal])
57+
5258
return (
5359
<Modal
5460
hideFooter

apps/studio/lib/constants/telemetry.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export enum TelemetryActions {
2222
CRON_JOB_CREATE_CLICKED = 'cron_job_create_clicked',
2323
CRON_JOB_HISTORY_CLICKED = 'cron_job_history_clicked',
2424

25+
FEATURE_PREVIEWS_CLICKED = 'feature_previews_clicked',
2526
FEATURE_PREVIEW_ENABLED = 'feature_preview_enabled',
2627
FEATURE_PREVIEW_DISABLED = 'feature_preview_disabled',
2728

@@ -159,3 +160,33 @@ export interface CronJobDeleteClickedEvent {
159160
export interface CronJobHistoryClickedEvent {
160161
action: TelemetryActions.CRON_JOB_HISTORY_CLICKED
161162
}
163+
164+
/**
165+
* The FeaturePreviewModal was opened.
166+
*
167+
* The FeaturePreviewModal can be opened clicking at the profile icon at the bottom left corner of the project sidebar.
168+
*
169+
* @group Events
170+
* @source studio
171+
*/
172+
export interface FeaturePreviewsClickedEvent {
173+
action: TelemetryActions.FEATURE_PREVIEWS_CLICKED
174+
}
175+
176+
/**
177+
* A feature preview was disabled by the user through the FeaturePreviewModal.
178+
*
179+
* The FeaturePreviewModal can be opened clicking at the profile icon at the bottom left corner of the project sidebar.
180+
*
181+
* @group Events
182+
* @source studio
183+
*/
184+
export interface FeaturePreviewDisabledEvent {
185+
action: TelemetryActions.FEATURE_PREVIEW_DISABLED
186+
properties: {
187+
/**
188+
* Feature key of the preview that was disabled. e.g. supabase-ui-api-side-panel
189+
*/
190+
feature: string
191+
}
192+
}

apps/studio/state/app-state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { proxy, subscribe, snapshot, useSnapshot } from 'valtio'
21
import type { Message as MessageType } from 'ai/react'
2+
import { LOCAL_STORAGE_KEYS as COMMON_LOCAL_STORAGE_KEYS } from 'common'
33
import { SupportedAssistantEntities } from 'components/ui/AIAssistantPanel/AIAssistant.types'
44
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
5-
import { LOCAL_STORAGE_KEYS as COMMON_LOCAL_STORAGE_KEYS } from 'common'
5+
import { proxy, snapshot, subscribe, useSnapshot } from 'valtio'
66

77
export type CommonDatabaseEntity = {
88
id: number

0 commit comments

Comments
 (0)