Skip to content

Commit

Permalink
chore: error handling for standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
chicharr committed Sep 18, 2024
1 parent ec4e6ea commit d854a0f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit d854a0f

Please sign in to comment.