Attribution window is configurable, not hard-coded
Why it matters
Attribution windows determine how far back from a conversion you look for a causal email touchpoint. A 7-day window and a 30-day window produce materially different revenue attribution numbers for the same campaign — especially for products with long consideration cycles. If the window is a magic number hard-coded in four different query files, changing your attribution model to match your actual sales cycle requires a multi-file search-and-replace with no guarantee you caught every instance. This is an iso-25010:2011 maintainability failure: the system cannot adapt to a known parameter without engineering effort and regression risk.
Severity rationale
Low because incorrect window values degrade attribution accuracy but don't cause data loss or security exposure — the risk is misleading reporting rather than a broken system.
Remediation
Extract the attribution window to a single named constant sourced from an environment variable so it can be changed in one place without touching query logic:
// lib/attribution/config.ts
export const ATTRIBUTION_WINDOW_DAYS = parseInt(
process.env.ATTRIBUTION_WINDOW_DAYS ?? '30',
10
)
export function getAttributionWindowStart(): Date {
return new Date(Date.now() - ATTRIBUTION_WINDOW_DAYS * 24 * 60 * 60 * 1000)
}
Import getAttributionWindowStart() in every attribution query. Set ATTRIBUTION_WINDOW_DAYS in your environment config (.env.local, Vercel env vars) so it's tunable without a deploy. Document the chosen value and rationale in a comment near the constant.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Campaign Analytics & Attribution Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability — Maintainability — modifiability
Taxons
History
- 2026-04-18·v1.0.0·Initial import from campaign-analytics-attribution·automated