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

fix: send empty string instead of null when the schema data is undefined #2948

Closed
wants to merge 1 commit into from

Conversation

sandeepdsvs
Copy link
Contributor

What are the changes introduced in this PR?

This PR is just for reviewing the changes made to fix the following issue discussed in this thread for Zen Business customer. This PR is just for review and should not be merged as this branch is used for dedicated deployment for transformer.

Please explain the objectives of your changes below

This PR will make sure empty string, '' is sent instead of null when the schema data is undefined

Type of change

If the pull request is a bug-fix, enhancement or a refactor, please fill in the details on the changes made.

  • Existing capabilities/behavior
    If any schema field's value is undefined, null was sent as part of payload.data for that field.

  • New capabilities/behavior
    If any schema field's value is undefined, empty string will be sent as part of payload.data for that field.

If the pull request is a new feature,

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

N/A

Any new dependencies introduced with this change?

N/A

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

N/A

If the PR has changes in more than 10 files, please mention why the changes were not split into multiple PRs.

N/A

If multiple linear tasks are associated with the PR changes, please elaborate on the reason:

N/A


Developer checklist

  • No breaking changes are being introduced.

  • Are all related docs linked with the PR?

  • Are all changes manually tested?

  • Does this change require any documentation changes?

  • 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.

@sandeepdsvs sandeepdsvs added the DO NOT MERGE Don't merge this PR without having discussion label Dec 21, 2023
Copy link
Contributor

coderabbitai bot commented Dec 21, 2023

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.

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

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

Copy link

Copy link

codecov bot commented Dec 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (290854c) 87.27% compared to head (95c16b2) 87.17%.
Report is 18 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2948      +/-   ##
===========================================
- Coverage    87.27%   87.17%   -0.10%     
===========================================
  Files          790      860      +70     
  Lines        29218    29295      +77     
  Branches      6834     6835       +1     
===========================================
+ Hits         25501    25539      +38     
- Misses        3373     3410      +37     
- Partials       344      346       +2     

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

@@ -131,21 +131,21 @@ const getUpdatedDataElement = (dataElement, isHashRequired, eachProperty, update
/**
* hash the original value for the properties apart from 'MADID' && 'EXTERN_ID as hashing is not required for them
* ref: https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash
* sending null values for the properties for which user hasn't provided any value
* sending empty string for the properties for which user hasn't provided any value
*/
if (isHashRequired && eachProperty !== 'MADID' && eachProperty !== 'EXTERN_ID') {
Copy link
Contributor

Choose a reason for hiding this comment

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

const getUpdatedDataElement = (dataElement, isHashRequired, eachProperty, updatedProperty) => {
  let tmpUpdatedProperty = updatedProperty;
  if (eachProperty !== 'MADID' && eachProperty !== 'EXTERN_ID') {
    return dataElement;
  }
  if (!tmpUpdatedProperty) {
    dataElement.push('');
    return dataElement;
  }
  /**
   * hash the original value for the properties apart from 'MADID' && 'EXTERN_ID as hashing is not required for them
   * ref: https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash
   * sending empty string for the properties for which user hasn't provided any value
   */
  if (isHashRequired) {
    tmpUpdatedProperty = `${tmpUpdatedProperty}`;
    dataElement.push(sha256(tmpUpdatedProperty));
  }
  return dataElement;
};

how about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Above block doesn't look correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can change to this

const getUpdatedDataElement = (dataElement, isHashRequired, eachProperty, updatedProperty) => {
  let tmpUpdatedProperty = updatedProperty;
  if (!tmpUpdatedProperty) {
    dataElement.push('');
  }
  if (eachProperty === 'MADID' || eachProperty === 'EXTERN_ID') {
    return dataElement;
  }
  /**
   * hash the original value for the properties apart from 'MADID' && 'EXTERN_ID as hashing is not required for them
   * ref: https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash
   * sending empty string for the properties for which user hasn't provided any value
   */
  if (isHashRequired && tmpUpdatedProperty) {
    tmpUpdatedProperty = `${tmpUpdatedProperty}`;
    dataElement.push(sha256(tmpUpdatedProperty));
  }
  return dataElement;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes make sense

@devops-github-rudderstack devops-github-rudderstack deleted the zen_biz_fb_audience_fix branch March 22, 2024 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE Don't merge this PR without having discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants