Repository navigation
feat: onboard postscript destination - #4438
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughA new Postscript destination integration has been introduced, including configuration, transformation logic, type definitions, utility functions, network handler, and comprehensive test coverage. The feature flag for Postscript is enabled, and all core modules for event transformation, batching, error handling, and API communication are implemented and tested. Changes
Sequence Diagram(s)sequenceDiagram
participant Source as RudderStack Source
participant Transform as Postscript Transform
participant Utils as Postscript Utils
participant API as Postscript API
Source->>Transform: Send batch of events (identify/track)
Transform->>Utils: Validate config and event fields
alt Identify Event
Transform->>Utils: Build subscriber payload
Utils->>API: Lookup subscriber by phone
API-->>Utils: Return subscriber existence
Utils-->>Transform: Subscriber ID or create flag
Transform->>Utils: Prepare create/update request
else Track Event
Transform->>Utils: Build custom event payload
end
Transform->>Utils: Batch responses for API
Utils->>API: Send batched requests
API-->>Utils: Return API responses
Utils-->>Transform: Success/error responses
Transform-->>Source: Return processed results
Suggested reviewers
Suggestions for Improvement:
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4438 +/- ##
===========================================
+ Coverage 91.57% 91.61% +0.04%
===========================================
Files 639 643 +4
Lines 33786 34006 +220
Branches 7988 8048 +60
===========================================
+ Hits 30940 31156 +216
- Misses 2588 2620 +32
+ Partials 258 230 -28 ☔ 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:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (5)
src/v0/destinations/postscript/networkHandler.ts (1)
46-53: Consider passing actual status code to RetryableError.The RetryableError constructor currently hardcodes status 500, but the actual error status could be 502, 503, 504, etc. This might cause confusion during debugging.
Consider this improvement:
- throw new RetryableError( - `[${DESTINATION_NAME}] Server error occurred`, - 500, - destinationResponse, - ); + throw new RetryableError( + `[${DESTINATION_NAME}] Server error occurred`, + status, + destinationResponse, + );src/v0/destinations/postscript/transform.ts (1)
55-56: Improve type safety when accessing context traitsConsider using a more type-safe approach instead of using
as anytype assertion. This will help catch potential runtime errors during development.- const contextTraits = (message.context as any)?.traits ?? {}; + const contextTraits = message.context?.traits ?? {};If the types don't align, consider extending the RudderMessage type or creating a utility function to safely extract traits.
src/v0/destinations/postscript/utils.ts (3)
33-33: Use ES6 import syntax for consistencyReplace the CommonJS
require()with ES6 import syntax to maintain consistency with the rest of the codebase.-// Import the subscriber field mapping -const subscriberMapping = require('./data/postscriptSubscriberConfig.json'); +// Import the subscriber field mapping +import subscriberMapping from './data/postscriptSubscriberConfig.json';
96-98: Replace delete operator for better performanceThe
deleteoperator can impact performance. Use undefined assignment as suggested by the static analysis tool.// For update operations, remove subscriber_id from payload as it goes in the URL if (isUpdate && payload.subscriber_id) { - delete payload.subscriber_id; + payload.subscriber_id = undefined; }Note: Since
removeUndefinedAndNullValuesis called at the end of the function, this will effectively remove the field from the final payload.
117-120: Improve snake_case conversion logicThe current regex-based conversion won't handle edge cases like consecutive capitals (e.g., "IOSVersion" → "i_o_s_version" instead of "ios_version").
- // Convert camelCase to snake_case for custom properties - const snakeCaseKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`); + // Convert camelCase to snake_case for custom properties + const snakeCaseKey = key + .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') + .replace(/([a-z\d])([A-Z])/g, '$1_$2') + .toLowerCase();
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
src/v0/destinations/postscript/data/postscriptSubscriberConfig.jsonis excluded by!**/*.jsontest/integrations/component.test.tsis excluded by!**/test/**
📒 Files selected for processing (8)
src/features.ts(1 hunks)src/v0/destinations/postscript/config.ts(1 hunks)src/v0/destinations/postscript/networkHandler.test.ts(1 hunks)src/v0/destinations/postscript/networkHandler.ts(1 hunks)src/v0/destinations/postscript/testData.ts(1 hunks)src/v0/destinations/postscript/transform.ts(1 hunks)src/v0/destinations/postscript/types.ts(1 hunks)src/v0/destinations/postscript/utils.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
src/v0/destinations/postscript/utils.ts (1)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
src/v0/destinations/postscript/testData.ts (2)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#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.
src/v0/destinations/postscript/transform.ts (1)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
src/v0/destinations/postscript/networkHandler.test.ts (1)
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.
🧬 Code Graph Analysis (3)
src/v0/destinations/postscript/networkHandler.ts (2)
src/v0/destinations/postscript/config.ts (1)
DESTINATION_NAME(27-27)src/adapters/utils/networkUtils.js (1)
getDynamicErrorType(87-95)
src/v0/destinations/postscript/networkHandler.test.ts (1)
src/v0/destinations/postscript/config.ts (1)
DESTINATION_NAME(27-27)
src/v0/destinations/postscript/types.ts (3)
src/types/rudderEvents.ts (2)
Metadata(121-121)RudderMessage(43-43)src/types/controlPlaneConfig.ts (3)
Destination(30-48)Connection(54-60)DestinationConnectionConfig(50-52)src/types/destinationTransformation.ts (3)
RouterTransformationRequestData(94-105)BatchedRequest(40-53)BatchRequestOutput(55-66)
🪛 Biome (1.9.4)
src/v0/destinations/postscript/utils.ts
[error] 97-97: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- 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: test_and_publish
🔇 Additional comments (15)
src/features.ts (1)
100-100: LGTM - Feature flag addition follows established pattern.The PostScript feature flag is correctly added to the routerTransform configuration and maintains proper alphabetical ordering.
src/v0/destinations/postscript/config.ts (1)
1-28: Well-structured configuration file.The configuration constants are properly organized and typed. The use of const assertion for
EXTERNAL_ID_TYPESensures type safety, and the API endpoint structure follows good practices.src/v0/destinations/postscript/networkHandler.ts (2)
25-65: Solid error handling implementation.The response handler correctly categorizes different HTTP status codes and uses appropriate RudderStack error types. The logic follows established patterns and includes proper error metadata.
73-78: Standard networkHandler implementation.The networkHandler function correctly implements the standard interface used across RudderStack destinations, assigning all required methods.
src/v0/destinations/postscript/networkHandler.test.ts (3)
12-245: Excellent comprehensive test coverage.The test suite demonstrates outstanding practices with systematic coverage of all HTTP status codes, proper use of helper functions for maintainability, and thorough validation of error types and metadata. The TestCase interface approach makes the tests both readable and scalable.
248-294: Thorough edge case testing.The edge case tests properly validate handling of empty/null response bodies and ensure original response preservation in error scenarios. This level of detail helps ensure robust error handling.
296-361: Complete initialization and metadata testing.The tests properly verify network handler initialization and error metadata tagging, ensuring the handler integrates correctly with RudderStack's error reporting infrastructure.
src/v0/destinations/postscript/testData.ts (5)
11-35: Well-structured mock configurations.The mock destination and connection configurations provide appropriate test data with all necessary fields for PostScript destination testing.
36-49: Good use of factory function for metadata generation.The
generateMetadatafactory function ensures consistent metadata structure across test cases, which improves maintainability and reduces duplication.
52-127: Comprehensive event test data coverage.The test events cover key scenarios including subscriber creation, updates with external IDs, and custom event tracking. The data structure properly represents real-world PostScript integration use cases.
128-171: Valuable error scenario test data.The invalid events provide essential test coverage for error handling, including missing required fields and unsupported event types. This helps ensure robust validation in the transformation logic.
174-198: Well-organized batch testing support.The batch test data and expected count constants enable comprehensive testing of the PostScript destination's batch processing capabilities and validation logic.
src/v0/destinations/postscript/transform.ts (1)
111-136: LGTM! Clean track event processingThe function correctly validates required fields and builds the custom event payload with proper error handling.
src/v0/destinations/postscript/utils.ts (1)
213-213: Verify pagination handling for large subscriber lookupsI only found a single instance of
params.append('limit', '100')in
• src/v0/destinations/postscript/utils.ts:213There’s no accompanying offset, page, or cursor logic to fetch additional pages if more than 100 subscribers exist. Please confirm one of the following:
- 100 is guaranteed to cover all lookup cases (add a comment explaining why).
- Or implement proper pagination (e.g., using an
offsetorcursorparameter) to handle larger batches.src/v0/destinations/postscript/types.ts (1)
1-246: Well-structured type definitionsThe type definitions are comprehensive and well-organized, following established patterns in the codebase. Good use of zod for schema validation.
|
Remove skip test for postscript |
|
Resolve coderabbit comments |
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (3)
src/v0/destinations/postscript/transform.ts (2)
247-250: Avoid mutating error objects directlyModifying the error message property directly can cause issues if the error object is used elsewhere. Create a new error instead.
- if (error instanceof Error) { - // Log the error for debugging while still proceeding - error.message = `Subscriber lookup failed: ${error.message}`; - } + if (error instanceof Error) { + // Log the error for debugging while still proceeding + const lookupError = new Error(`Subscriber lookup failed: ${error.message}`); + // Consider logging this error for debugging + }
282-291: Simplify connection handling logicThe default connection object creation seems like a workaround. Consider making the connection parameter required or handling the undefined case more elegantly.
const batchedResponses = batchResponseBuilder( allProcessedEvents, postscriptDestination, - postscriptConnection ?? { - sourceId: 'default-source-id', - destinationId: 'default-destination-id', - enabled: true, - config: { - destination: {}, - }, - }, + postscriptConnection, );Then update the
batchResponseBuilderfunction signature to accept an optional connection parameter if it's not actually used.src/v0/destinations/postscript/types.ts (1)
54-57: Remove unusedPostscriptExternalIdinterfaceThe
PostscriptExternalIdinterface is defined but not used anywhere in the codebase. Consider removing it to eliminate dead code.-export interface PostscriptExternalId { - type: 'subscriber_id' | 'external_id' | 'shopify_customer_id'; - id: string | number; -}
🧹 Nitpick comments (4)
src/v0/destinations/postscript/utils.ts (3)
42-42: Use standard header casing for Content-TypeHTTP header names should follow standard casing conventions. Use
Content-Typeinstead ofContent-type.- 'Content-type': 'application/json', + 'Content-Type': 'application/json',
97-97: Replace delete operator with undefined assignment for better performanceThe delete operator can impact performance. Consider using an undefined assignment instead.
- delete payload.subscriber_id; + payload.subscriber_id = undefined;
302-303: Remove or make optional the unused connection parameterThe
connectionparameter is marked as unused. Either remove it from the function signature or make it optional if it might be used in the future.export const batchResponseBuilder = ( events: ProcessedEvent[], destination: PostscriptDestination, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - connection: PostscriptConnection, + connection?: PostscriptConnection, ): PostscriptBatchResponse[] => {src/v0/destinations/postscript/types.ts (1)
214-214: Use Record<string, unknown> for consistencyFor type safety and consistency with other parts of the codebase, use
unknowninstead ofany.- Record<string, any>, // params + Record<string, unknown>, // params
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
test/integrations/destinations/postscript/common.tsis excluded by!**/test/**test/integrations/destinations/postscript/router/errorHandlingTestData.tsis excluded by!**/test/**test/integrations/destinations/postscript/router/identifyTestData.tsis excluded by!**/test/**test/integrations/destinations/postscript/router/mixedEventsTestData.tsis excluded by!**/test/**test/integrations/destinations/postscript/router/trackTestData.tsis excluded by!**/test/**
📒 Files selected for processing (4)
src/v0/destinations/postscript/config.ts(1 hunks)src/v0/destinations/postscript/transform.ts(1 hunks)src/v0/destinations/postscript/types.ts(1 hunks)src/v0/destinations/postscript/utils.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- src/v0/destinations/postscript/config.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
src/v0/destinations/postscript/transform.ts (6)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#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.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-10-08T15:52:59.819Z
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.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#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.
src/v0/destinations/postscript/utils.ts (1)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
🧬 Code Graph Analysis (1)
src/v0/destinations/postscript/types.ts (3)
src/types/rudderEvents.ts (2)
Metadata(121-121)RudderMessage(43-43)src/types/controlPlaneConfig.ts (3)
Destination(30-48)Connection(54-60)DestinationConnectionConfig(50-52)src/types/destinationTransformation.ts (3)
RouterTransformationRequestData(94-105)BatchedRequest(40-53)BatchRequestOutput(55-66)
🪛 Biome (1.9.4)
src/v0/destinations/postscript/utils.ts
[error] 97-97: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- 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: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: UT Tests
- GitHub Check: test_and_publish
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
|
@coderabbitai Can you do one round of review, check if it following all idiomatic of typescript |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@maheshkutty, I'll perform a comprehensive TypeScript idioms review of the PostScript destination implementation. Let me examine the key files to check for best practices and idiomatic TypeScript patterns. 🏁 Script executed: Length of output: 32089 Based on my analysis of the PostScript destination TypeScript implementation, here's a comprehensive review of TypeScript idioms and best practices: ✅ Excellent TypeScript Practices Already Implemented
🔧 Areas for Improvement1. config.ts - Add
|
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
src/v0/destinations/postscript/transform.ts (2)
234-237: Avoid mutating error objects directly.This is a duplicate of a previous review comment. Modifying the error message property directly can cause issues if the error object is used elsewhere. Create a new error instead.
- if (error instanceof Error) { - // Log the error for debugging while still proceeding - error.message = `Subscriber lookup failed: ${error.message}`; - } + if (error instanceof Error) { + // Log the error for debugging while still proceeding + const lookupError = new Error(`Subscriber lookup failed: ${error.message}`); + logger.warn('PostScript subscriber lookup failed:', lookupError); + }
275-284: Simplify connection handling logic.This is a duplicate of a previous review comment. The default connection object creation seems like a workaround. Consider making the connection parameter required or handling the undefined case more elegantly.
const batchedResponses = batchResponseBuilder( allProcessedEvents, postscriptDestination, - postscriptConnection ?? { - sourceId: 'default-source-id', - destinationId: 'default-destination-id', - enabled: true, - config: { - destination: {}, - }, - }, + postscriptConnection, );Then update the
batchResponseBuilderfunction signature to accept an optional connection parameter if it's not actually used.
🧹 Nitpick comments (2)
src/v0/destinations/postscript/utils.test.ts (1)
123-135: Replace delete operator with undefined assignment for better performance.The static analysis tool correctly identifies a performance issue with the delete operator. Using undefined assignment is more efficient and achieves the same result.
- it('should build headers without partner key when env var is not set', () => { - delete process.env.POSTSCRIPT_PARTNER_API_KEY; - const apiKey = 'test_api_key_123'; - const headers = buildHeaders(apiKey); - - expect(headers).toEqual({ - 'Content-type': 'application/json', - Accept: 'application/json', - Authorization: 'Bearer test_api_key_123', - 'X-Postscript-Partner-Key': undefined, - }); - }); + it('should build headers without partner key when env var is not set', () => { + process.env.POSTSCRIPT_PARTNER_API_KEY = undefined; + const apiKey = 'test_api_key_123'; + const headers = buildHeaders(apiKey); + + expect(headers).toEqual({ + 'Content-type': 'application/json', + Accept: 'application/json', + Authorization: 'Bearer test_api_key_123', + 'X-Postscript-Partner-Key': undefined, + }); + });src/v0/destinations/postscript/utils.ts (1)
95-98: Replace delete operator with undefined assignment for better performance.The static analysis tool correctly identifies a performance issue with the delete operator. Using undefined assignment is more efficient and achieves the same result.
- // For update operations, remove subscriber_id from payload as it goes in the URL - if (isUpdate && payload.subscriber_id) { - delete payload.subscriber_id; - } + // For update operations, remove subscriber_id from payload as it goes in the URL + if (isUpdate && payload.subscriber_id) { + payload.subscriber_id = undefined; + }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
src/v0/destinations/postscript/README.mdis excluded by!**/*.mdsrc/v0/destinations/postscript/docs/businesslogic.mdis excluded by!**/*.mdsrc/v0/destinations/postscript/docs/retl.mdis excluded by!**/*.mdtest/integrations/component.test.tsis excluded by!**/test/**test/integrations/destinations/postscript/router/identifyTestData.tsis excluded by!**/test/**
📒 Files selected for processing (3)
src/v0/destinations/postscript/transform.ts(1 hunks)src/v0/destinations/postscript/utils.test.ts(1 hunks)src/v0/destinations/postscript/utils.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
src/v0/destinations/postscript/transform.ts (7)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#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.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#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.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-10-08T15:52:59.819Z
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.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.
src/v0/destinations/postscript/utils.test.ts (3)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#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.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
src/v0/destinations/postscript/utils.ts (9)
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#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.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#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.
Learnt from: vinayteki95
PR: rudderlabs/rudder-transformer#4220
File: src/middlewares/destTransformCompactedPayloadV1.ts:13-19
Timestamp: 2025-04-02T08:16:58.002Z
Learning: In the Rudder Transformer project, error handling should throw errors with descriptive messages (after logging them) rather than returning HTTP status codes, so that Bugsnag can catch them for debugging purposes.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#2852
File: src/v0/destinations/sfmc/transform.js:251-251
Timestamp: 2024-07-27T07:02:57.329Z
Learning: Remember to suggest including dynamic variables in error messages for better clarity and debugging.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#2852
File: src/v0/destinations/sfmc/transform.js:251-251
Timestamp: 2024-10-08T15:52:59.819Z
Learning: Remember to suggest including dynamic variables in error messages for better clarity and debugging.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#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.
Learnt from: anantjain45823
PR: rudderlabs/rudder-transformer#2842
File: src/v1/sources/shopify/enrichmentLayer.js:36-42
Timestamp: 2024-10-08T15:52:59.819Z
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.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
🪛 Biome (1.9.4)
src/v0/destinations/postscript/utils.test.ts
[error] 124-124: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
src/v0/destinations/postscript/utils.ts
[error] 97-97: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
⏰ 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 (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (5)
src/v0/destinations/postscript/utils.test.ts (1)
76-803: Excellent test coverage and structure.The test suite demonstrates comprehensive coverage of all utility functions with well-organized test cases covering normal operations, edge cases, and error scenarios. The mocking strategy effectively isolates the functions under test while providing realistic test data.
src/v0/destinations/postscript/transform.ts (1)
152-288: Well-structured router transformation logic.The main
processRouterDestfunction demonstrates excellent design with clear separation of concerns, proper error handling, and efficient batch processing. The subscriber lookup optimization and event ordering preservation are particularly well implemented.src/v0/destinations/postscript/utils.ts (3)
283-295: Excellent error handling in subscriber lookup.The error handling in the
performSubscriberLookupfunction demonstrates good resilience by logging the error and continuing with fallback behavior. This approach ensures the transformation continues even if the lookup API is temporarily unavailable.
78-153: Well-implemented payload building with comprehensive field mapping.The
buildSubscriberPayloadfunction effectively uses RudderStack's utility functions likeconstructPayload,extractCustomFields, andgenerateExclusionListto create a robust field mapping system. The handling of update vs create operations and external ID management is particularly well done.
308-340: Efficient batch response building.The
batchResponseBuilderfunction correctly creates individual responses for each event using the appropriate RudderStack patterns. The use ofdefaultRequestConfigandgetSuccessRespEventsfollows established conventions.
|
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:
|
|
Allure Test reports for this run are available at:
|
|
* chore: ai generated docs for airship * chore: migrate some streaming destination to new test format (#4435) * chore: migrate some streaming destination to new test format * chore: rebase to develop * fix: type * chore: review comments * chore: ing-svc workflow takes latest go tests * chore: restart deployment after creating a develop image (#4528) * chore: restart deployment after creating a develop image * fix: review comments * fix: add dependencies for kubectl * chore: review comments * chore: review comments * chore: add another job for dedicated deployment * chore: update sku mappings for product viewed event (#4467) * chore: update sku mappings for product viewed event, fix skipped tests * chore: remove skip false --------- Co-authored-by: Mahesh Kutty <[email protected]> * chore: add checkout step for deployment restart action (#4532) * chore: auto create ing-svc pr for go-tests * chore: restructure workflows * chore: workflow add permissions * chore: address security and compatibility issues * refactor: remove unused marketo bulk upload metrics (#4537) - Remove 13 unused marketo_bulk_upload metrics that were defined but not collected - These metrics were from old implementation and not actively used - Reduces Prometheus cardinality and improves performance - Keeps only actively used marketo metrics: fetch_token, lead_lookup, activity Fixes INT-3978 * chore: use latest vars for pod restart (#4538) * chore: gitworkflow version upgrades * chore: scan push revert to old version * chore: add lint rules to catch invalid or unresolved imports (#4531) * feat: onboard postscript destination (#4438) * feat: onboard postscript destination * chore: add nwhandler tests * chore: add comments, update tests, fix properties inconsistencies * chore: address comments * chore: add util tests * feat: onboard postscript destination * chore: add nwhandler tests * chore: add comments, update tests, fix properties inconsistencies * chore: address comments * chore: add util tests * chore: address comments * fix: subscriber updation logic * chore: add tests for code coverage * chore: address comments * chore: address comments, add docs * chore: remove catch --------- Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> * chore(release): 1.106.0 --------- Co-authored-by: Vinay Teki <[email protected]> Co-authored-by: Dilip Kola <[email protected]> Co-authored-by: Manish Kumar <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: Yashasvi Bajpai <[email protected]> Co-authored-by: Mahesh Kutty <[email protected]> Co-authored-by: GitHub Actions <[email protected]>



What are the changes introduced in this PR?
This pull request introduces the PostScript destination to the codebase, enabling integration with the PostScript SMS marketing platform. The changes include configuration setup, data mapping, network handling, transformation logic, and test data for the new destination.
PostScript Destination Implementation:
Configuration Setup:
POSTSCRIPTto thedefaultFeaturesConfiginsrc/features.ts, enabling the PostScript feature.src/v0/destinations/postscript/config.tsto define API endpoints, field mappings, external ID types, and destination name constants.Data Mapping:
postscriptSubscriberConfig.jsoninsrc/v0/destinations/postscript/datato map RudderStack traits to PostScript subscriber fields, including phone number, email, and tags.Network Handling:
networkHandlerinsrc/v0/destinations/postscript/networkHandler.tsfor API response handling, including retry logic for server errors and throttling for rate limits.Transformation Logic:
processRouterDestinsrc/v0/destinations/postscript/transform.tsto handle identify and track events, perform subscriber lookups, and batch events for efficient API submission.Test Data:
testData.tsinsrc/v0/destinations/postscriptto provide mock data for identify, track, and error scenarios, enabling comprehensive testing of the PostScript integration.What is the related Linear task?
Resolves INT-3834
Please explain the objectives of your changes below
Adding new destination support
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
None
Any new dependencies introduced with this change?
None
Any new generic utility introduced or modified. Please explain the changes.
None
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.