Skip to content

Commit e745772

Browse files
rmi22186claude
andcommitted
breaking: remove deprecated logCheckout, logPurchase, and logRefund methods
These deprecated eCommerce methods have been removed in favor of logProductAction which provides the same functionality with a more flexible API. Users should migrate to logProductAction with the appropriate ProductActionType (Checkout, Purchase, Refund). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 765f3ba commit e745772

15 files changed

Lines changed: 5 additions & 1025 deletions

snippet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'startTrackingLocation',
4444
'stopTrackingLocation',
4545
];
46-
var ecommerceMethods = ['setCurrencyCode', 'logCheckout'];
46+
var ecommerceMethods = ['setCurrencyCode'];
4747
var identityMethods = ['identify', 'login', 'logout', 'modify'];
4848
var roktMethods = [
4949
'selectPlacements',

snippet.rokt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'startTrackingLocation',
4444
'stopTrackingLocation',
4545
];
46-
var ecommerceMethods = ['setCurrencyCode', 'logCheckout'];
46+
var ecommerceMethods = ['setCurrencyCode'];
4747
var identityMethods = ['identify', 'login', 'logout', 'modify'];
4848
var roktMethods = [
4949
'selectPlacements',

src/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ const Constants = {
2525
PromotionIdRequired: 'Promotion ID is required',
2626
BadAttribute: 'Attribute value cannot be object or array',
2727
BadKey: 'Key value cannot be object or array',
28-
BadLogPurchase:
29-
'Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions',
3028
AudienceAPINotEnabled:
3129
'Your workspace is not enabled to retrieve user audiences.',
3230
},

src/ecommerce.interfaces.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ export interface SDKCart {
6464

6565
// Used for the public `eCommerce` namespace
6666
export interface SDKECommerceAPI extends IECommerceShared {
67-
logCheckout(
68-
step: number,
69-
option?: string,
70-
attrs?: SDKEventAttrs,
71-
customFlags?: SDKEventCustomFlags
72-
): void;
7367
logImpression(
7468
impression: SDKProductImpression,
7569
attrs?: SDKEventAttrs,
@@ -98,27 +92,6 @@ export interface SDKECommerceAPI extends IECommerceShared {
9892
*/
9993
Cart: SDKCart;
10094

101-
/*
102-
* @deprecated
103-
*/
104-
logPurchase(
105-
transactionAttributes: TransactionAttributes,
106-
product: SDKProduct | SDKProduct[],
107-
clearCart?: boolean,
108-
attrs?: SDKEventAttrs,
109-
customFlags?: SDKEventCustomFlags
110-
): void;
111-
112-
/*
113-
* @deprecated
114-
*/
115-
logRefund(
116-
transactionAttributes: TransactionAttributes,
117-
product: SDKProduct | SDKProduct[],
118-
clearCart?: boolean,
119-
attrs?: SDKEventAttrs,
120-
customFlags?: SDKEventCustomFlags
121-
): void;
12295
}
12396

12497
interface ExtractedActionAttributes {

src/events.interfaces.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ export interface IEvents {
2727
eventType: valueof<typeof EventType>
2828
): void;
2929
logAST(): void;
30-
logCheckoutEvent(
31-
step: number,
32-
33-
// User options specified during the checkout process
34-
// e.g., FedEx, DHL, UPS for delivery options;
35-
// Visa, MasterCard, AmEx for payment options.
36-
option?: string,
37-
38-
attrs?: SDKEventAttrs,
39-
customFlags?: SDKEventCustomFlags
40-
): void;
4130
logCommerceEvent(
4231
commerceEvent: SDKEvent,
4332
attrs?: SDKEventAttrs,
@@ -66,18 +55,6 @@ export interface IEvents {
6655
customFlags?: SDKEventCustomFlags,
6756
eventOptions?: SDKEventOptions
6857
): void;
69-
logPurchaseEvent(
70-
transactionAttributes: TransactionAttributes,
71-
product: SDKProduct | SDKProduct[],
72-
attrs?: SDKEventAttrs,
73-
customFlags?: SDKEventCustomFlags
74-
): void;
75-
logRefundEvent(
76-
transactionAttributes: TransactionAttributes,
77-
product: SDKProduct | SDKProduct[],
78-
attrs?: SDKEventAttrs,
79-
customFlags?: SDKEventCustomFlags
80-
): void;
8158
startTracking(callback: Callback): void;
8259
stopTracking(): void;
8360
}

src/events.js

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,6 @@ export default function Events(mpInstance) {
9999
self.logEvent({ messageType: Types.MessageType.AppStateTransition });
100100
};
101101

102-
this.logCheckoutEvent = function(step, option, attrs, customFlags) {
103-
var event = mpInstance._Ecommerce.createCommerceEventObject(
104-
customFlags
105-
);
106-
107-
if (event) {
108-
event.EventName += mpInstance._Ecommerce.getProductActionEventName(
109-
Types.ProductActionType.Checkout
110-
);
111-
event.EventCategory = Types.CommerceEventType.ProductCheckout;
112-
event.ProductAction = {
113-
ProductActionType: Types.ProductActionType.Checkout,
114-
CheckoutStep: step,
115-
CheckoutOptions: option,
116-
ProductList: [],
117-
};
118-
119-
self.logCommerceEvent(event, attrs);
120-
}
121-
};
122-
123102
this.logProductActionEvent = function(
124103
productActionType,
125104
product,
@@ -185,75 +164,6 @@ export default function Events(mpInstance) {
185164
}
186165
};
187166

188-
this.logPurchaseEvent = function(
189-
transactionAttributes,
190-
product,
191-
attrs,
192-
customFlags
193-
) {
194-
var event = mpInstance._Ecommerce.createCommerceEventObject(
195-
customFlags
196-
);
197-
198-
if (event) {
199-
event.EventName += mpInstance._Ecommerce.getProductActionEventName(
200-
Types.ProductActionType.Purchase
201-
);
202-
event.EventCategory = Types.CommerceEventType.ProductPurchase;
203-
event.ProductAction = {
204-
ProductActionType: Types.ProductActionType.Purchase,
205-
};
206-
event.ProductAction.ProductList = mpInstance._Ecommerce.buildProductList(
207-
event,
208-
product
209-
);
210-
211-
mpInstance._Ecommerce.convertTransactionAttributesToProductAction(
212-
transactionAttributes,
213-
event.ProductAction
214-
);
215-
216-
self.logCommerceEvent(event, attrs);
217-
}
218-
};
219-
220-
this.logRefundEvent = function(
221-
transactionAttributes,
222-
product,
223-
attrs,
224-
customFlags
225-
) {
226-
if (!transactionAttributes) {
227-
mpInstance.Logger.error(Messages.ErrorMessages.TransactionRequired);
228-
return;
229-
}
230-
231-
var event = mpInstance._Ecommerce.createCommerceEventObject(
232-
customFlags
233-
);
234-
235-
if (event) {
236-
event.EventName += mpInstance._Ecommerce.getProductActionEventName(
237-
Types.ProductActionType.Refund
238-
);
239-
event.EventCategory = Types.CommerceEventType.ProductRefund;
240-
event.ProductAction = {
241-
ProductActionType: Types.ProductActionType.Refund,
242-
};
243-
event.ProductAction.ProductList = mpInstance._Ecommerce.buildProductList(
244-
event,
245-
product
246-
);
247-
248-
mpInstance._Ecommerce.convertTransactionAttributesToProductAction(
249-
transactionAttributes,
250-
event.ProductAction
251-
);
252-
253-
self.logCommerceEvent(event, attrs);
254-
}
255-
};
256-
257167
this.logPromotionEvent = function(
258168
promotionType,
259169
promotion,

src/mp-instance.ts

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -921,37 +921,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
921921
tax
922922
);
923923
},
924-
/**
925-
* Logs a checkout action
926-
* @for mParticle.eCommerce
927-
* @method logCheckout
928-
* @param {Number} step checkout step number
929-
* @param {String} checkout option string
930-
* @param {Object} attrs
931-
* @param {Object} [customFlags] Custom flags for the event
932-
* @deprecated
933-
*/
934-
logCheckout: function(step, option, attrs, customFlags) {
935-
self.Logger.warning(
936-
'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead'
937-
);
938-
939-
if (!self._Store.isInitialized) {
940-
self.ready(function() {
941-
self.eCommerce.logCheckout(
942-
step,
943-
option,
944-
attrs,
945-
customFlags
946-
);
947-
});
948-
949-
return;
950-
}
951-
952-
self._SessionManager.resetSessionTimer();
953-
self._Events.logCheckoutEvent(step, option, attrs, customFlags);
954-
},
955924
/**
956925
* Logs a product action
957926
* @for mParticle.eCommerce
@@ -994,51 +963,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
994963
eventOptions
995964
);
996965
},
997-
/**
998-
* Logs a product purchase
999-
* @for mParticle.eCommerce
1000-
* @method logPurchase
1001-
* @param {Object} transactionAttributes transactionAttributes object
1002-
* @param {Object} product the product being purchased
1003-
* @param {Boolean} [clearCart] boolean to clear the cart after logging or not. Defaults to false
1004-
* @param {Object} [attrs] other attributes related to the product purchase
1005-
* @param {Object} [customFlags] Custom flags for the event
1006-
* @deprecated
1007-
*/
1008-
logPurchase: function(
1009-
transactionAttributes,
1010-
product,
1011-
clearCart,
1012-
attrs,
1013-
customFlags
1014-
) {
1015-
self.Logger.warning(
1016-
'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead'
1017-
);
1018-
if (!self._Store.isInitialized) {
1019-
self.ready(function() {
1020-
self.eCommerce.logPurchase(
1021-
transactionAttributes,
1022-
product,
1023-
clearCart,
1024-
attrs,
1025-
customFlags
1026-
);
1027-
});
1028-
return;
1029-
}
1030-
if (!transactionAttributes || !product) {
1031-
self.Logger.error(Messages.ErrorMessages.BadLogPurchase);
1032-
return;
1033-
}
1034-
self._SessionManager.resetSessionTimer();
1035-
self._Events.logPurchaseEvent(
1036-
transactionAttributes,
1037-
product,
1038-
attrs,
1039-
customFlags
1040-
);
1041-
},
1042966
/**
1043967
* Logs a product promotion
1044968
* @for mParticle.eCommerce
@@ -1106,47 +1030,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
11061030
eventOptions
11071031
);
11081032
},
1109-
/**
1110-
* Logs a refund
1111-
* @for mParticle.eCommerce
1112-
* @method logRefund
1113-
* @param {Object} transactionAttributes transaction attributes related to the refund
1114-
* @param {Object} product product being refunded
1115-
* @param {Boolean} [clearCart] boolean to clear the cart after refund is logged. Defaults to false.
1116-
* @param {Object} [attrs] attributes related to the refund
1117-
* @param {Object} [customFlags] Custom flags for the event
1118-
* @deprecated
1119-
*/
1120-
logRefund: function(
1121-
transactionAttributes,
1122-
product,
1123-
clearCart,
1124-
attrs,
1125-
customFlags
1126-
) {
1127-
self.Logger.warning(
1128-
'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead'
1129-
);
1130-
if (!self._Store.isInitialized) {
1131-
self.ready(function() {
1132-
self.eCommerce.logRefund(
1133-
transactionAttributes,
1134-
product,
1135-
clearCart,
1136-
attrs,
1137-
customFlags
1138-
);
1139-
});
1140-
return;
1141-
}
1142-
self._SessionManager.resetSessionTimer();
1143-
self._Events.logRefundEvent(
1144-
transactionAttributes,
1145-
product,
1146-
attrs,
1147-
customFlags
1148-
);
1149-
},
11501033
expandCommerceEvent: function(event) {
11511034
return self._Ecommerce.expandCommerceEvent(event);
11521035
},

0 commit comments

Comments
 (0)