Skip to content

Commit

Permalink
Search bar only analytics fix (#1555)
Browse files Browse the repository at this point in the history
Fix the analytics for the search bar only assets

When analyticsEventsEnabled was added to the SDK, the parameter order of the AnalyticsReporter constructor changed and it broke analytics for the search bar only assets. This caused analytics to only be sent if `analyticsOptions` was present in the config. The data sent was also messed up.

Fix the parameter order so that it is the same as the regular SDK

J=none
TEST=manual

Build the search bar only assets and test analytics with voice search and the clear button. See that analytics are properly sent even without analyticsOptions existing, and see that the data is now correct. Test `setAnalyticsOptIn` and confirm that it can disable analytics
  • Loading branch information
cea2aj committed Sep 24, 2021
1 parent 7f600ea commit 702e751
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/answers-search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { SEARCH_BAR_COMPONENTS_REGISTRY } from './ui/components/search-bar-only-

const DEFAULTS = {
locale: LOCALE,
querySource: QUERY_SOURCE
querySource: QUERY_SOURCE,
analyticsEventsEnabled: true
};

/**
Expand Down Expand Up @@ -172,6 +173,7 @@ class AnswersSearchBar {
parsedConfig.experienceKey,
parsedConfig.experienceVersion,
parsedConfig.businessId,
parsedConfig.analyticsEventsEnabled,
parsedConfig.analyticsOptions,
parsedConfig.environment);

Expand Down Expand Up @@ -284,6 +286,14 @@ class AnswersSearchBar {
return this;
}

/**
* Opt in or out of analytic events
* @param {boolean} analyticsEventsEnabled
*/
setAnalyticsOptIn (analyticsEventsEnabled) {
this._analyticsReporterService.setAnalyticsOptIn(analyticsEventsEnabled);
}

/**
* Opt in or out of convertion tracking analytics
* @param {boolean} optIn
Expand Down

0 comments on commit 702e751

Please sign in to comment.