Skip to content

feat(telemetry): sending telemetry events via insights#6974

Draft
tkrugg wants to merge 8 commits intomasterfrom
feat/telemetry-next
Draft

feat(telemetry): sending telemetry events via insights#6974
tkrugg wants to merge 8 commits intomasterfrom
feat/telemetry-next

Conversation

@tkrugg
Copy link
Copy Markdown
Contributor

@tkrugg tkrugg commented Apr 14, 2026

Summary

  • Add push-based telemetry that sends __start__ and __render__ events through the existing insights events pipeline, replacing the need to crawl every InstantSearch implementation
  • Extract extractWidgetPayload into a shared utility so both the old metadata middleware (pull-based) and the new telemetry (push-based) can reuse widget collection logic
  • Persist a telemetry session ID in sessionStorage so it survives page reloads within the same browser session
  • Measure bootstrap performance with timeSincePageLoad (browser) and timeSinceInit (universal)

How it works

Telemetry is embedded in the insights middleware. When insights is active, two events are sent:

Event When Payload
__start__ On started() Common fields + performance metrics
__render__ Every emit('render') Common fields + widget snapshot

Events flow through sendEventToInsights using insightsMethod: '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)

Metric Source Measures Availability
timeSincePageLoad performance.now() ms since page navigation start Browser only
timeSinceInit Date.now() delta ms from instantsearch() constructor to boot Universal

@tkrugg tkrugg changed the title Feat/telemetry next feat(telemetry): sending telemetry events via insights Apr 14, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 14, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 7 complexity · 0 duplication

Metric Results
Complexity 7
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@6974

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@6974

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@6974

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@6974

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@6974

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@6974

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@6974

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@6974

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@6974

commit: 0234c11

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.
@tkrugg tkrugg force-pushed the feat/telemetry-next branch from b197b2a to 08f42af Compare April 15, 2026 10:43
tkrugg added 4 commits April 15, 2026 12:51
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.
@tkrugg tkrugg force-pushed the feat/telemetry-next branch from 84eb0c3 to 0234c11 Compare April 15, 2026 11:39
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.

1 participant