Title: Improve user facing integrations configuration · Issue #4789 · getsentry/sentry-javascript · GitHub
Open Graph Title: Improve user facing integrations configuration · Issue #4789 · getsentry/sentry-javascript
X Title: Improve user facing integrations configuration · Issue #4789 · getsentry/sentry-javascript
Description: Problem Statement I've briefly chatted to @AbhiPrasad about this but we wanted to open the discussion up and get some feedback and ideas from others... The current integration options are as follows: /** * If this is set to false, defaul...
Open Graph Description: Problem Statement I've briefly chatted to @AbhiPrasad about this but we wanted to open the discussion up and get some feedback and ideas from others... The current integration options are as follow...
X Description: Problem Statement I've briefly chatted to @AbhiPrasad about this but we wanted to open the discussion up and get some feedback and ideas from others... The current integration options are as fo...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/4789
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve user facing integrations configuration","articleBody":"### Problem Statement\n\nI've briefly chatted to @AbhiPrasad about this but we wanted to open the discussion up and get some feedback and ideas from others...\r\n\r\nThe current integration options are as follows:\r\n\r\n```ts\r\n /**\r\n * If this is set to false, default integrations will not be added, otherwise this will internally be set to the\r\n * recommended default integrations.\r\n * TODO: We should consider changing this to `boolean | Integration[]`\r\n */\r\n defaultIntegrations?: false | Integration[];\r\n\r\n /**\r\n * List of integrations that should be installed after SDK was initialized.\r\n * Accepts either a list of integrations or a function that receives\r\n * default integrations and returns a new, updated list.\r\n */\r\n integrations?: Integration[] | ((integrations: Integration[]) => Integration[]);\r\n```\r\n\r\nThere are a few issues I see with this:\r\n- `defaultIntegrations: false` is not tree shakeable. \r\n- It looks like `defaultIntegrations` allowing an array is an internal implementation detail that has leaked into the public api\r\n - it's not clear why users would ever supply an array here \r\n- It appears that the `integrations` function option solely exists to allow users to remove default integrations easily\r\n - Is there a better/cleaner way to offer this functionality?\r\n\r\nUltimately, we're stuck between a rock and hard place trying to provide a fully featured standard configuration, simple customisability and the ability to fully customise for those who want to reduce bundle size to the bare minimum. \r\n\n\n### Solution Brainstorm\n\nWe could remove `defaultIntegrations` and supply a way to init the SDKs without any defaults and preferably one that allows tree shaking.\r\n\r\nThe obvious way to do this would be to have two different `init` functions, one which includes the defaults and one which doesn't. For now I'm going to call these `init` and `initRaw` but I'm open to better suggestions!\r\n\r\nIt's also worth noting that `initRaw` could also include no default Transport to allow for greatest \"tree shakeability\".\r\n\r\n```ts\r\nimport { init, initRaw, defaultIntegrations } from '@sentry/xxx';\r\n\r\n// init the sdk with defaults\r\ninit({\r\n dsn: '__DSN__',\r\n});\r\n\r\n// this does the same as above!\r\ninitRaw({\r\n dsn: '__DSN__',\r\n integrations: defaultIntegrations,\r\n})\r\n```\r\nAdding a custom integration:\r\n```ts\r\nimport { init, initRaw, defaultIntegrations } from '@sentry/xxx';\r\nimport { MyWonderfulIntegration } from './integrations';\r\n\r\ninit({\r\n dsn: '__DSN__',\r\n integrations: [new MyWonderfulIntegration()]\r\n});\r\n\r\ninitRaw({\r\n dsn: '__DSN__',\r\n integrations: [...defaultIntegrations, new MyWonderfulIntegration()],\r\n})\r\n```\r\nRemoving an integration:\r\n```ts\r\nimport { init, initRaw, defaultIntegrations } from '@sentry/xxx';\r\n\r\ninit({\r\n dsn: '__DSN__',\r\n // this wont tree shake 🤷♂️\r\n integrations: (itgs) => itgs.filter(i => i.name !== \"Breadcrumbs\")\r\n});\r\n\r\ninitRaw({\r\n dsn: '__DSN__',\r\n // this wont tree shake either 🤷♂️\r\n integrations: defaultIntegrations.filter(i => i.name !== \"Breadcrumbs\"),\r\n})\r\n\r\ninitRaw({\r\n dsn: '__DSN__',\r\n integrations: [ /* manually include all the integrations you need for greatest tree shakability! */ ]\r\n})\r\n```\r\n\r\nThe `integrations` function option + filtering by name string to remove an integration feels a bit nasty but currently it appears to be the simplest solution to exclude an integration 🤔","author":{"url":"https://github.com/timfish","@type":"Person","name":"timfish"},"datePublished":"2022-03-25T16:31:54Z","url":"https://github.com/getsentry/sentry-javascript/issues/4789"}
| 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:541a13c9-eec1-0aa4-f5a7-e22d63cf1150 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B382:3C80E1:5A0FB0:7C0DD5:6B04A29B |
| html-safe-nonce | 568c83e3dfa5bf4dbc62d70753daeecf4ff4f274dfc2b5d82fc66cc5a43a1a5d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzgyOjNDODBFMTo1QTBGQjA6N0MwREQ1OjZCMDRBMjlCIiwidmlzaXRvcl9pZCI6IjI3NjI5NjA3NzgzNjg5NTA5MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 43224557011554e6c890cfc8bcd5b0deba59cb26d91233f792aa05e7c327770b |
| hovercard-subject-tag | issue:1181000946 |
| 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/4789/issue_layout |
| twitter:image | https://opengraph.githubassets.com/093abf1180147be30aea86c0d41126ac5741aa75e992ce74d88e8289612d2611/getsentry/sentry-javascript/issues/4789 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/093abf1180147be30aea86c0d41126ac5741aa75e992ce74d88e8289612d2611/getsentry/sentry-javascript/issues/4789 |
| og:image:alt | Problem Statement I've briefly chatted to @AbhiPrasad about this but we wanted to open the discussion up and get some feedback and ideas from others... The current integration options are as follow... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | timfish |
| 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