From c2e8ed62c9de31a7a11a4ef0336fa20274353ec5 Mon Sep 17 00:00:00 2001 From: Tom Meyer Date: Fri, 2 Sep 2022 10:01:50 -0400 Subject: [PATCH] v1.10.1 (#1777) ### Bug Fixes - Gracefully handle analytics-related error to prevent uncaught errors from blocking the search on load. (#1774) - Pinned the Google Maps API version to v3.47. This is the last one to officially support IE11. (#1681) --- package-lock.json | 2 +- package.json | 2 +- src/core/analytics/analyticsreporter.js | 7 ++++--- .../map/providers/googlemapprovider.js | 2 +- tests/core/analytics/analyticsreporter.js | 20 ++++++++++--------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index b80d5001d..4dac00c0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@yext/answers-search-ui", - "version": "1.10.0", + "version": "1.10.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 881355864..61f5d0b30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@yext/answers-search-ui", - "version": "1.10.0", + "version": "1.10.1", "description": "Javascript Answers Programming Interface", "main": "dist/answers-umd.js", "repository": { diff --git a/src/core/analytics/analyticsreporter.js b/src/core/analytics/analyticsreporter.js index bd38cbcd4..3325a50b6 100644 --- a/src/core/analytics/analyticsreporter.js +++ b/src/core/analytics/analyticsreporter.js @@ -1,7 +1,6 @@ /** @module AnalyticsReporter */ import AnalyticsEvent from './analyticsevent'; -import { AnswersAnalyticsError } from '../errors/errors'; import { PRODUCTION } from '../constants'; import HttpRequester from '../http/httprequester'; import { getAnalyticsUrl } from '../utils/urlutils'; @@ -98,11 +97,13 @@ export default class AnalyticsReporter { ytag('optin', true); cookieData = ytag('yfpc', null); } else if (this._conversionTrackingEnabled) { - throw new AnswersAnalyticsError('Tried to enable conversion tracking without including ytag'); + console.error('Tried to enable conversion tracking without including ytag'); + return false; } if (!(event instanceof AnalyticsEvent)) { - throw new AnswersAnalyticsError('Tried to send invalid analytics event', event); + console.error('Tried to send invalid analytics event', event); + return false; } if (includeQueryId) { diff --git a/src/ui/components/map/providers/googlemapprovider.js b/src/ui/components/map/providers/googlemapprovider.js index bf205ea08..dc2d79faf 100644 --- a/src/ui/components/map/providers/googlemapprovider.js +++ b/src/ui/components/map/providers/googlemapprovider.js @@ -98,7 +98,7 @@ export default class GoogleMapProvider extends MapProvider { onLoad(); }, async: true, - src: `https://maps.googleapis.com/maps/api/js?${self.generateCredentials()}&language=${self._language}` + src: `https://maps.googleapis.com/maps/api/js?${self.generateCredentials()}&language=${self._language}&v=3.47` }); DOM.append('body', script); diff --git a/tests/core/analytics/analyticsreporter.js b/tests/core/analytics/analyticsreporter.js index 2bbc8bb64..86441b1c5 100644 --- a/tests/core/analytics/analyticsreporter.js +++ b/tests/core/analytics/analyticsreporter.js @@ -1,6 +1,5 @@ import AnalyticsReporter from '../../../src/core/analytics/analyticsreporter'; import HttpRequester from '../../../src/core/http/httprequester'; -import { AnswersAnalyticsError } from '../../../src/core/errors/errors'; import AnalyticsEvent from '../../../src/core/analytics/analyticsevent'; import { getAnalyticsUrl } from '../../../src/core/utils/urlutils'; import { PRODUCTION } from '../../../src/core/constants'; @@ -21,10 +20,13 @@ describe('reporting events', () => { analyticsReporter = new AnalyticsReporter('abc123', null, '213412', true); }); - it('throws an error if given a non-AnalyticsEvent', () => { - expect(() => { - analyticsReporter.report({ event_type: 'fake event' }); - }).toThrow(AnswersAnalyticsError); + it('logs a console error if given a non-AnalyticsEvent', () => { + const consoleErrorSpy = jest.spyOn(console, 'error'); + expect(analyticsReporter.report({ event_type: 'fake event' })).toBeFalsy(); + expect(consoleErrorSpy).toHaveBeenLastCalledWith( + 'Tried to send invalid analytics event', + { event_type: 'fake event' } + ); }); it('sends the event via beacon in the "data" property', () => { @@ -68,11 +70,11 @@ describe('reporting events', () => { expect.anything()); }); - it('throws error if opted in and ytag missing', () => { + it('logs a console error if opted in and ytag missing', () => { analyticsReporter.setConversionTrackingEnabled(true); - expect(() => { - analyticsReporter.report(new AnalyticsEvent('thumbs_up')); - }).toThrow(AnswersAnalyticsError); + const consoleErrorSpy = jest.spyOn(console, 'error'); + expect(analyticsReporter.report(new AnalyticsEvent('thumbs_up'))).toBeFalsy(); + expect(consoleErrorSpy).toHaveBeenLastCalledWith('Tried to enable conversion tracking without including ytag'); }); it('includes cookies if opted in and ytag present', () => {