Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: trade desk real time conversions #3023

Merged
merged 20 commits into from
Feb 5, 2024

Conversation

Gauravudia
Copy link
Contributor

@Gauravudia Gauravudia commented Jan 23, 2024

What are the changes introduced in this PR?

  • Added real time conversions support through event streaming sources.
  • refactored the code and created separate transform.js for real time conversion and first party data flow.
  • created data config for conversions
  • added ecomm mapping
  • added unit, component testcases
  • renamed destination -> payload for generic utility extractCustomFields

API doc :- https://partner.thetradedesk.com/v3/portal/data/doc/DataConversionEventsApi

What is the related Linear task?

Resolves INT-898

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.

created generateExclusionList utility for generating the exclusion list from mapping configs passed in input

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

N/A


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?

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.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Expanded the_trade_desk destination with real-time conversion tracking.
    • Enhanced e-commerce event mapping for the_trade_desk.
    • Introduced processing of inputs and conversion events for The Trade Desk destination.
  • Improvements

    • Added new utility functions to support The Trade Desk integration.
    • Implemented new constants for endpoint configurations and event mappings.
  • Tests

    • Added test cases for new utility functions related to The Trade Desk integration.
  • Refactor

    • Replaced lodash with get-value library for utility functions.
    • Reorganized configuration imports in utility module.
  • Style

    • Updated destinationCanonicalNames with variations for 'THE_TRADE_DESK'.

@Gauravudia Gauravudia self-assigned this Jan 23, 2024
@Gauravudia Gauravudia requested a review from a team as a code owner January 23, 2024 12:34
Copy link
Contributor

coderabbitai bot commented Jan 23, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The update to the the_trade_desk destination configuration in a CDK (Customer Data Platform) involves enhancing its capabilities to include real-time conversion tracking and advanced e-commerce event mapping. The changes introduce new utilities for mapping configurations, processing input records and conversions, and handling various data aspects such as revenue extraction and privacy settings. Additionally, the integration now supports various ID types for better event tracking and has improved its codebase by replacing lodash with get-value.

Changes

File Path Change Summary
.../the_trade_desk/config.js Expanded functionality for real-time conversion tracking and e-commerce event mapping, including new constants and getMappingConfig utility.
.../the_trade_desk/transform.js Added to process input records and conversions, routing events to The Trade Desk destination.
.../the_trade_desk/transformConversion.js
.../the_trade_desk/transformRecord.js
Introduced functionality for transforming and processing conversion events and record inputs.
.../the_trade_desk/utils.js
.../the_trade_desk/utils.test.js
Updated with new utility functions, get-value library integration, and additional test cases.
.../constants/destinationCanonicalNames.js
.../constants/index.js
Added variations of 'THE_TRADE_DESK' and a new constant RECORD to accommodate different casing and spacing.
.../v0/destinations/the_trade_desk/networkHandler.js Modified proxyRequest function to include additional checks and headers for a specific endpoint.
.../test/integrations/destinations/the_trade_desk/common.ts Addition of trackerId constant and modification of sampleDestination object.
.../test/integrations/destinations/the_trade_desk/delivery/data.ts
.../test/integrations/destinations/the_trade_desk/network.ts
.../test/integrations/destinations/the_trade_desk/router/data.ts
Various changes related to test data and imports for The Trade Desk integration.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 generate unit tests for this file.
    • @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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@Gauravudia Gauravudia marked this pull request as draft January 23, 2024 12:43
@koladilip
Copy link
Contributor

@coderabbitai review

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 15

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 724a4ac and e449f25.
Files ignored due to path filters (3)
  • src/cdk/v2/destinations/the_trade_desk/data/TTDCommonConfig.json is excluded by: !**/*.json
  • src/cdk/v2/destinations/the_trade_desk/data/TTDItemConfig.json is excluded by: !**/*.json
  • src/cdk/v2/destinations/the_trade_desk/rtWorkflow.yaml is excluded by: !**/*.yaml
Files selected for processing (7)
  • src/cdk/v2/destinations/the_trade_desk/config.js (2 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transform.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transformConversion.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transformRecord.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/utils.js (2 hunks)
  • src/cdk/v2/destinations/the_trade_desk/utils.test.js (2 hunks)
  • src/constants/destinationCanonicalNames.js (1 hunks)
Additional comments: 12
src/cdk/v2/destinations/the_trade_desk/transform.js (1)
  • 8-8: The groupBy function from lodash is used here, but lodash has been replaced by get-value in other parts of the codebase. Verify if this is intentional or if groupBy should also be replaced with a function from get-value or native JavaScript.
src/cdk/v2/destinations/the_trade_desk/config.js (1)
  • 17-83: The constants defined here are well-structured and follow the naming conventions. However, ensure that the REAL_TIME_CONVERSION_ENDPOINT and other constants match the expected values and are correctly used throughout the codebase.
src/constants/destinationCanonicalNames.js (1)
  • 144-152: The added variations for 'THE_TRADE_DESK' are consistent with the naming conventions used for other destinations in the DestCanonicalNames object. This change is approved.
src/cdk/v2/destinations/the_trade_desk/utils.js (8)
  • 1-1: The get-value library is imported as get, which is a good replacement for lodash for getting values from objects. Ensure that all instances where lodash was used for this purpose have been updated to use get.
  • 21-23: The utility functions getTTLInMin, getBaseEndpoint, and getFirstPartyEndpoint are well-defined and follow clean coding practices.
  • 24-24: The prepareCommonPayload function uses constructPayload from a utility module. Verify that this utility function is correctly implemented and handles all edge cases.
  • 65-83: The getDeviceAdvertisingId function correctly handles different OS types and returns the appropriate advertising ID type. However, ensure that all possible OS types are covered and that the default case is handled correctly.
  • 101-108: The getAdvertisingId function correctly falls back to the external ID object if the device advertising ID is not available. Ensure that the external ID object is always in the expected format.
  • 125-150: The populateEventName function uses a combination of custom event mappings and a predefined event map. Ensure that the event mappings are correctly configured and that the function handles all possible cases.
  • 160-181: The getDataProcessingOptions function has strict validation for the region and policies. Ensure that these validations align with the business requirements and that all supported regions and policies are handled.
  • 184-186: The getPrivacySetting function retrieves privacy settings from the integration object. Ensure that the integration object is always in the expected format and that privacy settings are handled correctly.
src/cdk/v2/destinations/the_trade_desk/utils.test.js (1)
  • 1-11: The test cases for the utility functions are comprehensive and cover a variety of scenarios. Ensure that all new utility functions have corresponding test cases and that all edge cases are covered.

src/cdk/v2/destinations/the_trade_desk/transform.js Outdated Show resolved Hide resolved
src/cdk/v2/destinations/the_trade_desk/transform.js Outdated Show resolved Hide resolved
src/cdk/v2/destinations/the_trade_desk/utils.js Outdated Show resolved Hide resolved
src/cdk/v2/destinations/the_trade_desk/utils.js Outdated Show resolved Hide resolved
src/cdk/v2/destinations/the_trade_desk/utils.js Outdated Show resolved Hide resolved
src/cdk/v2/destinations/the_trade_desk/utils.js Outdated Show resolved Hide resolved
@Gauravudia Gauravudia marked this pull request as ready for review January 25, 2024 07:21
@Gauravudia Gauravudia requested review from sivashanmukh and a team as code owners January 25, 2024 07:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e449f25 and d244eab.
Files ignored due to path filters (1)
  • src/cdk/v2/destinations/the_trade_desk/rtWorkflow.yaml is excluded by: !**/*.yaml
Files selected for processing (12)
  • src/cdk/v2/destinations/the_trade_desk/config.js (2 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transform.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transformConversion.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/transformRecord.js (1 hunks)
  • src/cdk/v2/destinations/the_trade_desk/utils.js (2 hunks)
  • src/cdk/v2/destinations/the_trade_desk/utils.test.js (2 hunks)
  • src/constants/index.js (1 hunks)
  • src/v0/destinations/the_trade_desk/networkHandler.js (2 hunks)
  • test/integrations/destinations/the_trade_desk/common.ts (2 hunks)
  • test/integrations/destinations/the_trade_desk/delivery/data.ts (2 hunks)
  • test/integrations/destinations/the_trade_desk/network.ts (2 hunks)
  • test/integrations/destinations/the_trade_desk/router/data.ts (4 hunks)
Files skipped from review due to trivial changes (1)
  • src/constants/index.js
Files skipped from review as they are similar to previous changes (5)
  • src/cdk/v2/destinations/the_trade_desk/config.js
  • src/cdk/v2/destinations/the_trade_desk/transform.js
  • src/cdk/v2/destinations/the_trade_desk/transformConversion.js
  • src/cdk/v2/destinations/the_trade_desk/transformRecord.js
  • src/cdk/v2/destinations/the_trade_desk/utils.test.js
Additional comments: 16
test/integrations/destinations/the_trade_desk/common.ts (4)
  • 6-6: trackerId has been added as a new constant. Ensure that this ID is not sensitive and can be safely included in the test files.
  • 14-14: The trackerId has been added to the sampleDestination object. Verify that all tests and usages of sampleDestination have been updated to handle the new trackerId property.
Verification successful

The output from the executed script indicates that the trackerId property is present in various files within the the_trade_desk test directory. This confirms that the tests related to sampleDestination in the the_trade_desk integration have been updated to include the trackerId property. However, the script was executed with the same parameters as before, and thus, it did not search beyond the the_trade_desk directory.

To ensure a comprehensive verification, we need to confirm that sampleDestination is not used elsewhere in the codebase without the trackerId property. Therefore, I will generate a new script that searches for sampleDestination across the entire codebase without limiting the search to TypeScript files, as non-test files could potentially use sampleDestination as well.


The output from the latest script indicates that the sampleDestination occurrences are still only found within the the_trade_desk directory and all instances have been updated to include the trackerId property. There are no indications of sampleDestination being used without the trackerId in any other part of the codebase according to the search results provided.

Based on the information available, it appears that all tests and usages of sampleDestination within the the_trade_desk directory have been updated to handle the new trackerId property. No evidence has been found of sampleDestination being used elsewhere in the codebase.

Therefore, the review comment has been verified as accurate.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all tests using sampleDestination have been updated.
rg --type ts "sampleDestination" --files-with-matches | xargs rg "trackerId"

Length of output: 1636



Script:

#!/bin/bash
# Search for `sampleDestination` across the entire codebase and check for the presence of `trackerId` in the same files.
rg "sampleDestination" --type ts --files-with-matches | xargs rg "trackerId"

Length of output: 1636



Script:

#!/bin/bash
# Search for `sampleDestination` across the entire codebase without limiting to TypeScript files.
rg "sampleDestination" --files-with-matches | xargs rg "trackerId"

Length of output: 1626

* 38-79: The `sampleContextForConversion` object has been added. Ensure that this context is used appropriately in tests and that no sensitive information is included. * 81-94: The `integrationObject` has been added. Verify that this object is used correctly in tests and that it aligns with the integration's requirements.
src/v0/destinations/the_trade_desk/networkHandler.js (2)
  • 14-37: The proxyRequest function has been modified to include additional checks and headers for a specific endpoint. Ensure that these changes do not affect other endpoints and that the error handling is consistent with the rest of the codebase.
  • 57-57: The responseHandler function has been modified to handle a specific error case from The Trade Desk. Verify that this error handling is consistent with the expected behavior and that it does not conflict with other error handling logic.
test/integrations/destinations/the_trade_desk/network.ts (2)
  • 1-1: The trackerId has been imported from ./common. Verify that it is being used correctly in the network calls and that the import is necessary.
  • 106-208: New network call data has been added for the realtimeconversion endpoint. Verify that the data structure matches the expected format for The Trade Desk API and that the tests cover all necessary cases.
src/cdk/v2/destinations/the_trade_desk/utils.js (1)
  • 33-252: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [2-252]

The file utils.js has undergone significant changes with the addition of new utility functions and the replacement of lodash with the get-value library. Ensure that these changes do not introduce any regressions and that all new functions are covered by unit tests.

test/integrations/destinations/the_trade_desk/delivery/data.ts (2)
  • 8-8: The trackerId has been imported. Verify that it is being used correctly in the test data and that the import is necessary.
  • 249-413: New test data has been added for the realtimeconversion endpoint. Verify that the test data accurately represents the expected payloads and responses for The Trade Desk API and that the tests cover all necessary cases.
test/integrations/destinations/the_trade_desk/router/data.ts (5)
  • 9-13: Added new imports trackerId, sampleContextForConversion, and integrationObject are necessary for the new test configurations. Ensure these are being used correctly in the test data.
  • 556-1138: The addition of a large block of test configurations for e-commerce events such as 'Product Added', 'Product Viewed', etc., is extensive. Ensure that the structure of these test objects aligns with the expected input for the the_trade_desk destination and that all necessary fields are present and correctly named.
  • 1140-1239: The test configuration for 'Custom event abc' has been added. Verify that the custom event mapping and the properties used in the test configuration are consistent with the expected behavior for custom events in the the_trade_desk destination.
Verification successful

The test configuration for 'Custom event abc' is consistent with the expected behavior for custom events in the the_trade_desk destination, as evidenced by the logic found in 'transformConversion.js' and 'utils.js' which handle the mapping of custom properties.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the custom event mapping and properties are consistent with the expected behavior.
# This is a placeholder for the actual verification commands, which would depend on the custom event handling logic.

Length of output: 0



Script:

#!/bin/bash
# Search for references to custom event handling for 'the_trade_desk' destination.
rg "the_trade_desk" --files-with-matches

Length of output: 247


Script:

#!/bin/bash
# Search for any patterns that might indicate custom event mapping logic for 'the_trade_desk'.
ast-grep --lang javascript --pattern '$_("the_trade_desk", $_)'

Length of output: 65



Script:

#!/bin/bash
# Examine the contents of 'networkHandler.js' for custom event handling logic.
cat src/v0/destinations/the_trade_desk/networkHandler.js

Length of output: 3248


Script:

#!/bin/bash
# Check for custom event handling in common test files for 'the_trade_desk'.
cat test/integrations/destinations/the_trade_desk/common.ts

Length of output: 2339



Script:

#!/bin/bash
# Search for files that might contain custom event mapping logic or configuration for 'the_trade_desk'.
rg "customProperties" --files-with-matches

Length of output: 1706


Script:

#!/bin/bash
# Search for any patterns that might indicate how the properties are transformed or mapped for 'the_trade_desk'.
ast-grep --lang javascript --pattern '$_("properties", $_)'

Length of output: 61



Script:

#!/bin/bash
# Examine the contents of 'transformConversion.js' for custom event mapping logic.
cat src/cdk/v2/destinations/the_trade_desk/transformConversion.js

Length of output: 2748


Script:

#!/bin/bash
# Examine the contents of 'utils.js' for utility functions related to custom event mapping.
cat src/cdk/v2/destinations/the_trade_desk/utils.js

Length of output: 7456

* 1242-1333: The test configuration for 'Mapped standard trade desk event' has been added. It is important to ensure that the event mapping from 'custom event abc' to 'direction' is valid and that the `eventsMapping` configuration is being used correctly in the destination.
Verification successful

The examination of the_trade_desk/utils.js reveals that the function populateEventName processes the eventsMapping configuration to map event names accordingly. This aligns with the test configuration for 'Mapped standard trade desk event', where 'custom event abc' is mapped to 'direction'. Based on this, the event mapping appears to be valid and correctly implemented in the destination.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the event mapping is valid and correctly implemented in the destination.
# This is a placeholder for the actual verification commands, which would depend on the event mapping logic.

Length of output: 0



Script:

#!/bin/bash
# Search for references to 'eventsMapping' in the codebase to understand how it's used.
rg "eventsMapping"

Length of output: 26366



Script:

#!/bin/bash
# Examine the utility functions in the_trade_desk/utils.js to understand how eventsMapping is processed.
cat src/cdk/v2/destinations/the_trade_desk/utils.js

Length of output: 7456

* 1336-1502: The test configuration for a 'Batch call with different event types' has been added. This includes a mix of 'record' and 'track' events, as well as an 'identify' event which is flagged as not supported. Confirm that the batch call is structured correctly and that the unsupported event type is handled as expected.
Verification successful

The verification process has identified references to batch processing functions and error handling for unsupported event types within the codebase. This aligns with the structure and behavior described in the provided code snippet, indicating that the batch call is structured correctly and the unsupported event type is handled as expected.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the batch call is structured correctly and that the unsupported event type is handled as expected.
# This is a placeholder for the actual verification commands, which would depend on the batch processing logic.

Length of output: 0



Script:

#!/bin/bash
# Search for the logic that handles batch calls and specifically how unsupported event types are processed.
# We expect to find some function or method that processes the input and generates the output as shown in the code snippet.

# First, let's find any files that might be related to the batch processing logic.
fd --type f --exec rg 'batch.*process|process.*batch' {}

# Next, let's look for any error handling that might be related to unsupported event types.
fd --type f --exec rg 'unsupported event type|event type.*not supported' {}

Length of output: 2311

@Gauravudia
Copy link
Contributor Author

@coderabbitai review

@sanpj2292
Copy link
Contributor

@coderabbitai resume

@devops-github-rudderstack
Copy link
Contributor

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (717639b) 87.15% compared to head (9aba8ca) 87.23%.

Files Patch % Lines
...destinations/the_trade_desk/transformConversion.js 93.47% 3 Missing ⚠️
...c/v0/destinations/the_trade_desk/networkHandler.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3023      +/-   ##
===========================================
+ Coverage    87.15%   87.23%   +0.07%     
===========================================
  Files          529      531       +2     
  Lines        28796    28980     +184     
  Branches      6865     6906      +41     
===========================================
+ Hits         25098    25280     +182     
- Misses        3355     3357       +2     
  Partials       343      343              

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

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

@devops-github-rudderstack
Copy link
Contributor

Copy link

sonarqubecloud bot commented Feb 5, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
98.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@Gauravudia Gauravudia merged commit 212d5f0 into develop Feb 5, 2024
14 checks passed
@Gauravudia Gauravudia deleted the feat/theTradeDesk-conversions branch February 5, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants