mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 04:34:15 -04:00
(errorhandling) ignore loading errors for ad and gtm scripts
most of the time these are CORS errors which need separate investigation but as these errors are quite common, they keep coming in sentry
This commit is contained in:
parent
f990ebf1fd
commit
14ee946971
@ -40,6 +40,7 @@ import dark from '../plugins/dark.ts';
|
|||||||
import sorter from 'avris-sorter';
|
import sorter from 'avris-sorter';
|
||||||
import { sleep } from '../src/helpers.ts';
|
import { sleep } from '../src/helpers.ts';
|
||||||
import md5 from 'js-md5';
|
import md5 from 'js-md5';
|
||||||
|
import { LoadScriptError } from '../src/errors.ts';
|
||||||
import type { default as dialogueBox, DialogueMessage } from '../components/DialogueBox.vue';
|
import type { default as dialogueBox, DialogueMessage } from '../components/DialogueBox.vue';
|
||||||
import type { Color } from '../src/bootstrap.ts';
|
import type { Color } from '../src/bootstrap.ts';
|
||||||
|
|
||||||
@ -217,14 +218,28 @@ export default dark.extend({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.$loadScript('publift', 'https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js');
|
try {
|
||||||
|
await this.$loadScript('publift', 'https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js');
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof LoadScriptError) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async loadGTM(): Promise<void> {
|
async loadGTM(): Promise<void> {
|
||||||
if (!this.adsEnabled) {
|
if (!this.adsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.$loadScript('gtm', 'https://www.googletagmanager.com/gtag/js?id=G-TDJEP12Q3M');
|
try {
|
||||||
|
await this.$loadScript('gtm', 'https://www.googletagmanager.com/gtag/js?id=G-TDJEP12Q3M');
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof LoadScriptError) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag(..._args: unknown[]): void {
|
function gtag(..._args: unknown[]): void {
|
||||||
|
@ -11,6 +11,7 @@ import type { RootState } from '../store/index.ts';
|
|||||||
|
|
||||||
import translations from '../data/translations.suml';
|
import translations from '../data/translations.suml';
|
||||||
import baseTranslations from '../locale/_base/translations.suml';
|
import baseTranslations from '../locale/_base/translations.suml';
|
||||||
|
import { LoadScriptError } from '../src/errors.ts';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@ -96,7 +97,7 @@ export default ({ app, store }: { app: Vue, store: Store<RootState> }): void =>
|
|||||||
script.crossOrigin = 'true';
|
script.crossOrigin = 'true';
|
||||||
script.addEventListener('load', () => resolve());
|
script.addEventListener('load', () => resolve());
|
||||||
script.addEventListener('error', (event) => {
|
script.addEventListener('error', (event) => {
|
||||||
reject(new Error(`failed to load ${name} (${src}): ${typeof event === 'string' ? event : event.type}`));
|
reject(new LoadScriptError(name, src, typeof event === 'string' ? event : event.type));
|
||||||
});
|
});
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
});
|
});
|
||||||
|
6
src/errors.ts
Normal file
6
src/errors.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export class LoadScriptError extends Error {
|
||||||
|
constructor(scriptName: string, src: string, type: string) {
|
||||||
|
super(`failed to load ${scriptName} (${src}): ${type}`);
|
||||||
|
this.name = this.constructor.name;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user