Repository navigation
feat(braze): optimize Track API batching algorithm - #4685
Conversation
Summary by CodeRabbit
WalkthroughAdds a Braze Track API batching implementation and tests: new batching utilities to create/clean track chunks, split by external_id and per-type limits (75), updated processBatch to use chunks and emit per-chunk metrics, a new config constant, and comprehensive unit tests for batching behavior. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant PB as processBatch
participant BF as batchForTrackAPI
participant MS as Metrics
participant RB as Request Builder
participant OUT as Output Array
PB->>BF: batchForTrackAPI(attributes, events, purchases)
BF-->>PB: [trackChunks] (each: {attributes, events, purchases, externalIds})
loop For each chunk
PB->>MS: addTrackStats(chunk, destination)
PB->>RB: cleanTrackChunk(chunk)
RB-->>PB: cleaned body (only non-empty attributes/events/purchases)
PB->>OUT: push per-chunk request
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.js⚙️ CodeRabbit configuration file
Files:
🧬 Code graph analysis (2)src/v0/destinations/braze/batchForTrackAPI.test.js (1)
src/v0/destinations/braze/util.js (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Allure Test reports for this run are available at:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4685 +/- ##
=========================================
Coverage 91.79% 91.80%
=========================================
Files 645 650 +5
Lines 34086 34486 +400
Branches 8050 8099 +49
=========================================
+ Hits 31290 31660 +370
- Misses 2544 2596 +52
+ Partials 252 230 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Implement new batchForTrackAPI function for improved batching logic - Add support for TRACK_BRAZE_MAX_EXTERNAL_ID_COUNT limit (75 external IDs per batch) - Optimize batching to respect both external ID count and request count limits - Refactor processBatch to use new batching algorithm - Add comprehensive test coverage for batchForTrackAPI function - Improve performance by reducing unnecessary API calls and better data grouping This change improves the efficiency of Braze Track API calls by implementing a smarter batching strategy that considers both the number of unique external IDs and the total number of requests per batch type.
8222117 to
8185d8c
Compare
|
Allure Test reports for this run are available at:
|
|



Summary
This PR implements a new batching algorithm for the Braze Track API that optimizes how events, attributes, and purchases are grouped and sent to Braze.
Resolves INT-4170
Changes Made
Core Implementation
Key Improvements
Testing
Technical Details
The new algorithm works by:
Impact
Testing
All tests pass, including the new comprehensive test suite for the batching algorithm.