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

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add telemetry for rls tester run query
  • Loading branch information
joshenlim committed May 12, 2026
commit cf1c904477d471ef6e7475556b788df7785aafec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
SelectTrigger,
SelectValue,
} from '@ui/components/shadcn/ui/select'
import { LOCAL_STORAGE_KEYS } from 'common'
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { Code, ExternalLink } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import {
Expand Down Expand Up @@ -42,6 +42,7 @@ import type { Policy } from '@/components/interfaces/Auth/Policies/PolicyTableRo
import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import { AiAssistantDropdown } from '@/components/ui/AiAssistantDropdown'
import { FeaturePreviewBadge } from '@/components/ui/FeaturePreviewBadge'
import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'
import { useRoleImpersonationStateSnapshot } from '@/state/role-impersonation-state'
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
Expand All @@ -51,10 +52,13 @@ interface RLSTesterSheetProps {
}

export const RLSTesterSheet = ({ handleSelectEditPolicy }: RLSTesterSheetProps) => {
const { ref } = useParams()
const aiSnap = useAiAssistantStateSnapshot()
const { openSidebar } = useSidebarManagerSnapshot()
const { setRole } = useRoleImpersonationStateSnapshot()

const { mutate: sendEvent } = useSendEventMutation()

const [open, setOpen] = useState(false)
const [selectedOption, setSelectedOption] = useState<'anon' | 'authenticated'>('anon')

Expand Down Expand Up @@ -103,8 +107,18 @@ export const RLSTesterSheet = ({ handleSelectEditPolicy }: RLSTesterSheetProps)
if (format === 'lib') {
if (!inferredSQL) return
await testQuery({ value: acceptUntrustedSql(inferredSQL), ...executionCallbacks })
sendEvent({
action: 'rls_tester_query_ran',
properties: { type: 'inferred' },
groups: { project: ref ?? 'Unknown' },
})
} else {
await testQuery({ value, ...executionCallbacks })
sendEvent({
action: 'rls_tester_query_ran',
properties: { type: 'raw' },
groups: { project: ref ?? 'Unknown' },
})
}
}

Expand Down
13 changes: 13 additions & 0 deletions packages/common/telemetry-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3439,6 +3439,18 @@ export interface HeaderLocalVersionPopoverOpenedEvent {
groups: Partial<TelemetryGroups>
}

/**
* User ran a query in the RLS tester feature preview.
*
* @group Events
* @source studio
*/
export interface RLSTesterQueryRanEvent {
action: 'rls_tester_query_ran'
properties: { type: 'raw' | 'inferred' }
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
groups: Partial<TelemetryGroups>
}

/**
* @hidden
*/
Expand Down Expand Up @@ -3638,3 +3650,4 @@ export type TelemetryEvent =
| HeaderUserDropdownOpenedEvent
| HeaderLocalDropdownOpenedEvent
| HeaderLocalVersionPopoverOpenedEvent
| RLSTesterQueryRanEvent
Loading