diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a3b858..630b02a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +## [v3.5.4](https://github.com/gbmhunter/NinjaCalc/tree/v3.5.4) (2024-03-31) + +* Added Umami analytics script. + ## [v3.5.3](https://github.com/gbmhunter/NinjaCalc/tree/v3.5.3) (2024-01-10) * Fixed incorrect URL to the NinjaCalc app from the homepage. diff --git a/package.json b/package.json index e6c949e..b79adc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ninja-calc", - "version": "3.5.2", + "version": "3.5.4", "private": true, "scripts": { "dev": "next dev", diff --git a/pages/_document.js b/pages/_document.js index 30a78ce..140f152 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -83,6 +83,9 @@ class MyDocument extends Document { }} /> + {/* Umami analytics. Tracking is disabled in dev. by setting + umami.disabled in local storage to 1. */} + diff --git a/pages/index.js b/pages/index.js index 632730d..93ab046 100644 --- a/pages/index.js +++ b/pages/index.js @@ -88,7 +88,17 @@ class Home extends React.Component { this.addCalc(CalcMovingAverageFilterDesigner) } - componentDidMount = () => {} + componentDidMount = () => { + // Enable Umami analytics script in production and disable + // in dev. environment. Use the umami.disabled key in local storage for doing so + if (process.env.NODE_ENV === 'production') { + // It's not good enough just to set the key to 0, it needs to be removed + window.localStorage.removeItem('umami.disabled'); + } else { + console.log('Detected dev. environment, setting umami.disabled in local storage to "1".'); + window.localStorage.setItem('umami.disabled', '1'); + } + } addCalc = (calcModule) => { let calculators = this.state.calculators