-
Notifications
You must be signed in to change notification settings - Fork 44
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
refactor: Create Interfaces for eCommerce #964
refactor: Create Interfaces for eCommerce #964
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
src/ecommerce.interfaces.ts
Outdated
|
||
/* | ||
* @deprecated | ||
*/ | ||
logPurchase( | ||
transactionAttributes: TransactionAttributes, | ||
product: SDKProduct | SDKProduct[], | ||
clearCart?: boolean, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags | ||
): void; | ||
/* | ||
* @deprecated | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for consistency with spacing, either add a line before the deprecation on line 111 or remove the new line at 100
src/ecommerce.interfaces.ts
Outdated
"Category"?: string; | ||
"Name"?: string; | ||
"Id"?: string; | ||
"Item Price"?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a customer is allowed to add this as a string or number, but then we parse it into a number
https://github.com/mParticle/mparticle-web-sdk/blob/master/src/ecommerce.js#L267-L273
src/ecommerce.interfaces.ts
Outdated
"Name"?: string; | ||
"Id"?: string; | ||
"Item Price"?: string; | ||
"Quantity"?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a customer is allowed to add it as a string or number, but then we parse it into a number https://github.com/mParticle/mparticle-web-sdk/blob/master/src/ecommerce.js#L282-L287
src/ecommerce.interfaces.ts
Outdated
"Quantity"?: string; | ||
"Position"?: number; | ||
"Variant"?: string; | ||
"Total Product Amount": string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/mParticle/mparticle-web-sdk/blob/master/src/ecommerce.js#L299 makes this a number
"Total Product Amount": string; | |
"Total Product Amount": number; |
src/ecommerce.interfaces.ts
Outdated
"Coupon Code"?: string; | ||
"Total Amount"?: number; | ||
"Shipping Amount"?: string; | ||
"Tax Amount"?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this gets sanitized and is a number - https://github.com/mParticle/mparticle-web-sdk/blob/master/src/ecommerce.js#L33-L37
"Tax Amount"?: string; | |
"Tax Amount"?: number; |
src/ecommerce.interfaces.ts
Outdated
"Affiliation"?: string; | ||
"Coupon Code"?: string; | ||
"Total Amount"?: number; | ||
"Shipping Amount"?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this gets sanitized and is a number - https://github.com/mParticle/mparticle-web-sdk/blob/master/src/ecommerce.js#L28-L31
src/sdkRuntimeModels.ts
Outdated
@@ -150,7 +156,7 @@ export interface SDKProduct { | |||
Position?: number; | |||
CouponCode?: string; | |||
TotalAmount?: number; | |||
Attributes?: { [key: string]: string }; | |||
Attributes?: Record<string, unknown> | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creatProduct
technically assigns this to null
if there are no attributes. Probably should be a future refactor to have it be undefined
.
Attributes?: Record<string, unknown> | undefined; | |
Attributes?: Record<string, unknown> | null; |
@@ -36,7 +36,7 @@ interface IECommerceShared { | |||
brand?: string, | |||
position?: number, | |||
couponCode?: string, | |||
attributes?: SDKEventAttrs, | |||
attributes?: SDKEventAttrs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
,
@@ -339,7 +339,7 @@ export function convertProducts( | |||
price: sdkProduct.Price, | |||
quantity: sdkProduct.Quantity, | |||
coupon_code: sdkProduct.CouponCode, | |||
custom_attributes: sdkProduct.Attributes, | |||
custom_attributes: sdkProduct.Attributes as Record<string, string>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see if this should be string, unknown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Record<string, string>
doesn't work because EventsApi.Product
requires custom_attributes
to be [key: string]: string
Quality Gate passedIssues Measures |
61ce006
into
refactor/ts-migration-blackout-2024
Instructions
development
Summary
Testing Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)