instantsearch.js 4.75.3 → 4.75.4

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.
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.75.3';
7
+ var _default = '4.75.4';
8
8
  exports.default = _default;
@@ -323,10 +323,33 @@ function createInsightsMiddleware() {
323
323
  return insightsClient(method, payload, extraParams);
324
324
  };
325
325
  }
326
+ var viewedObjectIDs = new Set();
327
+ var lastQueryId;
328
+ instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function (_ref11) {
329
+ var results = _ref11.results;
330
+ if (!results.queryID || results.queryID !== lastQueryId) {
331
+ lastQueryId = results.queryID;
332
+ viewedObjectIDs.clear();
333
+ }
334
+ });
326
335
  instantSearchInstance.sendEventToInsights = function (event) {
327
336
  if (onEvent) {
328
337
  onEvent(event, insightsClientWithLocalCredentials);
329
338
  } else if (event.insightsMethod) {
339
+ if (event.insightsMethod === 'viewedObjectIDs') {
340
+ var _payload = event.payload;
341
+ var difference = _payload.objectIDs.filter(function (objectID) {
342
+ return !viewedObjectIDs.has(objectID);
343
+ });
344
+ if (difference.length === 0) {
345
+ return;
346
+ }
347
+ difference.forEach(function (objectID) {
348
+ return viewedObjectIDs.add(objectID);
349
+ });
350
+ _payload.objectIDs = difference;
351
+ }
352
+
330
353
  // Source is used to differentiate events sent by instantsearch from those sent manually.
331
354
  event.payload.algoliaSource = ['instantsearch'];
332
355
  if ($$automatic) {
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.75.3 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.75.4 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -14043,10 +14043,33 @@
14043
14043
  return insightsClient(method, payload, extraParams);
14044
14044
  };
14045
14045
  }
14046
+ var viewedObjectIDs = new Set();
14047
+ var lastQueryId;
14048
+ instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function (_ref11) {
14049
+ var results = _ref11.results;
14050
+ if (!results.queryID || results.queryID !== lastQueryId) {
14051
+ lastQueryId = results.queryID;
14052
+ viewedObjectIDs.clear();
14053
+ }
14054
+ });
14046
14055
  instantSearchInstance.sendEventToInsights = function (event) {
14047
14056
  if (onEvent) {
14048
14057
  onEvent(event, insightsClientWithLocalCredentials);
14049
14058
  } else if (event.insightsMethod) {
14059
+ if (event.insightsMethod === 'viewedObjectIDs') {
14060
+ var _payload = event.payload;
14061
+ var difference = _payload.objectIDs.filter(function (objectID) {
14062
+ return !viewedObjectIDs.has(objectID);
14063
+ });
14064
+ if (difference.length === 0) {
14065
+ return;
14066
+ }
14067
+ difference.forEach(function (objectID) {
14068
+ return viewedObjectIDs.add(objectID);
14069
+ });
14070
+ _payload.objectIDs = difference;
14071
+ }
14072
+
14050
14073
  // Source is used to differentiate events sent by instantsearch from those sent manually.
14051
14074
  event.payload.algoliaSource = ['instantsearch'];
14052
14075
  if ($$automatic) {
@@ -16109,7 +16132,7 @@
16109
16132
  };
16110
16133
  }
16111
16134
 
16112
- var version$1 = '4.75.3';
16135
+ var version$1 = '4.75.4';
16113
16136
 
16114
16137
  var withUsage$v = createDocumentationMessageGenerator({
16115
16138
  name: 'instantsearch'