diff --git a/api/src/third-parties/matomo.js b/api/src/third-parties/matomo.js index a582800a8..51b1b626d 100644 --- a/api/src/third-parties/matomo.js +++ b/api/src/third-parties/matomo.js @@ -1,6 +1,7 @@ // https://developer.matomo.org/api-reference/tracking-api const fetch = require("node-fetch"); const { MATOMO_URL, MATOMO_IDSITE_1 } = require("../config"); +const { v4: uuid } = require("uuid"); const { capture } = require("./sentry"); const __DEV__ = process.env.NODE_ENV === "development"; @@ -13,14 +14,8 @@ class _MatomoBackend { this.initDone = true; } - makeid(length = 16) { - var result = ""; - var characters = "01234567890abcdefABCDEF"; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; + makeid() { + return uuid(); } setCustomDimensions(newDimensions) { diff --git a/app/src/services/matomo.js b/app/src/services/matomo.js index 75273a434..86d81bb49 100644 --- a/app/src/services/matomo.js +++ b/app/src/services/matomo.js @@ -1,4 +1,5 @@ // https://developer.matomo.org/api-reference/tracking-api +import { v4 as uuid } from 'uuid'; class _Matomo { init({ baseUrl, idsite, userId, _idvc }) { @@ -14,14 +15,8 @@ class _Matomo { this.idsite2 = idsite; } - makeid(length = 16) { - var result = ''; - var characters = '01234567890abcdefABCDEF'; - var charactersLength = characters.length; - for (var i = 0; i < length; i++) { - result += characters.charAt(Math.floor(Math.random() * charactersLength)); - } - return result; + makeid() { + return uuid(); } setCustomDimensions(newDimensions) {