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: Report purchase events to mParticle when bundling ecommerce data #50

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

rmi22186
Copy link
Collaborator

@rmi22186 rmi22186 commented Oct 4, 2024

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • {provide a thorough description of the changes}

Testing Plan

  • Was this tested locally? If not, explain why. Locally tested and added a unit test to show that the reporting service has an event on it. With the previous code, it failed, but now with the new code, it passes.

Link to test app showing the fix
https://share.zight.com/kpuvJZvD

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@@ -129,6 +129,8 @@ var constructor = function () {
quantity,
eventAttributes
);

return reportEvent;

Choose a reason for hiding this comment

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

wouldn't this be return reportEvent === true? thats how at least other log events functions have it as and I think it makes sense in case its not true? but also the video you shared for testing seems to be working as expected

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good attention to detail! Yes so it seems that Braze returns true from when you call their login method already, so, so doing just return reportEvent is fine. I'm not sure why we do return reportEvent === true since it is essentially the same thing. For now, to be consistent, I will just follow that format even though it's unnecessary, but I can make a ticket to refactor in the future to just return the boolean instead of the equivalence.

test/tests.js Outdated
@@ -1756,6 +1756,7 @@ user.getUserIdentities is not a function,\n`;
baz: 'bar',
};

debugger;

Choose a reason for hiding this comment

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

noobie question, but wouldn't this pause the process of the test running and should be removed? I might be wrong

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes this is a mistake. I left it here. We should never have debugger in live code.

test/tests.js Outdated
@@ -1832,6 +1833,8 @@ user.getUserIdentities is not a function,\n`;
var purchaseEventProperties = window.braze.purchaseEventProperties[0];

purchaseEventProperties.should.eql(expectedPurchaseEvent);

reportService.event.should.be.ok();
Copy link

@mmustafa-tse mmustafa-tse Oct 4, 2024

Choose a reason for hiding this comment

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

I feel like this should be more like
reportService.event.should.have.property( 'EventName', 'eCommerce - Purchase' );

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think being more specific is a good call. Will update.

Copy link

@mmustafa-tse mmustafa-tse left a comment

Choose a reason for hiding this comment

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

LGTM!

@rmi22186 rmi22186 merged commit 333b7eb into master-v4 Oct 8, 2024
2 checks passed
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.

3 participants