umami/scripts/update-tracker.js
2022-11-03 21:33:37 -07:00

20 lines
469 B
JavaScript

/* eslint-disable no-console */
require('dotenv').config();
const fs = require('fs');
const path = require('path');
const endPoint = process.env.COLLECT_API_ENDPOINT;
if (endPoint) {
const file = path.resolve(__dirname, '../public/umami.js');
const tracker = fs.readFileSync(file);
fs.writeFileSync(
path.resolve(file),
tracker.toString().replace(/"\/api\/collect"/g, `"${endPoint}"`),
);
console.log(`Updated tracker endpoint: ${endPoint}.`);
}