Skip to content

Commit

Permalink
Merge pull request #961 from yext/hotfix/v1.24.1
Browse files Browse the repository at this point in the history
### Bug Fixes
* RTF click analytics no longer fire twice on results cards. Direct answer cards have been unchanged.
  • Loading branch information
oshi97 authored Sep 28, 2021
2 parents c345e23 + 7edda52 commit 1ac89a7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 42 deletions.
38 changes: 0 additions & 38 deletions cards/card_component.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component {
})
);
}

const rtfElement = this._container.querySelector('.js-yxt-rtfValue');
if (rtfElement) {
const fieldName = rtfElement.dataset.fieldName;
rtfElement.addEventListener('click', e => this._handleRtfClickAnalytics(e, fieldName));
}
}

setState(data) {
Expand Down Expand Up @@ -94,38 +88,6 @@ BaseCard["{{componentName}}"] = class extends ANSWERS.Component {
);
}

/**
* A click handler for links in a Rich Text attriubte. When such a link is
* clicked, an {@link AnalyticsEvent} needs to be fired.
*
* @param {MouseEvent} event The click event.
* @param {string} fieldName The name of the Rich Text field used in the
* attriubte.
*/
_handleRtfClickAnalytics (event, fieldName) {
const ctaType = event.target.dataset.ctaType;
if (!ctaType) {
return;
}

const analyticsOptions = {
directAnswer: false,
verticalKey: this.verticalKey,
searcher: this._config.isUniversal ? 'UNIVERSAL' : 'VERTICAL',
entityId: this.result.id,
url: event.target.href
};
if (!fieldName) {
console.warn('Field name not provided for RTF click analytics');
} else {
analyticsOptions.fieldName = fieldName;
}

const analyticsEvent = new ANSWERS.AnalyticsEvent(ctaType);
analyticsEvent.addOptions(analyticsOptions);
this.analyticsReporter.report(analyticsEvent);
}

static get type() {
return `{{componentName}}`;
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "answers-hitchhiker-theme",
"version": "1.24.0",
"version": "1.24.1",
"description": "A starter answers theme for hitchhikers",
"scripts": {
"test": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --verbose",
Expand Down
2 changes: 1 addition & 1 deletion static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "answers-hitchhiker-theme",
"version": "1.24.0",
"version": "1.24.1",
"description": "Toolchain for use with the HH Theme",
"main": "Gruntfile.js",
"scripts": {
Expand Down

0 comments on commit 1ac89a7

Please sign in to comment.