Skip to content

feat(js): Add SDK Options page#12502

Merged
mydea merged 21 commits intomasterfrom
fn/js-sdk-options
Feb 5, 2025
Merged

feat(js): Add SDK Options page#12502
mydea merged 21 commits intomasterfrom
fn/js-sdk-options

Conversation

@mydea
Copy link
Copy Markdown
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
@vercel
Copy link
Copy Markdown

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 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 11:30am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2025 11:30am
develop-docs ⬜️ Ignored (Inspect) Visit Preview Feb 5, 2025 11:30am

children?: React.ReactNode;
noGuides?: boolean;
notSupported?: string[];
notSupported?: `${PlatformCategory}`[];
Copy link
Copy Markdown
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
Copy Markdown
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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I actually extracted this out a bit here: #12558

Copy link
Copy Markdown
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 ✅ !

Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated

</SdkOption>

<SdkOption name="tracePropagationTargets" type='Array<string | RegExp>'>
Copy link
Copy Markdown
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
Copy Markdown
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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

idea (logaf-l) should we then add something liks "see description" for the default value field?

Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated
Comment thread docs/platforms/javascript/common/options.mdx Outdated
Copy link
Copy Markdown
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!

Comment thread src/components/sdkOption.tsx Outdated
</a>
</h3>

<table className="w-auto">
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

children?: React.ReactNode;
noGuides?: boolean;
notSupported?: string[];
notSupported?: `${PlatformCategory}`[];
Copy link
Copy Markdown
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

Comment thread src/components/sdkOption.tsx Outdated
Comment thread src/components/sdkOption.tsx Outdated
Comment thread src/middleware.ts Outdated
Comment thread src/components/sdkOptionOverview.tsx Outdated
Comment thread platform-includes/configuration/config-intro/javascript.mdx Outdated
Comment thread src/components/sdkOptionOverview.tsx Outdated
Comment thread src/components/sdkOptionOverview.tsx
Comment thread src/components/sdkOptionOverview.tsx Outdated
@inventarSarah
Copy link
Copy Markdown
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
Copy Markdown
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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 31, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.7MB 4.19kB (0.04%) ⬆️
sentry-docs-client-array-push 9.38MB 3.48kB (0.04%) ⬆️

Affected Assets, Files, and Routes:

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 529.59kB 0.83%
../app/[[...path]]/page.js.nft.json -78 bytes 375.92kB -0.02%
../app/platform-redirect/page.js.nft.json -78 bytes 375.84kB -0.02%
../app/sitemap.xml/route.js.nft.json -78 bytes 373.81kB -0.02%
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/mdxComponents.ts → Total Size: 3.54kB

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

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

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

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

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

Files in 2065.js:

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

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

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

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

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

App Routes Affected:

App Route Size Change Total Size Change (%)
/[[...path]] 4.37kB 3.08MB 0.14%
/platform-redirect 2 bytes 2.58MB 0.0%
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 5.75kB 22.76kB 33.77% ⚠️
static/css/*.css 2.59kB 6.54kB 65.54% ⚠️
static/css/*.css -7.52kB 8.57kB -46.73%
static/chunks/9557-*.js -3 bytes 391.11kB -0.0%
server/app/_not-*.js 481 bytes 252.08kB 0.19%
server/app/[[...path]]/page_client-*.js 481 bytes 252.04kB 0.19%
server/app/platform-*.js 481 bytes 237.37kB 0.2%
static/chunks/app/[[...path]]/page-*.js 1.22kB 72.41kB 1.71%
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/1kyi_2LsGAboYqBDpC2GN/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/1kyi_2LsGAboYqBDpC2GN/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/chunks/3920-*.js (Deleted) -41.5kB 0 bytes -100.0% 🗑️
static/yQisTFHL2fFEoitC_2EX3/_buildManifest.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/yQisTFHL2fFEoitC_2EX3/_ssgManifest.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/docPage/type.scss → Total Size: 39 bytes

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

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

@mydea
Copy link
Copy Markdown
Member Author

mydea commented Feb 4, 2025

I think this is ready for review now, I tried to address the things that have already been brought up. The options list itself for sure can use some more iteration and work, but IMHO we can do that step by step then too.

Comment thread src/components/sdkOption/index.tsx Outdated
Copy link
Copy Markdown
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

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

Thanks @mydea! I don't see any issues here, however since a lot of these changes are on the more technical side, please also make sure a docs engineer approves as well before merging.

Copy link
Copy Markdown
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.

Thanks for the update, let's ship it and maybe check if can render the ToC during build time in a follow up PR 👍

@mydea
Copy link
Copy Markdown
Member Author

mydea commented Feb 5, 2025

after talking with @stephanie-anderson , for now we leave it under configuration > options!

@mydea mydea merged commit d43e215 into master Feb 5, 2025
@mydea mydea deleted the fn/js-sdk-options branch February 5, 2025 11:49
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants