Skip to content

Commit

Permalink
add nullchecks before using toString
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-via committed Apr 26, 2024
1 parent 1b50a6d commit c0639b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const getEcommercePayload = (event: MCEvent) => {
.join()
payload.contents = payload.products.map((product: Product) => ({
id: product.product_id,
item_price: product.price.toString(),
item_price: product.price ? product.price.toString() : '',
quantity: product.quantity,
}))
payload.num_items =
Expand Down Expand Up @@ -98,7 +98,7 @@ export const getEventData = async (
language: payload.language || client.language.split(',')[0].substring(0, 2),
...remainingEventData,
user_data: {
client_ip_address: payload.client_ip_address || client.ip.toString(),
client_ip_address: payload.client_ip_address || client.ip?.toString(),
client_user_agent: payload.client_user_agent || parsedUserAgent.ua,
...(payload.click_id && { click_id: payload.click_id }),
...hashedUserProperties,
Expand Down

0 comments on commit c0639b3

Please sign in to comment.