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: bug fix for track event #2852

Merged
merged 8 commits into from
Nov 29, 2023
Merged

fix: bug fix for track event #2852

merged 8 commits into from
Nov 29, 2023

Conversation

utsabc
Copy link
Member

@utsabc utsabc commented Nov 27, 2023

Description of the change

> incident
For the above incident we are getting Generic Transformation error as the nature of the error is unhandled exception

The customer is wrongly instrumenting an invalid track event which does not containing event property for which we are missing validation. This PR Addresses the above issue with adding more validations for the SFMC destination for which the issue occurs

Resolves INT-1085

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

Summary by CodeRabbit

  • New Features

    • Enhanced event validation in the integration with marketing cloud service to ensure accurate tracking.
  • Bug Fixes

    • Improved error messages for better clarity on issues related to event mapping and supported types.
  • Tests

    • Added comprehensive tests for the responseBuilderSimple function to validate functionality and error handling.

@utsabc utsabc requested a review from a team as a code owner November 27, 2023 09:32
Copy link
Contributor

coderabbitai bot commented Nov 27, 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.

Walkthrough

The changes involve updates to the sfmc/transform.js file, where additional validation checks for message.event have been implemented, including checks for its definition, non-nullity, non-emptiness, correct mapping, and string type. The error messages have been refined to provide clearer information on the encountered issues. The responseBuilderSimple function has been modified and exported. Corresponding tests have been added to sfmc/transform.test.js to ensure the robustness of these updates.

Changes

File Path Change Summary
src/v0/.../sfmc/transform.js Added isDefinedAndNotNull and isEmpty imports; updated responseBuilderSimple with additional checks and error messages; exported responseBuilderSimple.
src/v0/.../sfmc/transform.test.js Introduced new test suite for responseBuilderSimple function, covering various scenarios and error handling.

Assessment against linked issues

Objective Addressed Explanation
Checking in latest GATransform artifacts under the dipanjan branch (#1) The provided summary does not mention GATransform artifacts or the dipanjan branch, focusing instead on SFMC transform changes.

Poem

In the code where bugs might creep,
A rabbit hopped, no time to sleep.
With checks and tests, it mended ways,
Ensuring code bright, like dawn's first rays. 🐇✨


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

Note: For conversation with the bot, please use the review comments on code diffs or files.

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

@utsabc utsabc added the bug fix label Nov 27, 2023
@utsabc utsabc self-assigned this Nov 27, 2023
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: 4

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9eda50e and 46d3f1c.
Files selected for processing (1)
  • src/v0/destinations/sfmc/transform.js (4 hunks)
Additional comments: 1
src/v0/destinations/sfmc/transform.js (1)
  • 3-8: The addition of isDefinedAndNotNull and isEmpty to the imports suggests that these utility functions will be used for validation checks in the code.

Copy link

codecov bot commented Nov 27, 2023

Codecov Report

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

Comparison is base (8c02b8c) 87.16% compared to head (6f57ddc) 87.17%.

Files Patch % Lines
src/v0/destinations/sfmc/transform.js 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2852   +/-   ##
========================================
  Coverage    87.16%   87.17%           
========================================
  Files          772      772           
  Lines        28788    28794    +6     
  Branches      6764     6767    +3     
========================================
+ Hits         25094    25100    +6     
  Misses        3351     3351           
  Partials       343      343           

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 46d3f1c and f7f7ab7.
Files selected for processing (1)
  • src/v0/destinations/sfmc/transform.js (4 hunks)
Additional comments: 2
src/v0/destinations/sfmc/transform.js (2)
  • 225-237: The changes made to the responseBuilderSimple function for additional validation of message.event are correctly implemented and align with the summary provided. The error messages are also more specific, which will aid in troubleshooting.

  • 250-250: The updated error message for unsupported event types is more informative and user-friendly, which aligns with the summary provided.

@sanpj2292
Copy link
Contributor

The issue is already fixed as part of #2846. But if there is anything we are doing extra, please feel free to ignore the mentioned PR with this one

@utsabc
Copy link
Member Author

utsabc commented Nov 28, 2023

The issue is already fixed as part of #2846. But if there is anything we are doing extra, please feel free to ignore the mentioned PR with this one

@sanpj2292 I added some validations in case event is missing from track events

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f7f7ab7 and eebe877.
Files selected for processing (2)
  • src/v0/destinations/sfmc/transform.js (5 hunks)
  • src/v0/destinations/sfmc/transform.test.js (1 hunks)
Additional comments: 2
src/v0/destinations/sfmc/transform.js (1)
  • 287-287: The addition of responseBuilderSimple to the module exports is consistent with the changes made in the file and the summary provided.
src/v0/destinations/sfmc/transform.test.js (1)
  • 1-178: The test suite for responseBuilderSimple is well-structured and covers a variety of scenarios including error handling and payload validation. The use of MockAxiosAdapter for simulating token retrieval is appropriate and the assertions within each test case are relevant to the expected outcomes. Good job on ensuring that the tests are comprehensive and that they validate both the success and error paths.

src/v0/destinations/sfmc/transform.js Outdated Show resolved Hide resolved
src/v0/destinations/sfmc/transform.js Outdated Show resolved Hide resolved
src/v0/destinations/sfmc/transform.js Outdated Show resolved Hide resolved
src/v0/destinations/sfmc/transform.js Outdated Show resolved Hide resolved
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 eebe877 and b4d5228.
Files selected for processing (2)
  • src/v0/destinations/sfmc/transform.js (5 hunks)
  • src/v0/destinations/sfmc/transform.test.js (1 hunks)
Additional comments: 7
src/v0/destinations/sfmc/transform.js (6)
  • 3-8: The changes to the imports are consistent with the summary and the removal of isEmpty from the imports is reflected in the code.

  • 225-226: The error message "Creating or updating contacts is disabled" has been updated and is now more specific, addressing the previous comment.

  • 229-230: The error message "Event name is required for this track events" has been updated and is now more specific, addressing the previous comment.

  • 232-237: The checks for message.event have been added as per the summary, ensuring that the event name is not empty, is a string, and is present in hashMapExternalKey.

  • 251-252: The error message "Event type not supported" now includes the unsupported event type, addressing the previous comment.

  • 288-288: The responseBuilderSimple function is now explicitly exported, which is consistent with the summary.

src/v0/destinations/sfmc/transform.test.js (1)
  • 1-125: The test suite for responseBuilderSimple function is comprehensive and covers various scenarios including identify calls, error handling for missing event names, unsupported event types, and mapped track calls. The setup of a mock Axios adapter is also correctly implemented for testing HTTP requests. The tests appear to be well-structured and should validate the functionality effectively.

sanpj2292
sanpj2292 previously approved these changes Nov 28, 2023
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

88.9% 88.9% Coverage
0.0% 0.0% Duplication

@utsabc utsabc merged commit cd9a046 into develop Nov 29, 2023
14 checks passed
@devops-github-rudderstack devops-github-rudderstack deleted the fix.sfmc-invalid-track-event branch March 1, 2024 01:26
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.

3 participants