Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly pass
searcher
in DA analytics (#1106)
Update the direct answer card component to correctly pass the `searcher` as part of analytics events. Like in the SDK, 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 `addDefaultEventOptions` 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 `this._config.data.searcher` directly fixes this issue. Since this data is available in the config, I updated all references to `searcher` and removed it from state so there is no ambiguity in how the information is being set/updated. See [this Slack thread](https://yext.slack.com/archives/C016ZKY42CF/p1666202290083719) where the issue was raised for more context. J=TECHOPS-7011 TEST=manual Spin up the test-site and test on both universal and vertical pages. 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 and RTF analytics requests continued to pass the `searcher` correctly.
- Loading branch information