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: rework commerce events #11

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 4 additions & 6 deletions src/commerce-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function buildProductActionEvents(event) {
if (!event.ProductAction) {
actionEventName = HeapConstants.EventNameProductAction;
} else {
var productActionKey = event.ProductAction.ProductActionType;
var productActionKey = ProductActionNames[event.ProductAction.ProductActionType];
actionEventName = HeapConstants.EventNameProductActionPart + productActionKey;
}

Expand Down Expand Up @@ -277,12 +277,10 @@ function buildPromotionItemEvent(promotion) {
var key = validatedPromotionKeys[i];
var value = validatedPromotionValues[key];

if (value === undefined || key === undefined) {
return;
if (value && key) {
var constKey = HeapConstants[key];
properties[constKey] = value;
}

var constKey = HeapConstants[key];
properties[constKey] = value;
}
event.Name = HeapConstants.EventNameItem;
event.Properties = properties;
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end-testapp/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var SDKsettings = {
initialize, this may be apiKey, projectId, primaryCustomerType, etc. These are passed
into the src/initialization.js file as the
*/
appId: 'testAppId',
applicationId: 'testAppId',
userIdentificationType: 'customerid',
forwardWebRequestsServerSide: false,
};
Expand Down
2 changes: 2 additions & 0 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ describe('Heap Forwarder', function () {

if (eventName.includes('Action')) {
properties.skus.length.should.equal(2);
eventName.includes('Purchase').should.be.ok;
}
}

Expand Down Expand Up @@ -500,6 +501,7 @@ describe('Heap Forwarder', function () {

if (eventName.includes('Promotion')) {
properties.skus.length.should.equal(2);
eventName.includes('Click').should.be.ok;
}
}
done();
Expand Down
Loading