@constructor-io/constructorio-client-javascript 2.27.9 → 2.27.10
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 +63 -0
- package/package.json +1 -1
package/lib/modules/tracker.js
CHANGED
|
@@ -159,6 +159,69 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
159
159
|
this.requests.send();
|
|
160
160
|
return true;
|
|
161
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Send item detail load event to API
|
|
164
|
+
*
|
|
165
|
+
* @function trackItemDetailLoad
|
|
166
|
+
* @param {object} parameters - Additional parameters to be sent with request
|
|
167
|
+
* @param {string} parameters.item_name - Product item name
|
|
168
|
+
* @param {string} parameters.item_id - Product item unique identifier
|
|
169
|
+
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
170
|
+
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
171
|
+
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
172
|
+
* @returns {(true|Error)}
|
|
173
|
+
* @description User loaded an item detail page
|
|
174
|
+
* @example
|
|
175
|
+
* constructorio.tracker.trackItemDetailLoad(
|
|
176
|
+
* {
|
|
177
|
+
* item_name: 'Red T-Shirt',
|
|
178
|
+
* item_id: 'KMH876',
|
|
179
|
+
* },
|
|
180
|
+
* );
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
}, {
|
|
184
|
+
key: "trackItemDetailLoad",
|
|
185
|
+
value: function trackItemDetailLoad(parameters) {
|
|
186
|
+
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
187
|
+
|
|
188
|
+
// Ensure parameters are provided (required)
|
|
189
|
+
if (parameters && (0, _typeof2["default"])(parameters) === 'object' && !Array.isArray(parameters)) {
|
|
190
|
+
var url = "".concat(this.options.serviceUrl, "/behavior?");
|
|
191
|
+
var queryParams = {
|
|
192
|
+
action: 'item_detail_load'
|
|
193
|
+
};
|
|
194
|
+
var item_name = parameters.item_name,
|
|
195
|
+
name = parameters.name,
|
|
196
|
+
item_id = parameters.item_id,
|
|
197
|
+
customer_id = parameters.customer_id,
|
|
198
|
+
variation_id = parameters.variation_id; // Ensure support for both item_name and name as parameters
|
|
199
|
+
|
|
200
|
+
if (item_name) {
|
|
201
|
+
queryParams.name = item_name;
|
|
202
|
+
} else if (name) {
|
|
203
|
+
queryParams.name = name;
|
|
204
|
+
} // Ensure support for both item_id and customer_id as parameters
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if (item_id) {
|
|
208
|
+
queryParams.customer_id = item_id;
|
|
209
|
+
} else if (customer_id) {
|
|
210
|
+
queryParams.customer_id = customer_id;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (variation_id) {
|
|
214
|
+
queryParams.variation_id = variation_id;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this.requests.queue("".concat(url).concat(applyParamsAsString(queryParams, this.options)), undefined, undefined, networkParameters);
|
|
218
|
+
this.requests.send();
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this.requests.send();
|
|
223
|
+
return new Error('parameters are required of type object');
|
|
224
|
+
}
|
|
162
225
|
/**
|
|
163
226
|
* Send autocomplete select event to API
|
|
164
227
|
*
|