From 56a809823423099a8acf05d57b7c53af51e2c3f0 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 2 Jan 2025 20:30:00 +0100 Subject: [PATCH] Updated url. --- src/metriki/static/metriki.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/metriki/static/metriki.js b/src/metriki/static/metriki.js index c2dfd60..c687f71 100644 --- a/src/metriki/static/metriki.js +++ b/src/metriki/static/metriki.js @@ -26,9 +26,20 @@ class Metriki { } } emit(data){ - this.ws.send(JSON.stringify(data)) + const me = this + try{ + this.ws.send(JSON.stringify(data)) + }catch(e){ + this.isConnected = false + setTimeout(() => { + me.emitVisit() + },500) + } } emitVisit(){ + if(!(this.isRendered && this.isConnected)) { + return; + } this.emit({"href":window.location.href,"html":document.documentElement.outerHTML,"title":document.title,"domain":window.location.host}) this.addEventListeners() }