@@ -4,13 +4,14 @@ import {FeedbackType} from '../components/ThumbsFeedback';
44import { DefaultRawDataType } from '../models/index' ;
55import { useAnalytics } from './useAnalytics' ;
66import { GdaClickEventData } from '../components/GenerativeDirectAnswer'
7+ import { SearchAction } from "../models/SearchEventPayload" ;
78
89/**
910 * Analytics event types for cta click, title click, and citation click.
1011 *
1112 * @public
1213 */
13- export type CardCtaEventType = 'CTA_CLICK' | 'TITLE ' | 'CITATION_CLICK' | 'DRIVING_DIRECTIONS' | 'WEBSITE ' | 'TAP_TO_CALL' ;
14+ export type CardCtaEventType = 'CTA_CLICK' | 'TITLE_CLICK ' | 'CITATION_CLICK' | 'DRIVING_DIRECTIONS' | 'VIEW_WEBSITE ' | 'TAP_TO_CALL' ;
1415
1516/**
1617 * The data types use to construct the payload in the analytics event.
@@ -78,17 +79,19 @@ export function useCardAnalytics<T>(): (
7879 console . error ( 'Unable to report a CTA event. Missing field: experienceKey.' ) ;
7980 return ;
8081 }
82+ // convert the legacy card event type to the format the current reporter expects.
83+ let action :SearchAction = eventType === 'TITLE_CLICK' ? 'TITLE' : eventType === 'VIEW_WEBSITE' ? 'WEBSITE' : eventType ;
8184 analytics ?. report ( {
82- action : eventType ,
85+ action : action ,
8386 destinationUrl : url ,
8487 entity : entityId ,
8588 locale,
86- searchId,
87- queryId,
88- verticalKey : verticalKey || '' ,
89- isDirectAnswer,
90- isGenerativeDirectAnswer,
91- experienceKey,
89+ searchId,
90+ queryId,
91+ verticalKey : verticalKey || '' ,
92+ isDirectAnswer,
93+ isGenerativeDirectAnswer,
94+ experienceKey,
9295 } ) ;
9396 } , [ analytics , queryId , verticalKey ] ) ;
9497
@@ -141,7 +144,7 @@ export function useCardAnalytics<T>(): (
141144 if ( ! analytics ) {
142145 return ;
143146 }
144- if ( analyticsEventType === 'TITLE ' || analyticsEventType === 'CTA_CLICK' || analyticsEventType === 'CITATION_CLICK' || analyticsEventType === 'DRIVING_DIRECTIONS' || analyticsEventType === 'WEBSITE ' || analyticsEventType === 'TAP_TO_CALL' ) {
147+ if ( analyticsEventType === 'TITLE_CLICK ' || analyticsEventType === 'CTA_CLICK' || analyticsEventType === 'CITATION_CLICK' || analyticsEventType === 'DRIVING_DIRECTIONS' || analyticsEventType === 'VIEW_WEBSITE ' || analyticsEventType === 'TAP_TO_CALL' ) {
145148 reportCtaEvent ( cardResult , analyticsEventType ) ;
146149 }
147150 if ( analyticsEventType === 'THUMBS_DOWN' || analyticsEventType === 'THUMBS_UP' ) {
0 commit comments