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
🏥 Server Maintenance / 🧹 Prune & Clean (push) Failing after 8s
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
🏥 Server Maintenance / 🧹 Prune & Clean (push) Failing after 8s
This commit is contained in:
@@ -1,25 +1,14 @@
|
||||
name: Analytics Mailer
|
||||
name: Analytics Mailer (Monthly)
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run weekly on Monday at 08:00 UTC
|
||||
- cron: '0 8 * * 1'
|
||||
# Run monthly on the 1st day of the month at 08:30 UTC
|
||||
- cron: '30 8 1 * *'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
interval:
|
||||
description: 'Interval to run (weekly or monthly)'
|
||||
required: true
|
||||
default: 'weekly'
|
||||
type: choice
|
||||
options:
|
||||
- weekly
|
||||
- monthly
|
||||
|
||||
jobs:
|
||||
send-reports:
|
||||
name: 📊 Send Analytics Reports
|
||||
name: 📊 Send Analytics Reports (Monthly)
|
||||
runs-on: docker
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
@@ -56,18 +45,5 @@ jobs:
|
||||
- name: Build analytics mailer
|
||||
run: pnpm --filter @mintel/analytics-mailer build
|
||||
|
||||
- name: Determine Interval
|
||||
id: set-interval
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "schedule" ]; then
|
||||
if [ "${{ github.event.schedule }}" = "0 8 * * 1" ]; then
|
||||
echo "interval=weekly" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "interval=monthly" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
else
|
||||
echo "interval=${{ github.event.inputs.interval }}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Run Analytics Mailer
|
||||
run: pnpm --filter @mintel/analytics-mailer run start -- --interval=${{ steps.set-interval.outputs.interval }}
|
||||
run: pnpm --filter @mintel/analytics-mailer run start
|
||||
@@ -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