@constructor-io/constructorio-client-javascript 2.48.0 → 2.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules/tracker.js +10 -3
- package/lib/utils/helpers.js +12 -4
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/lib/modules/tracker.js
CHANGED
|
@@ -1093,12 +1093,19 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
1093
1093
|
orderId = _parameters$orderId === void 0 ? order_id : _parameters$orderId,
|
|
1094
1094
|
section = parameters.section,
|
|
1095
1095
|
analyticsTags = parameters.analyticsTags;
|
|
1096
|
+
var apiKey = this.options.apiKey;
|
|
1096
1097
|
if (orderId) {
|
|
1097
|
-
// Don't send another purchase event if we have already tracked the order
|
|
1098
|
-
if (helpers.hasOrderIdRecord(
|
|
1098
|
+
// Don't send another purchase event if we have already tracked the order for the current key
|
|
1099
|
+
if (helpers.hasOrderIdRecord({
|
|
1100
|
+
orderId: orderId,
|
|
1101
|
+
apiKey: apiKey
|
|
1102
|
+
})) {
|
|
1099
1103
|
return false;
|
|
1100
1104
|
}
|
|
1101
|
-
helpers.addOrderIdRecord(
|
|
1105
|
+
helpers.addOrderIdRecord({
|
|
1106
|
+
orderId: orderId,
|
|
1107
|
+
apiKey: apiKey
|
|
1108
|
+
});
|
|
1102
1109
|
|
|
1103
1110
|
// Add order_id to the tracking params
|
|
1104
1111
|
bodyParams.order_id = orderId;
|
package/lib/utils/helpers.js
CHANGED
|
@@ -104,8 +104,12 @@ var utils = {
|
|
|
104
104
|
}
|
|
105
105
|
return null;
|
|
106
106
|
},
|
|
107
|
-
hasOrderIdRecord: function hasOrderIdRecord(
|
|
108
|
-
var
|
|
107
|
+
hasOrderIdRecord: function hasOrderIdRecord(_ref) {
|
|
108
|
+
var orderId = _ref.orderId,
|
|
109
|
+
apiKey = _ref.apiKey;
|
|
110
|
+
var orderPerKeyId = orderId;
|
|
111
|
+
if (apiKey) orderPerKeyId = "".concat(apiKey, "-").concat(orderId);
|
|
112
|
+
var orderIdHash = CRC32.str(orderPerKeyId.toString());
|
|
109
113
|
var purchaseEventStorage = store.local.get(purchaseEventStorageKey);
|
|
110
114
|
if (typeof purchaseEventStorage === 'string') {
|
|
111
115
|
purchaseEventStorage = JSON.parse(purchaseEventStorage);
|
|
@@ -115,8 +119,12 @@ var utils = {
|
|
|
115
119
|
}
|
|
116
120
|
return null;
|
|
117
121
|
},
|
|
118
|
-
addOrderIdRecord: function addOrderIdRecord(
|
|
119
|
-
var
|
|
122
|
+
addOrderIdRecord: function addOrderIdRecord(_ref2) {
|
|
123
|
+
var orderId = _ref2.orderId,
|
|
124
|
+
apiKey = _ref2.apiKey;
|
|
125
|
+
var orderPerKeyId = orderId;
|
|
126
|
+
if (apiKey) orderPerKeyId = "".concat(apiKey, "-").concat(orderId);
|
|
127
|
+
var orderIdHash = CRC32.str(orderPerKeyId.toString());
|
|
120
128
|
var purchaseEventStorage = store.local.get(purchaseEventStorageKey);
|
|
121
129
|
if (typeof purchaseEventStorage === 'string') {
|
|
122
130
|
purchaseEventStorage = JSON.parse(purchaseEventStorage);
|
package/lib/version.js
CHANGED