Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(createAlgoliaInsightsPlugin): automatically load Insights when not passed #1106

Merged
merged 6 commits into from
Mar 13, 2023

Conversation

sarahdayan
Copy link
Member

@sarahdayan sarahdayan commented Mar 8, 2023

This automatically loads the Insights library when using the Insights plugin without passing a client.

The insightsClient parameter is now optional, allowing us to later initialize the plugin internally without a client if we can't find one on the page.

FX-2245

positions?: number[];
};

type QueueItemMap = Record<string, unknown>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be more strictly typed, but it requires updating TypeScript, which then triggers other type issues.

Let's handle this in another PR.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 8, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6a51c83:

Sandbox Source
@algolia/autocomplete-example-github-repositories-custom-plugin Configuration
@algolia/autocomplete-example-instantsearch Configuration
@algolia/autocomplete-example-playground Configuration
@algolia/autocomplete-example-preview-panel-in-modal Configuration
@algolia/autocomplete-example-react-renderer Configuration
@algolia/autocomplete-example-starter-algolia Configuration
@algolia/autocomplete-example-starter Configuration
@algolia/autocomplete-example-reshape Configuration
@algolia/autocomplete-example-vue Configuration

Comment on lines +236 to +245
script.onerror = () => {
// eslint-disable-next-line no-console
console.error(errorMessage);
};

document.body.appendChild(script);
} catch (cause) {
// eslint-disable-next-line no-console
console.error(errorMessage);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge fan of using console.errors but since there's no global error handler in Autocomplete, throwing would be hardly catchable for users.

I'd rather use those now (Sentry lets you catch calls to the Console API) and work on an onError handler in a separate PR to centralize error handling.

@sarahdayan sarahdayan changed the base branch from next to feat/automatic-events March 8, 2023 15:56
@sarahdayan sarahdayan marked this pull request as ready for review March 8, 2023 15:58
@sarahdayan sarahdayan requested a review from Haroenv March 9, 2023 14:56
@sarahdayan sarahdayan requested a review from dhayab March 13, 2023 10:21
@sarahdayan sarahdayan merged commit f5298f4 into feat/automatic-events Mar 13, 2023
@sarahdayan sarahdayan deleted the feat/pull-insights branch March 13, 2023 13:33
Haroenv pushed a commit that referenced this pull request Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants