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: criteo add support for multiple hash methods #1812

Merged
merged 4 commits into from
Aug 1, 2024

Conversation

anantjain45823
Copy link
Contributor

@anantjain45823 anantjain45823 commented Jul 31, 2024

PR Description

Supporting multiple hashes for email for criteo in one call driven through UI option for hashing.
Criteo Docs: https://help.criteo.com/kb/guide/en/intro-to-the-criteo-onetag-8fjCDwCENw/Steps/775595,853887,2616497,2616569,2616738,2617588

Please include a summary of the change along with the relevant motivation and context.
Screenshot 2024-07-31 at 10 39 39 AM

Linear task (optional)

https://linear.app/rudderstack/issue/INT-2438/add-double-hashing-method-in-criteo-device-mode

Linear task link

Cross Browser Tests

Please confirm you have tested for the following browsers:

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features

    • Introduced functionality to generate multiple email hashes using various hashing methods (sha256, md5, none) for enhanced email processing.
    • Streamlined email handling by replacing direct email object construction with a more flexible hashing approach.
  • Tests

    • Added comprehensive tests for the new email hashing functionality to ensure correct behavior under various input conditions.

These changes provide users with greater control and flexibility in managing email properties within the integration.

@anantjain45823 anantjain45823 self-assigned this Jul 31, 2024
@anantjain45823 anantjain45823 requested a review from a team July 31, 2024 05:11
Copy link
Contributor

coderabbitai bot commented Jul 31, 2024

Walkthrough

Walkthrough

The recent changes introduce a new function, getEmailHashes, to enhance email handling in the Criteo integration. This function allows for the generation of email hashes using multiple methods, including SHA256 and MD5, all in a single call. The handleCommonFields function has been updated to utilize this new capability, improving the flexibility and efficiency of email processing while aligning with Criteo's updated identity management guidelines.

Changes

File Change Summary
.../Criteo/utils.js Added getEmailHashes function to generate SHA256 and MD5 hashes for emails; updated handleCommonFields to use it.
.../Criteo/utils.test.js Introduced tests for getEmailHashes, validating SHA256 and MD5 hashing methods and handling various input cases.

Possibly related issues


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 testing code for this file.
    • 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 generate unit testing code 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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @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.

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 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

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.

Copy link

codecov bot commented Jul 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.70%. Comparing base (1a8fee8) to head (f5b06a5).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1812      +/-   ##
===========================================
+ Coverage    56.67%   56.70%   +0.02%     
===========================================
  Files          473      473              
  Lines        16108    16118      +10     
  Branches      3223     3224       +1     
===========================================
+ Hits          9129     9139      +10     
+ Misses        5735     5717      -18     
- Partials      1244     1262      +18     

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

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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 22e43da and 50a7e83.

Files selected for processing (1)
  • packages/analytics-js-integrations/src/integrations/Criteo/utils.js (3 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
packages/analytics-js-integrations/src/integrations/Criteo/utils.js (1)
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
GitHub Check: codecov/patch
packages/analytics-js-integrations/src/integrations/Criteo/utils.js

[warning] 37-37: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L37
Added line #L37 was not covered by tests


[warning] 40-40: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L40
Added line #L40 was not covered by tests


[warning] 44-44: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L44
Added line #L44 was not covered by tests

Additional comments not posted (2)
packages/analytics-js-integrations/src/integrations/Criteo/utils.js (2)

33-56: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to getEmailHashes are correctly implemented in the codebase.

Verification successful

The function usage of getEmailHashes is correctly implemented.

  • The function is used in packages/analytics-js-integrations/src/integrations/Criteo/utils.js and matches the new signature.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `getEmailHashes` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'getEmailHashes'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify all function calls to `getEmailHashes` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type js -A 5 'getEmailHashes'

Length of output: 1240

Tools
GitHub Check: codecov/patch

[warning] 37-37: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L37
Added line #L37 was not covered by tests


[warning] 40-40: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L40
Added line #L40 was not covered by tests


[warning] 44-44: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L44
Added line #L44 was not covered by tests


77-78: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to handleCommonFields are correctly implemented in the codebase.

Verification successful

Let's correct the file type and re-run the script to verify the function calls to handleCommonFields.


LGTM! All function calls to handleCommonFields are correctly implemented.

The function calls to handleCommonFields match the new signature and are consistent throughout the codebase.

  • packages/analytics-js-integrations/src/integrations/Criteo/browser.js
  • packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `handleCommonFields` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type python -A 5 $'handleCommonFields'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify all function calls to `handleCommonFields` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type js -A 5 $'handleCommonFields'

Length of output: 5734

Copy link

github-actions bot commented Jul 31, 2024

size-limit report 📦

Name Size (Base) Size (Current) Size Limit Status
Cookies Utils - Legacy - NPM (ESM) 1.54 KB 1.54 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (CJS) 1.75 KB 1.75 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (UMD) 1.53 KB 1.53 KB (0%) 2 KB
Cookies Utils - Modern - NPM (ESM) 1.17 KB 1.17 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (CJS) 1.4 KB 1.4 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (UMD) 1.16 KB 1.16 KB (0%) 1.5 KB
Plugins Module Federation Mapping - Legacy - CDN 332 B 332 B (0%) 512 B
Plugins - Legacy - CDN 15.88 KB 15.88 KB (0%) 16 KB
Plugins Module Federation Mapping - Modern - CDN 331 B 331 B (0%) 512 B
Plugins - Modern - CDN 7.19 KB 7.19 KB (0%) 7.5 KB
Common - No bundling 15.89 KB 15.89 KB (0%) 16.5 KB
Core (v1.1) - NPM (ESM) 29.81 KB 29.81 KB (0%) 32 KB
Core (v1.1) - NPM (CJS) 29.97 KB 29.97 KB (0%) 32 KB
Core (v1.1) - NPM (UMD) 29.89 KB 29.89 KB (0%) 32 KB
Core (Content Script - v1.1) - NPM (ESM) 29.33 KB 29.33 KB (0%) 30 KB
Core (Content Script - v1.1) - NPM (CJS) 29.54 KB 29.54 KB (0%) 30 KB
Core (Content Script - v1.1) - NPM (UMD) 29.42 KB 29.42 KB (0%) 30 KB
Core - Legacy - CDN 47.4 KB 47.4 KB (0%) 48 KB
Core - Modern - CDN 24.09 KB 24.09 KB (0%) 24.5 KB
Service Worker - Legacy - NPM (ESM) 29.46 KB 29.46 KB (0%) 30 KB
Service Worker - Legacy - NPM (CJS) 29.61 KB 29.61 KB (0%) 30 KB
Service Worker - Legacy - NPM (UMD) 29.44 KB 29.44 KB (0%) 30 KB
Service Worker - Modern - NPM (ESM) 24.59 KB 24.59 KB (0%) 25 KB
Service Worker - Modern - NPM (CJS) 24.88 KB 24.88 KB (0%) 25 KB
Service Worker - Modern - NPM (UMD) 24.67 KB 24.67 KB (0%) 25 KB
Load Snippet 724 B 724 B (0%) 1 KB
Core - Legacy - NPM (ESM) 47.29 KB 47.29 KB (0%) 47.5 KB
Core - Legacy - NPM (CJS) 47.5 KB 47.5 KB (0%) 48 KB
Core - Legacy - NPM (UMD) 47.28 KB 47.28 KB (0%) 47.5 KB
Core - Modern - NPM (ESM) 23.83 KB 23.83 KB (0%) 24.5 KB
Core - Modern - NPM (CJS) 24.06 KB 24.06 KB (0%) 24.5 KB
Core - Modern - NPM (UMD) 23.86 KB 23.86 KB (0%) 24.5 KB
Core (Bundled) - Legacy - NPM (ESM) 47.29 KB 47.29 KB (0%) 47.5 KB
Core (Bundled) - Legacy - NPM (CJS) 47.53 KB 47.53 KB (0%) 48 KB
Core (Bundled) - Legacy - NPM (UMD) 47.28 KB 47.28 KB (0%) 47.5 KB
Core (Bundled) - Modern - NPM (ESM) 38.54 KB 38.54 KB (0%) 39 KB
Core (Bundled) - Modern - NPM (CJS) 38.8 KB 38.8 KB (0%) 39 KB
Core (Bundled) - Modern - NPM (UMD) 38.53 KB 38.53 KB (0%) 39 KB
Core (Content Script) - Legacy - NPM (ESM) 46.75 KB 46.75 KB (0%) 47 KB
Core (Content Script) - Legacy - NPM (CJS) 47.01 KB 47.01 KB (0%) 47.5 KB
Core (Content Script) - Legacy - NPM (UMD) 46.77 KB 46.77 KB (0%) 47 KB
Core (Content Script) - Modern - NPM (ESM) 38.01 KB 38.01 KB (0%) 38.5 KB
Core (Content Script) - Modern - NPM (CJS) 38.3 KB 38.3 KB (0%) 38.5 KB
Core (Content Script) - Modern - NPM (UMD) 37.99 KB 37.99 KB (0%) 38.5 KB
All Integrations - Legacy - CDN 93.68 KB 93.7 KB (+0.03% ▲) 95.3 KB
All Integrations - Modern - CDN 88.71 KB 88.78 KB (+0.08% ▲) 91 KB

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 50a7e83 and cd089ee.

Files selected for processing (2)
  • packages/analytics-js-integrations/tests/integrations/Criteo/utils.test.js (2 hunks)
  • packages/analytics-js-integrations/src/integrations/Criteo/utils.js (4 hunks)
Additional context used
Learnings (3)
Common learnings
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js (1)
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
packages/analytics-js-integrations/src/integrations/Criteo/utils.js (1)
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
GitHub Check: codecov/patch
packages/analytics-js-integrations/src/integrations/Criteo/utils.js

[warning] 40-40: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L40
Added line #L40 was not covered by tests


[warning] 44-44: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L44
Added line #L44 was not covered by tests

Additional comments not posted (5)
packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js (3)

Line range hint 9-34:
LGTM! The test cases for handleCommonFields are comprehensive.

The test cases cover different scenarios for various hash methods, ensuring the function behaves as expected.


Line range hint 36-182:
LGTM! The test cases for handleProductAdded are comprehensive.

The test cases cover different scenarios for various input conditions, ensuring the function behaves as expected.


185-214: LGTM! The test cases for getEmailHashes are comprehensive.

The test cases cover different scenarios for various hash methods and input conditions, ensuring the function behaves as expected.

packages/analytics-js-integrations/src/integrations/Criteo/utils.js (2)

Line range hint 57-84:
LGTM! The updates to handleCommonFields are well-implemented.

The changes align with the new functionality introduced by getEmailHashes.


26-56: Ensure test coverage for all branches and conditions in getEmailHashes.

The static analysis tools indicate that some lines are not covered by tests. Ensure that all branches and conditions are tested.

Tools
GitHub Check: codecov/patch

[warning] 40-40: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L40
Added line #L40 was not covered by tests


[warning] 44-44: packages/analytics-js-integrations/src/integrations/Criteo/utils.js#L44
Added line #L44 was not covered by tests

shrouti1507
shrouti1507 previously approved these changes Jul 31, 2024
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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cd089ee and fa58765.

Files selected for processing (1)
  • packages/analytics-js-integrations/tests/integrations/Criteo/utils.test.js (2 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js (1)
Learnt from: pierreavizou
PR: rudderlabs/rudder-sdk-js#1613
File: packages/analytics-js-integrations/src/integrations/Criteo/utils.js:36-42
Timestamp: 2024-03-27T17:02:27.599Z
Learning: The implementation for handling SHA256 email hashes in the Criteo integration sends both md5 and sha256 hashes regardless of the `hashMethod` selection, as per Criteo's recommendation to comply with new regulations and ensure compatibility during their system transition.
Additional comments not posted (4)
packages/analytics-js-integrations/__tests__/integrations/Criteo/utils.test.js (4)

185-195: LGTM!

The test case for getEmailHashes with hashMethod 'both' is well-written and covers the scenario adequately.


197-206: LGTM!

The test case for getEmailHashes with empty email input is well-written and covers the scenario adequately.


208-213: LGTM!

The test case for getEmailHashes with hashMethod 'sha256' is well-written and covers the scenario adequately.


215-219: LGTM!

The test case for getEmailHashes with hashMethod 'none' is well-written and covers the scenario adequately.

Copy link

sonarcloud bot commented Aug 1, 2024

@anantjain45823 anantjain45823 merged commit 23a0e37 into develop Aug 1, 2024
9 checks passed
@anantjain45823 anantjain45823 deleted the feat.supportMultipleHashMethodsForCriteo branch August 1, 2024 06:02
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.

2 participants