@algolia/autocomplete-core 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-core 1.12.1 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-core 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) :
@@ -291,7 +291,7 @@
291
291
  return undefined;
292
292
  }
293
293
 
294
- var version = '1.12.1';
294
+ var version = '1.13.0';
295
295
 
296
296
  var userAgents = [{
297
297
  segment: 'autocomplete-core',
@@ -800,7 +800,7 @@
800
800
  return (hint === "string" ? String : Number)(input);
801
801
  }
802
802
  var VIEW_EVENT_DELAY = 400;
803
- var ALGOLIA_INSIGHTS_VERSION = '2.6.0';
803
+ var ALGOLIA_INSIGHTS_VERSION = '2.13.0';
804
804
  var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
805
805
  var sendViewedObjectIDs = debounce(function (_ref) {
806
806
  var onItemsChange = _ref.onItemsChange,
@@ -853,6 +853,12 @@
853
853
  }
854
854
  });
855
855
  }
856
+
857
+ // We return an empty plugin if `insightsClient` is still undefined at
858
+ // this stage, which can happen in server environments.
859
+ if (!insightsClient) {
860
+ return {};
861
+ }
856
862
  var insights = createSearchInsightsApi(insightsClient);
857
863
  var previousItems = createRef([]);
858
864
  var debouncedOnStateChange = debounce(function (_ref3) {
@@ -891,7 +897,7 @@
891
897
  __algoliaSearchParameters: _objectSpread(_objectSpread({}, __autocomplete_clickAnalytics ? {
892
898
  clickAnalytics: true
893
899
  } : {}), userToken ? {
894
- userToken: userToken
900
+ userToken: normalizeUserToken(userToken)
895
901
  } : {}),
896
902
  insights: insights
897
903
  }
@@ -1004,6 +1010,14 @@
1004
1010
  }
1005
1011
  }
1006
1012
 
1013
+ /**
1014
+ * While `search-insights` supports both string and number user tokens,
1015
+ * the Search API only accepts strings. This function normalizes the user token.
1016
+ */
1017
+ function normalizeUserToken(userToken) {
1018
+ return typeof userToken === 'number' ? userToken.toString() : userToken;
1019
+ }
1020
+
1007
1021
  function checkOptions(options) {
1008
1022
  "development" !== 'production' ? warn(!options.debug, 'The `debug` option is meant for development debugging and should not be used in production.') : void 0;
1009
1023
  }