@mparticle/web-sdk
Advanced tools
Comparing version 2.12.2 to 2.12.3
@@ -5,2 +5,8 @@ ## Releases | ||
#### 2.12.3 - 2021-01-20 | ||
- Bugfix - update is first run to booleans | ||
- Bugfix - Sanitize ecommerce amounts to numbers | ||
- Bugfix - Set sessionStartDate to 0 instead of null | ||
- Bugfix - Error events - Set to null if stack trace is undefined; Add context to error events | ||
#### 2.12.2 - 2020-11-12 | ||
@@ -7,0 +13,0 @@ |
{ | ||
"name": "@mparticle/web-sdk", | ||
"version": "2.12.2", | ||
"version": "2.12.3", | ||
"description": "mParticle core SDK for web applications", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -144,6 +144,3 @@ import Constants from './constants'; | ||
JSON.stringify( | ||
mpInstance._ServerModel.convertEventToDTO( | ||
event, | ||
mpInstance._Store.isFirstRun | ||
) | ||
mpInstance._ServerModel.convertEventToDTO(event) | ||
) | ||
@@ -150,0 +147,0 @@ ); |
@@ -65,5 +65,2 @@ import { Batch } from '@mparticle/event-models'; | ||
if (event) { | ||
//add this for cleaner processing later | ||
event.IsFirstRun = this.mpInstance._Store.isFirstRun; | ||
this.pendingEvents.push(event); | ||
@@ -70,0 +67,0 @@ this.mpInstance.Logger.verbose( |
@@ -22,9 +22,18 @@ import Types from './types'; | ||
if (transactionAttributes.hasOwnProperty('Revenue')) { | ||
productAction.TotalAmount = transactionAttributes.Revenue; | ||
productAction.TotalAmount = this.sanitizeAmount( | ||
transactionAttributes.Revenue, | ||
'Revenue' | ||
); | ||
} | ||
if (transactionAttributes.hasOwnProperty('Shipping')) { | ||
productAction.ShippingAmount = transactionAttributes.Shipping; | ||
productAction.ShippingAmount = this.sanitizeAmount( | ||
transactionAttributes.Shipping, | ||
'Shipping' | ||
); | ||
} | ||
if (transactionAttributes.hasOwnProperty('Tax')) { | ||
productAction.TaxAmount = transactionAttributes.Tax; | ||
productAction.TaxAmount = this.sanitizeAmount( | ||
transactionAttributes.Tax, | ||
'Tax' | ||
); | ||
} | ||
@@ -264,2 +273,4 @@ if (transactionAttributes.hasOwnProperty('Step')) { | ||
return null; | ||
} else { | ||
price = mpInstance._Helpers.parseNumber(price); | ||
} | ||
@@ -274,4 +285,6 @@ | ||
if (!quantity) { | ||
if (!mpInstance._Helpers.Validators.isStringOrNumber(quantity)) { | ||
quantity = 1; | ||
} else { | ||
quantity = mpInstance._Helpers.parseNumber(quantity); | ||
} | ||
@@ -542,2 +555,20 @@ | ||
}; | ||
// sanitizes any non number, non string value to 0 | ||
this.sanitizeAmount = function(amount, category) { | ||
if (!mpInstance._Helpers.Validators.isStringOrNumber(amount)) { | ||
var message = [ | ||
category, | ||
'must be of type number. A', | ||
typeof amount, | ||
'was passed. Converting to 0', | ||
].join(' '); | ||
mpInstance.Logger.warning(message); | ||
return 0; | ||
} | ||
// if amount is a string, it will be parsed into a number if possible, or set to 0 | ||
return mpInstance._Helpers.parseNumber(amount); | ||
}; | ||
} |
@@ -134,2 +134,31 @@ import Types from './types'; | ||
var productList = Array.isArray(product) ? product : [product]; | ||
productList.forEach(function(product) { | ||
if (product.TotalAmount) { | ||
product.TotalAmount = mpInstance._Ecommerce.sanitizeAmount( | ||
product.TotalAmount, | ||
'TotalAmount' | ||
); | ||
} | ||
if (product.Position) { | ||
product.Position = mpInstance._Ecommerce.sanitizeAmount( | ||
product.Position, | ||
'Position' | ||
); | ||
} | ||
if (product.Price) { | ||
product.Price = mpInstance._Ecommerce.sanitizeAmount( | ||
product.Price, | ||
'Price' | ||
); | ||
} | ||
if (product.Quantity) { | ||
product.Quantity = mpInstance._Ecommerce.sanitizeAmount( | ||
product.Quantity, | ||
'Quantity' | ||
); | ||
} | ||
}); | ||
if (event) { | ||
@@ -144,3 +173,3 @@ event.EventCategory = mpInstance._Ecommerce.convertProductActionToEventType( | ||
ProductActionType: productActionType, | ||
ProductList: Array.isArray(product) ? product : [product], | ||
ProductList: productList, | ||
}; | ||
@@ -147,0 +176,0 @@ |
@@ -389,7 +389,7 @@ // | ||
s: 'Error', | ||
t: error.stack, | ||
t: error.stack || null, | ||
}; | ||
if (attrs) { | ||
var sanitized = self._Helpers.sanitizeAttributes(attrs); | ||
var sanitized = self._Helpers.sanitizeAttributes(attrs, data.m); | ||
for (var prop in sanitized) { | ||
@@ -396,0 +396,0 @@ data[prop] = sanitized[prop]; |
@@ -389,3 +389,3 @@ import Constants from './constants'; | ||
? store.sessionStartDate.getTime() | ||
: null; | ||
: 0; | ||
data.gs.ia = store.integrationAttributes; | ||
@@ -392,0 +392,0 @@ |
@@ -199,3 +199,3 @@ import Types from './types'; | ||
? mpInstance._Store.sessionStartDate.getTime() | ||
: null, | ||
: 0, | ||
Debug: mpInstance._Store.SDKConfig.isDevelopmentMode, | ||
@@ -216,2 +216,6 @@ Location: mpInstance._Store.currentPosition, | ||
if (eventObject.EventDataType === MessageType.AppStateTransition) { | ||
eventObject.IsFirstRun = mpInstance._Store.isFirstRun; | ||
} | ||
eventObject.CurrencyCode = mpInstance._Store.currencyCode; | ||
@@ -242,3 +246,3 @@ var currentUser = user || mpInstance.Identity.getCurrentUser(); | ||
this.convertEventToDTO = function(event, isFirstRun) { | ||
this.convertEventToDTO = function(event) { | ||
var dto = { | ||
@@ -282,3 +286,3 @@ n: event.EventName, | ||
if (event.EventDataType === MessageType.AppStateTransition) { | ||
dto.fr = isFirstRun; | ||
dto.fr = event.IsFirstRun; | ||
dto.iu = false; | ||
@@ -285,0 +289,0 @@ dto.at = ApplicationTransitionType.AppInit; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1519708
27534