Skip to content

Batch-write analytics events instead of per-event inserts - #579

Merged
A6dulmalik merged 1 commit into
MindBlockLabs:mainfrom
demilade18-git:issue/542-batch-write
Jul 21, 2026
Merged

Batch-write analytics events instead of per-event inserts#579
A6dulmalik merged 1 commit into
MindBlockLabs:mainfrom
demilade18-git:issue/542-batch-write

Conversation

@demilade18-git

Copy link
Copy Markdown
Contributor

Description

Add an in-memory buffering layer that batches incoming AnalyticsEvent writes and flushes them every N seconds or M events, instead of issuing one INSERT per tracked event.

Changes

  • Add TrackEventProvider with in-memory buffer
  • Buffer flushes on both time (5s) and size (50 events) thresholds
  • Buffer flushed on OnModuleDestroy for graceful shutdown
  • Failed saves re-queue events back into the buffer
  • Create analytics module infrastructure (module, entity, controller, providers)

Acceptance Criteria

  • Buffer flushes on both time and size thresholds
  • No events are lost on graceful shutdown (flush on OnModuleDestroy)
  • Load test shows reduced DB write amplification vs. baseline

Closes #542

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
mind-block-app-frontend Skipped Skipped Jul 21, 2026 10:02am

@A6dulmalik

Copy link
Copy Markdown
Member

@demilade18-git resolve conflict and fix the failed checks, thank you.

…serts

Add an in-memory buffering layer in TrackEventProvider that batches
incoming AnalyticsEvent writes and flushes every 5 seconds or 50 events,
whichever comes first. Buffer is flushed on module destroy to prevent
data loss during graceful shutdown.

Closes MindBlockLabs#542
@demilade18-git
demilade18-git force-pushed the issue/542-batch-write branch from 5fd9397 to 0fa5b70 Compare July 21, 2026 10:02
@A6dulmalik
A6dulmalik merged commit 68b7bef into MindBlockLabs:main Jul 21, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Batch-write analytics events instead of per-event inserts

2 participants