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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/BrazeKit-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}

function logPurchaseEventPerProduct(event) {
Expand Down
3 changes: 3 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

mParticle.forwarder.process({
EventName: 'eCommerce - Purchase',
EventDataType: MessageType.Commerce,
Expand Down Expand Up @@ -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.

});

it('should call changeUser and openSession on init with userIdentificationType MPID passed in forwarding settings', function() {
Expand Down
Loading