11import Types from './types' ;
22import Constants from './constants' ;
3+ import { ErrorCodes } from './logging/errorCodes' ;
34
45var Messages = Constants . Messages ;
56
@@ -116,7 +117,8 @@ export default function Ecommerce(mpInstance) {
116117 mpInstance . Logger . error (
117118 'Could not convert product action type ' +
118119 productActionType +
119- ' to event type'
120+ ' to event type' ,
121+ ErrorCodes . ECOMMERCE_ERROR
120122 ) ;
121123 return null ;
122124 }
@@ -132,7 +134,8 @@ export default function Ecommerce(mpInstance) {
132134 mpInstance . Logger . error (
133135 'Could not convert promotion action type ' +
134136 promotionActionType +
135- ' to event type'
137+ ' to event type' ,
138+ ErrorCodes . ECOMMERCE_ERROR
136139 ) ;
137140 return null ;
138141 }
@@ -262,20 +265,25 @@ export default function Ecommerce(mpInstance) {
262265 attributes = mpInstance . _Helpers . sanitizeAttributes ( attributes , name ) ;
263266
264267 if ( typeof name !== 'string' ) {
265- mpInstance . Logger . error ( 'Name is required when creating a product' ) ;
268+ mpInstance . Logger . error (
269+ 'Name is required when creating a product' ,
270+ ErrorCodes . ECOMMERCE_ERROR
271+ ) ;
266272 return null ;
267273 }
268274
269275 if ( ! mpInstance . _Helpers . Validators . isStringOrNumber ( sku ) ) {
270276 mpInstance . Logger . error (
271- 'SKU is required when creating a product, and must be a string or a number'
277+ 'SKU is required when creating a product, and must be a string or a number' ,
278+ ErrorCodes . ECOMMERCE_ERROR
272279 ) ;
273280 return null ;
274281 }
275282
276283 if ( ! mpInstance . _Helpers . Validators . isStringOrNumber ( price ) ) {
277284 mpInstance . Logger . error (
278- 'Price is required when creating a product, and must be a string or a number'
285+ 'Price is required when creating a product, and must be a string or a number' ,
286+ ErrorCodes . ECOMMERCE_ERROR
279287 ) ;
280288 return null ;
281289 } else {
@@ -284,7 +292,8 @@ export default function Ecommerce(mpInstance) {
284292
285293 if ( position && ! mpInstance . _Helpers . Validators . isNumber ( position ) ) {
286294 mpInstance . Logger . error (
287- 'Position must be a number, it will be set to null.'
295+ 'Position must be a number, it will be set to null.' ,
296+ ErrorCodes . ECOMMERCE_ERROR
288297 ) ;
289298 position = null ;
290299 }
@@ -312,7 +321,10 @@ export default function Ecommerce(mpInstance) {
312321
313322 this . createPromotion = function ( id , creative , name , position ) {
314323 if ( ! mpInstance . _Helpers . Validators . isStringOrNumber ( id ) ) {
315- mpInstance . Logger . error ( Messages . ErrorMessages . PromotionIdRequired ) ;
324+ mpInstance . Logger . error (
325+ Messages . ErrorMessages . PromotionIdRequired ,
326+ ErrorCodes . ECOMMERCE_ERROR
327+ ) ;
316328 return null ;
317329 }
318330
@@ -327,14 +339,16 @@ export default function Ecommerce(mpInstance) {
327339 this . createImpression = function ( name , product ) {
328340 if ( typeof name !== 'string' ) {
329341 mpInstance . Logger . error (
330- 'Name is required when creating an impression.'
342+ 'Name is required when creating an impression.' ,
343+ ErrorCodes . ECOMMERCE_ERROR
331344 ) ;
332345 return null ;
333346 }
334347
335348 if ( ! product ) {
336349 mpInstance . Logger . error (
337- 'Product is required when creating an impression.'
350+ 'Product is required when creating an impression.' ,
351+ ErrorCodes . ECOMMERCE_ERROR
338352 ) ;
339353 return null ;
340354 }
@@ -355,7 +369,8 @@ export default function Ecommerce(mpInstance) {
355369 ) {
356370 if ( ! mpInstance . _Helpers . Validators . isStringOrNumber ( id ) ) {
357371 mpInstance . Logger . error (
358- Messages . ErrorMessages . TransactionIdRequired
372+ Messages . ErrorMessages . TransactionIdRequired ,
373+ ErrorCodes . ECOMMERCE_ERROR
359374 ) ;
360375 return null ;
361376 }
0 commit comments