Skip to content

feat: add value based audience to facebook custom audience destination - #4322

Merged
manish339k merged 7 commits into
developfrom
feat.fb.value.based.audience
Jun 27, 2025
Merged

manish339k merged 7 commits into
developfrom
feat.fb.value.based.audience

Conversation

@manish339k

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

onboarding facebook value based custom audience

What is the related Linear task?

Resolves INT-3490

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 May 14, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for the 'LOOKALIKE_VALUE' field in Facebook Custom Audience integration.
    • Enhanced validation to ensure correct usage of 'LOOKALIKE_VALUE' for Value-Based Custom Audiences.
  • Bug Fixes

    • Improved handling and normalization of 'LOOKALIKE_VALUE', including defaulting invalid or missing values to zero.
  • Tests

    • Expanded and refactored test coverage for 'LOOKALIKE_VALUE', including edge cases and input validation.

Summary by CodeRabbit

  • New Features

    • Added support for the 'LOOKALIKE_VALUE' field in Facebook Custom Audience configurations, enabling value-based audience features.
  • Bug Fixes

    • Improved validation to ensure 'LOOKALIKE_VALUE' is only used appropriately for value-based audiences, with clear error messages for misconfiguration.
  • Tests

    • Enhanced and expanded test coverage for handling the 'LOOKALIKE_VALUE' field and related edge cases.
  • Refactor

    • Streamlined test cases for better maintainability and consistency.

Walkthrough

This change introduces support for a new user schema field, LOOKALIKE_VALUE, in the Facebook Custom Audience integration. It updates configuration, validation, and data transformation logic to handle this field, adds strict validation for its usage, and refactors related utility functions and their tests to ensure correct processing and coverage for the new field.

Changes

File(s) Change Summary
src/v0/destinations/fb_custom_audience/config.js Added 'LOOKALIKE_VALUE' to the exported schemaFields array.
src/v0/destinations/fb_custom_audience/recordTransform.js Added isValueBasedAudience flag to config and function signatures; enforced validation for LOOKALIKE_VALUE usage according to audience type.
src/v0/destinations/fb_custom_audience/util.js Refactored getUpdatedDataElement to support LOOKALIKE_VALUE, changed argument names, normalized values, and handled numeric parsing and defaults for the new field.
src/v0/destinations/fb_custom_audience/util.test.js Refactored tests into parameterized cases; added comprehensive edge case coverage for LOOKALIKE_VALUE including numeric parsing, negative, non-numeric, and empty values.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant processRecordInputsV2
    participant preparePayload
    participant util_getUpdatedDataElement

    User->>processRecordInputsV2: Provide groupedRecordInputs (with config)
    processRecordInputsV2->>preparePayload: Pass events and config (with isValueBasedAudience)
    preparePayload->>preparePayload: Validate LOOKALIKE_VALUE usage
    preparePayload->>util_getUpdatedDataElement: Transform user data (including LOOKALIKE_VALUE)
    util_getUpdatedDataElement-->>preparePayload: Return processed data
    preparePayload-->>processRecordInputsV2: Return payload
Loading

Suggested reviewers

  • yashasvibajpai
  • ItsSudip

Suggestions for improvement:

  • Consider adding inline documentation or comments explaining the rationale for the new validation rules, especially for future maintainers.
  • If more fields like LOOKALIKE_VALUE are anticipated, abstracting the validation logic into a dedicated function or module could enhance scalability and clarity.
  • Ensure that downstream consumers of the payload are aware of the new numeric defaulting behavior for LOOKALIKE_VALUE to avoid surprises.

📜 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 e7f814b88cf71c71bd723ac7b52403343a208575 and 5436b1f.

⛔ Files ignored due to path filters (2)
  • test/integrations/destinations/fb_custom_audience/router/data.ts is excluded by !**/test/**
  • test/integrations/destinations/fb_custom_audience/router/rETL.ts is excluded by !**/test/**
📒 Files selected for processing (4)
  • src/v0/destinations/fb_custom_audience/config.js (1 hunks)
  • src/v0/destinations/fb_custom_audience/recordTransform.js (5 hunks)
  • src/v0/destinations/fb_custom_audience/util.js (3 hunks)
  • src/v0/destinations/fb_custom_audience/util.test.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/v0/destinations/fb_custom_audience/config.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/v0/destinations/fb_custom_audience/util.test.js
  • src/v0/destinations/fb_custom_audience/recordTransform.js
  • src/v0/destinations/fb_custom_audience/util.js
⏰ Context from checks skipped due to timeout of 90000ms (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: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
✨ 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.

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented May 14, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.14%. Comparing base (b9da033) to head (5436b1f).
Report is 90 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4322   +/-   ##
========================================
  Coverage    91.14%   91.14%           
========================================
  Files          638      638           
  Lines        33475    33484    +9     
  Branches      7903     7907    +4     
========================================
+ Hits         30510    30519    +9     
+ Misses        2726     2696   -30     
- Partials       239      269   +30     

☔ 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:

@manish339k
manish339k marked this pull request as ready for review May 15, 2025 10:12
@manish339k
manish339k requested review from a team and sivashanmukh as code owners May 15, 2025 10:12
@manish339k
manish339k requested review from a team, chandumlg and krishna2020 May 15, 2025 10:12

@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/fb_custom_audience/util.js (1)

149-152: Appropriate value handling for lookalike audiences.

Good implementation for processing LOOKALIKE_VALUE by ensuring it's a finite number and defaulting to 0 if not. This prevents invalid values from being sent to Facebook's API.

Consider adding a warning log when defaulting to 0 for non-finite values to help with debugging:

  if (eachProperty === 'LOOKALIKE_VALUE') {
    const finalValue = Number.isFinite(tmpUpdatedProperty) ? tmpUpdatedProperty : 0;
+   if (!Number.isFinite(tmpUpdatedProperty)) {
+     console.warn(`Non-finite value provided for LOOKALIKE_VALUE, defaulting to 0`);
+   }
    dataElement.push(finalValue);
  } else if (isHashRequired && eachProperty !== 'MADID' && eachProperty !== 'EXTERN_ID') {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 302c12d and 3de623b38c4fafa58bdff36eb58ef4256485ddb7.

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

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

  • src/v0/destinations/fb_custom_audience/config.js
  • src/v0/destinations/fb_custom_audience/util.js
  • src/v0/destinations/fb_custom_audience/recordTransform.js
🧬 Code Graph Analysis (1)
src/v0/destinations/fb_custom_audience/util.js (1)
src/v0/util/index.js (5)
  • require (19-19)
  • require (20-26)
  • require (28-28)
  • require (32-32)
  • require (34-34)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • 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 (javascript-typescript)
🔇 Additional comments (7)
src/v0/destinations/fb_custom_audience/config.js (1)

23-23: Addition of LOOKALIKE_VALUE looks good.

The new 'LOOKALIKE_VALUE' field is appropriately added to the schema fields array, enabling support for Facebook value-based custom audiences. This simple change enables the system to recognize and validate this field type.

src/v0/destinations/fb_custom_audience/util.js (2)

5-9: Clean up of imports is good.

Restructuring the imports to source directly from @rudderstack/integrations-lib improves code maintainability and follows better practices by standardizing imports across the codebase.


132-134: Proper handling for LOOKALIKE_VALUE.

The function correctly handles the LOOKALIKE_VALUE field by returning the raw user information without string conversion, which is appropriate for numeric values expected in value-based audiences.

src/v0/destinations/fb_custom_audience/recordTransform.js (4)

121-130: Config destructuring updated appropriately.

The addition of isValueBasedAudience to the destructured config object allows the function to access this flag for validation purposes. This is a clean way to pass the new configuration parameter.


151-155: Good validation to prevent misconfiguration.

This validation correctly prevents users from using the LOOKALIKE_VALUE field in non-value-based audiences, which helps maintain data integrity and prevents API errors.


174-182: Appropriate validation for value-based audiences.

This check ensures that value-based audiences include the required LOOKALIKE_VALUE field for the add operation, which is a good safeguard against invalid configurations.


261-262: Config parameter properly propagated.

The isValueBasedAudience flag is correctly extracted from the connection config and passed to the preparePayload function, ensuring the validation logic works as expected.

Also applies to: 283-283

@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:

@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:

maheshkutty
maheshkutty previously approved these changes May 23, 2025
ItsSudip
ItsSudip previously approved these changes May 26, 2025
@manish339k
manish339k dismissed stale reviews from ItsSudip and maheshkutty via 4ecc6bc June 18, 2025 02:41
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@manish339k
manish339k force-pushed the feat.fb.value.based.audience branch from 4ecc6bc to 613a07a Compare June 18, 2025 02:52
@manish339k manish339k changed the title feat: onboarding facebook value based audience feat: add value based audience to facebook custom audience destination Jun 18, 2025
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@koladilip koladilip 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.

Fix sonar issue

@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@manish339k
manish339k force-pushed the feat.fb.value.based.audience branch from 5edcd6d to bd64f63 Compare June 23, 2025 08:17
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@manish339k
manish339k force-pushed the feat.fb.value.based.audience branch from bd64f63 to e7f814b Compare June 26, 2025 06:19
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@manish339k
manish339k force-pushed the feat.fb.value.based.audience branch from e7f814b to 5436b1f Compare June 27, 2025 08:04
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

@manish339k
manish339k merged commit 8ae6bf6 into develop Jun 27, 2025
@manish339k
manish339k deleted the feat.fb.value.based.audience branch June 27, 2025 12:34
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.

5 participants