fix(analytics-mailer): strictly enforce monthly reports and remove weekly logic completely
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 3s
Monorepo Pipeline / 🧹 Lint (push) Failing after 1m24s
Monorepo Pipeline / 🧪 Test (push) Successful in 42s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m10s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
Some checks failed
Monorepo Pipeline / ⚡ Prioritize Release (push) Successful in 3s
Monorepo Pipeline / 🧹 Lint (push) Failing after 1m24s
Monorepo Pipeline / 🧪 Test (push) Successful in 42s
Monorepo Pipeline / 🏗️ Build (push) Successful in 2m10s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build Gatekeeper (Product) (push) Has been skipped
Monorepo Pipeline / 🐳 Build Build-Base (push) Has been skipped
Monorepo Pipeline / 🐳 Build Production Runtime (push) Has been skipped
This commit is contained in:
@@ -4,31 +4,27 @@
|
||||
"domain": "klz-cables.com",
|
||||
"clientEmail": "klaus.mintel@klz-cables.com, michael.bodemer@klz-cables.com, marc@mintel.me",
|
||||
"clientName": "KLZ Cables",
|
||||
"greeting": "Hallo Klaus, hallo Michael,",
|
||||
"interval": "monthly"
|
||||
"greeting": "Hallo Klaus, hallo Michael,"
|
||||
},
|
||||
{
|
||||
"websiteId": "b9035279-72f1-49bc-909d-b073d184c388",
|
||||
"domain": "mintel.me",
|
||||
"clientEmail": "marc@mintel.me",
|
||||
"clientName": "Mintel.me",
|
||||
"greeting": "Hallo Team Mintel,",
|
||||
"interval": "monthly"
|
||||
"greeting": "Hallo Team Mintel,"
|
||||
},
|
||||
{
|
||||
"websiteId": "caa402bc-b2d2-4349-a254-84c0dd2a4460",
|
||||
"domain": "mb-grid-solutions.com",
|
||||
"clientEmail": "marc@mintel.me",
|
||||
"clientName": "MB Grid Solutions",
|
||||
"greeting": "Hallo Marc,",
|
||||
"interval": "monthly"
|
||||
"greeting": "Hallo Marc,"
|
||||
},
|
||||
{
|
||||
"websiteId": "d773ea10-a3b3-4ccf-9024-987e14c4d669",
|
||||
"domain": "e-tib.com",
|
||||
"clientEmail": "d.joseph@e-tib.com, marc@mintel.me",
|
||||
"clientName": "E-TIB GmbH",
|
||||
"greeting": "Hallo Danny,",
|
||||
"interval": "monthly"
|
||||
"greeting": "Hallo Danny,"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -3,7 +3,7 @@ import path from "path";
|
||||
import axios from "axios";
|
||||
import { render } from "@mintel/mail";
|
||||
import { AnalyticsTemplate } from "@mintel/mail";
|
||||
import { getLast7Days, getThisMonth, getThisYear } from "./utils/time-calculator";
|
||||
import { getThisMonth, getThisYear } from "./utils/time-calculator";
|
||||
import nodemailer from "nodemailer";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
@@ -29,7 +29,6 @@ interface ConfigClient {
|
||||
clientEmail: string;
|
||||
clientName: string;
|
||||
greeting?: string;
|
||||
interval?: "weekly" | "monthly";
|
||||
}
|
||||
|
||||
async function getUmamiToken(): Promise<string> {
|
||||
@@ -107,12 +106,6 @@ export async function fetchUmamiData(api: any, websiteId: string, startAt: numbe
|
||||
|
||||
async function main() {
|
||||
const isDryRun = process.argv.includes("--dry-run");
|
||||
const intervalArg = process.argv.find(a => a.startsWith("--interval="));
|
||||
const runInterval = intervalArg ? intervalArg.split("=")[1] : "monthly";
|
||||
|
||||
if (runInterval !== "weekly" && runInterval !== "monthly") {
|
||||
throw new Error("Invalid interval. Use --interval=weekly or --interval=monthly");
|
||||
}
|
||||
|
||||
// Load config
|
||||
const configPath = path.resolve(process.cwd(), "config.json");
|
||||
@@ -136,19 +129,12 @@ async function main() {
|
||||
} : undefined,
|
||||
});
|
||||
|
||||
const timeRanges = runInterval === "weekly"
|
||||
? [getLast7Days(), getThisMonth(), getThisYear()]
|
||||
: [getThisMonth(), getThisYear()];
|
||||
const timeRanges = [getThisMonth(), getThisYear()];
|
||||
|
||||
console.log(`Generating reports...`);
|
||||
|
||||
for (const client of clients) {
|
||||
if (client.websiteId === "replace-with-umami-website-id") continue;
|
||||
const clientInterval = client.interval || "monthly";
|
||||
if (clientInterval !== runInterval) {
|
||||
console.log(`Skipping ${client.domain} (runs ${clientInterval}, currently executing ${runInterval})`);
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(`Processing ${client.domain} (${client.clientName})...`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user