From 166e5a23df77e08653e286308f8821aad0dbc10d Mon Sep 17 00:00:00 2001 From: Alex Florisca Date: Fri, 8 Jun 2018 15:59:24 +0100 Subject: [PATCH] Stop error from google ads sdk spamming sentry (#121) * Stop error from google ads sdk spamming sentry * Static method * Fixed tests * OOps --- src/js/ads.js | 3 +-- src/js/video.js | 2 +- test/ads.test.js | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/js/ads.js b/src/js/ads.js index 087b5df..2c41c71 100644 --- a/src/js/ads.js +++ b/src/js/ads.js @@ -21,7 +21,7 @@ class VideoAds { this.adsCompleted = false; } - loadAdsLibrary() { + static loadAdsLibrary() { return new Promise((resolve, reject) => { let googleSdkScript = document.querySelector('[src="//imasdk.googleapis.com/js/sdkloader/ima3.js"]'); @@ -43,7 +43,6 @@ class VideoAds { }); googleSdkScript.addEventListener('error', (e) => { - this.reportError(e); reject(e); }); } diff --git a/src/js/video.js b/src/js/video.js index 7e578b0..c45054b 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -201,7 +201,7 @@ class Video { } init() { - return (this.opts.advertising ? this.videoAds.loadAdsLibrary() : Promise.resolve()) + return (this.opts.advertising ? VideoAds.loadAdsLibrary() : Promise.resolve()) .catch(() => { // If ad doesn't load for some reason, load video as normal this.opts.advertising = false; diff --git a/test/ads.test.js b/test/ads.test.js index 5d1f180..0013f13 100644 --- a/test/ads.test.js +++ b/test/ads.test.js @@ -40,7 +40,7 @@ describe('Ads', () => { }); it('should add the video advertising script if the configuration parameter is passed', () => { - return ads.loadAdsLibrary() + return Ads.loadAdsLibrary() .then(() => { proclaim.ok(document.querySelector('[src="//imasdk.googleapis.com/js/sdkloader/ima3.js"]')); });