Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Added error handling for JSON.parse

perso182109e8d6d31cb
diff --git a/src/tracker/index.js b/src/tracker/index.js
index 2f0fe8267..fa5a30e9d 100644
--- a/src/tracker/index.js
+++ b/src/tracker/index.js
@@ -233,7 +233,12 @@
};
const track = (obj, data) => {
- const identity = JSON.parse(localStorage.getItem('umami.identity'));
+ let identity;
+ try {
+ identity = JSON.parse(localStorage.getItem('umami.identity'));
+ } catch (error) {
+ identity = null;
+ }
if (typeof obj === 'string') {
return send({
...getPayload(),