From e521883ada9d7fc60fb68ea80ef7d1e6c7f9bc5c Mon Sep 17 00:00:00 2001 From: nmanu1 <88398086+nmanu1@users.noreply.github.com> Date: Tue, 25 Oct 2022 12:41:19 -0400 Subject: [PATCH 1/2] 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. --- directanswercards/card_component.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/directanswercards/card_component.js b/directanswercards/card_component.js index 0fadc0462..c29a9e7a2 100644 --- a/directanswercards/card_component.js +++ b/directanswercards/card_component.js @@ -25,7 +25,6 @@ BaseDirectAnswerCard["{{componentName}}"] = class extends ANSWERS.Component { this.validateDataForRender(cardData); return super.setState({ ...cardData, - searcher: data.searcher, feedbackEnabled: ANSWERS.getAnalyticsOptIn(), feedbackSubmitted: data.feedbackSubmitted, isArray: Array.isArray(this.answer.value), @@ -97,7 +96,7 @@ BaseDirectAnswerCard["{{componentName}}"] = class extends ANSWERS.Component { .addOptions({ directAnswer: true, verticalKey: this.verticalConfigId, - searcher: this.getState('searcher'), + searcher: this._config.data.searcher, entityId: this.associatedEntityId }); @@ -120,7 +119,7 @@ BaseDirectAnswerCard["{{componentName}}"] = class extends ANSWERS.Component { */ addDefaultEventOptions(eventOptions = {}) { return Object.assign({}, { - searcher: this.getState('searcher'), + searcher: this._config.data.searcher, verticalConfigId: this.verticalConfigId, entityId: this.associatedEntityId, ...eventOptions @@ -144,7 +143,7 @@ BaseDirectAnswerCard["{{componentName}}"] = class extends ANSWERS.Component { verticalKey: this.verticalConfigId, directAnswer: true, fieldName: this.answer.fieldApiName, - searcher: this.getState('searcher'), + searcher: this._config.data.searcher, entityId: this.associatedEntityId, url: event.target.href }; From aaad24e1fec29e933e3a22015728ef859a2af0aa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 25 Oct 2022 14:33:53 -0400 Subject: [PATCH 2/2] Update Package Version to v1.29.4 (#1105) *An automated PR which updates the version number in package.json and package-lock.json files* --- package-lock.json | 4 ++-- package.json | 4 ++-- static/package-lock.json | 4 ++-- static/package.json | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index b859993a1..3f25f8506 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "devDependencies": { "@axe-core/puppeteer": "^4.3.1", "@babel/core": "^7.9.6", diff --git a/package.json b/package.json index f795b784b..d6764a13e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "description": "A starter Search theme for hitchhikers", "keywords": [ - "jambo", + "jambo", "templates", "handlebars", "site", diff --git a/static/package-lock.json b/static/package-lock.json index 5e22674b6..fe4c1cac7 100644 --- a/static/package-lock.json +++ b/static/package-lock.json @@ -1,12 +1,12 @@ { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "license": "BSD-3-Clause", "dependencies": { "@vimeo/player": "^2.15.3", diff --git a/static/package.json b/static/package.json index d0299d8c6..a6b70ac14 100644 --- a/static/package.json +++ b/static/package.json @@ -1,6 +1,6 @@ { "name": "answers-hitchhiker-theme", - "version": "1.29.3", + "version": "1.29.4", "description": "Toolchain for use with the HH Theme", "main": "Gruntfile.js", "scripts": {