@constructor-io/constructorio-client-javascript 2.33.4 → 2.34.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 +6 -2
- package/lib/modules/autocomplete.js +4 -11
- package/lib/modules/browse.js +10 -34
- package/lib/modules/quizzes.js +11 -21
- package/lib/modules/recommendations.js +3 -10
- package/lib/modules/search.js +2 -10
- package/lib/modules/tracker.js +3 -5
- package/lib/utils/helpers.js +33 -0
- package/lib/utils/request-queue.js +1 -5
- package/package.json +2 -2
package/lib/constructorio.js
CHANGED
|
@@ -7,7 +7,9 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
|
|
9
9
|
/* eslint-disable camelcase, no-unneeded-ternary, max-len */
|
|
10
|
-
var ConstructorioID = require('@constructor-io/constructorio-id');
|
|
10
|
+
var ConstructorioID = require('@constructor-io/constructorio-id');
|
|
11
|
+
|
|
12
|
+
var fetchPonyfill = require('fetch-ponyfill'); // Modules
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
var Search = require('./modules/search');
|
|
@@ -131,7 +133,9 @@ var ConstructorIO = /*#__PURE__*/function () {
|
|
|
131
133
|
userId: userId,
|
|
132
134
|
segments: segments,
|
|
133
135
|
testCells: testCells,
|
|
134
|
-
fetch: fetch
|
|
136
|
+
fetch: fetch || fetchPonyfill({
|
|
137
|
+
Promise: Promise
|
|
138
|
+
}).fetch,
|
|
135
139
|
trackingSendDelay: trackingSendDelay,
|
|
136
140
|
sendTrackingEvents: sendTrackingEvents,
|
|
137
141
|
sendReferrerWithTrackingEvents: sendReferrerWithTrackingEvents,
|
|
@@ -7,10 +7,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
|
|
9
9
|
/* eslint-disable object-curly-newline, no-underscore-dangle */
|
|
10
|
-
var qs = require('qs');
|
|
11
|
-
|
|
12
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
13
|
-
|
|
14
10
|
var EventDispatcher = require('../utils/event-dispatcher');
|
|
15
11
|
|
|
16
12
|
var _require = require('../utils/helpers'),
|
|
@@ -18,7 +14,8 @@ var _require = require('../utils/helpers'),
|
|
|
18
14
|
cleanParams = _require.cleanParams,
|
|
19
15
|
applyNetworkTimeout = _require.applyNetworkTimeout,
|
|
20
16
|
trimNonBreakingSpaces = _require.trimNonBreakingSpaces,
|
|
21
|
-
encodeURIComponentRFC3986 = _require.encodeURIComponentRFC3986
|
|
17
|
+
encodeURIComponentRFC3986 = _require.encodeURIComponentRFC3986,
|
|
18
|
+
stringify = _require.stringify; // Create URL from supplied query (term) and parameters
|
|
22
19
|
|
|
23
20
|
|
|
24
21
|
function createAutocompleteUrl(query, parameters, options) {
|
|
@@ -100,9 +97,7 @@ function createAutocompleteUrl(query, parameters, options) {
|
|
|
100
97
|
|
|
101
98
|
queryParams._dt = Date.now();
|
|
102
99
|
queryParams = cleanParams(queryParams);
|
|
103
|
-
var queryString =
|
|
104
|
-
indices: false
|
|
105
|
-
});
|
|
100
|
+
var queryString = stringify(queryParams);
|
|
106
101
|
var cleanedQuery = query.replace(/^\//, '|'); // For compatibility with backend API
|
|
107
102
|
|
|
108
103
|
return "".concat(serviceUrl, "/autocomplete/").concat(encodeURIComponentRFC3986(trimNonBreakingSpaces(cleanedQuery)), "?").concat(queryString);
|
|
@@ -158,9 +153,7 @@ var Autocomplete = /*#__PURE__*/function () {
|
|
|
158
153
|
|
|
159
154
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
160
155
|
var requestUrl;
|
|
161
|
-
var fetch = this.options
|
|
162
|
-
Promise: Promise
|
|
163
|
-
}).fetch;
|
|
156
|
+
var fetch = this.options.fetch;
|
|
164
157
|
var signal;
|
|
165
158
|
|
|
166
159
|
if (typeof AbortController === 'function') {
|
package/lib/modules/browse.js
CHANGED
|
@@ -13,10 +13,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
14
|
|
|
15
15
|
/* eslint-disable object-curly-newline, no-underscore-dangle, max-len, complexity */
|
|
16
|
-
var qs = require('qs');
|
|
17
|
-
|
|
18
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
19
|
-
|
|
20
16
|
var EventDispatcher = require('../utils/event-dispatcher');
|
|
21
17
|
|
|
22
18
|
var helpers = require('../utils/helpers'); // Create query params from parameters and options
|
|
@@ -163,9 +159,7 @@ function createBrowseUrlFromFilter(filterName, filterValue, parameters, options)
|
|
|
163
159
|
}
|
|
164
160
|
|
|
165
161
|
var queryParams = createQueryParams(parameters, options);
|
|
166
|
-
var queryString =
|
|
167
|
-
indices: false
|
|
168
|
-
});
|
|
162
|
+
var queryString = helpers.stringify(queryParams);
|
|
169
163
|
return "".concat(serviceUrl, "/browse/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(filterName)), "/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(filterValue)), "?").concat(queryString);
|
|
170
164
|
} // Create URL from supplied id's
|
|
171
165
|
|
|
@@ -181,9 +175,7 @@ function createBrowseUrlFromIDs(ids, parameters, options) {
|
|
|
181
175
|
ids: ids
|
|
182
176
|
});
|
|
183
177
|
|
|
184
|
-
var queryString =
|
|
185
|
-
indices: false
|
|
186
|
-
});
|
|
178
|
+
var queryString = helpers.stringify(queryParams);
|
|
187
179
|
return "".concat(serviceUrl, "/browse/items?").concat(queryString);
|
|
188
180
|
} // Create URL for facets
|
|
189
181
|
|
|
@@ -195,9 +187,7 @@ function createBrowseUrlForFacets(parameters, options) {
|
|
|
195
187
|
|
|
196
188
|
|
|
197
189
|
delete queryParams._dt;
|
|
198
|
-
var queryString =
|
|
199
|
-
indices: false
|
|
200
|
-
});
|
|
190
|
+
var queryString = helpers.stringify(queryParams);
|
|
201
191
|
return "".concat(serviceUrl, "/browse/facets?").concat(queryString);
|
|
202
192
|
} // Create URL from supplied facet name and parameters
|
|
203
193
|
|
|
@@ -214,9 +204,7 @@ function createBrowseUrlForFacetOptions(facetName, parameters, options) {
|
|
|
214
204
|
queryParams.facet_name = facetName; // Endpoint does not accept _dt
|
|
215
205
|
|
|
216
206
|
delete queryParams._dt;
|
|
217
|
-
var queryString =
|
|
218
|
-
indices: false
|
|
219
|
-
});
|
|
207
|
+
var queryString = helpers.stringify(queryParams);
|
|
220
208
|
return "".concat(serviceUrl, "/browse/facet_options?").concat(queryString);
|
|
221
209
|
}
|
|
222
210
|
/**
|
|
@@ -276,9 +264,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
276
264
|
|
|
277
265
|
var networkParameters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
278
266
|
var requestUrl;
|
|
279
|
-
var fetch = this.options
|
|
280
|
-
Promise: Promise
|
|
281
|
-
}).fetch;
|
|
267
|
+
var fetch = this.options.fetch;
|
|
282
268
|
var signal;
|
|
283
269
|
|
|
284
270
|
if (typeof AbortController === 'function') {
|
|
@@ -356,9 +342,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
356
342
|
|
|
357
343
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
358
344
|
var requestUrl;
|
|
359
|
-
var fetch = this.options
|
|
360
|
-
Promise: Promise
|
|
361
|
-
}).fetch;
|
|
345
|
+
var fetch = this.options.fetch;
|
|
362
346
|
var signal;
|
|
363
347
|
|
|
364
348
|
if (typeof AbortController === 'function') {
|
|
@@ -428,9 +412,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
428
412
|
var _this3 = this;
|
|
429
413
|
|
|
430
414
|
var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
431
|
-
var fetch = this.options
|
|
432
|
-
Promise: Promise
|
|
433
|
-
}).fetch;
|
|
415
|
+
var fetch = this.options.fetch;
|
|
434
416
|
var serviceUrl = this.options.serviceUrl;
|
|
435
417
|
var queryParams = createQueryParams(parameters, this.options);
|
|
436
418
|
var signal;
|
|
@@ -443,9 +425,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
443
425
|
}
|
|
444
426
|
|
|
445
427
|
delete queryParams._dt;
|
|
446
|
-
var queryString =
|
|
447
|
-
indices: false
|
|
448
|
-
});
|
|
428
|
+
var queryString = helpers.stringify(queryParams);
|
|
449
429
|
var requestUrl = "".concat(serviceUrl, "/browse/groups?").concat(queryString);
|
|
450
430
|
return fetch(requestUrl, {
|
|
451
431
|
signal: signal
|
|
@@ -492,9 +472,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
492
472
|
var _this4 = this;
|
|
493
473
|
|
|
494
474
|
var requestUrl;
|
|
495
|
-
var fetch = this.options
|
|
496
|
-
Promise: Promise
|
|
497
|
-
}).fetch;
|
|
475
|
+
var fetch = this.options.fetch;
|
|
498
476
|
var signal;
|
|
499
477
|
|
|
500
478
|
if (typeof AbortController === 'function') {
|
|
@@ -554,9 +532,7 @@ var Browse = /*#__PURE__*/function () {
|
|
|
554
532
|
var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
555
533
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
556
534
|
var requestUrl;
|
|
557
|
-
var fetch = this.options
|
|
558
|
-
Promise: Promise
|
|
559
|
-
}).fetch;
|
|
535
|
+
var fetch = this.options.fetch;
|
|
560
536
|
var signal;
|
|
561
537
|
|
|
562
538
|
if (typeof AbortController === 'function') {
|
package/lib/modules/quizzes.js
CHANGED
|
@@ -6,13 +6,11 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
6
6
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
|
|
9
11
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
12
|
|
|
11
13
|
/* eslint-disable object-curly-newline, no-underscore-dangle */
|
|
12
|
-
var qs = require('qs');
|
|
13
|
-
|
|
14
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
15
|
-
|
|
16
14
|
var EventDispatcher = require('../utils/event-dispatcher');
|
|
17
15
|
|
|
18
16
|
var helpers = require('../utils/helpers'); // Create URL from supplied quizId and parameters
|
|
@@ -64,25 +62,21 @@ function createQuizUrl(quizId, parameters, options, path) {
|
|
|
64
62
|
|
|
65
63
|
if (versionId) {
|
|
66
64
|
queryParams.version_id = versionId;
|
|
67
|
-
} // Pull answers from parameters
|
|
65
|
+
} // Pull a (answers) from parameters and transform
|
|
68
66
|
|
|
69
67
|
|
|
70
68
|
if (answers) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
}));
|
|
77
|
-
});
|
|
69
|
+
answersParamString = "&".concat(helpers.stringify({
|
|
70
|
+
a: answers.map(function (ans) {
|
|
71
|
+
return (0, _toConsumableArray2["default"])(ans).join(',');
|
|
72
|
+
})
|
|
73
|
+
}));
|
|
78
74
|
}
|
|
79
75
|
}
|
|
80
76
|
|
|
81
77
|
queryParams._dt = Date.now();
|
|
82
78
|
queryParams = helpers.cleanParams(queryParams);
|
|
83
|
-
var queryString =
|
|
84
|
-
indices: false
|
|
85
|
-
});
|
|
79
|
+
var queryString = helpers.stringify(queryParams);
|
|
86
80
|
return "".concat(serviceUrl, "/v1/quizzes/").concat(encodeURIComponent(quizId), "/").concat(encodeURIComponent(path), "/?").concat(queryString).concat(answersParamString);
|
|
87
81
|
}
|
|
88
82
|
/**
|
|
@@ -130,9 +124,7 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
130
124
|
|
|
131
125
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
132
126
|
var requestUrl;
|
|
133
|
-
var fetch = this.options
|
|
134
|
-
Promise: Promise
|
|
135
|
-
}).fetch;
|
|
127
|
+
var fetch = this.options.fetch;
|
|
136
128
|
var controller = new AbortController();
|
|
137
129
|
var signal = controller.signal;
|
|
138
130
|
|
|
@@ -191,9 +183,7 @@ var Quizzes = /*#__PURE__*/function () {
|
|
|
191
183
|
|
|
192
184
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
193
185
|
var requestUrl;
|
|
194
|
-
var fetch = this.options
|
|
195
|
-
Promise: Promise
|
|
196
|
-
}).fetch;
|
|
186
|
+
var fetch = this.options.fetch;
|
|
197
187
|
var controller = new AbortController();
|
|
198
188
|
var signal = controller.signal;
|
|
199
189
|
|
|
@@ -6,10 +6,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
6
6
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
12
|
-
|
|
9
|
+
/* eslint-disable object-curly-newline, no-param-reassign */
|
|
13
10
|
var EventDispatcher = require('../utils/event-dispatcher');
|
|
14
11
|
|
|
15
12
|
var helpers = require('../utils/helpers'); // Create URL from supplied parameters
|
|
@@ -83,9 +80,7 @@ function createRecommendationsUrl(podId, parameters, options) {
|
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
queryParams = helpers.cleanParams(queryParams);
|
|
86
|
-
var queryString =
|
|
87
|
-
indices: false
|
|
88
|
-
});
|
|
83
|
+
var queryString = helpers.stringify(queryParams);
|
|
89
84
|
return "".concat(serviceUrl, "/recommendations/v1/pods/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(podId)), "?").concat(queryString);
|
|
90
85
|
}
|
|
91
86
|
/**
|
|
@@ -137,9 +132,7 @@ var Recommendations = /*#__PURE__*/function () {
|
|
|
137
132
|
|
|
138
133
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
139
134
|
var requestUrl;
|
|
140
|
-
var fetch = this.options
|
|
141
|
-
Promise: Promise
|
|
142
|
-
}).fetch;
|
|
135
|
+
var fetch = this.options.fetch;
|
|
143
136
|
var signal;
|
|
144
137
|
|
|
145
138
|
if (typeof AbortController === 'function') {
|
package/lib/modules/search.js
CHANGED
|
@@ -11,10 +11,6 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
11
11
|
/* eslint-disable max-len */
|
|
12
12
|
|
|
13
13
|
/* eslint-disable object-curly-newline, no-underscore-dangle */
|
|
14
|
-
var qs = require('qs');
|
|
15
|
-
|
|
16
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
17
|
-
|
|
18
14
|
var EventDispatcher = require('../utils/event-dispatcher');
|
|
19
15
|
|
|
20
16
|
var helpers = require('../utils/helpers'); // Create URL from supplied query (term) and parameters
|
|
@@ -151,9 +147,7 @@ function createSearchUrl(query, parameters, options) {
|
|
|
151
147
|
|
|
152
148
|
queryParams._dt = Date.now();
|
|
153
149
|
queryParams = helpers.cleanParams(queryParams);
|
|
154
|
-
var queryString =
|
|
155
|
-
indices: false
|
|
156
|
-
});
|
|
150
|
+
var queryString = helpers.stringify(queryParams);
|
|
157
151
|
return "".concat(serviceUrl, "/search/").concat(helpers.encodeURIComponentRFC3986(helpers.trimNonBreakingSpaces(query)), "?").concat(queryString);
|
|
158
152
|
}
|
|
159
153
|
/**
|
|
@@ -212,9 +206,7 @@ var Search = /*#__PURE__*/function () {
|
|
|
212
206
|
|
|
213
207
|
var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
214
208
|
var requestUrl;
|
|
215
|
-
var fetch = this.options
|
|
216
|
-
Promise: Promise
|
|
217
|
-
}).fetch;
|
|
209
|
+
var fetch = this.options.fetch;
|
|
218
210
|
var signal;
|
|
219
211
|
|
|
220
212
|
if (typeof AbortController === 'function') {
|
package/lib/modules/tracker.js
CHANGED
|
@@ -15,8 +15,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
16
|
|
|
17
17
|
/* eslint-disable object-curly-newline, no-underscore-dangle, camelcase, no-unneeded-ternary */
|
|
18
|
-
var qs = require('qs');
|
|
19
|
-
|
|
20
18
|
var EventEmitter = require('events');
|
|
21
19
|
|
|
22
20
|
var helpers = require('../utils/helpers');
|
|
@@ -91,9 +89,7 @@ function applyParams(parameters, options) {
|
|
|
91
89
|
|
|
92
90
|
|
|
93
91
|
function applyParamsAsString(parameters, options) {
|
|
94
|
-
return
|
|
95
|
-
indices: false
|
|
96
|
-
});
|
|
92
|
+
return helpers.stringify(applyParams(parameters, options));
|
|
97
93
|
}
|
|
98
94
|
/**
|
|
99
95
|
* Interface to tracking related API calls
|
|
@@ -166,6 +162,7 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
166
162
|
* @param {object} parameters - Additional parameters to be sent with request
|
|
167
163
|
* @param {string} parameters.item_name - Product item name
|
|
168
164
|
* @param {string} parameters.item_id - Product item unique identifier
|
|
165
|
+
* @param {string} parameters.url - Current page URL
|
|
169
166
|
* @param {string} [parameters.variation_id] - Product item variation unique identifier
|
|
170
167
|
* @param {object} [networkParameters] - Parameters relevant to the network request
|
|
171
168
|
* @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
|
|
@@ -176,6 +173,7 @@ var Tracker = /*#__PURE__*/function () {
|
|
|
176
173
|
* {
|
|
177
174
|
* item_name: 'Red T-Shirt',
|
|
178
175
|
* item_id: 'KMH876',
|
|
176
|
+
* url: 'https://constructor.io/product/KMH876',
|
|
179
177
|
* },
|
|
180
178
|
* );
|
|
181
179
|
*/
|
package/lib/utils/helpers.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
6
|
+
|
|
3
7
|
/* eslint-disable no-param-reassign */
|
|
4
8
|
var CRC32 = require('crc-32');
|
|
5
9
|
|
|
@@ -150,6 +154,35 @@ var utils = {
|
|
|
150
154
|
return controller.abort();
|
|
151
155
|
}, timeout);
|
|
152
156
|
}
|
|
157
|
+
},
|
|
158
|
+
stringify: function stringify(object, prefix, objectType) {
|
|
159
|
+
if (!object) {
|
|
160
|
+
return '';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var allValues = [];
|
|
164
|
+
Object.keys(object).forEach(function (key) {
|
|
165
|
+
var value = object[key];
|
|
166
|
+
var encodedKey = utils.encodeURIComponentRFC3986(key);
|
|
167
|
+
var stringifiedValue; // Check for both null and undefined
|
|
168
|
+
|
|
169
|
+
if (value != null) {
|
|
170
|
+
var nextPrefix = prefix ? "".concat(prefix, "%5B").concat(encodedKey, "%5D") : encodedKey;
|
|
171
|
+
|
|
172
|
+
if (Array.isArray(value)) {
|
|
173
|
+
stringifiedValue = utils.stringify(value, nextPrefix, 'array');
|
|
174
|
+
} else if ((0, _typeof2["default"])(value) === 'object') {
|
|
175
|
+
stringifiedValue = utils.stringify(value, nextPrefix, 'object');
|
|
176
|
+
} else if (objectType === 'object') {
|
|
177
|
+
stringifiedValue = "".concat(nextPrefix, "=").concat(utils.encodeURIComponentRFC3986(value));
|
|
178
|
+
} else {
|
|
179
|
+
stringifiedValue = "".concat(prefix || encodedKey, "=").concat(utils.encodeURIComponentRFC3986(value));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
allValues.push(stringifiedValue);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return allValues.join('&');
|
|
153
186
|
}
|
|
154
187
|
};
|
|
155
188
|
module.exports = utils;
|
|
@@ -7,8 +7,6 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
7
7
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
8
|
|
|
9
9
|
/* eslint-disable brace-style, no-unneeded-ternary */
|
|
10
|
-
var fetchPonyfill = require('fetch-ponyfill');
|
|
11
|
-
|
|
12
10
|
var store = require('./store');
|
|
13
11
|
|
|
14
12
|
var HumanityCheck = require('./humanity-check');
|
|
@@ -65,9 +63,7 @@ var RequestQueue = /*#__PURE__*/function () {
|
|
|
65
63
|
value: function sendEvents() {
|
|
66
64
|
var _this2 = this;
|
|
67
65
|
|
|
68
|
-
var fetch = this.options
|
|
69
|
-
Promise: Promise
|
|
70
|
-
}).fetch;
|
|
66
|
+
var fetch = this.options.fetch;
|
|
71
67
|
var queue = RequestQueue.get();
|
|
72
68
|
|
|
73
69
|
if ( // Consider user "human" if no DOM context is available
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-client-javascript",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.34.1",
|
|
4
4
|
"description": "Constructor.io JavaScript client",
|
|
5
5
|
"main": "lib/constructorio.js",
|
|
6
6
|
"types": "lib/types/constructorio.d.ts",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"minami": "^1.2.3",
|
|
63
63
|
"mocha": "^9.1.3",
|
|
64
64
|
"nyc": "^15.1.0",
|
|
65
|
+
"qs": "^6.11.0",
|
|
65
66
|
"sinon": "^7.5.0",
|
|
66
67
|
"sinon-chai": "^3.7.0",
|
|
67
68
|
"tsd": "^0.24.1"
|
|
@@ -71,7 +72,6 @@
|
|
|
71
72
|
"crc-32": "^1.2.2",
|
|
72
73
|
"events": "^3.0.0",
|
|
73
74
|
"fetch-ponyfill": "^7.1.0",
|
|
74
|
-
"qs": "6.9.7",
|
|
75
75
|
"store2": "^2.14.2"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|