@constructor-io/constructorio-client-javascript 2.58.0 → 2.58.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.
@@ -163,8 +163,7 @@ var ConstructorIO = /*#__PURE__*/function () {
163
163
  segments = options.segments,
164
164
  testCells = options.testCells,
165
165
  sessionId = options.sessionId,
166
- _options$userId = options.userId,
167
- userId = _options$userId === void 0 ? '' : _options$userId;
166
+ userId = options.userId;
168
167
  if (apiKey) {
169
168
  this.options.apiKey = apiKey;
170
169
  }
@@ -179,7 +178,11 @@ var ConstructorIO = /*#__PURE__*/function () {
179
178
  if (sessionId && !helpers.canUseDOM()) {
180
179
  this.options.sessionId = sessionId;
181
180
  }
182
- this.options.userId = userId;
181
+
182
+ // If User ID is passed
183
+ if ('userId' in options) {
184
+ this.options.userId = userId;
185
+ }
183
186
  }
184
187
  }
185
188
  }]);
@@ -709,6 +709,7 @@ var Tracker = /*#__PURE__*/function () {
709
709
  * @param {string} [parameters.numResultsPerPage] - Number of results per page
710
710
  * @param {object} [parameters.selectedFilters] - Key - Value map of selected filters
711
711
  * @param {string} [parameters.section] - The section name for the item Ex. "Products"
712
+ * @param {object} [parameters.analyticsTags] - Pass additional analytics data
712
713
  * @param {object} [networkParameters] - Parameters relevant to the network request
713
714
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
714
715
  * @returns {(true|Error)}
@@ -762,7 +763,8 @@ var Tracker = /*#__PURE__*/function () {
762
763
  selected_filters = parameters.selected_filters,
763
764
  _parameters$selectedF2 = parameters.selectedFilters,
764
765
  selectedFilters = _parameters$selectedF2 === void 0 ? selected_filters : _parameters$selectedF2,
765
- section = parameters.section;
766
+ section = parameters.section,
767
+ analyticsTags = parameters.analyticsTags;
766
768
  var bodyParams = {
767
769
  item_name: itemName,
768
770
  item_id: itemId,
@@ -774,7 +776,8 @@ var Tracker = /*#__PURE__*/function () {
774
776
  num_results_per_page: numResultsPerPage,
775
777
  selected_filters: selectedFilters,
776
778
  section: section,
777
- search_term: searchTerm
779
+ search_term: searchTerm,
780
+ analytics_tags: analyticsTags
778
781
  };
779
782
  var queryParams = {};
780
783
  if (section) {
@@ -808,6 +811,7 @@ var Tracker = /*#__PURE__*/function () {
808
811
  * @param {string} [parameters.resultId] - Search result identifier (returned in response from Constructor)
809
812
  * @param {string} [parameters.itemIsConvertible] - Whether or not an item is available for a conversion
810
813
  * @param {string} [parameters.section] - The section name for the item Ex. "Products"
814
+ * @param {object} [parameters.analyticsTags] - Pass additional analytics data
811
815
  * @param {object} [networkParameters] - Parameters relevant to the network request
812
816
  * @param {number} [networkParameters.timeout] - Request timeout (in milliseconds)
813
817
  * @returns {(true|Error)}
@@ -851,7 +855,8 @@ var Tracker = /*#__PURE__*/function () {
851
855
  item_is_convertible = parameters.item_is_convertible,
852
856
  _parameters$itemIsCon = parameters.itemIsConvertible,
853
857
  itemIsConvertible = _parameters$itemIsCon === void 0 ? item_is_convertible : _parameters$itemIsCon,
854
- section = parameters.section;
858
+ section = parameters.section,
859
+ analyticsTags = parameters.analyticsTags;
855
860
 
856
861
  // Ensure support for both item_name and name as parameters
857
862
  if (itemName) {
@@ -874,6 +879,9 @@ var Tracker = /*#__PURE__*/function () {
874
879
  if (section) {
875
880
  queryParams.section = section;
876
881
  }
882
+ if (analyticsTags) {
883
+ queryParams.analytics_tags = analyticsTags;
884
+ }
877
885
  this.requests.queue("".concat(url).concat(applyParamsAsString(queryParams, this.options)), undefined, undefined, networkParameters);
878
886
  this.requests.send();
879
887
  return true;
@@ -97,6 +97,7 @@ declare class Tracker {
97
97
  resultId?: string;
98
98
  itemIsConvertible?: string;
99
99
  section?: string;
100
+ analyticsTags?: Record<string, string>;
100
101
  },
101
102
  networkParameters?: NetworkParameters
102
103
  ): true | Error;
@@ -9,7 +9,7 @@ function canUseStorage(type) {
9
9
  storage.removeItem(x);
10
10
  return true;
11
11
  } catch (e) {
12
- return e instanceof DOMException && (e.name === 'QuotaExceededError' || e.name === 'QUOTA_EXCEEDED_ERR' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED' || e.toString().indexOf('QUOTA_EXCEEDED_ERR') !== -1 || e.toString().indexOf('QuotaExceededError') !== -1) && storage && storage.length !== 0;
12
+ return typeof DOMException !== 'undefined' && e instanceof DOMException && (e.name === 'QuotaExceededError' || e.name === 'QUOTA_EXCEEDED_ERR' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED' || e.toString().indexOf('QUOTA_EXCEEDED_ERR') !== -1 || e.toString().indexOf('QuotaExceededError') !== -1) && storage && storage.length !== 0;
13
13
  }
14
14
  }
15
15
  var session = {
package/lib/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _default = '2.58.0';
7
+ var _default = '2.58.2';
8
8
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-client-javascript",
3
- "version": "2.58.0",
3
+ "version": "2.58.2",
4
4
  "description": "Constructor.io JavaScript client",
5
5
  "main": "lib/constructorio.js",
6
6
  "types": "lib/types/index.d.ts",