diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-24 13:50:53 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-24 13:50:53 +0100 |
| commit | ca734febb23133e2b405cdc69e58d9cf6011298f (patch) | |
| tree | d421b89fc268b3da5c4dd2b8098a34c4466ee209 /src/js/utilities/ackee.js | |
| parent | e10f46c20226609198ac2a1cceab056e87e4d847 (diff) | |
| parent | 204a0c7b9665e3f85b3839a3007c1063bd436e77 (diff) | |
feat: replace Matomo with Ackee
I cannot test locally because of CORS policy.
Diffstat (limited to 'src/js/utilities/ackee.js')
| -rw-r--r-- | src/js/utilities/ackee.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/js/utilities/ackee.js b/src/js/utilities/ackee.js new file mode 100644 index 0000000..8584e2e --- /dev/null +++ b/src/js/utilities/ackee.js @@ -0,0 +1,42 @@ +import * as ackeeTracker from 'ackee-tracker'; + +/** + * Retrieve the Ackee website. + * @returns {string} The ackee website. + */ +function getAckeeDomain() { + return `https://${process.env.ACKEE_DOMAIN}`; +} + +/** + * Retrieve the domain Id. + * @returns {string} The domain Id configured in Ackee settings. + */ +function getAckeeSiteId() { + return process.env.ACKEE_SITE_ID; +} + +/** + * Create a new Ackee instance. + * @returns An Ackee instance. + */ +function createAckeeInstance() { + const domain = getAckeeDomain(); + + return ackeeTracker.create(domain, { + detailed: true, + ignoreLocalhost: true, + ignoreOwnVisits: true, + }); +} + +/** + * Create or update an Ackee record. + * @param {*} instance An Ackee Instance + */ +function setAckeeRecord(instance) { + const siteId = getAckeeSiteId(); + instance.record(siteId); +} + +export { createAckeeInstance, setAckeeRecord }; |
