Skip to content

Commit

Permalink
Merge 96d6e72 into f6baeb1
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeyer2115 authored Sep 2, 2022
2 parents f6baeb1 + 96d6e72 commit bdf88f0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
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": "@yext/answers-search-ui",
"version": "1.10.0",
"version": "1.10.1",
"description": "Javascript Answers Programming Interface",
"main": "dist/answers-umd.js",
"repository": {
Expand Down
7 changes: 4 additions & 3 deletions src/core/analytics/analyticsreporter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/map/providers/googlemapprovider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 11 additions & 9 deletions tests/core/analytics/analyticsreporter.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit bdf88f0

Please sign in to comment.