Skip to content

Commit

Permalink
fix(deps): update search-insights (#6433)
Browse files Browse the repository at this point in the history
* fix(deps): update search-insights

fixes #6432

* InsightsMethodMap has tuples now as value

algolia/search-insights.js#552
  • Loading branch information
Haroenv authored Nov 14, 2024
1 parent 9a088ad commit 05d93de
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion packages/instantsearch.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"instantsearch-ui-components": "0.9.0",
"preact": "^10.10.0",
"qs": "^6.5.1 < 6.10",
"search-insights": "^2.15.0"
"search-insights": "^2.17.2"
},
"peerDependencies": {
"algoliasearch": ">= 3.1 < 6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ See https://www.algolia.com/doc/api-reference/widgets/configure/js/`);
});

test('insights: options passes options to middleware', () => {
const insightsClient = Object.assign(jest.fn(), { version: '2.15.0' });
const insightsClient = Object.assign(jest.fn(), { version: '2.17.2' });
const search = new InstantSearch({
searchClient: createSearchClientWithAutomaticInsightsOptedIn(),
indexName: 'test',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('insights', () => {
expect(document.body).toMatchInlineSnapshot(`
<body>
<script
src="https://cdn.jsdelivr.net/npm/search-insights@2.15.0/dist/search-insights.min.js"
src="https://cdn.jsdelivr.net/npm/search-insights@2.17.2/dist/search-insights.min.js"
/>
</body>
`);
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('insights', () => {
expect(document.body).toMatchInlineSnapshot(`
<body>
<script
src="https://cdn.jsdelivr.net/npm/search-insights@2.15.0/dist/search-insights.min.js"
src="https://cdn.jsdelivr.net/npm/search-insights@2.17.2/dist/search-insights.min.js"
/>
</body>
`);
Expand All @@ -251,7 +251,7 @@ describe('insights', () => {
expect(document.body).toMatchInlineSnapshot(`
<body>
<script
src="https://cdn.jsdelivr.net/npm/search-insights@2.15.0/dist/search-insights.min.js"
src="https://cdn.jsdelivr.net/npm/search-insights@2.17.2/dist/search-insights.min.js"
/>
</body>
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type InsightsProps<
TInsightsClient extends ProvidedInsightsClient = ProvidedInsightsClient
> = {
insightsClient?: TInsightsClient;
insightsInitParams?: Partial<InsightsMethodMap['init'][0]>;
insightsInitParams?: Partial<InsightsMethodMap['init'][0][0]>;
onEvent?: (event: InsightsEvent, insightsClient: TInsightsClient) => void;
/**
* @internal indicator for the default insights middleware
Expand All @@ -41,7 +41,7 @@ export type InsightsProps<
$$automatic?: boolean;
};

const ALGOLIA_INSIGHTS_VERSION = '2.15.0';
const ALGOLIA_INSIGHTS_VERSION = '2.17.2';
const ALGOLIA_INSIGHTS_SRC = `https://cdn.jsdelivr.net/npm/search-insights@${ALGOLIA_INSIGHTS_VERSION}/dist/search-insights.min.js`;

export type InsightsClientWithGlobals = InsightsClient & {
Expand Down Expand Up @@ -115,7 +115,7 @@ export function createInsightsMiddleware<
'could not extract Algolia credentials from searchClient in insights middleware.'
);

let queuedInitParams: Partial<InsightsMethodMap['init'][0]> | undefined =
let queuedInitParams: Partial<InsightsMethodMap['init'][0][0]> | undefined =
undefined;
let queuedUserToken: string | undefined = undefined;
let queuedAuthenticatedUserToken: string | undefined = undefined;
Expand Down Expand Up @@ -143,7 +143,7 @@ export function createInsightsMiddleware<
const [, value] =
find(queue.slice().reverse(), ([method]) => method === key) || [];

return value;
return value as any as NonNullable<typeof value>;
});
}

Expand Down Expand Up @@ -418,7 +418,7 @@ export function createInsightsMiddleware<
TMethod extends InsightsMethod
>(
method: TMethod,
payload: InsightsMethodMap[TMethod][0]
payload: InsightsMethodMap[TMethod][0][0]
) => void;

let insightsClientWithLocalCredentials =
Expand Down
4 changes: 2 additions & 2 deletions packages/instantsearch.js/src/types/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type InsightsMethod =
*/
export type InsightsEvent<TMethod extends InsightsMethod = InsightsMethod> = {
insightsMethod?: TMethod;
payload: InsightsMethodMap[TMethod][0];
payload: InsightsMethodMap[TMethod][0][0];
widgetType: string;
eventType: string; // 'view' | 'click' | 'conversion', but we're not restricting.
eventModifier?: string; // 'internal', but we're not restricting.
Expand All @@ -52,7 +52,7 @@ export type InsightsClientPayload = {
type QueueItemMap = {
[MethodName in keyof InsightsMethodMap]: [
methodName: MethodName,
...args: InsightsMethodMap[MethodName]
...args: InsightsMethodMap[MethodName][0][0]
];
};

Expand Down
2 changes: 1 addition & 1 deletion packages/react-instantsearch-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Bug Fixes

* **algoliasearch:** correctly retrieve headers for v5 ([#6268](https://github.com/algolia/instantsearch/issues/6268)) ([25c72cf](https://github.com/algolia/instantsearch/commit/25c72cf2f1957b72dc237b32a8a73a006753d5e1))
* **deps:** update dependency search-insights to 2.15.0 ([#6273](https://github.com/algolia/instantsearch/issues/6273)) ([efeed39](https://github.com/algolia/instantsearch/commit/efeed39ae23a2ff244e40878a0a11eec5dd18211))
* **deps:** update dependency search-insights to 2.17.2 ([#6273](https://github.com/algolia/instantsearch/issues/6273)) ([efeed39](https://github.com/algolia/instantsearch/commit/efeed39ae23a2ff244e40878a0a11eec5dd18211))



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('insights', () => {
<body>
<div />
<script
src="https://cdn.jsdelivr.net/npm/search-insights@2.15.0/dist/search-insights.min.js"
src="https://cdn.jsdelivr.net/npm/search-insights@2.17.2/dist/search-insights.min.js"
/>
</body>
`);
Expand Down
4 changes: 2 additions & 2 deletions tests/common/shared/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const attribute = 'one';
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });

const options = {
instantSearchOptions: {
Expand Down Expand Up @@ -109,7 +109,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const attribute = 'one';
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });

const options = {
instantSearchOptions: {
Expand Down
16 changes: 8 additions & 8 deletions tests/common/widgets/hits/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -138,7 +138,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 25;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -274,7 +274,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -356,7 +356,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -445,7 +445,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -531,7 +531,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -628,7 +628,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -710,7 +710,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down
16 changes: 8 additions & 8 deletions tests/common/widgets/infinite-hits/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -138,7 +138,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 25;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -274,7 +274,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -356,7 +356,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -445,7 +445,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -531,7 +531,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -628,7 +628,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down Expand Up @@ -710,7 +710,7 @@ export function createInsightsTests(
const delay = 100;
const margin = 10;
const hitsPerPage = 2;
window.aa = Object.assign(jest.fn(), { version: '2.15.0' });
window.aa = Object.assign(jest.fn(), { version: '2.17.2' });
const options = {
instantSearchOptions: {
indexName: 'indexName',
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/createInsightsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ try {
delete window.AlgoliaAnalyticsObject;
} catch (error) {} // eslint-disable-line no-empty

export function createInsights<TVersion extends string | undefined = '2.15.0'>({
forceVersion = '2.15.0',
export function createInsights<TVersion extends string | undefined = '2.17.2'>({
forceVersion = '2.17.2',
}: {
forceVersion?: TVersion;
} = {}) {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27910,10 +27910,10 @@ scule@^0.2.1:
resolved "https://registry.yarnpkg.com/scule/-/scule-0.2.1.tgz#0c1dc847b18e07219ae9a3832f2f83224e2079dc"
integrity sha512-M9gnWtn3J0W+UhJOHmBxBTwv8mZCan5i1Himp60t6vvZcor0wr+IM0URKmIglsWJ7bRujNAVVN77fp+uZaWoKg==

search-insights@^2.15.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/search-insights/-/search-insights-2.15.0.tgz#61c7db9d13218ee966937ad2462385b05c0df624"
integrity sha512-ch2sPCUDD4sbPQdknVl9ALSi9H7VyoeVbsxznYz6QV55jJ8CI3EtwpO1i84keN4+hF5IeHWIeGvc08530JkVXQ==
search-insights@^2.17.2:
version "2.17.2"
resolved "https://registry.yarnpkg.com/search-insights/-/search-insights-2.17.2.tgz#d13b2cabd44e15ade8f85f1c3b65c8c02138629a"
integrity sha512-zFNpOpUO+tY2D85KrxJ+aqwnIfdEGi06UH2+xEb+Bp9Mwznmauqc9djbnBibJO5mpfUPPa8st6Sx65+vbeO45g==

section-matter@^1.0.0:
version "1.0.0"
Expand Down

0 comments on commit 05d93de

Please sign in to comment.