Skip to content

Commit 14879a3

Browse files
author
Paul Boocock
committed
Fix AddToCart and RemoveFromCart types (close #926)
1 parent 69251c7 commit 14879a3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

libraries/tracker-core/src/core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,13 +1049,13 @@ export interface AddToCartEvent {
10491049
/** A Product Stock Keeping Unit (SKU) */
10501050
sku: string;
10511051
/** The number added to the cart */
1052-
quantity: string;
1052+
quantity: number;
10531053
/** The name of the product */
10541054
name?: string;
10551055
/** The category of the product */
10561056
category?: string;
10571057
/** The price of the product */
1058-
unitPrice?: string;
1058+
unitPrice?: number;
10591059
/** The currency of the product */
10601060
currency?: string;
10611061
}
@@ -1094,13 +1094,13 @@ export interface RemoveFromCartEvent {
10941094
/** A Product Stock Keeping Unit (SKU) */
10951095
sku: string;
10961096
/** The number removed from the cart */
1097-
quantity: string;
1097+
quantity: number;
10981098
/** The name of the product */
10991099
name?: string;
11001100
/** The category of the product */
11011101
category?: string;
11021102
/** The price of the product */
1103-
unitPrice?: string;
1103+
unitPrice?: number;
11041104
/** The currency of the product */
11051105
currency?: string;
11061106
}

libraries/tracker-core/test/core.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ test('should track a social interaction', (t) => {
393393
});
394394
test('should track an add-to-cart event', (t) => {
395395
const sku = '4q345';
396-
const unitPrice = '17';
397-
const quantity = '2';
396+
const unitPrice = 17.0;
397+
const quantity = 2;
398398
const name = 'red shoes';
399399
const category = 'clothing';
400400
const currency = 'USD';
@@ -420,8 +420,8 @@ test('should track an add-to-cart event', (t) => {
420420
});
421421
test('should track a remove-from-cart event', (t) => {
422422
const sku = '4q345';
423-
const unitPrice = '17';
424-
const quantity = '2';
423+
const unitPrice = 17.0;
424+
const quantity = 2;
425425
const name = 'red shoes';
426426
const category = 'clothing';
427427
const currency = 'USD';
@@ -845,7 +845,7 @@ test('should run plugin before and after track callbacks on each track event', (
845845
})
846846
),
847847
tracker.track(buildPageView({ pageUrl: url, pageTitle: str, referrer: url })),
848-
tracker.track(buildAddToCart({ category: str, name: str, quantity: str, sku: str, unitPrice: str })),
848+
tracker.track(buildAddToCart({ category: str, name: str, quantity: num, sku: str, unitPrice: num })),
849849
tracker.track(buildScreenView({ id: str, name: str })),
850850
tracker.track(buildSiteSearch({ filters, pageResults: num, terms: arr, totalResults: num })),
851851
tracker.track(buildStructEvent({ category: str, action: str })),
@@ -875,7 +875,7 @@ test('should run plugin before and after track callbacks on each track event', (
875875
})
876876
),
877877
tracker.track(buildFormSubmission({ elements: [], formClasses: [], formId: str })),
878-
tracker.track(buildRemoveFromCart({ category: str, name: str, quantity: str, sku: str, unitPrice: str })),
878+
tracker.track(buildRemoveFromCart({ category: str, name: str, quantity: num, sku: str, unitPrice: num })),
879879
tracker.track(buildConsentGranted({ id: str, version: str }).event),
880880
tracker.track(buildConsentWithdrawn({ all: true }).event),
881881
tracker.track(

0 commit comments

Comments
 (0)