From d854a0ffa87e47b5e8a0481a33970eb979c13352 Mon Sep 17 00:00:00 2001 From: Francisco Chicharro Sanz Date: Wed, 18 Sep 2024 14:50:36 +0200 Subject: [PATCH] chore: error handling for standalone --- src/standalone.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/standalone.js b/src/standalone.js index 861ff0e..f578d7b 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -11,10 +11,15 @@ */ import { sampleRUM } from './index.js'; -const scriptSrc = (document.currentScript && document.currentScript.src) - ? new URL(document.currentScript.src, window.location.origin).origin : null; -const scriptParams = (document.currentScript && document.currentScript.dataset) - ? document.currentScript.dataset : null; -window.RUM_BASE = window.RUM_BASE || scriptSrc; -window.RUM_PARAMS = window.RUM_PARAMS || scriptParams; -sampleRUM(); +try { + const scriptSrc = (document.currentScript && document.currentScript.src) + ? new URL(document.currentScript.src, window.location.origin).origin : null; + const scriptParams = (document.currentScript && document.currentScript.dataset) + ? document.currentScript.dataset : null; + window.RUM_BASE = window.RUM_BASE || scriptSrc; + window.RUM_PARAMS = window.RUM_PARAMS || scriptParams; + + sampleRUM(); +} catch (error) { + // something went wrong +}