Repository navigation
refactor(iterable): update api limits and batching logic - #4232
Conversation
Summary by CodeRabbit
WalkthroughThis pull request refactors configuration constants and updates event batching in the Iterable integration. The Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Util
Client->>Util: Invoke batchTrackEvents(trackEvents)
Util->>Util: Call prepareAndSplitTrackBatchesBasedOnPayloadSize(trackEvents)
Util-->>Util: Return split event batches
Util->>Util: For each batch, execute processTrackBatch(batch)
Util-->>Client: Return batched processing result
Suggestions for Improvements
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📥 CommitsReviewing files that changed from the base of the PR and between 7f167e327f3e35645ef14759d8c1990ab47bc1cd and 9f458b3. 📒 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`: Focus on ESLint errors (max 3) and warnings (max 5).
🧬 Code Definitions (1)src/v0/destinations/iterable/util.test.js (3)
⏰ Context from checks skipped due to timeout of 90000ms (8)
🔇 Additional comments (15)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
Allure Test reports for this run are available at:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4232 +/- ##
========================================
Coverage 91.05% 91.05%
========================================
Files 627 627
Lines 33049 33068 +19
Branches 7818 7817 -1
========================================
+ Hits 30092 30111 +19
- Misses 2710 2740 +30
+ Partials 247 217 -30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
68a25b7 to
5dbc6a8
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/v0/destinations/iterable/util.js (1)
1-1: Added ESLint directive.The
eslint-disable unicorn/consistent-destructuringdirective may be necessary but consider using a more targeted approach to only disable the rule for specific lines or blocks if possible.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 68a25b709d429b0429d4b4fddcfdc63ebfd057ce and 5dbc6a89c6ae1afe8cced3236ce4f7adf343e0bd.
📒 Files selected for processing (3)
src/v0/destinations/iterable/config.js(2 hunks)src/v0/destinations/iterable/util.js(8 hunks)src/v0/destinations/iterable/util.test.js(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).
**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).
src/v0/destinations/iterable/util.test.jssrc/v0/destinations/iterable/config.jssrc/v0/destinations/iterable/util.js
🧬 Code Definitions (2)
src/v0/destinations/iterable/util.test.js (3)
src/v0/destinations/iterable/util.js (6)
require(5-5)require(6-13)require(16-16)require(17-17)chunk(523-523)prepareAndSplitTrackBatchesBasedOnPayloadSize(563-596)src/v0/destinations/iterable/config.js (1)
require(1-1)src/v0/destinations/iterable/transform.js (6)
require(3-3)require(5-19)require(29-29)require(30-30)require(31-31)require(32-32)
src/v0/destinations/iterable/util.js (3)
src/v0/destinations/iterable/util.test.js (2)
require(1-16)require(34-34)src/v0/destinations/iterable/config.js (2)
require(1-1)constructEndpoint(74-77)src/v0/destinations/iterable/transform.js (6)
require(3-3)require(5-19)require(29-29)require(30-30)require(31-31)require(32-32)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: Code Coverage
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: test_and_publish
- GitHub Check: ingestion-service-test
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (22)
src/v0/destinations/iterable/util.test.js (6)
14-14: Import added for new track batch function.The import statement has been updated to include the new
prepareAndSplitTrackBatchesBasedOnPayloadSizefunction, which is a key part of the refactored batching logic.
17-31: Good configuration mocking approach.Nice implementation of the config module mock with smaller values for testing purposes. This makes it easier to test the batching logic without creating large payloads and follows best practices for unit testing by isolating the test from the actual configuration values.
33-34: Clean import of the mocked config.Good practice to import the mocked module explicitly to ensure the tests are using the modified configuration values.
36-37: Clear comment about lodash mocking.Good clarification that lodash doesn't need to be mocked for this test suite.
1066-1091: Improved test case for update user batches.The test has been enhanced to handle empty input cases and verify the presence of expected properties across all batches. This increases test robustness and ensures the batching function behaves correctly under various conditions.
1117-1178: Well-structured tests for the new track batching function.The new test cases thoroughly verify the behavior of
prepareAndSplitTrackBatchesBasedOnPayloadSizeunder different scenarios:
- When payload size exceeds the limit, ensuring multiple batches are created
- When payload size is under the limit, ensuring a single batch is created
This follows good testing practices by covering both edge cases and normal operation.
src/v0/destinations/iterable/config.js (3)
81-82: Clear documentation for the API limit.Good documentation comment explaining that Iterable has a unified 4MB request size limit for all operations. This helps future developers understand the rationale behind the constant.
84-86: Improved constant organization.Good refactoring of the batch size limits into clearly named constants that reflect their purpose:
INITIAL_CHUNK_SIZEfor the initial batching of all operationsCATALOG_MAX_ITEMS_PER_REQUESTfor the catalog operation limitThis makes the code more maintainable and self-documenting.
110-112: Updated module exports.The module exports have been updated to include the new constants. This ensures they are accessible to other modules that need to reference them.
src/v0/destinations/iterable/util.js (13)
14-15: Simplified configuration import.Good refactoring to import all configuration from a single object, making the code cleaner and more maintainable.
21-21: Destructured configuration imports.Clean destructuring of the configuration imports to access the specific components needed.
375-375: Updated size limit check.The function now references the unified
MAX_BODY_SIZE_IN_BYTESconstant from the configurations object, aligning with the PR's goal of consolidating batch size limits.
474-474: Updated initial chunk size.The function now uses the new
INITIAL_CHUNK_SIZEconstant instead of a hard-coded value, improving maintainability.
484-489: Improved documentation for catalog operations.Clear comments explaining the Iterable API's limit of 1,000 items per request for catalog operations. This helps future developers understand the constraints.
492-500: Refactored catalog batch processing.The catalog batch processing has been simplified to focus on the item count limit, making the code more maintainable. The new approach properly maps catalog items to their respective catalog IDs.
518-521: Improved JSON structure for catalog operations.The JSON structure now clearly separates documents and the
replaceUploadedFieldsOnlyflag, which improves readability and aligns with the Iterable API requirements.
523-527: Better variable extraction.The function now cleanly extracts destination, message, and endpoint information for the API call.
539-550: Updated documentation and chunking for catalog events.The function now clearly explains that catalog events are chunked based on the Iterable API's limit of 1,000 items per request. The code uses the new
CATALOG_MAX_ITEMS_PER_REQUESTconstant for clarity.
558-596: Well-implemented track batching function.The new
prepareAndSplitTrackBatchesBasedOnPayloadSizefunction is a good addition that follows the same pattern as the user update batching function. It correctly:
- Tracks cumulative payload size
- Creates new batches when size exceeds the limit
- Handles the final batch correctly
This promotes code reuse and consistency in the batching logic.
604-628: Refactored track batch processing.The
processTrackBatchfunction has been refactored to use the new batching function, making the code more modular and easier to maintain. The changes correctly handle the array of batch responses.
638-644: Updated track events batching.The function now uses the new
INITIAL_CHUNK_SIZEconstant and correctly handles the array of batch responses fromprocessTrackBatch.
814-814: Export of new track batching function.The new
prepareAndSplitTrackBatchesBasedOnPayloadSizefunction is properly exported for use in other modules and tests.
|
Allure Test reports for this run are available at:
|
5dbc6a8 to
7f167e3
Compare
|
Allure Test reports for this run are available at:
|
Update Iterable destination to use a single 4MB request size limit for both identify and track operations, and a 1,000 items per request limit for catalog operations. - Replace separate batch size limits with a single MAX_BODY_SIZE_IN_BYTES constant - Add CATALOG_MAX_ITEMS_PER_REQUEST constant for catalog operations - Add INITIAL_CHUNK_SIZE constant to replace hard-coded values - Simplify catalog batching logic to only respect item count limit - Add tests to verify batching behavior
7f167e3 to
9f458b3
Compare
|
Allure Test reports for this run are available at:
|
|



What are the changes introduced in this PR?
Update Iterable destination to use a single 4MB request size limit for both identify and track operations, and a 1,000 items per request limit for catalog operations.
What is the related Linear task?
Resolves INT-3475
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
N/A
Any new dependencies introduced with this change?
N/A
Any new generic utility introduced or modified. Please explain the changes.
N/A
Any technical or performance related pointers to consider with the change?
N/A
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.