Skip to content

feat: add new identify flow and subscription event in track call for attentive tag - #4468

Merged
manish339k merged 7 commits into
developfrom
feat.attentive.new.flow
Jul 21, 2025
Merged

manish339k merged 7 commits into
developfrom
feat.attentive.new.flow

Conversation

@manish339k

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

Key Changes:
✅ Enhanced identify flow using Identity Resolution + User Attributes APIs when enableNewIdentifyFlow enabled
✅ New subscription_event track call for subscription management

What is the related Linear task?

Resolves INT-3829

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

N/A

Any technical or performance related pointers to consider with the change?

N/A

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

@coderabbitai

coderabbitai Bot commented Jul 9, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Introduced a new modular identify flow with improved event processing and validation, enabled via a configuration flag.
    • Added comprehensive subscription event handling, allowing for separate subscribe and unsubscribe operations based on user consents.
    • Enhanced error handling for missing or invalid user information and consents.
  • Improvements

    • Improved mapping and processing of user channels (email, SMS) for subscription management.
    • Added utility for extracting user contacts based on provided consents.

Summary by CodeRabbit

  • New Features

    • Introduced a new modular identify flow that processes identity resolution and user attributes separately, activated by a configuration flag.
    • Added support for handling subscription events, allowing users to manage subscribe and unsubscribe actions for channels such as SMS and email.
    • Added a new configuration category for identity resolution and a utility to map channels to subscription types.
    • Introduced a helper to filter user data based on consented channels.
  • Bug Fixes

    • Improved validation to ensure required fields are present in identify and subscription events.
    • Enhanced error handling for missing or invalid configuration and consent data.

Walkthrough

A new configuration category IDENTITY_RESOLUTION was added with utilities to map communication channels to subscription types. The identify event processing was enhanced with a modular flow controlled by a feature flag, splitting identity resolution and user attribute updates into separate API calls. Track event processing now supports subscription events, handling user consents for subscribe and unsubscribe actions with validation and error handling.

Changes

File(s) Change Summary
src/v0/destinations/attentive_tag/config.js Added IDENTITY_RESOLUTION category; introduced CHANNEL_MAPPING and mapChannelToSubscriptionType utility function.
src/v0/destinations/attentive_tag/transform.js Added modular identify flow with separate identity resolution and user attribute calls; added subscription event handling with consent filtering, subscribe/unsubscribe flows, and enhanced error handling; updated identify and track builders accordingly.
src/v0/destinations/attentive_tag/util.js Added getConsentedUserContacts helper to filter user contact info based on consented channels.

Sequence Diagram(s)

sequenceDiagram
    participant Source as Event Source
    participant Transform as transform.js
    participant API as Attentive API

    Source->>Transform: Send identify event
    alt enableNewIdentifyFlow = true
        Transform->>Transform: responseBuilderForIdentityResolution
        Transform->>API: Identity resolution API call
        Transform->>Transform: responseBuilderForUserAttributes
        Transform->>API: User attributes API call
        Transform->>Source: Aggregate responses
    else
        Transform->>Transform: identifyResponseBuilder (legacy)
        Transform->>API: Single API call
        Transform->>Source: Response
    end
Loading
sequenceDiagram
    participant Source as Event Source
    participant Transform as transform.js
    participant API as Attentive API

    Source->>Transform: Send track event ("subscription_event")
    Transform->>Transform: subscriptionResponseBuilder
    Transform->>Transform: getConsentedUserContacts
    alt Subscribe consents present
        Transform->>API: Subscribe API call(s)
    end
    alt Unsubscribe consents present
        Transform->>API: Unsubscribe API call(s)
    end
    Transform->>Source: Aggregate responses
Loading

Suggested reviewers

  • sivashanmukh
  • krishna2020

Suggestions for improvement:

  • Add unit and integration tests covering the new identify flow and subscription event processing to ensure robustness and correct error handling.
  • Update documentation to include the new IDENTITY_RESOLUTION configuration category, the feature flag for the new identify flow, and subscription event handling details.
  • Consider exposing the feature flag for the new identify flow in configuration management for easier toggling across environments.
  • Review and possibly extend validation to cover edge cases in consent filtering and subscription management.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b64573 and 1337abe.

⛔ Files ignored due to path filters (1)
  • src/v0/destinations/attentive_tag/data/identityResolutionConfig.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • src/v0/destinations/attentive_tag/config.js (2 hunks)
  • src/v0/destinations/attentive_tag/transform.js (7 hunks)
  • src/v0/destinations/attentive_tag/util.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/v0/destinations/attentive_tag/util.js
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧠 Learnings (2)
src/v0/destinations/attentive_tag/config.js (2)
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/attentive_tag/transform.js (7)
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4497
File: src/v0/destinations/tiktok_ads/transformV2.js:686-691
Timestamp: 2025-07-15T06:27:07.479Z
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: 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: krishna2020
PR: rudderlabs/rudder-transformer#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.
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: 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: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function throws an error if request is not defined, making additional null checks in the getEventFromV2Request function unnecessary.
⏰ 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 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)
🔇 Additional comments (9)
src/v0/destinations/attentive_tag/config.js (2)

5-11: LGTM - Well-organized API endpoint configuration.

The ENDPOINTS constant provides a clean, centralized way to manage API endpoint paths. The descriptive comment clearly explains the purpose of these endpoints.


16-16: LGTM - Appropriate config category for new identify flow.

The IDENTITY_RESOLUTION config category is well-named and follows the existing pattern for other config categories.

src/v0/destinations/attentive_tag/transform.js (7)

46-67: LGTM - Well-structured identity resolution builder.

The function correctly constructs the payload by combining identity data and external identifiers, with appropriate validation to ensure required fields are present before making the API call.


69-102: LGTM - Comprehensive user attributes builder with proper validation.

The function correctly separates user identification data from custom properties and includes appropriate validation to prevent empty payloads. The logic for handling external identifiers is well-implemented.


104-128: LGTM - Effective aggregation of identity resolution responses.

The function properly orchestrates both identity resolution and user attributes API calls, collecting valid responses and providing clear error messaging when no valid responses are generated.


130-135: LGTM - Clean feature flag implementation.

The conditional logic cleanly separates the new identify flow from the existing implementation, maintaining backward compatibility while enabling the new functionality.


195-237: LGTM - Robust subscription response builders.

Both subscribe and unsubscribe response builders include proper validation, error handling, and payload construction. The filtering logic for subscription types and channels is well-implemented.


239-298: LGTM - Comprehensive subscription event handling.

The function properly separates subscribe and unsubscribe consents, validates required fields, and constructs appropriate API responses. The error handling covers all edge cases effectively.


308-310: LGTM - Appropriate subscription event routing.

The early detection and routing of subscription events is well-placed, preventing unnecessary timestamp validation for subscription events while maintaining the existing flow for other track events.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov

codecov Bot commented Jul 9, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.27%. Comparing base (f776f97) to head (1337abe).
Report is 66 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4468      +/-   ##
===========================================
+ Coverage    91.24%   91.27%   +0.02%     
===========================================
  Files          641      640       -1     
  Lines        33727    33805      +78     
  Branches      7954     7986      +32     
===========================================
+ Hits         30775    30854      +79     
- Misses        2687     2717      +30     
+ Partials       265      234      -31     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@manish339k
manish339k marked this pull request as ready for review July 10, 2025 03:39
@manish339k
manish339k requested review from a team and sivashanmukh as code owners July 10, 2025 03:40
@manish339k
manish339k requested review from a team, krishna2020 and yashasvibajpai July 10, 2025 03:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/v0/destinations/attentive_tag/transform.js (2)

311-313: Consider extracting the subscription event name as a constant.

The hardcoded event name comparison could be more maintainable.

Extract the event name constant at the top of the file:

+const SUBSCRIPTION_EVENT_NAME = 'subscription_event';
+
 const trackResponseBuilder = (message, { Config }) => {
   const { apiKey } = Config;
   let endpoint;
   let payload;
   const event = get(message, 'event');
   if (!event) {
     throw new InstrumentationError('[Attentive Tag] :: Event name is not present');
   }
-  if (event.toLowerCase().trim().replace(/\s+/g, '_') === 'subscription_event') {
+  if (event.toLowerCase().trim().replace(/\s+/g, '_') === SUBSCRIPTION_EVENT_NAME) {
     return subscriptionResponseBuilder(message, { Config });
   }

39-301: Add comprehensive test coverage for the new functionality.

The PR introduces significant new functionality (identity flow and subscription events) but doesn't include test files. Please ensure adequate test coverage for all new functions.

Would you like me to help generate unit tests for the new identify flow and subscription event handling?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c11f7dd and 1aa6849.

⛔ Files ignored due to path filters (4)
  • src/v0/destinations/attentive_tag/data/identityConfig.json is excluded by !**/*.json
  • test/integrations/destinations/attentive_tag/processor/identifyTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/attentive_tag/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/attentive_tag/processor/validationTestData.ts is excluded by !**/test/**
📒 Files selected for processing (2)
  • src/v0/destinations/attentive_tag/config.js (1 hunks)
  • src/v0/destinations/attentive_tag/transform.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/attentive_tag/config.js
  • src/v0/destinations/attentive_tag/transform.js
🧠 Learnings (1)
src/v0/destinations/attentive_tag/transform.js (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.
🔇 Additional comments (7)
src/v0/destinations/attentive_tag/config.js (1)

8-8: Configuration addition looks good.

The new IDENTITY configuration category follows the established pattern and naming convention.

src/v0/destinations/attentive_tag/transform.js (6)

39-60: Identity resolution logic is well-structured.

The function properly validates required fields and handles the payload construction cleanly.


62-95: User attributes processing is robust.

Good validation to prevent empty payloads and clean separation of standard vs custom properties.


97-121: New identify flow orchestration is well-designed.

Proper error handling when no valid responses are generated, with a clear error message.


123-128: Feature flag implementation ensures backward compatibility.

Good use of default value and clean delegation to the new identify flow.


204-218: Subscribe consent processing is implemented correctly.

Proper validation of required fields with clear error messaging.


220-250: Unsubscribe logic handles channel transformation correctly.

Good implementation with proper handling of optional fields and channel name mapping.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
src/v0/destinations/attentive_tag/transform.js (4)

62-95: Consider edge case handling for empty traits object.

The function handles most scenarios well, but there's a potential issue when traits is an empty object or null.

const processUserAttributes = (message, apiKey) => {
-  const traits = getFieldValueFromMessage(message, 'traits') || {};
+  const traits = getFieldValueFromMessage(message, 'traits');
+  if (!traits || typeof traits !== 'object') {
+    return null;
+  }

97-121: Enhance error message with more specific details.

The error message could be more helpful by indicating which specific validations failed.

if (responses.length === 0) {
  throw new InstrumentationError(
-    '[Attentive Tag]: Identify payload is not valid, either user or properties is empty',
+    '[Attentive Tag]: No valid API calls generated - check that user identifiers and custom properties are provided',
  );
}

204-218: Validate signUpSourceId earlier to prevent processing overhead.

Move the signUpSourceId validation before processing the filtered user to avoid unnecessary work.

const processSubscribeConsents = (filteredUser, signUpSourceId, apiKey) => {
+  if (!signUpSourceId) {
+    throw new ConfigurationError(
+      '[Attentive Tag]: SignUp Source Id is required for subscribe event',
+    );
+  }
+
  if (Object.keys(filteredUser).length === 0) return [];

-  if (!signUpSourceId) {
-    throw new ConfigurationError(
-      '[Attentive Tag]: SignUp Source Id is required for subscribe event',
-    );
-  }

220-250: Channel mapping logic could be more maintainable.

The hardcoded channel mapping ('sms' → 'TEXT', others → 'EMAIL') should be extracted to a constant or helper function for better maintainability.

+const CHANNEL_MAPPING = {
+  sms: 'TEXT',
+  email: 'EMAIL'
+};
+
+const mapChannelToSubscriptionType = (channel) => {
+  return CHANNEL_MAPPING[channel?.toLowerCase()] || 'EMAIL';
+};

// In the processUnsubscribeConsents function:
const subscriptions = unsubscribeConsents
  .filter((consent) => consent.type)
  .map((consent) => ({
    type: consent.type,
-    channel: consent.channel === 'sms' ? 'TEXT' : 'EMAIL',
+    channel: mapChannelToSubscriptionType(consent.channel),
  }));
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1aa6849 and 0327afd.

⛔ Files ignored due to path filters (1)
  • test/integrations/destinations/attentive_tag/processor/validationTestData.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/attentive_tag/transform.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/attentive_tag/transform.js
🧠 Learnings (1)
src/v0/destinations/attentive_tag/transform.js (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: krishna2020
PR: rudderlabs/rudder-transformer#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.
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: 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: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function throws an error if request is not defined, making additional null checks in the getEventFromV2Request function unnecessary.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in the Shopify source throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • 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: 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: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
src/v0/destinations/attentive_tag/transform.js (5)

39-60: The identity resolution logic looks solid.

The function correctly validates required fields and constructs the payload appropriately. The conditional logic ensures API calls are only made when necessary data is present.


123-128: LGTM - Clean feature flag implementation.

The conditional logic properly maintains backward compatibility while enabling the new identify flow when the feature flag is enabled.


188-202: Good implementation addressing previous feedback.

The case-insensitive channel comparison and optional chaining properly handle edge cases as suggested in previous reviews.


252-305: Robust subscription event handling with proper validation.

The function properly validates user data as suggested in previous reviews and handles both subscribe and unsubscribe scenarios effectively. The error handling is comprehensive.


315-317: Event name normalization is consistent.

The event name processing using toLowerCase().trim().replace(/\s+/g, '_') is consistent with the existing switch statement logic below.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@yashasvibajpai
yashasvibajpai requested a review from Copilot July 10, 2025 04:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a feature-flagged identify flow leveraging Identity Resolution and User Attributes APIs, and adds support for a new subscription_event in the track call for subscription management.

  • Implements identifyResponseBuilderNew with processIdentityResolution and processUserAttributes under the enableNewIdentifyFlow flag
  • Adds subscription-event handling in trackResponseBuilder via subscriptionResponseBuilder, with helpers for filtering and processing consents
  • Expands test coverage: new validation tests for identify and subscription errors and un-skips existing integration tests

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/v0/destinations/attentive_tag/config.js Added IDENTITY config category and mapChannelToSubscriptionType
src/v0/destinations/attentive_tag/data/identityConfig.json New mapping for identity resolution (phone, email)
src/v0/destinations/attentive_tag/transform.js New helper functions for identify and subscription flows; updated builders
test/integrations/.../validationTestData.ts Added validation tests for new identify flow and subscription error cases
test/integrations/.../trackTestData.ts & identifyTestData.ts Removed skip flags to activate previously-skipped tests
Comments suppressed due to low confidence (2)

src/v0/destinations/attentive_tag/transform.js:320

  • Add positive test cases for successful subscription_event handling (e.g., valid subscribe and unsubscribe flows) to ensure the new code path is fully exercised.
  if (event.toLowerCase().trim().replace(/\s+/g, '_') === 'subscription_event') {

src/v0/destinations/attentive_tag/transform.js:194

  • [nitpick] Consider adding JSDoc comments for the new helper functions (filterUserByConsents, processSubscribeConsents, etc.) to clarify their purpose, parameters, and return values.
const filterUserByConsents = (user, consents) => {

@manish339k

Copy link
Copy Markdown
Contributor Author

I will raise doc PR after we merge this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/v0/destinations/attentive_tag/transform.js (1)

68-101: Consider relaxing the validation logic for user attributes.

The current validation on lines 96-97 returns null if either user or properties is empty. This might be too restrictive - consider allowing updates when a user has valid contact info even without custom properties.

- // If user or properties is empty, return null as we don't want to send empty user or properties
- if (Object.keys(user).length === 0 || Object.keys(properties).length === 0) {
-   return null;
- }
+ // If user is empty, return null. Allow empty properties for users with valid contact info
+ if (Object.keys(user).length === 0) {
+   return null;
+ }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b12ef5 and 5b64573.

⛔ Files ignored due to path filters (1)
  • src/v0/destinations/attentive_tag/data/identityResolutionConfig.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • src/v0/destinations/attentive_tag/config.js (2 hunks)
  • src/v0/destinations/attentive_tag/transform.js (5 hunks)
  • src/v0/destinations/attentive_tag/util.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/v0/destinations/attentive_tag/config.js
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/attentive_tag/transform.js
  • src/v0/destinations/attentive_tag/util.js
🧠 Learnings (2)
src/v0/destinations/attentive_tag/transform.js (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: krishna2020
PR: rudderlabs/rudder-transformer#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.
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: 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: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function throws an error if request is not defined, making additional null checks in the getEventFromV2Request function unnecessary.
src/v0/destinations/attentive_tag/util.js (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.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • 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: 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: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
src/v0/destinations/attentive_tag/util.js (1)

141-155: Function implementation looks solid with proper defensive programming.

The filterUserByConsents function is well-structured with appropriate null safety and case-insensitive channel comparison. The logic correctly filters user contact information based on consent channels.

src/v0/destinations/attentive_tag/transform.js (8)

4-9: Import statements properly updated for new functionality.

The additional imports for mapChannelToSubscriptionType and configuration categories are correctly added to support the new subscription event handling.


45-66: Identity resolution logic is well-implemented with proper validation.

The function correctly constructs the payload and validates required fields before returning a response. The conditional logic ensures API calls are only made when necessary data is available.


104-127: New identify flow implementation is well-structured.

The modular approach with separate identity resolution and user attributes processing provides clear separation of concerns. The error handling appropriately catches cases where no valid responses are generated.


129-134: Feature flag implementation maintains backward compatibility effectively.

The conditional logic based on enableNewIdentifyFlow ensures existing functionality remains unchanged while allowing new features to be enabled when ready.


194-208: Subscribe response builder handles validation appropriately.

The function correctly validates required fields and returns empty arrays when conditions aren't met, which integrates well with the response aggregation logic.


210-240: Unsubscribe logic properly handles consent mapping and validation.

The implementation correctly filters consents, maps channels to subscription types, and includes optional notification data. The validation ensures only valid unsubscribe requests are processed.


242-295: Subscription event handling is comprehensive and well-structured.

The implementation properly separates subscribe and unsubscribe consents, validates user data, and aggregates responses. The error handling covers edge cases appropriately.


305-307: Track event routing for subscription events is implemented correctly.

The conditional logic properly detects subscription events and routes them to the appropriate handler before falling through to existing event processing.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@ItsSudip ItsSudip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some positive scenarios for both the identify and track events?

@manish339k

Copy link
Copy Markdown
Contributor Author

Can we add some positive scenarios for both the identify and track events?

I have added most of the positive tests here #4457

@manish339k
manish339k merged commit 004401a into develop Jul 21, 2025
@manish339k
manish339k deleted the feat.attentive.new.flow branch July 21, 2025 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants