@constructor-io/constructorio-client-javascript 2.34.0 → 2.34.2

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.
@@ -6,8 +6,10 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
6
6
 
7
7
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
8
 
9
- /* eslint-disable camelcase, no-unneeded-ternary, max-len */
10
- var ConstructorioID = require('@constructor-io/constructorio-id'); // Modules
9
+ /* eslint-disable camelcase, no-unneeded-ternary, max-len, complexity */
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');
@@ -54,6 +56,7 @@ var ConstructorIO = /*#__PURE__*/function () {
54
56
  * @param {object} parameters - Parameters for client instantiation
55
57
  * @param {string} parameters.apiKey - Constructor.io API key
56
58
  * @param {string} [parameters.serviceUrl='https://ac.cnstrc.com'] - API URL endpoint
59
+ * @param {string} [parameters.quizzesServiceUrl='https://quizzes.cnstrc.com'] - Quizzes API URL endpoint
57
60
  * @param {array} [parameters.segments] - User segments
58
61
  * @param {object} [parameters.testCells] - User test cells
59
62
  * @param {string} [parameters.clientId] - Client ID, defaults to value supplied by 'constructorio-id' module
@@ -83,6 +86,7 @@ var ConstructorIO = /*#__PURE__*/function () {
83
86
  var apiKey = options.apiKey,
84
87
  versionFromOptions = options.version,
85
88
  serviceUrl = options.serviceUrl,
89
+ quizzesServiceUrl = options.quizzesServiceUrl,
86
90
  segments = options.segments,
87
91
  testCells = options.testCells,
88
92
  clientId = options.clientId,
@@ -126,12 +130,15 @@ var ConstructorIO = /*#__PURE__*/function () {
126
130
  apiKey: apiKey,
127
131
  version: versionFromOptions || versionFromGlobal || computePackageVersion(),
128
132
  serviceUrl: serviceUrl && serviceUrl.replace(/\/$/, '') || 'https://ac.cnstrc.com',
133
+ quizzesServiceUrl: quizzesServiceUrl && quizzesServiceUrl.replace(/\/$/, '') || 'https://quizzes.cnstrc.com',
129
134
  sessionId: sessionId || session_id,
130
135
  clientId: clientId || client_id,
131
136
  userId: userId,
132
137
  segments: segments,
133
138
  testCells: testCells,
134
- fetch: fetch,
139
+ fetch: fetch || fetchPonyfill({
140
+ Promise: Promise
141
+ }).fetch,
135
142
  trackingSendDelay: trackingSendDelay,
136
143
  sendTrackingEvents: sendTrackingEvents,
137
144
  sendReferrerWithTrackingEvents: sendReferrerWithTrackingEvents,
@@ -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 object-curly-newline, no-underscore-dangle */
10
- var fetchPonyfill = require('fetch-ponyfill');
11
-
12
10
  var EventDispatcher = require('../utils/event-dispatcher');
13
11
 
14
12
  var _require = require('../utils/helpers'),
@@ -155,9 +153,7 @@ var Autocomplete = /*#__PURE__*/function () {
155
153
 
156
154
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
157
155
  var requestUrl;
158
- var fetch = this.options && this.options.fetch || fetchPonyfill({
159
- Promise: Promise
160
- }).fetch;
156
+ var fetch = this.options.fetch;
161
157
  var signal;
162
158
 
163
159
  if (typeof AbortController === 'function') {
@@ -13,8 +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 fetchPonyfill = require('fetch-ponyfill');
17
-
18
16
  var EventDispatcher = require('../utils/event-dispatcher');
19
17
 
20
18
  var helpers = require('../utils/helpers'); // Create query params from parameters and options
@@ -266,9 +264,7 @@ var Browse = /*#__PURE__*/function () {
266
264
 
267
265
  var networkParameters = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
268
266
  var requestUrl;
269
- var fetch = this.options && this.options.fetch || fetchPonyfill({
270
- Promise: Promise
271
- }).fetch;
267
+ var fetch = this.options.fetch;
272
268
  var signal;
273
269
 
274
270
  if (typeof AbortController === 'function') {
@@ -346,9 +342,7 @@ var Browse = /*#__PURE__*/function () {
346
342
 
347
343
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
348
344
  var requestUrl;
349
- var fetch = this.options && this.options.fetch || fetchPonyfill({
350
- Promise: Promise
351
- }).fetch;
345
+ var fetch = this.options.fetch;
352
346
  var signal;
353
347
 
354
348
  if (typeof AbortController === 'function') {
@@ -418,9 +412,7 @@ var Browse = /*#__PURE__*/function () {
418
412
  var _this3 = this;
419
413
 
420
414
  var networkParameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
421
- var fetch = this.options && this.options.fetch || fetchPonyfill({
422
- Promise: Promise
423
- }).fetch;
415
+ var fetch = this.options.fetch;
424
416
  var serviceUrl = this.options.serviceUrl;
425
417
  var queryParams = createQueryParams(parameters, this.options);
426
418
  var signal;
@@ -480,9 +472,7 @@ var Browse = /*#__PURE__*/function () {
480
472
  var _this4 = this;
481
473
 
482
474
  var requestUrl;
483
- var fetch = this.options && this.options.fetch || fetchPonyfill({
484
- Promise: Promise
485
- }).fetch;
475
+ var fetch = this.options.fetch;
486
476
  var signal;
487
477
 
488
478
  if (typeof AbortController === 'function') {
@@ -542,9 +532,7 @@ var Browse = /*#__PURE__*/function () {
542
532
  var parameters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
543
533
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
544
534
  var requestUrl;
545
- var fetch = this.options && this.options.fetch || fetchPonyfill({
546
- Promise: Promise
547
- }).fetch;
535
+ var fetch = this.options.fetch;
548
536
  var signal;
549
537
 
550
538
  if (typeof AbortController === 'function') {
@@ -11,8 +11,6 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
11
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
12
 
13
13
  /* eslint-disable object-curly-newline, no-underscore-dangle */
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
@@ -24,8 +22,8 @@ function createQuizUrl(quizId, parameters, options, path) {
24
22
  sessionId = options.sessionId,
25
23
  segments = options.segments,
26
24
  userId = options.userId,
27
- version = options.version;
28
- var serviceUrl = 'https://quizzes.cnstrc.com';
25
+ version = options.version,
26
+ quizzesServiceUrl = options.quizzesServiceUrl;
29
27
  var queryParams = {
30
28
  c: version
31
29
  };
@@ -79,7 +77,7 @@ function createQuizUrl(quizId, parameters, options, path) {
79
77
  queryParams._dt = Date.now();
80
78
  queryParams = helpers.cleanParams(queryParams);
81
79
  var queryString = helpers.stringify(queryParams);
82
- return "".concat(serviceUrl, "/v1/quizzes/").concat(encodeURIComponent(quizId), "/").concat(encodeURIComponent(path), "/?").concat(queryString).concat(answersParamString);
80
+ return "".concat(quizzesServiceUrl, "/v1/quizzes/").concat(encodeURIComponent(quizId), "/").concat(encodeURIComponent(path), "/?").concat(queryString).concat(answersParamString);
83
81
  }
84
82
  /**
85
83
  * Interface to quiz related API calls
@@ -126,9 +124,7 @@ var Quizzes = /*#__PURE__*/function () {
126
124
 
127
125
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
128
126
  var requestUrl;
129
- var fetch = this.options && this.options.fetch || fetchPonyfill({
130
- Promise: Promise
131
- }).fetch;
127
+ var fetch = this.options.fetch;
132
128
  var controller = new AbortController();
133
129
  var signal = controller.signal;
134
130
 
@@ -187,9 +183,7 @@ var Quizzes = /*#__PURE__*/function () {
187
183
 
188
184
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
189
185
  var requestUrl;
190
- var fetch = this.options && this.options.fetch || fetchPonyfill({
191
- Promise: Promise
192
- }).fetch;
186
+ var fetch = this.options.fetch;
193
187
  var controller = new AbortController();
194
188
  var signal = controller.signal;
195
189
 
@@ -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 object-curly-newline, no-param-reassign */
10
- var fetchPonyfill = require('fetch-ponyfill');
11
-
12
10
  var EventDispatcher = require('../utils/event-dispatcher');
13
11
 
14
12
  var helpers = require('../utils/helpers'); // Create URL from supplied parameters
@@ -134,9 +132,7 @@ var Recommendations = /*#__PURE__*/function () {
134
132
 
135
133
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
136
134
  var requestUrl;
137
- var fetch = this.options && this.options.fetch || fetchPonyfill({
138
- Promise: Promise
139
- }).fetch;
135
+ var fetch = this.options.fetch;
140
136
  var signal;
141
137
 
142
138
  if (typeof AbortController === 'function') {
@@ -11,8 +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 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 query (term) and parameters
@@ -208,9 +206,7 @@ var Search = /*#__PURE__*/function () {
208
206
 
209
207
  var networkParameters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
210
208
  var requestUrl;
211
- var fetch = this.options && this.options.fetch || fetchPonyfill({
212
- Promise: Promise
213
- }).fetch;
209
+ var fetch = this.options.fetch;
214
210
  var signal;
215
211
 
216
212
  if (typeof AbortController === 'function') {
@@ -162,6 +162,7 @@ var Tracker = /*#__PURE__*/function () {
162
162
  * @param {object} parameters - Additional parameters to be sent with request
163
163
  * @param {string} parameters.item_name - Product item name
164
164
  * @param {string} parameters.item_id - Product item unique identifier
165
+ * @param {string} parameters.url - Current page URL
165
166
  * @param {string} [parameters.variation_id] - Product item variation unique identifier
166
167
  * @param {object} [networkParameters] - Parameters relevant to the network request
167
168
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
@@ -172,6 +173,7 @@ var Tracker = /*#__PURE__*/function () {
172
173
  * {
173
174
  * item_name: 'Red T-Shirt',
174
175
  * item_id: 'KMH876',
176
+ * url: 'https://constructor.io/product/KMH876',
175
177
  * },
176
178
  * );
177
179
  */
@@ -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 && this.options.fetch || fetchPonyfill({
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.34.0",
3
+ "version": "2.34.2",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/constructorio.d.ts",