Skip to content

Fix: 4 issues (#935, #936, #937, #938) - #961

Merged
Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
victorisiguzoruzoma874:simple/935-936-937-938
Oct 20, 2026
Merged

Kingsman-99 merged 1 commit into
Stellar-split:mainfrom
victorisiguzoruzoma874:simple/935-936-937-938

Conversation

@victorisiguzoruzoma874

Copy link
Copy Markdown
Contributor

Closes #935
Closes #936
Closes #937
Closes #938

Issues

#935 Add application metrics and analytics

Overview

Track user behavior and application metrics for insights.

Requirements

  • Choose analytics provider
  • Track key user actions
  • Implement event tracking
  • Add custom properties
  • Create analytics dashboards
  • Respect user privacy

Acceptance Criteria

[ ] Metrics collected accurately
[ ] Dashboards show insights
[ ] Privacy preserved
[ ] Performance not impacted
[ ] Data actionable

Definition of Done

All CI checks must pass before the PR is reviewed.

#936 Implement automated backup and disaster recovery plan

Overview

Ensure data is backed up and can be recovered in case of disaster.

Requirements

  • Implement automated backups
  • Test backup restoration
  • Document recovery procedures
  • Setup alert on backup failure
  • Implement geo-redundancy
  • Schedule regular disaster recovery drills

Acceptance Criteria

[ ] Backups created regularly
[ ] Restoration tested
[ ] RTO < 1 hour
[ ] RPO < 1 hour
[ ] Documentation complete
[ ] Team trained on recovery

Definition of Done

All CI checks must pass before the PR is reviewed.

#937 Implement invoice versioning and amendment tracking

Overview

Track changes to invoices with version history, amendments, and audit trail for creator accountability.

Requirements

  • Design version storage schema
  • Implement change diff calculation
  • Add amendment reasons and comments
  • Create audit log for all changes
  • Notify affected parties of amendments
  • Display version timeline in UI

Acceptance Criteria

[ ] Invoice versions stored and retrievable
[ ] Changes clearly highlighted with diffs
[ ] Amendment reasons tracked
[ ] Notifications sent on changes
[ ] Version history shows timeline

Definition of Done

All CI checks must pass before the PR is reviewed.

#938 Add invoice aging analytics and reports

Overview

Generate detailed reports on invoice aging, overdue rates, and collection efficiency.

Requirements

  • Calculate invoice aging buckets
  • Implement aging report generation
  • Add trend analysis
  • Create visual aging charts
  • Export aging reports
  • Set aging alerts

Acceptance Criteria

[ ] Aging reports accurate
[ ] Trends visible and actionable
[ ] Charts render correctly
[ ] Exports work properly
[ ] Alerts trigger appropriately

Definition of Done

All CI checks must pass before the PR is reviewed.

Summary

Analytics must be consent-gated and non-blocking: batch events and flush via sendBeacon/keepalive, never include wallet addresses or emails. Backup scheduling relies on the deployment platform's cron; the instrumentation hook only registers the handler. Invoice versioning should reuse the existing audit log and notification systems rather than introducing parallel ones. Aging calculations must be pure and unit-tested so CI can validate bucket boundaries. Update .env.example and ensure all new modules have tests before opening the PR.

Changes

  • Create a privacy-preserving analytics module (src/lib/analytics.ts) that defines typed event names and custom properties, gates all tracking behind explicit user consent stored in localStorage, batches events and flushes them asynchronously (via navigator.sendBeacon or fetch keepalive) so it never blocks the UI, and strips PII (addresses, emails) before sending. Export an initAnalytics, trackEvent, setConsent, and getConsent API used by the rest of the app. (src/lib/analytics.ts)
  • Add analytics configuration to the app config: analytics provider endpoint, sampling rate, and a feature flag (NEXT_PUBLIC_ANALYTICS_ENABLED) read from env, plus backup/DR configuration (backup bucket, geo-replica region, schedule interval, alert webhook) so both analytics and backup features can be toggled per environment. Document the new env vars in .env.example. (src/lib/config.ts)
  • Initialize the analytics client on the server/edge runtime in instrumentation.ts: when NEXT_RUNTIME is nodejs or edge and analytics is enabled, call initAnalytics with the configured endpoint and sampling rate. Also register the backup scheduler hook (cron-style registration) that triggers the automated backup job and emits a failure alert through the notifications system when a backup run fails. (instrumentation.ts)
  • Initialize the client-side analytics in instrumentation-client.ts: call initAnalytics (consent-gated, non-blocking) alongside Sentry init, and export a helper that flushes queued events on page hide. Ensure no analytics code runs when consent has not been granted. (instrumentation-client.ts)
  • Update the CSP middleware to allow the configured analytics provider endpoint (connect-src) and backup/alert webhook origins when analytics is enabled, while keeping the default policy strict when disabled. Read allowed origins from config so no hardcoded third-party domains leak into the CSP. (src/middleware.ts)
  • Instrument key user actions with trackEvent: wrap the invoice list fetch in useInvoices to emit invoice_list_viewed and invoice_created events with custom properties (count, status breakdown, no addresses), and emit wallet_connected when a publicKey becomes available. Keep tracking fire-and-forget so the data fetch is not delayed. (src/hooks/useInvoices.ts)
  • Add analytics event tracking to the API client wrapper: emit api_request events (method, path template, status, duration) for mutating requests, redacting query strings and bodies. Ensure the tracking call is scheduled after the response resolves and never throws into the caller. (src/lib/apiClient.ts)
  • Extend the analytics page to render the new dashboards: add an application metrics section (event counts, funnel for invoice create→pay→release, active wallets) sourced from the analytics module, plus an invoice aging section that consumes the new aging analytics library to render bucket charts and trend lines. Keep charts dynamically imported and lazy so initial load performance is unaffected. (src/app/analytics/page.tsx)
  • Extend AnalyticsPanel to display application metrics (event totals, conversion funnel, active users) alongside the existing invoice stats, and add an aging summary card that shows the current aging buckets and a trend indicator. Respect the existing range presets and keep the panel collapsible. (src/components/AnalyticsPanel.tsx)
  • Create the invoice aging analytics library: compute aging buckets (current, 1-30, 31-60, 61-90, 90+ days overdue) from invoice deadlines and status, calculate overdue rate and collection efficiency, produce trend series over time, and expose threshold-based alert evaluation that returns which invoices crossed aging thresholds. Include pure functions with unit-testable signatures. (src/lib/invoiceAging.ts)
  • Add aging report export helpers: extend csvExport.ts with a function that serializes aging bucket rows and trend data to CSV using the existing escapeCSVField/downloadCSV utilities, and add a filename generator for aging reports. (src/lib/csvExport.ts)
  • Add an aging worksheet to the Excel export: extend invoiceExcelExport.ts with a function that builds aging bucket and trend rows and includes them as an additional worksheet in the generated workbook, reusing the existing filter options. (src/lib/invoiceExcelExport.ts)
  • Add aging alert notifications: extend notifications.ts with a new preference (agingAlert) and a notifyInvoiceAging function that fires when an invoice crosses an aging threshold, plus a notifyBackupFailure function used by the backup scheduler to alert on failed backup runs. (src/lib/notifications.ts)
  • Add aging columns and an aging filter to InvoiceTable: compute days-overdue and aging bucket per invoice using the new invoiceAging library, add an optional 'aging' column to the column visibility map, and support sorting by aging bucket. (src/components/InvoiceTable.tsx)
  • Add an 'Export aging report' action to ExportModal that calls the new CSV/Excel aging export helpers with the currently selected date range and filters, and shows success/error feedback consistent with the existing export flow. (src/components/ExportModal.tsx)
  • Extend the invoice cache schema to version 2: add an INVOICE_VERSIONS_STORE object store keyed by version id with indexes by-invoice and by-timestamp, and an AMENDMENTS_STORE for amendment reasons/comments. Bump DB_VERSION and export the new store names and interfaces so versioning code can persist structured versions. (src/lib/db/schema.ts)
  • Create the invoice versioning library: define InvoiceVersion and Amendment types, implement diff calculation between two invoice snapshots (field-level before/after for amount, recipients, deadline, notes, status), functions to record a new version with an amendment reason/comment, and helpers to retrieve version history and produce a timeline-friendly list. (src/lib/invoiceVersioning.ts)
  • Extend auditLog.ts with a helper to append invoice version/amendment audit entries (category 'invoice', action 'invoice_amended', details containing the amendment reason and changed fields) and to filter audit entries by invoice target, so version changes are captured in the audit trail. (src/lib/auditLog.ts)
  • Update VersionHistory to consume the new invoiceVersioning library: render a chronological version timeline with version numbers, amendment reasons/comments, and highlighted field diffs, and trigger notifications to affected parties (creator, recipients, payers) via notifications.ts when a new version is recorded. (src/components/VersionHistory.tsx)
  • Extend InvoiceTimeline to include amendment/version events: add 'Amended' and 'VersionRestored' event types with icons and colors, and render amendment reasons inline in the expanded event details so the timeline shows the full version history alongside payment events. (src/components/InvoiceTimeline.tsx)
  • Update AuditLogTable to display version/amendment entries with their diff summary and amendment reason, and add an export option that includes version history in the JSON archive so accountability data is complete. (src/components/AuditLogTable.tsx)
  • Create the backup and disaster recovery runbook documentation (docs/disaster-recovery.md) covering automated backup schedule, geo-redundant storage configuration, restoration procedure with tested steps, RTO/RPO targets under one hour, failure alerting, and the recurring DR drill checklist. Reference the env vars added to config.ts. (docs/disaster-recovery.md)
  • Add a backup job module (src/lib/backup.ts) that implements the automated backup routine: snapshot the invoice cache and audit data, upload to the primary and geo-replica storage targets from config, verify the upload, and on failure call notifyBackupFailure. Export a runBackup function invoked by the scheduler registered in instrumentation.ts, plus a verifyRestoration helper used by DR drills. (src/lib/backup.ts)

Co-authored-by: Simple Agent <agent@simple.dev>
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@victorisiguzoruzoma874 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 19, 2026

Copy link
Copy Markdown

@victorisiguzoruzoma874 is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Kingsman-99
Kingsman-99 merged commit dbf9f50 into Stellar-split:main Oct 20, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants