@algolia/autocomplete-core 1.14.0 → 1.15.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.14.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-core 1.15.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.14.0';
294
+ var version = '1.15.0';
295
295
 
296
296
  var userAgents = [{
297
297
  segment: 'autocomplete-core',
@@ -564,6 +564,15 @@
564
564
  apiKey: apiKey
565
565
  });
566
566
  },
567
+ /**
568
+ * Sets the authenticated user token to attach to events.
569
+ * Unsets the authenticated token by passing `undefined`.
570
+ *
571
+ * @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/
572
+ */
573
+ setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) {
574
+ searchInsights('setAuthenticatedUserToken', authenticatedUserToken);
575
+ },
567
576
  /**
568
577
  * Sets the user token to attach to events.
569
578
  */
@@ -911,10 +920,28 @@
911
920
  }
912
921
  insightsClient('addAlgoliaAgent', 'insights-plugin');
913
922
  setInsightsContext();
923
+
924
+ // Handles user token changes
914
925
  insightsClient('onUserTokenChange', setInsightsContext);
915
926
  insightsClient('getUserToken', null, function (_error, userToken) {
916
927
  setInsightsContext(userToken);
917
928
  });
929
+
930
+ // Handles authenticated user token changes
931
+ insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) {
932
+ if (authenticatedUserToken) {
933
+ setInsightsContext(authenticatedUserToken);
934
+ } else {
935
+ insightsClient('getUserToken', null, function (_error, userToken) {
936
+ return setInsightsContext(userToken);
937
+ });
938
+ }
939
+ });
940
+ insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) {
941
+ if (authenticatedUserToken) {
942
+ setInsightsContext(authenticatedUserToken);
943
+ }
944
+ });
918
945
  onSelect(function (_ref5) {
919
946
  var item = _ref5.item,
920
947
  state = _ref5.state,