Title: SDK lifecycle hooks · Issue #7262 · getsentry/sentry-javascript · GitHub
Open Graph Title: SDK lifecycle hooks · Issue #7262 · getsentry/sentry-javascript
X Title: SDK lifecycle hooks · Issue #7262 · getsentry/sentry-javascript
Description: Problem Statement In order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on startTransaction, and transaction.finish() so that profiling can start/end profiles. Replay also ...
Open Graph Description: Problem Statement In order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on startTransaction, and transaction.finish() so that profil...
X Description: Problem Statement In order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on startTransaction, and transaction.finish() so that profil...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/7262
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SDK lifecycle hooks","articleBody":"### Problem Statement\r\n\r\nIn order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on `startTransaction`, and `transaction.finish()` so that profiling can start/end profiles.\r\n\r\nReplay also needs something similar, but centered around [TBD FILL THIS IN]. For now we aim not to solve for the Replay case specifically, but we should keep it in mind.\r\n\r\n### Solution Brainstorm\r\n\r\nLet's introduce hooks to the Sentry client. These live on the client and as stored as simple function pointers.\r\n\r\n```ts\r\ntype Hook = Record\u003cKnownHooks, Function[]>;\r\n```\r\n\r\n^ The type above prob needs to actually be a union or overload of some sort so we get better intellisense, but our TS version might hold us back from it 😭.\r\n\r\nWhenever we need to add a hook, we access the client, and call `client.on('...');\r\n\r\nWhenever a hook is called, we call `client.emit('...')`, which will iterate through the array of hooks and call them all one at a time.\r\n\r\nThis is special case - but we need this to unblock profiling so let's :shipit:. We keep these APIs completely internal, we can change it later on.\r\n\r\n- [x] #7343\r\n- [x] https://github.com/getsentry/sentry-javascript/pull/7387\r\n\r\n### Stretch\r\n\r\nSend profiling + transactions in the same envelope\r\n\r\n- profiling stops first when transaction is finished\r\n- we need some way to combine envelopes (`createEnvelope`) in `transaction.finish`","author":{"url":"https://github.com/AbhiPrasad","@type":"Person","name":"AbhiPrasad"},"datePublished":"2023-02-23T08:48:35Z","url":"https://github.com/getsentry/sentry-javascript/issues/7262"}
| 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:27901ba7-e833-80d4-f5c1-6a418889cbb2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4EE:3FA310:496981:65729B:6B049F04 |
| html-safe-nonce | 707c5d11e126c48dbb8e332b594c966d9db218c0e367029f756c8060076c05bb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENEVFOjNGQTMxMDo0OTY5ODE6NjU3MjlCOjZCMDQ5RjA0IiwidmlzaXRvcl9pZCI6Ijc1MDM3Mjk0NzgwNTY0MjUwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 626b58c0810ef2599675365701f290ec17f08b9bbebb771cec306ac1d4bc0147 |
| hovercard-subject-tag | issue:1596450324 |
| 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/7262/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f7dea5bb13b2c923724067773e129410cffd3884417fc2481cf1c607a0cfde54/getsentry/sentry-javascript/issues/7262 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f7dea5bb13b2c923724067773e129410cffd3884417fc2481cf1c607a0cfde54/getsentry/sentry-javascript/issues/7262 |
| og:image:alt | Problem Statement In order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on startTransaction, and transaction.finish() so that profil... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AbhiPrasad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| 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 | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| 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