@@ -121,16 +121,16 @@ export default function Events(
121121 mpInstance . _APIClient . sendEventToServer ( event ) ;
122122 } ;
123123
124- this . logAST = function ( ) : void {
124+ this . logAST = ( ) : void => {
125125 this . logEvent ( { messageType : Types . MessageType . AppStateTransition } ) ;
126126 } ;
127127
128- this . logCheckoutEvent = function (
128+ this . logCheckoutEvent = (
129129 step : number ,
130130 option ?: string ,
131131 attrs ?: SDKEventAttrs ,
132132 customFlags ?: SDKEventCustomFlags
133- ) : void {
133+ ) : void => {
134134 const event = mpInstance . _Ecommerce . createCommerceEventObject (
135135 customFlags
136136 ) ;
@@ -151,14 +151,14 @@ export default function Events(
151151 }
152152 } ;
153153
154- this . logProductActionEvent = function (
154+ this . logProductActionEvent = (
155155 productActionType : valueof < typeof ProductActionType > ,
156156 product : SDKProduct | SDKProduct [ ] ,
157157 customAttrs ?: SDKEventAttrs ,
158158 customFlags ?: SDKEventCustomFlags ,
159159 transactionAttributes ?: TransactionAttributes ,
160160 options ?: SDKEventOptions
161- ) : void {
161+ ) : void => {
162162 const event = mpInstance . _Ecommerce . createCommerceEventObject (
163163 customFlags ,
164164 options
@@ -217,12 +217,12 @@ export default function Events(
217217 }
218218 } ;
219219
220- this . logPurchaseEvent = function (
220+ this . logPurchaseEvent = (
221221 transactionAttributes : TransactionAttributes ,
222222 product : SDKProduct | SDKProduct [ ] ,
223223 attrs ?: SDKEventAttrs ,
224224 customFlags ?: SDKEventCustomFlags
225- ) : void {
225+ ) : void => {
226226 const event = mpInstance . _Ecommerce . createCommerceEventObject (
227227 customFlags
228228 ) ;
@@ -249,12 +249,12 @@ export default function Events(
249249 }
250250 } ;
251251
252- this . logRefundEvent = function (
252+ this . logRefundEvent = (
253253 transactionAttributes : TransactionAttributes ,
254254 product : SDKProduct | SDKProduct [ ] ,
255255 attrs ?: SDKEventAttrs ,
256256 customFlags ?: SDKEventCustomFlags
257- ) : void {
257+ ) : void => {
258258 if ( ! transactionAttributes ) {
259259 mpInstance . Logger . error ( Messages . ErrorMessages . TransactionRequired ) ;
260260 return ;
@@ -286,13 +286,13 @@ export default function Events(
286286 }
287287 } ;
288288
289- this . logPromotionEvent = function (
289+ this . logPromotionEvent = (
290290 promotionType : valueof < typeof PromotionActionType > ,
291291 promotion : SDKPromotion | SDKPromotion [ ] ,
292292 attrs ?: SDKEventAttrs ,
293293 customFlags ?: SDKEventCustomFlags ,
294294 eventOptions ?: SDKEventOptions
295- ) : void {
295+ ) : void => {
296296 const event = mpInstance . _Ecommerce . createCommerceEventObject (
297297 customFlags
298298 ) ;
@@ -315,12 +315,12 @@ export default function Events(
315315 }
316316 } ;
317317
318- this . logImpressionEvent = function (
318+ this . logImpressionEvent = (
319319 impression : SDKImpression | SDKImpression [ ] | SDKProductImpression | SDKProductImpression [ ] ,
320320 attrs ?: SDKEventAttrs ,
321321 customFlags ?: SDKEventCustomFlags ,
322322 options ?: SDKEventOptions
323- ) : void {
323+ ) : void => {
324324 const event = mpInstance . _Ecommerce . createCommerceEventObject (
325325 customFlags
326326 ) ;
@@ -335,13 +335,21 @@ export default function Events(
335335 event . ProductImpressions = [ ] ;
336336
337337 rawList . forEach ( function ( item ) {
338- const imp = item as SDKImpression ;
339- event . ProductImpressions . push ( {
340- ProductImpressionList : imp . Name ,
341- ProductList : Array . isArray ( imp . Product )
342- ? imp . Product
343- : [ imp . Product ] ,
344- } ) ;
338+ if ( 'Name' in item ) {
339+ const imp = item as SDKImpression ;
340+ event . ProductImpressions . push ( {
341+ ProductImpressionList : imp . Name ,
342+ ProductList : Array . isArray ( imp . Product )
343+ ? imp . Product
344+ : [ imp . Product ] ,
345+ } ) ;
346+ } else {
347+ const imp = item as SDKProductImpression ;
348+ event . ProductImpressions . push ( {
349+ ProductImpressionList : imp . ProductImpressionList ,
350+ ProductList : imp . ProductList || [ ] ,
351+ } ) ;
352+ }
345353 } ) ;
346354
347355 this . logCommerceEvent ( event , attrs , options ) ;
0 commit comments