Repository navigation
feat(reddit): onboard v3 api - #4699
Conversation
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Config src/cdk/v2/destinations/reddit/config.js |
Adds and exports V3_ENDPOINT constant pointing to Reddit Ads API V3. |
Types src/cdk/v2/destinations/reddit/types.ts |
New Zod schemas and TypeScript type aliases for Reddit destination config, metadata, user/product/event schemas, payload and response shapes. |
V3 Transform src/cdk/v2/destinations/reddit/transformV3.ts |
New V3 transform exporting process(...): validates input, maps events (multi-mapping supported), prepares user/product/metadata, hashes PII when configured, builds Reddit V3 payloads and RedditResponse(s) with V3_ENDPOINT and Authorization header. |
Workflows src/cdk/v2/destinations/reddit/procWorkflowV3.yaml, src/cdk/v2/destinations/reddit/rtWorkflow.yaml |
Adds process binding in procWorkflowV3; updates rtWorkflow to decide version, branch to V2/V3 transforms (externals), select appropriate transformed output, refactors batch logic to use prepareBatches and combineBatchRequestsWithSameJobIds, and adds bindings (isDefinedAndNotNull, combineBatchRequestsWithSameJobIds). |
Utilities src/cdk/v2/destinations/reddit/utils.js, src/cdk/v2/destinations/reddit/utils.test.js |
Introduces decideVersion, convertToUpperSnakeCase, generateAndValidateTimestamp, hashSHA256, and prepareBatches; updates batchEventChunks to be version-aware (different payload paths for v2/v3), removes batchEvents export, expands revenue handling, and adds comprehensive tests covering new helpers and edge cases. |
Sequence Diagram(s)
sequenceDiagram
participant E as Incoming Events
participant Router as rtWorkflow
participant Decide as decideVersion
participant XfrmV2 as transformWithV2
participant XfrmV3 as transformWithV3
participant ProcV3 as procWorkflowV3 (process)
participant Batch as prepareBatches / batchEventChunks
participant Combine as combineBatchRequestsWithSameJobIds
participant Out as Final Payloads
E->>Router: submit events batch
Router->>Decide: determine target version (dest.Config.version or infer)
alt version == "v3"
Router->>XfrmV3: route to transformWithV3 (external)
XfrmV3->>ProcV3: call ./transformV3 (process)
ProcV3->>Batch: return responses (body.JSON.data.events)
else
Router->>XfrmV2: route to transformWithV2 (external)
XfrmV2->>Batch: return responses (body.JSON.events)
end
Batch->>Batch: partition non-batchable vs batchable, chunk per destination/version
Batch->>Combine: merge chunked batches, dedupe/merge jobIds
Combine->>Out: produce final outbound payloads with appropriate endpoint/header
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45–75 minutes
- Focus areas:
- src/cdk/v2/destinations/reddit/utils.js — version branching, timestamp validation, hashing, prepareBatches behavior, and payload path differences between v2/v3.
- src/cdk/v2/destinations/reddit/transformV3.ts — event mapping, multi-event outputs, PII hashing, timestamp handling, and header/endpoint assembly.
- src/cdk/v2/destinations/reddit/rtWorkflow.yaml & procWorkflowV3.yaml — branching logic, new bindings, and ensuring workflow payload shapes align with v2/v3 outputs.
- Tests in src/cdk/v2/destinations/reddit/utils.test.js — verify edge cases (timestamps, batching, version routing, dontBatch/test_id interactions).
Suggested labels
DO NOT MERGE
Suggested reviewers
- sivashanmukh
- utsabc
- krishna2020
- koladilip
- manish339k
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately reflects the main objective of adding Reddit API v3 support, which is the primary change across the PR. |
| Description check | ✅ Passed | The description comprehensively covers all required template sections with detailed explanations of changes, objectives, dependencies, utilities, and performance considerations. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feat/reddit-version-update
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 @coderabbitai help to get the list of available commands and usage tips.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4699 +/- ##
===========================================
+ Coverage 91.91% 91.96% +0.04%
===========================================
Files 651 653 +2
Lines 34613 34778 +165
Branches 8131 8188 +57
===========================================
+ Hits 31816 31982 +166
+ Misses 2548 2547 -1
Partials 249 249 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/cdk/v2/destinations/reddit/transformV3.ts (1)
6-6: Consider using Node.js built-in crypto module.The
sha256package (v0.2.0) is deprecated and unmaintained. For better security and maintenance, use Node.js built-incrypto.createHash('sha256')instead.Replace the sha256 import with:
-import sha256 from 'sha256'; +import { createHash } from 'crypto';Then update the hashing calls (lines 45-50) to use:
const hashString = (value: string) => createHash('sha256').update(value).digest('hex');Based on learnings.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
src/cdk/v2/destinations/reddit/data/userDataMapping.jsonis excluded by!**/*.jsontest/integrations/destinations/reddit/mocks.tsis excluded by!**/test/**test/integrations/destinations/reddit/router/data.tsis excluded by!**/test/**
📒 Files selected for processing (7)
src/cdk/v2/destinations/reddit/config.js(2 hunks)src/cdk/v2/destinations/reddit/procWorkflowV3.yaml(1 hunks)src/cdk/v2/destinations/reddit/rtWorkflow.yaml(3 hunks)src/cdk/v2/destinations/reddit/transformV3.ts(1 hunks)src/cdk/v2/destinations/reddit/types.ts(1 hunks)src/cdk/v2/destinations/reddit/utils.js(3 hunks)src/cdk/v2/destinations/reddit/utils.test.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/cdk/v2/destinations/reddit/config.jssrc/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/utils.test.js
🧬 Code graph analysis (4)
src/cdk/v2/destinations/reddit/utils.js (2)
src/cdk/v2/destinations/reddit/utils.test.js (1)
require(1-9)src/v0/util/index.js (1)
isDefinedAndNotNull(51-51)
src/cdk/v2/destinations/reddit/utils.test.js (1)
src/cdk/v2/destinations/reddit/utils.js (8)
require(1-1)populateRevenueField(61-91)decideVersion(4-11)batchEventChunks(13-38)removeUnsupportedFields(104-115)convertToUpperSnakeCase(117-129)generateAndValidateTimestamp(131-157)now(143-143)
src/cdk/v2/destinations/reddit/transformV3.ts (5)
src/types/rudderEvents.ts (1)
RudderMessage(43-43)src/cdk/v2/destinations/reddit/types.ts (6)
RedditUserData(135-135)RedditEventType(131-131)RedditEventMetadata(133-133)RedditRouterRequest(125-130)RedditConversionEventsPayload(134-134)RedditResponse(137-137)src/v0/util/index.js (3)
removeUndefinedAndNullValues(55-55)getHashFromArrayWithDuplicate(237-258)defaultRequestConfig(461-475)src/cdk/v2/destinations/reddit/config.js (2)
ecomEventMaps(5-26)V3_ENDPOINT(2-2)src/cdk/v2/destinations/reddit/utils.js (4)
convertToUpperSnakeCase(117-129)populateRevenueField(61-91)eventAt(138-138)generateAndValidateTimestamp(131-157)
src/cdk/v2/destinations/reddit/types.ts (3)
src/types/controlPlaneConfig.ts (1)
Destination(31-49)src/types/destinationTransformation.ts (1)
RouterTransformationRequestData(95-106)src/types/rudderEvents.ts (1)
RudderMessage(43-43)
🪛 GitHub Actions: Build Artifacts for PRs
src/cdk/v2/destinations/reddit/utils.js
[error] 133-135: InstrumentationError message mismatch in generateAndValidateTimestamp: test expects 'Timestamp is not present.' but actual message is 'Required field "timestamp" or "originalTimestamp" is missing from the message.'
[error] 133-135: InstrumentationError message mismatch in generateAndValidateTimestamp (undefined timestamp): test expects 'Timestamp is not present.' but actual message is 'Required field "timestamp" or "originalTimestamp" is missing from the message.'
src/cdk/v2/destinations/reddit/utils.test.js
[error] 680-680: generateAndValidateTimestamp: Expected error message to contain 'Timestamp is not present.' but got 'Required field "timestamp" or "originalTimestamp" is missing from the message.'
🪛 GitHub Actions: DT Tests
src/cdk/v2/destinations/reddit/utils.js
[error] 133-135: Timestamp timestamp validation error message mismatch in tests. Expected 'Timestamp is not present.' but actual thrown message is 'Required field "timestamp" or "originalTimestamp" is missing from the message.'
🔇 Additional comments (17)
src/cdk/v2/destinations/reddit/procWorkflowV3.yaml (1)
1-8: LGTM! Clean V3 workflow definition.The workflow binding and template correctly wire the V3 transformation path through the
processfunction. The structure follows established patterns.src/cdk/v2/destinations/reddit/config.js (1)
2-2: LGTM! V3 endpoint properly configured.The V3_ENDPOINT constant is correctly defined and exported for use in the V3 transformation flow.
Also applies to: 30-30
src/cdk/v2/destinations/reddit/transformV3.ts (3)
25-54: LGTM with observation on null handling.The user object preparation correctly handles OS-specific advertising IDs and optional hashing. The optional chaining safely handles missing properties.
Note: The hashing logic (lines 45-50) explicitly sets properties to
nullrather than leaving themundefined. This is acceptable but ensure downstream code handlesnullvalues appropriately.
91-148: LGTM! Well-structured metadata preparation.The helper functions correctly handle both single products and product arrays, with proper fallbacks for missing fields. The revenue conversion (line 131) correctly divides cents by 100 to get the currency value.
154-225: LGTM! Robust event processing logic.The track event processing correctly handles:
- Multi-event mapping (lines 165-181)
- Test event isolation (lines 176-177, 192-193)
- Proper timestamp validation (line 162)
- Response construction with appropriate headers (lines 214-218)
The unsupported message type handling (line 224) provides clear feedback.
src/cdk/v2/destinations/reddit/rtWorkflow.yaml (3)
14-43: LGTM! Version-aware routing correctly implemented.The conditional workflow execution based on
decideVersionoutput properly routes events through V2 or V3 transformation paths. The else clause (lines 40-43) safely defaults to V3 sincedecideVersiononly returns 'v2' or 'v3'.
99-99: LGTM! Improved batch request merging.Using
combineBatchRequestsWithSameJobIdsprovides intelligent merging of batched requests with the same job IDs, which aligns with the PR's enhanced batching objectives.
67-68: Correct the test_id path to align with V3 extraction logic.Lines 67-68 check for
test_idat.message.[0].body.JSON.data.test_id, but the V3 transformation extracts it frommessage.properties.test_id(transformV3.ts line 164). Since rtWorkflow.yaml is used for both V2 and V3 events, the JSONPath should consistently reference where test_id actually exists in the original message.The current expression checks the wrong location relative to how test_id flows through the V3 pipeline. For V2 events, the path will be falsy (correct outcome), but the logic is semantically incorrect. Consider updating to
.message.[0].properties.test_idif that matches your V3 message structure, or document why the body path is intentional.src/cdk/v2/destinations/reddit/utils.js (5)
4-11: LGTM! Conservative version detection.The function safely defaults to 'v2' for backward compatibility, only switching to 'v3' when explicitly configured. The use of
isDefinedAndNotNullcorrectly handles both null and undefined values.
13-38: LGTM! Version-aware batching implemented correctly.The function properly adapts event batching based on destination version, pushing to
.data.eventsfor V3 and.eventsfor V2, matching their respective payload structures.
61-91: LGTM! Uppercase event type support added.The function now handles both PascalCase (V2) and UPPER_SNAKE_CASE (V3) event types consistently, ensuring proper revenue calculation across both API versions.
117-129: LGTM! Clean event type conversion.The mapping table comprehensively covers Reddit's standard event types. Returning
undefinedfor unmapped types allows callers to handle custom events appropriately.
131-157: LGTM! Comprehensive timestamp validation.The function properly validates timestamp presence, format, and age constraints (within 7 days past, 5 minutes future). The logic correctly handles various timestamp formats (ISO strings, Unix milliseconds, Date objects).
However, note the pipeline failure: tests expect error message "Timestamp is not present." but this function throws "Required field "timestamp" or "originalTimestamp" is missing from the message." This will be addressed in the test file review.
src/cdk/v2/destinations/reddit/utils.test.js (1)
1-743: Excellent test coverage for new utilities!The test suite comprehensively covers all new and modified utilities with edge cases, boundary conditions, and error scenarios. The tests verify:
- Revenue calculation variants (PascalCase and UPPER_SNAKE_CASE)
- Version decision logic across multiple config scenarios
- Batching behavior for V2 and V3 destinations
- Field removal and immutability
- Event type conversion mappings
- Timestamp validation rules
src/cdk/v2/destinations/reddit/types.ts (3)
1-26: LGTM! Well-structured configuration schema.The
RedditDestinationConfigSchemaproperly defines required fields, constrains event mappings to valid types, and provides sensible defaults (hashData: true, version: 'v2'). Thepassthrough()allows flexibility for additional configuration fields.
28-57: LGTM! Comprehensive user data schema.The
RedditUserDataSchemaappropriately models all user data fields as optional, supporting flexible PII handling and hashing. The nested objects for data processing options and screen dimensions align with Reddit's API specifications.
108-137: LGTM! Complete response schema and type exports.The
RedditResponseSchemaproperly models the HTTP request structure with appropriate headers and body format. All type exports are correctly inferred from their respective schemas, providing full TypeScript type safety.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/cdk/v2/destinations/reddit/transformV3.ts (1)
68-68: Use InstrumentationError for consistency.This was flagged in a previous review. The generic
Errorshould be replaced withInstrumentationErrorto match error handling throughout the file (lines 205, 224).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/cdk/v2/destinations/reddit/transformV3.ts(1 hunks)src/cdk/v2/destinations/reddit/types.ts(1 hunks)src/cdk/v2/destinations/reddit/utils.test.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/cdk/v2/destinations/reddit/utils.test.js
🧠 Learnings (1)
📓 Common learnings
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
🧬 Code graph analysis (3)
src/cdk/v2/destinations/reddit/transformV3.ts (5)
src/types/rudderEvents.ts (1)
RudderMessage(43-43)src/cdk/v2/destinations/reddit/types.ts (6)
RedditUserData(138-138)RedditEventType(134-134)RedditEventMetadata(136-136)RedditRouterRequest(128-133)RedditConversionEventsPayload(137-137)RedditResponse(140-140)src/v0/util/index.js (3)
removeUndefinedAndNullValues(55-55)getHashFromArrayWithDuplicate(237-258)defaultRequestConfig(461-475)src/cdk/v2/destinations/reddit/config.js (2)
ecomEventMaps(5-26)V3_ENDPOINT(2-2)src/cdk/v2/destinations/reddit/utils.js (4)
convertToUpperSnakeCase(117-129)populateRevenueField(61-91)eventAt(138-138)generateAndValidateTimestamp(131-157)
src/cdk/v2/destinations/reddit/utils.test.js (1)
src/cdk/v2/destinations/reddit/utils.js (8)
require(1-1)populateRevenueField(61-91)decideVersion(4-11)batchEventChunks(13-38)removeUnsupportedFields(104-115)convertToUpperSnakeCase(117-129)generateAndValidateTimestamp(131-157)now(143-143)
src/cdk/v2/destinations/reddit/types.ts (3)
src/types/controlPlaneConfig.ts (1)
Destination(31-49)src/types/destinationTransformation.ts (1)
RouterTransformationRequestData(95-106)src/types/rudderEvents.ts (1)
RudderMessage(43-43)
⏰ 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). (8)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
src/cdk/v2/destinations/reddit/transformV3.ts (2)
154-199: LGTM! Well-structured multi-event handling.The logic correctly handles both single and multiple event types, properly isolates test events with
test_id, and constructs valid V3 payloads.
201-225: LGTM! Clean main processing function.The
processfunction properly validates message type, delegates toprocessTrackEvent, constructs V3 endpoints, and sets appropriate headers with Bearer token authentication.src/cdk/v2/destinations/reddit/utils.test.js (7)
1-9: LGTM! Comprehensive test imports.All new utility functions are properly imported and ready for testing.
130-198: LGTM! Thorough revenue calculation test coverage.The additional test cases properly cover edge cases: invalid prices for AddToCart, missing prices for ViewContent, uppercase event type variants (PURCHASE, ADD_TO_CART), and NaN handling.
200-263: LGTM! Complete version decision logic coverage.Tests validate all scenarios: v3 selection, default v2 fallback, null/undefined handling, and explicit v2 configuration.
265-438: LGTM! Version-aware batching tests.Tests correctly verify v2 and v3 batching paths, handling of empty inputs, single/multiple chunks, and non-array inputs. The distinction between
body.JSON.events(v2) andbody.JSON.data.events(v3) is properly validated.
440-603: LGTM! Field removal logic and immutability checks.Tests comprehensively verify which fields are retained/removed for each event type and confirm that the original input object is not mutated (lines 589-602).
605-659: LGTM! Event type conversion coverage.All standard event type mappings are tested, plus undefined behavior for unmapped types.
661-743: LGTM! Comprehensive timestamp validation tests.The corrected error message expectations (lines 675, 681) now match the implementation. Tests cover valid ISO strings, null/undefined, invalid formats, boundary conditions (7-day past, 5-minute future limits), Unix milliseconds, and Date objects.
src/cdk/v2/destinations/reddit/types.ts (4)
1-29: LGTM! Well-structured destination config schema.The schema correctly defines version enum with v2/v3 options, hashData boolean with default true, and eventsMapping array with proper event type constraints.
37-74: LGTM! Comprehensive data schemas.RedditUserDataSchema properly defines optional PII fields with nested objects for data_processing_options and screen_dimensions. RedditEventMetadataSchema correctly types
valueasz.number().optional()(line 72), which aligns with the arithmetic operations in transformV3.ts line 131.
76-93: LGTM! Effective use of discriminated union.The discriminated union on
tracking_typecleanly distinguishes CUSTOM events (requiringcustom_event_name) from predefined event types, enabling type-safe handling downstream.
95-140: LGTM! Complete type exports.All schemas are properly exported as TypeScript types using
z.infer, providing both runtime validation and compile-time type safety. The type aliases correctly compose with base types (Destination, RouterTransformationRequestData) from the framework.
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
src/cdk/v2/destinations/reddit/README.mdis excluded by!**/*.mdsrc/cdk/v2/destinations/reddit/docs/businesslogic.mdis excluded by!**/*.mdsrc/cdk/v2/destinations/reddit/docs/retl.mdis excluded by!**/*.mdtest/integrations/destinations/reddit/mocks.tsis excluded by!**/test/**
📒 Files selected for processing (2)
src/cdk/v2/destinations/reddit/transformV3.ts(1 hunks)src/cdk/v2/destinations/reddit/utils.js(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/cdk/v2/destinations/reddit/utils.js
🧠 Learnings (7)
📓 Common learnings
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
📚 Learning: 2025-07-15T06:27:07.528Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.tssrc/cdk/v2/destinations/reddit/utils.js
📚 Learning: 2025-04-02T08:21:38.217Z
Learnt from: vinayteki95
Repo: rudderlabs/rudder-transformer PR: 4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-09-29T08:38:40.752Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4678
File: src/v0/destinations/dub/utils.ts:59-61
Timestamp: 2025-09-29T08:38:40.752Z
Learning: In the Dub destination utils.ts, amount conversion should use `typeof rawPayload.amount === 'number'` check rather than truthy check to handle zero values properly, as removeUndefinedNullValuesAndEmptyObjectArray already handles undefined/null cleanup later in the pipeline.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
Applied to files:
src/cdk/v2/destinations/reddit/utils.js
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/cdk/v2/destinations/reddit/utils.js
📚 Learning: 2025-10-13T03:41:56.503Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4707
File: src/v1/destinations/am/networkHandler.ts:0-0
Timestamp: 2025-10-13T03:41:56.503Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), the populateResponseWithDontBatch function uses conditional status codes: 400 for events that already have metadata.dontBatch=true (meaning they've been retried individually and failed), and 500 for first-time failures (to trigger an unbatched retry). This two-phase retry pattern prevents infinite retries of persistently failing events.
Applied to files:
src/cdk/v2/destinations/reddit/utils.js
🧬 Code graph analysis (2)
src/cdk/v2/destinations/reddit/transformV3.ts (5)
src/types/rudderEvents.ts (1)
RudderMessage(43-43)src/cdk/v2/destinations/reddit/types.ts (6)
RedditUserData(138-138)RedditEventType(134-134)RedditEventMetadata(136-136)RedditRouterRequest(128-133)RedditConversionEventsPayload(137-137)RedditResponse(140-140)src/cdk/v2/destinations/reddit/utils.js (5)
hashSHA256(160-160)convertToUpperSnakeCase(118-130)populateRevenueField(62-92)eventAt(139-139)generateAndValidateTimestamp(132-158)src/v0/util/index.js (3)
removeUndefinedAndNullValues(55-55)getHashFromArrayWithDuplicate(237-258)defaultRequestConfig(461-475)src/cdk/v2/destinations/reddit/config.js (2)
ecomEventMaps(5-26)V3_ENDPOINT(2-2)
src/cdk/v2/destinations/reddit/utils.js (1)
src/v0/util/index.js (1)
isDefinedAndNotNull(51-51)
⏰ 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). (8)
- 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: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/cdk/v2/destinations/reddit/transformV3.ts (4)
93-121: Consider extracting the products array to reduce repeated type assertions.The function correctly handles both array and single-product scenarios. To improve readability, consider extracting the products check:
const prepareProductsArrayWithItemCount = (message: RudderMessage): RedditEventMetadata => { const { properties } = message; const products = (properties as { products?: any[] })?.products; if (products && products.length > 0) { let itemCount = 0; const mappedProducts = products.map((product) => { itemCount += 1; return { id: product.product_id, name: product.name, category: product.category, }; }); return { item_count: itemCount, products: mappedProducts }; } return { item_count: 1, products: [ { id: (properties as { product_id?: string })?.product_id, name: (properties as { name?: string })?.name, category: (properties as { category?: string })?.category, }, ], }; };
123-141: Consider adding a comment and improving type safety.
- The revenue conversion at line 133 correctly converts from cents (returned by
populateRevenueField) back to dollars. A brief comment would clarify this for future maintainers:// Convert revenue from cents (returned by populateRevenueField) to dollars value: value ? value / 100 : null,
- Line 140's type assertion
as Record<string, any>loses type safety. Since you're returningRedditEventMetadata, consider using that type directly or ensuring the return type is more specific.
156-201: Consider extracting the test_id wrapping logic to reduce duplication.The function correctly handles both single and multi-event mappings, but the test_id wrapping pattern (lines 178-182 and 194-198) is duplicated. Consider extracting it:
const wrapPayload = (payload: any, testId?: string) => { return testId ? { data: { events: [payload], test_id: testId } } : { data: { events: [payload] } }; }; // Then in processTrackEvent: if (Array.isArray(type)) { for (const t of type) { const metadata = prepareMetadata(message, t.tracking_type); const payload = { click_id: clickId, event_at: eventAt, action_source: actionSource, user: userObject, type: t, metadata, }; finalPayload.push(wrapPayload(payload, testId)); } } else { const metadata = prepareMetadata(message, type.tracking_type); const payload = { click_id: clickId, event_at: eventAt, action_source: actionSource, user: userObject, type, metadata, }; finalPayload.push(wrapPayload(payload, testId)); }
203-227: Consider creating a factory function for RedditResponse instead of relying on type casting.The double cast
as unknown as RedditResponseis necessary becausedefaultRequestConfig()returns a broader structure with additional fields (params, files, and extra body properties) that don't align with the RedditResponse schema. While the casting works at runtime, it bypasses type safety.Better approaches:
- Create a dedicated factory function (e.g.,
createRedditResponse()) that returns the exact RedditResponse structure without extra properties- Build a helper that transforms the generic request config to the Reddit-specific format
This would eliminate type casting, improve maintainability, and ensure the response structure strictly matches what RedditResponseSchema expects.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/cdk/v2/destinations/reddit/transformV3.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
📚 Learning: 2025-11-04T04:25:48.462Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/utils.js:118-130
Timestamp: 2025-11-04T04:25:48.462Z
Learning: In the Reddit destination (src/cdk/v2/destinations/reddit), the convertToUpperSnakeCase function in utils.js is designed to receive hard-coded title-case event names (Purchase, AddToCart, ViewContent, AddToWishlist, Search, Lead, SignUp, PageVisit) from ecomEventMaps in config.js and from the eventsMapping configuration. Input normalization is not needed since the inputs are always in this specific format.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-04-02T08:21:38.217Z
Learnt from: vinayteki95
Repo: rudderlabs/rudder-transformer PR: 4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-09-29T08:38:40.752Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4678
File: src/v0/destinations/dub/utils.ts:59-61
Timestamp: 2025-09-29T08:38:40.752Z
Learning: In the Dub destination utils.ts, amount conversion should use `typeof rawPayload.amount === 'number'` check rather than truthy check to handle zero values properly, as removeUndefinedNullValuesAndEmptyObjectArray already handles undefined/null cleanup later in the pipeline.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
🧬 Code graph analysis (1)
src/cdk/v2/destinations/reddit/transformV3.ts (5)
src/types/rudderEvents.ts (1)
RudderMessage(43-43)src/cdk/v2/destinations/reddit/types.ts (6)
RedditUserData(138-138)RedditEventType(134-134)RedditEventMetadata(136-136)RedditRouterRequest(128-133)RedditConversionEventsPayload(137-137)RedditResponse(140-140)src/cdk/v2/destinations/reddit/utils.js (5)
hashSHA256(160-160)convertToUpperSnakeCase(118-130)populateRevenueField(62-92)eventAt(139-139)generateAndValidateTimestamp(132-158)src/v0/util/index.js (3)
removeUndefinedAndNullValues(55-55)getHashFromArrayWithDuplicate(237-258)defaultRequestConfig(461-475)src/cdk/v2/destinations/reddit/config.js (2)
ecomEventMaps(5-26)V3_ENDPOINT(2-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). (8)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (4)
src/cdk/v2/destinations/reddit/transformV3.ts (4)
1-23: LGTM! Imports are clean and use updated utilities.The imports correctly use the refactored
hashSHA256utility from./utilsinstead of the deprecatedsha256package, addressing previous security concerns.
25-54: LGTM! User data preparation handles hashing and device IDs correctly.The function properly:
- Constructs user payload from the mapping
- Distinguishes between iOS (idfa) and Android (aaid) advertising identifiers
- Conditionally hashes PII fields based on configuration
- Cleans up undefined/null values before returning
62-91: LGTM! Event type mapping correctly handles normalization and multi-event scenarios.The function properly:
- Normalizes the incoming event name (line 70) before matching against both custom mappings and ecom fallbacks
- Supports mapping one event to multiple Reddit events (lines 80-88)
- Falls back to CUSTOM event type when no mapping exists (line 90)
Note: Line 90 uses the original
eventname forcustom_event_namerather thannormalizedEvent, which appropriately preserves the original casing for display purposes.
143-150: LGTM! Metadata assembly is clean and straightforward.
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/cdk/v2/destinations/reddit/transformV3.ts (3)
47-54: Minor: Redundant truthiness check.At line 47,
userDatais guaranteed to be truthy because of the early return at line 35. TheuserData &&condition is redundant.Consider simplifying:
- if (userData && hashData) { + if (hashData) { userData.email = userData?.email ? hashSHA256(userData.email) : null; userData.external_id = userData?.external_id ? hashSHA256(userData.external_id) : null; userData.ip_address = userData?.ip_address ? hashSHA256(userData.ip_address) : null; userData.phone_number = userData?.phone_number ? hashSHA256(userData.phone_number) : null; userData.idfa = userData?.idfa ? hashSHA256(userData.idfa) : null; userData.aaid = userData?.aaid ? hashSHA256(userData.aaid) : null; }
142-142: Optional: Consider more specific return type.The explicit cast to
Record<string, any>loses type information. Since the function signature specifiesRedditEventMetadataas the return type, the cast is unnecessary.Consider removing the explicit cast:
- return removeUndefinedAndNullValues(otherFields) as Record<string, any>; + return removeUndefinedAndNullValues(otherFields) as RedditEventMetadata;Or rely on the function signature without an explicit cast:
- return removeUndefinedAndNullValues(otherFields) as Record<string, any>; + return removeUndefinedAndNullValues(otherFields);
169-185: Optional: Consider explicit handling of undefined user data.When
userObjectisundefined(fromprepareUserObjectreturningundefined), the payload includesuser: undefined. WhileJSON.stringifynaturally omits undefined values, explicitly filtering this field improves code clarity and type safety.Consider conditionally including the
userfield:const payload = { click_id: clickId, event_at: eventAt, action_source: actionSource, - user: userObject, + ...(userObject && { user: userObject }), type: t, metadata, };Apply the same pattern to the single event type case at lines 188-195.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/cdk/v2/destinations/reddit/transformV3.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/transformV3.ts:96-123
Timestamp: 2025-11-05T15:14:25.321Z
Learning: In the Reddit destination v3 API (src/cdk/v2/destinations/reddit/transformV3.ts), the prepareProductsArrayWithItemCount function can include products with undefined fields (id, name, category all undefined) without issues. This has been validated against the actual Reddit API and works fine, so there's no need to filter out such products.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
📚 Learning: 2025-11-05T15:14:25.321Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/transformV3.ts:96-123
Timestamp: 2025-11-05T15:14:25.321Z
Learning: In the Reddit destination v3 API (src/cdk/v2/destinations/reddit/transformV3.ts), the prepareProductsArrayWithItemCount function can include products with undefined fields (id, name, category all undefined) without issues. This has been validated against the actual Reddit API and works fine, so there's no need to filter out such products.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-11-04T04:25:48.479Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/utils.js:118-130
Timestamp: 2025-11-04T04:25:48.479Z
Learning: In the Reddit destination (src/cdk/v2/destinations/reddit), the convertToUpperSnakeCase function in utils.js is designed to receive hard-coded title-case event names (Purchase, AddToCart, ViewContent, AddToWishlist, Search, Lead, SignUp, PageVisit) from ecomEventMaps in config.js and from the eventsMapping configuration. Input normalization is not needed since the inputs are always in this specific format.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-07-15T06:27:07.528Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-04-02T08:21:38.217Z
Learnt from: vinayteki95
Repo: rudderlabs/rudder-transformer PR: 4220
File: src/middlewares/routerTransformCompactedPayloadV1.ts:13-24
Timestamp: 2025-04-02T08:21:38.217Z
Learning: In the Rudder Transformer codebase, use generic Error objects instead of TransformationError when error monitoring with Bugsnag is needed, as TransformationError is configured to not trigger Bugsnag alerts.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-09-24T10:41:29.258Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4654
File: src/v1/destinations/am/networkHandler.ts:50-86
Timestamp: 2025-09-24T10:41:29.258Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), ItsSudip confirmed that hardcoded status codes (500/400) in RetryableError and AbortedError constructors are acceptable because the actual HTTP status verification happens before setting these codes in the error flow.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2024-07-27T07:02:57.329Z
Learnt from: anantjain45823
Repo: rudderlabs/rudder-transformer PR: 2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The user clarified that errors in the `setExtraNonEcomProperties` function should not cause the event to fail, indicating a preference for resilience over strict error propagation.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-09-29T08:38:40.752Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4678
File: src/v0/destinations/dub/utils.ts:59-61
Timestamp: 2025-09-29T08:38:40.752Z
Learning: In the Dub destination utils.ts, amount conversion should use `typeof rawPayload.amount === 'number'` check rather than truthy check to handle zero values properly, as removeUndefinedNullValuesAndEmptyObjectArray already handles undefined/null cleanup later in the pipeline.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-03-21T12:32:28.443Z
Learnt from: krishna2020
Repo: rudderlabs/rudder-transformer PR: 4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in Shopify source transformation throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
📚 Learning: 2025-09-26T05:46:18.503Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4683
File: src/v0/destinations/zendesk/transform.js:668-669
Timestamp: 2025-09-26T05:46:18.503Z
Learning: In Zendesk transform.js, user ItsSudip prefers to limit error payload propagation to only error?.response?.data (not the full error object or error.response) to avoid leaking sensitive information that might be contained in raw error objects, prioritizing security over detailed debugging context.
Applied to files:
src/cdk/v2/destinations/reddit/transformV3.ts
🧬 Code graph analysis (1)
src/cdk/v2/destinations/reddit/transformV3.ts (5)
src/types/rudderEvents.ts (1)
RudderMessage(43-43)src/cdk/v2/destinations/reddit/types.ts (8)
RedditUserData(138-138)RedditEventType(134-134)RedditEventMetadata(136-136)EventProperties(149-154)RedditProductType(135-135)RedditRouterRequest(128-133)RedditConversionEventsPayload(137-137)RedditResponse(140-140)src/cdk/v2/destinations/reddit/utils.js (5)
hashSHA256(160-160)convertToUpperSnakeCase(118-130)populateRevenueField(62-92)eventAt(139-139)generateAndValidateTimestamp(132-158)src/v0/util/index.js (3)
removeUndefinedAndNullValues(55-55)getHashFromArrayWithDuplicate(237-258)defaultRequestConfig(461-475)src/cdk/v2/destinations/reddit/config.js (2)
ecomEventMaps(5-26)V3_ENDPOINT(2-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). (7)
- GitHub Check: Code Coverage
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
src/cdk/v2/destinations/reddit/transformV3.ts (1)
205-243: LGTM: Well-structured main processing function.The
processfunction properly validates required configuration, handles track events, and constructs type-safe responses. All validation checks from previous reviews have been correctly implemented.
|
Allure Test reports for this run are available at:
|
e56cf6e to
a35a70d
Compare
…dder-transformer into feat/reddit-version-update
|
Allure Test reports for this run are available at:
|
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
src/cdk/v2/destinations/reddit/README.mdis excluded by!**/*.mdsrc/cdk/v2/destinations/reddit/docs/businesslogic.mdis excluded by!**/*.mdsrc/cdk/v2/destinations/reddit/docs/retl.mdis excluded by!**/*.md
📒 Files selected for processing (3)
src/cdk/v2/destinations/reddit/rtWorkflow.yaml(3 hunks)src/cdk/v2/destinations/reddit/utils.js(3 hunks)src/cdk/v2/destinations/reddit/utils.test.js(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/utils.test.js
🧠 Learnings (11)
📓 Common learnings
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/transformV3.ts:96-123
Timestamp: 2025-11-05T15:14:25.330Z
Learning: In the Reddit destination v3 API (src/cdk/v2/destinations/reddit/transformV3.ts), the prepareProductsArrayWithItemCount function can include products with undefined fields (id, name, category all undefined) without issues. This has been validated against the actual Reddit API and works fine, so there's no need to filter out such products.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
📚 Learning: 2025-11-04T04:25:48.479Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/utils.js:118-130
Timestamp: 2025-11-04T04:25:48.479Z
Learning: In the Reddit destination (src/cdk/v2/destinations/reddit), the convertToUpperSnakeCase function in utils.js is designed to receive hard-coded title-case event names (Purchase, AddToCart, ViewContent, AddToWishlist, Search, Lead, SignUp, PageVisit) from ecomEventMaps in config.js and from the eventsMapping configuration. Input normalization is not needed since the inputs are always in this specific format.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/utils.test.js
📚 Learning: 2025-07-15T06:27:07.528Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.528Z
Learning: For TikTok Ads destination in src/v0/destinations/tiktok_ads/transformV2.js, there are plans for a future enhancement to group events by eventSource when batching to ensure all events in a batch have the same event_source value, as acknowledged by ItsSudip in PR #4497.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/rtWorkflow.yaml
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/rtWorkflow.yamlsrc/cdk/v2/destinations/reddit/utils.test.js
📚 Learning: 2025-11-05T15:14:25.330Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4699
File: src/cdk/v2/destinations/reddit/transformV3.ts:96-123
Timestamp: 2025-11-05T15:14:25.330Z
Learning: In the Reddit destination v3 API (src/cdk/v2/destinations/reddit/transformV3.ts), the prepareProductsArrayWithItemCount function can include products with undefined fields (id, name, category all undefined) without issues. This has been validated against the actual Reddit API and works fine, so there's no need to filter out such products.
Applied to files:
src/cdk/v2/destinations/reddit/utils.js
📚 Learning: 2025-09-29T08:38:40.752Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4678
File: src/v0/destinations/dub/utils.ts:59-61
Timestamp: 2025-09-29T08:38:40.752Z
Learning: In the Dub destination utils.ts, amount conversion should use `typeof rawPayload.amount === 'number'` check rather than truthy check to handle zero values properly, as removeUndefinedNullValuesAndEmptyObjectArray already handles undefined/null cleanup later in the pipeline.
Applied to files:
src/cdk/v2/destinations/reddit/utils.js
📚 Learning: 2025-08-13T04:47:19.615Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4497
File: src/v0/destinations/tiktok_ads/transformV2.js:422-435
Timestamp: 2025-08-13T04:47:19.615Z
Learning: The getSuccessRespEvents function in src/v0/util/index.js is designed to be flexible and can accept both single request objects and arrays as the first parameter (message). It simply assigns the input directly to the batchedRequest property without processing, allowing downstream consumers to handle the appropriate format.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/rtWorkflow.yamlsrc/cdk/v2/destinations/reddit/utils.test.js
📚 Learning: 2025-10-13T03:41:56.503Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4707
File: src/v1/destinations/am/networkHandler.ts:0-0
Timestamp: 2025-10-13T03:41:56.503Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), the populateResponseWithDontBatch function uses conditional status codes: 400 for events that already have metadata.dontBatch=true (meaning they've been retried individually and failed), and 500 for first-time failures (to trigger an unbatched retry). This two-phase retry pattern prevents infinite retries of persistently failing events.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/rtWorkflow.yamlsrc/cdk/v2/destinations/reddit/utils.test.js
📚 Learning: 2025-05-29T13:29:39.436Z
Learnt from: maheshkutty
Repo: rudderlabs/rudder-transformer PR: 4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Applied to files:
src/cdk/v2/destinations/reddit/utils.jssrc/cdk/v2/destinations/reddit/utils.test.js
📚 Learning: 2024-07-27T07:02:57.329Z
Learnt from: anantjain45823
Repo: rudderlabs/rudder-transformer PR: 2842
File: src/v1/sources/shopify/identifierEventsLayer.test.js:5-40
Timestamp: 2024-07-27T07:02:57.329Z
Learning: The `processIdentifierEvent` function in `identifierEventsLayer.test.js` is designed to succeed for any input, hence no negative test cases are required.
Applied to files:
src/cdk/v2/destinations/reddit/rtWorkflow.yaml
📚 Learning: 2025-08-28T15:39:08.293Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4589
File: scripts/common.ts:74-78
Timestamp: 2025-08-28T15:39:08.293Z
Learning: User ItsSudip prefers simpler solutions over complex edge case handling, especially when the simpler approach is sufficient for the actual use case.
Applied to files:
src/cdk/v2/destinations/reddit/rtWorkflow.yaml
🧬 Code graph analysis (2)
src/cdk/v2/destinations/reddit/utils.js (3)
src/cdk/v2/destinations/reddit/utils.test.js (1)
require(1-10)src/v0/util/index.js (1)
isDefinedAndNotNull(51-51)src/cdk/v2/destinations/reddit/config.js (1)
maxBatchSize(3-3)
src/cdk/v2/destinations/reddit/utils.test.js (1)
src/cdk/v2/destinations/reddit/utils.js (10)
require(1-5)require(8-8)populateRevenueField(67-97)decideVersion(10-17)batchEventChunks(19-44)removeUnsupportedFields(110-121)convertToUpperSnakeCase(123-135)generateAndValidateTimestamp(137-163)now(149-149)prepareBatches(165-189)
⏰ 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). (10)
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Code Coverage
- GitHub Check: Check for formatting & lint errors
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
|
Allure Test reports for this run are available at:
|
|
* feat: introduce e2e tests UT (#4686) * chore: update slack notification list (#4706) * chore: skip pushing docker images for dependabot (#4714) * chore: skip building images for debendabot * chore: review comments * chore: skip docker login for dependabot * chore: skip docker login for dependabot * chore: misc * chore: misc * chore: misc * chore: misc * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: review comments * chore: add dub to new test structure (#4717) * chore: add readme for campaign_manager (#4710) * chore: update GAOC readme with quota link (#4723) * chore: apply security best practices (#4708) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> * feat: add validation of diff in staging deployment workflow (#4722) * chore(deps-dev): bump commander from 10.0.1 to 14.0.2 Bumps [commander](https://github.com/tj/commander.js) from 10.0.1 to 14.0.2. - [Release notes](https://github.com/tj/commander.js/releases) - [Changelog](https://github.com/tj/commander.js/blob/master/CHANGELOG.md) - [Commits](tj/commander.js@v10.0.1...v14.0.2) --- updated-dependencies: - dependency-name: commander dependency-version: 14.0.2 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore(deps-dev): bump supertest from 6.3.4 to 7.1.4 (#4525) --- updated-dependencies: - dependency-name: supertest dependency-version: 7.1.4 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: add env vars for controlling the connection pooling on python transformations (#4738) * chore: update facebook conversion api version from 22.0 to 24.0 (#4734) * chore: update facebook conversion api version from 22.0 to 23.0 * chore: update facebook conversion api version from 23.0 to 45.0 * chore: fix typo * chore: update facebook custom audience api version from 22.0 to 23.0 (#4735) * chore: update facebook custom audience api version from 22.0 to 23.0 * chore: update facebook custom audience api version from 23.0 to 24.0 * chore: update facebook custom audience api version from 24.0 to 23.0 as it has some breaking changes * chore: update facebook pixel api version from 22.0 to 24.0 (#4737) * chore: update facebook pixel api version from 22.0 to 24.0 * chore: update facebook app events api version from 22.0 to 24.0 (#4736) * chore: move rs-ai memory bank to transformer * chore: add nodemon for hot reloading (#4748) * chore: refactor code to update variable name in more readable format (#4747) * feat: source transformation endpoint for facebook_lead_ads_native source (#4746) * chore: disable clustering in nodemon configuration (#4749) * chore: run format check on all files (#4750) * fix: intercom rETL flow when user_id only provided as identifier (#4739) * chore: apply security best practices from step security (#4727) [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> * chore(deps): bump actions/setup-node from 5.0.0 to 6.0.0 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 5.0.0 to 6.0.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * chore: remove logs logging request/response body (#4754) * chore: disable pyroscope for primary process in cluster mode (#4756) * feat(reddit): onboard v3 api (#4699) * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * feat(reddit): onboard v3 api * chore: implement router batching flow * feat: enable batching scenario * chore: add test cases * chore: address coderabbit comments * chore: add mock for timestamp * chore: add documentation for reddit * fix: use crypto for hashing * chore: address coderabbit comment * chore: address comments * chore: add validation and remove double type assertion * chore: remove undefined files from final palyload * chore: fix test case * chore: apply format * chore: apply format * chore(deps): bump actions/checkout from 4.3.0 to 5.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.3.0 to 5.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4.3.0...08c6903) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * feat: add advertiser_tracking_enabled mapping for pinterest without featureFlag (#4740) * chore(deps): bump actions/stale from 10.0.0 to 10.1.0 Bumps [actions/stale](https://github.com/actions/stale) from 10.0.0 to 10.1.0. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](actions/stale@v10.0.0...v10.1.0) --- updated-dependencies: - dependency-name: actions/stale dependency-version: 10.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore: handle breaking changes for commander * chore: fix breaking commander changes * chore(release): 1.112.0 --------- Signed-off-by: StepSecurity Bot <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Rohith BCS <[email protected]> Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Sudip Paul <[email protected]> Co-authored-by: stepsecurity-app[bot] <188008098+stepsecurity-app[bot]@users.noreply.github.com> Co-authored-by: Krishna Chaitanya <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jayachand Mopidevi <[email protected]> Co-authored-by: GitHub Actions <[email protected]> Co-authored-by: shekhar-rudder <[email protected]>



Reddit API v3 Integration Support
What are the changes introduced in this PR?
This PR adds support for Reddit Ads API v3 while maintaining backward compatibility with the existing v2 implementation. The changes enable enhanced event tracking capabilities, improved data handling, and better batching logic for Reddit conversions.
What is the related Linear task?
https://linear.app/rudderstack/issue/INT-4207/reddit-api-version-update-from-v20-to-v30
Please explain the objectives of your changes below
Objectives:
test_idfieldAny changes to existing capabilities/behaviour, mention the reason & what are the changes?
Changes:
Router Workflow Modified (
rtWorkflow.yaml):Batching Logic Enhanced:
test_idare no longer batched (sent individually), and batching now combines requests with same job IDsUtility Functions Updated (
utils.js):Any new dependencies introduced with this change?
No new external dependencies. All functionality implemented using existing packages:
@rudderstack/integrations-lib(already in use)sha256(already in use)zod(already in use for other destinations)Any new generic utility introduced or modified. Please explain the changes.
New Utilities Added:
decideVersion(destination)- Determines API version (v2/v3) from destination configconvertToUpperSnakeCase(eventType)- Converts event names to Reddit v3 formatgenerateAndValidateTimestamp(timestamp)- Validates event timestampsModified Utilities:
batchEventChunks(eventChunks)- Enhanced to support both v2 and v3 payload structuresdata.eventsstructureeventsstructure (existing behavior)populateRevenueField(eventType, properties)- Added uppercase event type supportAny technical or performance related pointers to consider with the change?
Performance Considerations:
Smart Batching:
test_id) are sent individually to avoid batching issuesHashing Overhead:
hashDataflag)Multi-Event Mapping:
Technical Considerations:
@coderabbitai review
Developer checklist
Reviewer checklist
Files Changed Summary
New Files (4):
src/cdk/v2/destinations/reddit/transformV3.ts- v3 transformation logic (226 lines)src/cdk/v2/destinations/reddit/types.ts- TypeScript types and Zod schemas (138 lines)src/cdk/v2/destinations/reddit/data/userDataMapping.json- User data field mappings (65 lines)src/cdk/v2/destinations/reddit/procWorkflowV3.yaml- v3 processing workflow (8 lines)Modified Files (7):
src/cdk/v2/destinations/reddit/config.js- Added V3_ENDPOINT constantsrc/cdk/v2/destinations/reddit/rtWorkflow.yaml- Enhanced router workflow with version detectionsrc/cdk/v2/destinations/reddit/utils.js- Added 3 new utility functions, enhanced 2 existingsrc/cdk/v2/destinations/reddit/utils.test.js- Added ~40 unit tests for new functionalitytest/integrations/destinations/reddit/router/data.ts- Added 3 comprehensive integration tests for v3test/integrations/destinations/reddit/mocks.ts- Added mock functions for testingTest Coverage:
Configuration Example
To use Reddit API v3, add the
versionfield to destination config:{ "accountId": "a2_accountId123", "hashData": true, "version": "v3", "eventsMapping": [ { "from": "Order Completed", "to": "Purchase" } ] }Default: If
versionis not specified, it defaults tov2(backward compatible).Migration Notes
No migration required - this is a backward-compatible change.
To adopt v3:
"version": "v3"Customers can continue using v2 indefinitely.