@constructor-io/constructorio-client-javascript 2.51.2 → 2.53.1
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/constructorio.js +9 -5
- package/lib/modules/tracker.js +7 -1
- package/lib/types/tracker.d.ts +13 -0
- package/lib/version.js +1 -1
- package/package.json +2 -3
package/lib/constructorio.js
CHANGED
|
@@ -5,7 +5,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
5
5
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
6
6
|
/* eslint-disable camelcase, no-unneeded-ternary, max-len, complexity */
|
|
7
7
|
var ConstructorioID = require('@constructor-io/constructorio-id');
|
|
8
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
9
8
|
|
|
10
9
|
// Modules
|
|
11
10
|
var Search = require('./modules/search');
|
|
@@ -80,7 +79,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
80
79
|
clientId = options.clientId,
|
|
81
80
|
sessionId = options.sessionId,
|
|
82
81
|
userId = options.userId,
|
|
83
|
-
|
|
82
|
+
fetchFromOptions = options.fetch,
|
|
84
83
|
trackingSendDelay = options.trackingSendDelay,
|
|
85
84
|
sendReferrerWithTrackingEvents = options.sendReferrerWithTrackingEvents,
|
|
86
85
|
sendTrackingEvents = options.sendTrackingEvents,
|
|
@@ -123,9 +122,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
123
122
|
userId: userId,
|
|
124
123
|
segments: segments,
|
|
125
124
|
testCells: testCells,
|
|
126
|
-
fetch:
|
|
127
|
-
Promise: Promise
|
|
128
|
-
}).fetch,
|
|
125
|
+
fetch: fetchFromOptions || fetch,
|
|
129
126
|
trackingSendDelay: trackingSendDelay,
|
|
130
127
|
sendTrackingEvents: sendTrackingEvents,
|
|
131
128
|
sendReferrerWithTrackingEvents: sendReferrerWithTrackingEvents,
|
|
@@ -155,6 +152,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
155
152
|
* @param {string} [options.apiKey] - Constructor.io API key
|
|
156
153
|
* @param {array} [options.segments] - User segments
|
|
157
154
|
* @param {object} [options.testCells] - User test cells
|
|
155
|
+
* @param {number} [options.sessionId] - Session ID - Will only be set in DOM-less environments
|
|
158
156
|
* @param {string} [options.userId] - User ID
|
|
159
157
|
*/
|
|
160
158
|
(0, _createClass2["default"])(ConstructorIO, [{
|
|
@@ -164,6 +162,7 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
164
162
|
var apiKey = options.apiKey,
|
|
165
163
|
segments = options.segments,
|
|
166
164
|
testCells = options.testCells,
|
|
165
|
+
sessionId = options.sessionId,
|
|
167
166
|
_options$userId = options.userId,
|
|
168
167
|
userId = _options$userId === void 0 ? '' : _options$userId;
|
|
169
168
|
if (apiKey) {
|
|
@@ -175,6 +174,11 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
175
174
|
if (testCells) {
|
|
176
175
|
this.options.testCells = testCells;
|
|
177
176
|
}
|
|
177
|
+
|
|
178
|
+
// Set Session ID in dom-less environments only
|
|
179
|
+
if (sessionId && !helpers.canUseDOM()) {
|
|
180
|
+
this.options.sessionId = sessionId;
|
|
181
|
+
}
|
|
178
182
|
this.options.userId = userId;
|
|
179
183
|
}
|
|
180
184
|
}
|
package/lib/modules/tracker.js
CHANGED
|
@@ -438,6 +438,7 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
438
438
|
* @param {string} parameters.userInput - The current autocomplete search query
|
|
439
439
|
* @param {string} [parameters.groupId] - Group identifier of selected item
|
|
440
440
|
* @param {string} [parameters.section] - The section name for the item Ex. "Products"
|
|
441
|
+
* @param {object} [parameters.analyticsTags] - Pass additional analytics data
|
|
441
442
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
442
443
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
443
444
|
* @returns {(true|Error)}
|
|
@@ -469,7 +470,9 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
469
470
|
group_id = parameters.group_id,
|
|
470
471
|
_parameters$groupId3 = parameters.groupId,
|
|
471
472
|
groupId = _parameters$groupId3 === void 0 ? group_id : _parameters$groupId3,
|
|
472
|
-
section = parameters.section
|
|
473
|
+
section = parameters.section,
|
|
474
|
+
_parameters$analytics2 = parameters.analyticsTags,
|
|
475
|
+
analyticsTags = _parameters$analytics2 === void 0 ? null : _parameters$analytics2;
|
|
473
476
|
var queryParams = {};
|
|
474
477
|
var bodyParams = {
|
|
475
478
|
user_input: userInput,
|
|
@@ -484,6 +487,9 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
484
487
|
if (section) {
|
|
485
488
|
queryParams.section = section;
|
|
486
489
|
}
|
|
490
|
+
if (analyticsTags) {
|
|
491
|
+
bodyParams.analytics_tags = analyticsTags;
|
|
492
|
+
}
|
|
487
493
|
var requestURL = "".concat(baseUrl).concat(applyParamsAsString(queryParams, this.options));
|
|
488
494
|
var requestMethod = 'POST';
|
|
489
495
|
var requestBody = applyParams(bodyParams, _objectSpread(_objectSpread({}, this.options), {}, {
|
package/lib/types/tracker.d.ts
CHANGED
|
@@ -58,6 +58,19 @@ declare class Tracker {
|
|
|
58
58
|
networkParameters?: NetworkParameters
|
|
59
59
|
): true | Error;
|
|
60
60
|
|
|
61
|
+
trackSearchSubmitV2(
|
|
62
|
+
term: string,
|
|
63
|
+
parameters: {
|
|
64
|
+
originalQuery: string;
|
|
65
|
+
groupId?: string;
|
|
66
|
+
displayName?: string;
|
|
67
|
+
section?: string;
|
|
68
|
+
userInput: string;
|
|
69
|
+
analyticsTags?: Record<string, string>;
|
|
70
|
+
},
|
|
71
|
+
networkParameters?: NetworkParameters
|
|
72
|
+
): true | Error;
|
|
73
|
+
|
|
61
74
|
trackSearchResultsLoadedV2(
|
|
62
75
|
term: string,
|
|
63
76
|
parameters: {
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-client-javascript",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.53.1",
|
|
4
4
|
"description": "Constructor.io JavaScript client",
|
|
5
5
|
"main": "lib/constructorio.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,8 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@constructor-io/constructorio-id": "^2.4.17",
|
|
77
|
-
"crc-32": "^1.2.2"
|
|
78
|
-
"fetch-ponyfill": "^7.1.0"
|
|
77
|
+
"crc-32": "^1.2.2"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"@babel/runtime": "^7.19.0"
|