feat(telemetry): sending telemetry events via insights#6974
Draft
feat(telemetry): sending telemetry events via insights#6974
Conversation
Persist a telemetry session ID in sessionStorage so it survives page reloads within the same browser session.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
Telemetry events now call insightsClientWithLocalCredentials directly to avoid triggering user-provided onEvent callbacks. Update call count expectations in shared insights tests to account for telemetry events.
b197b2a to
08f42af
Compare
Bootstrap telemetry event now includes two performance metrics: - timeSincePageLoad: ms since page navigation start (browser only) - timeSinceInit: ms since instantsearch() constructor was called
Aligns with the InstantSearch.start() method name.
84eb0c3 to
0234c11
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__start__and__render__events through the existing insights events pipeline, replacing the need to crawl every InstantSearch implementationextractWidgetPayloadinto a shared utility so both the old metadata middleware (pull-based) and the new telemetry (push-based) can reuse widget collection logicsessionStorageso it survives page reloads within the same browser sessiontimeSincePageLoad(browser) andtimeSinceInit(universal)How it works
Telemetry is embedded in the insights middleware. When insights is active, two events are sent:
__start__started()__render__emit('render')Events flow through
sendEventToInsightsusinginsightsMethod: 'sendEvents', leveraging the search-insights library transport. This avoids direct HTTP calls and provides ad-blocker resilience.The old metadata middleware (crawler-based) is unchanged and still active.
Event shape
{ "eventType": "instantsearch_telemetry", "eventName": "__start__", "timestamp": 1710691200000, "session_id": "f47ac10b-...", "userToken": "...", "performance": { "timeSincePageLoad": 1234, "timeSinceInit": 87 }, "widgets": [...] }Performance metrics (
__start__only)timeSincePageLoadperformance.now()timeSinceInitDate.now()deltainstantsearch()constructor to boot