Skip to content

Commit

Permalink
Correctly pass searcher in DA analytics (#1786)
Browse files Browse the repository at this point in the history
Update the direct answer component to correctly pass the `searcher` as part of analytics events.

For RTF and thumbs feedback analytics events, the `searcher` was passed correctly because the options for those analytics events are set from `onMount`, at which point the `searcher` has been set in state. But, for other analytics events like CTA clicks that used `eventOptions` to set the options, the `searcher` is not necessarily set in state before the options for those events are calculated. In these cases, `this.getState('searcher')` returned `undefined`, so clicking on a CTA would hit the analytics endpoint without the required `searcher` data and get an error in the response. Using `data.searcher` directly fixes this issue.

See [this Slack thread](https://yext.slack.com/archives/C016ZKY42CF/p1666202290083719) where the issue was raised for more context.

J=TECHOPS-7011
TEST=manual

Serve the SDK locally with a direct answer component on a universal and vertical page. See that without this change, CTA clicks would result in a bad request to the analytics endpoint with the error `Record missing required field: searcher`. With this change, the correct value for `searcher` was sent in the request. Thumbs feedback analytics requests continued to pass the `searcher` correctly.
  • Loading branch information
nmanu1 committed Oct 25, 2022
1 parent 53c4685 commit ea3095a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/components/results/directanswercomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default class DirectAnswerComponent extends Component {
}
return JSON.stringify({
verticalConfigId: data.relatedItem?.verticalConfigId,
searcher: this.getState('searcher'),
searcher: data.searcher,
entityId: data.relatedItem?.data.id,
ctaLabel: this._viewDetailsText.toUpperCase().replace(' ', '_')
});
Expand Down

0 comments on commit ea3095a

Please sign in to comment.