instantsearch.js 4.75.3 → 4.75.5
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.
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +24 -1
- package/dist/instantsearch.development.d.ts +3 -3
- package/dist/instantsearch.development.js +26 -3
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +3 -3
- package/dist/instantsearch.production.min.d.ts +3 -3
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.d.ts +1 -1
- package/es/middlewares/createInsightsMiddleware.js +24 -1
- package/es/types/insights.d.ts +2 -2
- package/package.json +6 -6
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.75.
|
|
1
|
+
declare const _default: "4.75.5";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.75.
|
|
1
|
+
export default '4.75.5';
|
|
@@ -3,7 +3,7 @@ type ProvidedInsightsClient = InsightsClient | null | undefined;
|
|
|
3
3
|
export type InsightsEvent<TMethod extends InsightsMethod = InsightsMethod> = _InsightsEvent<TMethod>;
|
|
4
4
|
export type InsightsProps<TInsightsClient extends ProvidedInsightsClient = ProvidedInsightsClient> = {
|
|
5
5
|
insightsClient?: TInsightsClient;
|
|
6
|
-
insightsInitParams?: Partial<InsightsMethodMap['init'][0]>;
|
|
6
|
+
insightsInitParams?: Partial<InsightsMethodMap['init'][0][0]>;
|
|
7
7
|
onEvent?: (event: InsightsEvent, insightsClient: TInsightsClient) => void;
|
|
8
8
|
};
|
|
9
9
|
export type InsightsClientWithGlobals = InsightsClient & {
|
|
@@ -17,7 +17,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
17
17
|
import { getInsightsAnonymousUserTokenInternal } from "../helpers/index.js";
|
|
18
18
|
import { warning, noop, getAppIdAndApiKey, find, safelyRunOnBrowser } from "../lib/utils/index.js";
|
|
19
19
|
import { createUUID } from "../lib/utils/uuid.js";
|
|
20
|
-
var ALGOLIA_INSIGHTS_VERSION = '2.
|
|
20
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.17.2';
|
|
21
21
|
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
22
22
|
export function createInsightsMiddleware() {
|
|
23
23
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -317,10 +317,33 @@ export function createInsightsMiddleware() {
|
|
|
317
317
|
return insightsClient(method, payload, extraParams);
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
|
+
var viewedObjectIDs = new Set();
|
|
321
|
+
var lastQueryId;
|
|
322
|
+
instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function (_ref11) {
|
|
323
|
+
var results = _ref11.results;
|
|
324
|
+
if (!results.queryID || results.queryID !== lastQueryId) {
|
|
325
|
+
lastQueryId = results.queryID;
|
|
326
|
+
viewedObjectIDs.clear();
|
|
327
|
+
}
|
|
328
|
+
});
|
|
320
329
|
instantSearchInstance.sendEventToInsights = function (event) {
|
|
321
330
|
if (onEvent) {
|
|
322
331
|
onEvent(event, insightsClientWithLocalCredentials);
|
|
323
332
|
} else if (event.insightsMethod) {
|
|
333
|
+
if (event.insightsMethod === 'viewedObjectIDs') {
|
|
334
|
+
var _payload = event.payload;
|
|
335
|
+
var difference = _payload.objectIDs.filter(function (objectID) {
|
|
336
|
+
return !viewedObjectIDs.has(objectID);
|
|
337
|
+
});
|
|
338
|
+
if (difference.length === 0) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
difference.forEach(function (objectID) {
|
|
342
|
+
return viewedObjectIDs.add(objectID);
|
|
343
|
+
});
|
|
344
|
+
_payload.objectIDs = difference;
|
|
345
|
+
}
|
|
346
|
+
|
|
324
347
|
// Source is used to differentiate events sent by instantsearch from those sent manually.
|
|
325
348
|
event.payload.algoliaSource = ['instantsearch'];
|
|
326
349
|
if ($$automatic) {
|
package/es/types/insights.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type InsightsMethod = 'clickedObjectIDsAfterSearch' | 'clickedObjectIDs'
|
|
|
12
12
|
*/
|
|
13
13
|
export type InsightsEvent<TMethod extends InsightsMethod = InsightsMethod> = {
|
|
14
14
|
insightsMethod?: TMethod;
|
|
15
|
-
payload: InsightsMethodMap[TMethod][0];
|
|
15
|
+
payload: InsightsMethodMap[TMethod][0][0];
|
|
16
16
|
widgetType: string;
|
|
17
17
|
eventType: string;
|
|
18
18
|
eventModifier?: string;
|
|
@@ -29,7 +29,7 @@ export type InsightsClientPayload = {
|
|
|
29
29
|
type QueueItemMap = {
|
|
30
30
|
[MethodName in keyof InsightsMethodMap]: [
|
|
31
31
|
methodName: MethodName,
|
|
32
|
-
...args: InsightsMethodMap[MethodName]
|
|
32
|
+
...args: InsightsMethodMap[MethodName][0][0]
|
|
33
33
|
];
|
|
34
34
|
};
|
|
35
35
|
export type QueueItem = QueueItemMap[keyof QueueItemMap];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.75.
|
|
3
|
+
"version": "4.75.5",
|
|
4
4
|
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
|
|
5
5
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"instantsearch-ui-components": "0.9.0",
|
|
38
38
|
"preact": "^10.10.0",
|
|
39
39
|
"qs": "^6.5.1 < 6.10",
|
|
40
|
-
"search-insights": "^2.
|
|
40
|
+
"search-insights": "^2.17.2"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"algoliasearch": ">= 3.1 < 6"
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"watch:es": "yarn --silent build:es:base --watch"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@instantsearch/mocks": "1.
|
|
60
|
-
"@instantsearch/tests": "1.
|
|
61
|
-
"@instantsearch/testutils": "1.
|
|
59
|
+
"@instantsearch/mocks": "1.63.0",
|
|
60
|
+
"@instantsearch/tests": "1.63.0",
|
|
61
|
+
"@instantsearch/testutils": "1.52.0",
|
|
62
62
|
"@storybook/html": "5.3.9",
|
|
63
63
|
"@types/scriptjs": "0.0.2",
|
|
64
64
|
"algoliasearch": "5.1.1",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"scriptjs": "2.5.9",
|
|
67
67
|
"webpack": "4.47.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "091acdc7b9d9d46ec6fac6ea3b84a30f6044605b"
|
|
70
70
|
}
|