Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js): Add SDK Options page #12502

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

feat(js): Add SDK Options page #12502

wants to merge 14 commits into from

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 29, 2025

After talking some about this with @lforst and @Lms24, and triggered by talks with @inventarSarah, I decided to make a POC of a new SDK Options page for the JS SDKs.

This was borne out of the following thoughts:

  • Today, we have a page Configuration > Basic Options, which is a bit weird. First, it is pretty generic (originally applying to all SDKs, so containing a lot of generic language). Second, it is not fully up to date. And lastly, it is not really complete - some (many) options are described but not all.
  • It can be hard to actually find the available options.
  • It is hard for SDK maintainers to know where to document things.
  • The location/naming of this as "Configuration > Basic Options" is not super intutitive.

To improve on this, this PR introduces (for JS only, for now) a new top-level "SDK Options" nav item. This is a single page that contains all top-level SDK options that can be passed to Sentry.init(). There are a few goals here:

  1. Make it complete - this should include all top-level options we want to document. Including replay, profiling, ... It does not literally have to be complete, we can choose to omit options we do not want to document.
  2. Make it consistent - ensure all options have a consistent formatting, making it easy to read & author new options.
  3. Add an index that can make it easier to scan this. Ideally, auto-generated.
  4. Call out that certain options only apply to client/server SDKs

For this, I wrote two new components, a <SdkOption> component, and a <SdkOptionOverview> which just auto-generates an index for this. You can put headings and text between those for sectioning and explanation.

I also removed the old Basic options page as well as the transports page and folded that into the new page, adding redirects.

Some screenshots showing the different things:

Auto-generated Overview:
image

Option with env-var configuration:
image
Note that the env var entry will not be shown in environments where this is not auto-picked up.

Option with default value:

image

If in a meta-framework, options that are only available in one part or the other will be called out:
image

We can add more things to the SDK options if needed. The authoring experience with this should be pretty straightforward and make it easy to keep this up-to-date, hopefully.

Follow up

If this generally finds agreement, we can merge this. We should then make some passes over the actual options and make sure we add ones that have been forgotten, and/or improve docs on them where applicable. In some places, we have docs for options in more specific places, which should be folded into this page where possible.

When this is done, we would like to also add a top-level SDK APIs page, which does the same thing but for APIs, e.g. Sentry.captureException(), Sentry.setTag() etc. We can discuss this more separately.

The idea is that with these two pages, we'll be able to consolidate a good amount of the pages we currently have in various levels of nesting, and only keep additional pages for places where more explanation/examples are needed.

@mydea mydea self-assigned this Jan 29, 2025
Copy link

vercel bot commented Jan 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs 🛑 Canceled (Inspect) Jan 31, 2025 9:46am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 9:46am
develop-docs ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 9:46am


type Props = {
children?: React.ReactNode;
noGuides?: boolean;
notSupported?: string[];
notSupported?: `${PlatformCategory}`[];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wonder if we can remove that enum and just use string literals there overall, could not find a place where this was really used that way, but not sure... cc @chargome

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah getting rid of enums per se I think is a good idea, also could't spot anything where this would be actually used

@mydea mydea force-pushed the fn/js-sdk-options branch from 7dc93a6 to 9cbb304 Compare January 29, 2025 13:14
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this rewrite! IMHO, this is much cleaner than the previous "Basic Options" page, both in description as well as UI. Love the table with the type and default value information.
I read through the options (haven't done this in a while) and had some minor suggestions. Once this is out of draft state, I'm happy to ✅ !

docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved
docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved

<SdkOption name="debug" type='boolean' defaultValue='false'>

Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong with sending the event. The default is always `false`. It's generally not recommended to turn it on in production, though turning `debug` mode on will not cause any safety concerns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safety sounds weird here 🤔 either we say "security" or write something like it won't expose any critical information? Or just omit it?

Suggested change
Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong with sending the event. The default is always `false`. It's generally not recommended to turn it on in production, though turning `debug` mode on will not cause any safety concerns.
Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong with sending the event. The default is always `false`. It's generally not recommended to turn it on in production, though turning `debug` mode on will not cause any security concerns.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should just remove the last sentence here, not sure how relevant this is actually..?

docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved

</SdkOption>

<SdkOption name="tracePropagationTargets" type='Array<string | RegExp>'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also add a default value entry into the table. Which needs to be different on browser and server.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is a bit tricky because 1. it is hard to implement this nicely (we can, if we want to) and especially 2. the default value here is not an actual value but computed (e.g. based on the current host), which is why I opted to rather explain the default in this case?

docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved
docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved
docs/platforms/javascript/common/options.mdx Outdated Show resolved Hide resolved
Comment on lines 230 to 240
`proxy`: A proxy used for outbound requests. Can be http or https. -
`caCerts`: A path or list of paths to a CA certificate, or a buffer of CA
certificates. - `httpModule`: A custom HTTP module to use for requests.
Defaults to the the native `http` and `https` modules. - `keepAlive`:
Determines whether to keep the socket alive between requests. Defaults to
`false`.
</PlatformCategorySection>

<PlatformCategorySection supported={["browser", "desktop"]}>
- `headers`: An object containing headers to be sent with every request. Used
by the SDK's fetch and XHR transports. - `fetchOptions`: An object containing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we intentionally not putting the individual transport options into their own lines?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no! auto-format messed this up, good catch!

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change!

</a>
</h3>

<table className="w-auto">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about wrapping this table with a border radius? (same value as the alert)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it, it's a bit tricky because apparently border-collapse and border-radius do not like each other 😬 I ended up making the border 2px, which seems ok to me, but... 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm tricky, the prose class also makes this harder. Looks better with 1px imo and we need to adapt it to dark mode – I can do that tomorrow if you want!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more hacking around, figured out a way to make 1px borders work!


type Props = {
children?: React.ReactNode;
noGuides?: boolean;
notSupported?: string[];
notSupported?: `${PlatformCategory}`[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah getting rid of enums per se I think is a good idea, also could't spot anything where this would be actually used

src/components/sdkOption.tsx Outdated Show resolved Hide resolved
src/components/sdkOption.tsx Outdated Show resolved Hide resolved
src/middleware.ts Outdated Show resolved Hide resolved
src/components/sdkOptionOverview.tsx Outdated Show resolved Hide resolved
src/components/sdkOptionOverview.tsx Outdated Show resolved Hide resolved
src/components/sdkOptionOverview.tsx Outdated Show resolved Hide resolved
src/components/sdkOptionOverview.tsx Outdated Show resolved Hide resolved
@inventarSarah
Copy link
Collaborator

That looks much clearer!
How are these options currently sorted? Would it make sense to sort them alphabetically to make them easier to find?

@mydea
Copy link
Member Author

mydea commented Jan 30, 2025

That looks much clearer! How are these options currently sorted? Would it make sense to sort them alphabetically to make them easier to find?

I've thought about this too some, IMHO it makes sense to have them manually sorted - right now it is just the order that you put them into the mdx file! Once we have general agreement on the direction etc. I would take some time to reorder these better, for now I mostly just cobbled it together in the order it already was in basic options.

Copy link

codecov bot commented Jan 31, 2025

Bundle Report

Changes will increase total bundle size by 9.28kB (0.05%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.64MB 5.76kB (0.05%) ⬆️
sentry-docs-client-array-push 9.32MB 3.52kB (0.04%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 866.04kB -0.0%
static/css/*.css 27 bytes 17.03kB 0.16%
static/css/*.css 789 bytes 4.74kB 19.97% ⚠️
static/chunks/9557-*.js -3 bytes 391.11kB -0.0%
server/app/_not-*.js 495 bytes 247.69kB 0.2%
server/app/[[...path]]/page_client-*.js 495 bytes 247.65kB 0.2%
server/app/platform-*.js 495 bytes 232.98kB 0.21%
static/chunks/app/[[...path]]/page-*.js 1.21kB 68.33kB 1.81%
static/chunks/818-*.js (New) 41.51kB 41.51kB 100.0% 🚀
static/chunks/app/platform-*.js -1 bytes 12.89kB -0.01%
app-*.json -2 bytes 4.18kB -0.05%
static/4BpSU1Oz1U3yTMjG3zeQ8/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/4BpSU1Oz1U3yTMjG3zeQ8/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/chunks/3920-*.js (Deleted) -41.5kB 0 bytes -100.0% 🗑️
static/l80_Bm3Ieee2gGuZzW-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/l80_Bm3Ieee2gGuZzW-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

Files in static/chunks/app/[[...path]]/page-*.js:

  • ./src/components/tableOfContents.tsx → Total Size: 3.12kB

  • ./src/components/sdkOption/style.module.scss → Total Size: 110 bytes

Files in static/chunks/818-*.js:

  • ./src/components/sidebarTableOfContents/style.module.scss → Total Size: 277 bytes

  • ./src/components/docPage/type.scss → Total Size: 39 bytes

  • ./src/components/sidebarTableOfContents/index.tsx → Total Size: 5.55kB

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.63MB -0.0%
../instrumentation.js -3 bytes 965.23kB -0.0%
9523.js -3 bytes 941.45kB -0.0%
../app/[[...path]]/page.js 4.37kB 518.78kB 0.85%
../app/[[...path]]/page.js.nft.json 446 bytes 374.43kB 0.12%
../app/platform-redirect/page.js.nft.json 446 bytes 374.34kB 0.12%
../app/sitemap.xml/route.js.nft.json 446 bytes 372.31kB 0.12%
2065.js (New) 81.44kB 81.44kB 100.0% 🚀
../app/platform-redirect/page.js 2 bytes 30.83kB 0.01%
3845.js (Deleted) -81.39kB 0 bytes -100.0% 🗑️

Files in ../app/[[...path]]/page.js:

  • ./src/components/sdkOption/index.tsx → Total Size: 8.84kB

  • ./src/components/sdkOption/style.module.scss → Total Size: 86 bytes

  • ./src/components/platformCategorySection.tsx → Total Size: 1.06kB

  • ./src/components/tableOfContents.tsx → Total Size: 479 bytes

  • ./src/components/tableOfContents.tsx → Total Size: 2.89kB

  • ./src/mdxComponents.ts → Total Size: 3.39kB

Files in 2065.js:

  • ./src/components/sidebarTableOfContents/index.tsx → Total Size: 520 bytes

  • ./src/components/sidebarTableOfContents/index.tsx → Total Size: 5.23kB

  • ./src/components/docPage/index.tsx → Total Size: 8.77kB

  • ./src/components/sidebarTableOfContents/style.module.scss → Total Size: 268 bytes

  • ./src/components/docPage/type.scss → Total Size: 1 bytes

App Routes Affected:

App Route Size Change Total Size Change (%)
/platform-redirect 2 bytes 2.58MB 0.0%
/[[...path]] 4.37kB 3.07MB 0.14%

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.

4 participants