@algolia/autocomplete-js 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-js 1.14.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/autocomplete */
1
+ /*! @algolia/autocomplete-js 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) :
@@ -347,7 +347,7 @@
347
347
  return undefined;
348
348
  }
349
349
 
350
- var version = '1.14.0';
350
+ var version = '1.15.0';
351
351
 
352
352
  var userAgents$1 = [{
353
353
  segment: 'autocomplete-core',
@@ -620,6 +620,15 @@
620
620
  apiKey: apiKey
621
621
  });
622
622
  },
623
+ /**
624
+ * Sets the authenticated user token to attach to events.
625
+ * Unsets the authenticated token by passing `undefined`.
626
+ *
627
+ * @link https://www.algolia.com/doc/api-reference/api-methods/set-authenticated-user-token/
628
+ */
629
+ setAuthenticatedUserToken: function setAuthenticatedUserToken(authenticatedUserToken) {
630
+ searchInsights('setAuthenticatedUserToken', authenticatedUserToken);
631
+ },
623
632
  /**
624
633
  * Sets the user token to attach to events.
625
634
  */
@@ -967,10 +976,28 @@
967
976
  }
968
977
  insightsClient('addAlgoliaAgent', 'insights-plugin');
969
978
  setInsightsContext();
979
+
980
+ // Handles user token changes
970
981
  insightsClient('onUserTokenChange', setInsightsContext);
971
982
  insightsClient('getUserToken', null, function (_error, userToken) {
972
983
  setInsightsContext(userToken);
973
984
  });
985
+
986
+ // Handles authenticated user token changes
987
+ insightsClient('onAuthenticatedUserTokenChange', function (authenticatedUserToken) {
988
+ if (authenticatedUserToken) {
989
+ setInsightsContext(authenticatedUserToken);
990
+ } else {
991
+ insightsClient('getUserToken', null, function (_error, userToken) {
992
+ return setInsightsContext(userToken);
993
+ });
994
+ }
995
+ });
996
+ insightsClient('getAuthenticatedUserToken', null, function (_error, authenticatedUserToken) {
997
+ if (authenticatedUserToken) {
998
+ setInsightsContext(authenticatedUserToken);
999
+ }
1000
+ });
974
1001
  onSelect(function (_ref5) {
975
1002
  var item = _ref5.item,
976
1003
  state = _ref5.state,