@algolia/autocomplete-js 1.12.1 → 1.13.0

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.
@@ -1,4 +1,4 @@
1
- /*! @algolia/autocomplete-js 1.12.1 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-js 1.13.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -347,7 +347,7 @@
347
347
  return undefined;
348
348
  }
349
349
 
350
- var version = '1.12.1';
350
+ var version = '1.13.0';
351
351
 
352
352
  var userAgents$1 = [{
353
353
  segment: 'autocomplete-core',
@@ -856,7 +856,7 @@
856
856
  return (hint === "string" ? String : Number)(input);
857
857
  }
858
858
  var VIEW_EVENT_DELAY = 400;
859
- var ALGOLIA_INSIGHTS_VERSION = '2.6.0';
859
+ var ALGOLIA_INSIGHTS_VERSION = '2.13.0';
860
860
  var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
861
861
  var sendViewedObjectIDs = debounce(function (_ref) {
862
862
  var onItemsChange = _ref.onItemsChange,
@@ -909,6 +909,12 @@
909
909
  }
910
910
  });
911
911
  }
912
+
913
+ // We return an empty plugin if `insightsClient` is still undefined at
914
+ // this stage, which can happen in server environments.
915
+ if (!insightsClient) {
916
+ return {};
917
+ }
912
918
  var insights = createSearchInsightsApi(insightsClient);
913
919
  var previousItems = createRef([]);
914
920
  var debouncedOnStateChange = debounce(function (_ref3) {
@@ -947,7 +953,7 @@
947
953
  __algoliaSearchParameters: _objectSpread$f(_objectSpread$f({}, __autocomplete_clickAnalytics ? {
948
954
  clickAnalytics: true
949
955
  } : {}), userToken ? {
950
- userToken: userToken
956
+ userToken: normalizeUserToken(userToken)
951
957
  } : {}),
952
958
  insights: insights
953
959
  }
@@ -1060,6 +1066,14 @@
1060
1066
  }
1061
1067
  }
1062
1068
 
1069
+ /**
1070
+ * While `search-insights` supports both string and number user tokens,
1071
+ * the Search API only accepts strings. This function normalizes the user token.
1072
+ */
1073
+ function normalizeUserToken(userToken) {
1074
+ return typeof userToken === 'number' ? userToken.toString() : userToken;
1075
+ }
1076
+
1063
1077
  function checkOptions(options) {
1064
1078
  "development" !== 'production' ? warn(!options.debug, 'The `debug` option is meant for development debugging and should not be used in production.') : void 0 ;
1065
1079
  }