@@ -5,6 +5,8 @@ import { focusTrap } from '@primer/behaviors'
5
5
import { useTranslation } from '@/languages/components/useTranslation'
6
6
import { useMaxWidthBreakpoint , useMinWidthBreakpoint } from '../hooks/useBreakpoint'
7
7
import { useCTAPopoverContext } from '@/frame/components/context/CTAContext'
8
+ import { sendEvent } from '@/events/components/events'
9
+ import { EventType } from '@/events/types'
8
10
9
11
let previouslyFocused : HTMLElement | null = null
10
12
@@ -13,11 +15,13 @@ export function AISearchCTAPopup({
13
15
dismiss,
14
16
setIsSearchOpen,
15
17
isDismissible = true ,
18
+ bannerType = 'popover' ,
16
19
} : {
17
20
isOpen : boolean
18
21
dismiss ?: ( ) => void
19
22
setIsSearchOpen : ( value : boolean ) => void
20
23
isDismissible ?: boolean
24
+ bannerType ?: 'popover' | 'footer'
21
25
} ) {
22
26
const { t } = useTranslation ( 'search' )
23
27
const { permanentDismiss } = useCTAPopoverContext ( )
@@ -26,7 +30,21 @@ export function AISearchCTAPopup({
26
30
let overlayRef = useRef < HTMLDivElement > ( null )
27
31
let dismissButtonRef = useRef < HTMLButtonElement > ( null )
28
32
33
+ // Analytics helper functions
34
+ const sendCTAAnalytics = ( variation : 'dismiss' | 'ask_copilot' ) => {
35
+ const experimentName =
36
+ bannerType === 'footer' ? 'copilot_footer_banner' : 'copilot_popover_banner'
37
+ sendEvent ( {
38
+ type : EventType . experiment ,
39
+ experiment_name : experimentName ,
40
+ experiment_variation : variation ,
41
+ experiment_success : true ,
42
+ } )
43
+ }
44
+
29
45
const openSearch = ( ) => {
46
+ // Send analytics before taking action
47
+ sendCTAAnalytics ( 'ask_copilot' )
30
48
setIsSearchOpen ( true )
31
49
// They engaged with the CTA, so let's not show this popup for them anymore
32
50
permanentDismiss ( )
@@ -47,6 +65,8 @@ export function AISearchCTAPopup({
47
65
if ( isTooSmallForCTA ) {
48
66
return
49
67
}
68
+ // Send analytics before taking action
69
+ sendCTAAnalytics ( 'dismiss' )
50
70
if ( previouslyFocused ) {
51
71
previouslyFocused . focus ( )
52
72
}
0 commit comments