Skip to content

Commit 39e70b3

Browse files
committed
Formatting changes, keeping the old event type for reporter
1 parent 89b34f0 commit 39e70b3

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

docs/search-ui-react.cardctaeventtype.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@ Analytics event types for cta click, title click, and citation click.
99
**Signature:**
1010

1111
```typescript
12-
<<<<<<< HEAD
13-
type CardCtaEventType = 'CTA_CLICK' | 'TITLE' | 'CITATION_CLICK';
14-
=======
15-
type CardCtaEventType = 'CTA_CLICK' | 'TITLE_CLICK' | 'CITATION_CLICK' | 'DRIVING_DIRECTIONS' | 'VIEW_WEBSITE' | 'TAP_TO_CALL';
16-
>>>>>>> main
17-
```

src/hooks/useCardAnalytics.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import {FeedbackType} from '../components/ThumbsFeedback';
44
import {DefaultRawDataType} from '../models/index';
55
import {useAnalytics} from './useAnalytics';
66
import {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') {

src/models/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ export { StandardCardData, CtaData, isCtaData } from './StandardCardData';
33
export { SectionProps, SectionComponent } from './sectionComponent';
44
export { VerticalLink } from './verticalLink';
55
export { VerticalConfig, VerticalConfigMap } from './verticalConfig';
6-
export { DefaultRawDataType } from './DefaultRawDataType';
6+
export { DefaultRawDataType } from './DefaultRawDataType';
7+
export {SearchAnalyticsEventService} from './SearchAnalyticsEventService'

0 commit comments

Comments
 (0)