Title: Add lifecycle event hooks (on('start') / on('stop')) to notify when replay state changes · Issue #20281 · getsentry/sentry-javascript · GitHub
Open Graph Title: Add lifecycle event hooks (on('start') / on('stop')) to notify when replay state changes · Issue #20281 · getsentry/sentry-javascript
X Title: Add lifecycle event hooks (on('start') / on('stop')) to notify when replay state changes · Issue #20281 · getsentry/sentry-javascript
Description: Problem Statement When using replayIntegration in manual mode, there is no way for external code to know when the replay has stopped due to internal reasons such as maxReplayDuration expiry. This makes it impossible to keep external stat...
Open Graph Description: Problem Statement When using replayIntegration in manual mode, there is no way for external code to know when the replay has stopped due to internal reasons such as maxReplayDuration expiry. This m...
X Description: Problem Statement When using replayIntegration in manual mode, there is no way for external code to know when the replay has stopped due to internal reasons such as maxReplayDuration expiry. This m...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/20281
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add lifecycle event hooks (on('start') / on('stop')) to notify when replay state changes","articleBody":"### Problem Statement\n\nWhen using `replayIntegration` in manual mode, there is no way for external code to know when the replay has stopped due to internal reasons such as `maxReplayDuration` expiry.\n \nThis makes it impossible to keep external state in sync with the actual replay state. For example, a wrapper library that tracks active replay sessions via an `activeSession` array has no way to know when Sentry has internally stopped the replay — leading to stale state where the wrapper believes recording is still active when it is not.\n\nThe problem is not limited to `maxReplayDuration`. Any internal stop (error budget, rate limiting, idle timeout) has the same issue.\n \n\n### Solution Brainstorm\n\nAdd lifecycle event hooks to the `Replay` integration following the same `client.on(event, callback)` pattern already established in `@sentry/core`: \n \n```ts\nconst replay = getReplay(); \n \nreplay.on('start', () => { \n console.log('Replay started');\n}); \n \nreplay.on('stop', ({ reason }) => { \n // reason: 'maxDuration' | 'manual' | 'error' | 'inactivity' | ...\n console.log('Replay stopped, reason:', reason); \n});\n```\n \nThe `reason` field on the stop event would be particularly valuable — it lets consumers distinguish between an intentional manual stop and an internally triggered one, so they can decide whether to restart recording or just update their state. \n\n### Additional Context\n\n_No response_\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/behnammodi","@type":"Person","name":"behnammodi"},"datePublished":"2026-04-14T11:42:03Z","url":"https://github.com/getsentry/sentry-javascript/issues/20281"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5795d0ba-d8c6-6267-a237-ce45394032b4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E7D0:369B49:108186:16EDC2:6B04B1D3 |
| html-safe-nonce | d9913c8de8fb6891600ef77ce4d84c386437b5b673e4840a34000af381c2302a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0QwOjM2OUI0OToxMDgxODY6MTZFREMyOjZCMDRCMUQzIiwidmlzaXRvcl9pZCI6Ijc2NTgxNzg5NzY5NDI0MzY4MTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7905425820de127709225fdc34182fc55422ef5d59b092318a92983d0a2a70a9 |
| hovercard-subject-tag | issue:4261773872 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/20281/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dde81f315a77b1c59d01db249770d035271a6602b54e99b345ed1f9a70e8c533/getsentry/sentry-javascript/issues/20281 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dde81f315a77b1c59d01db249770d035271a6602b54e99b345ed1f9a70e8c533/getsentry/sentry-javascript/issues/20281 |
| og:image:alt | Problem Statement When using replayIntegration in manual mode, there is no way for external code to know when the replay has stopped due to internal reasons such as maxReplayDuration expiry. This m... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | behnammodi |
| hostname | github.com |
| expected-hostname | github.com |
| None | f1d110ea058a0915c1d8aa3fc2069fa15801e128f591e5762525abe77490ecb1 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ffa22a65e4c46d376940fe34b05e6a7e9c7fdb9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width