Skip to content

feat: Add APIs page for JavaScript #12605

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

Merged
merged 20 commits into from
Apr 3, 2025
Merged

feat: Add APIs page for JavaScript #12605

merged 20 commits into from
Apr 3, 2025

Conversation

mydea
Copy link
Member

@mydea mydea commented Feb 6, 2025

This adds a new top-level page to the JavaScript docs called "APIs", which is a list of all the top-level APIs that users may need.

This is a manually curated list, and not supposed to be fully exhaustive - but it should contain everything a user may want to call. These are all the Sentry.xxx functions, basically.

For this, some new components are added to handle formatting of this, as well as code-based syntax highlighting. For now only typescript is supported (to reduce bundle size?) but we can add more if needed. Platforms can also get a language defined now which controls how stuff is formatted.

As of now, parameters are formatted in a pseudo-typescript format. Not sure if that works for all languages, but we can do something platform specific in the future if needed.

There may be adjustments to be done to the APIs, and I most likely have forgotten one thing or another, but we can always tweak this further where needed.

Example API references:

@mydea mydea self-assigned this Feb 6, 2025
Copy link

vercel bot commented Feb 6, 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 Apr 2, 2025 11:51am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Apr 2, 2025 11:51am
develop-docs ⬜️ Ignored (Inspect) Visit Preview Apr 2, 2025 11:51am

Copy link

codecov bot commented Feb 6, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.63MB 20.32kB (0.19%) ⬆️
sentry-docs-client-array-push 9.45MB 6.14kB (0.07%) ⬆️

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 868.67kB -0.0%
static/css/*.css 209 bytes 5.09kB 4.28%
static/css/*.css 582 bytes 739.64kB 0.08%
static/css/*.css 12 bytes 18.71kB 0.06%
static/chunks/8931-*.js -3 bytes 397.42kB -0.0%
server/app/_not-*.js -759 bytes 255.27kB -0.3%
server/app/[[...path]]/page_client-*.js -759 bytes 255.23kB -0.3%
static/chunks/463-*.js (New) 254.43kB 254.43kB 100.0% 🚀
server/app/platform-*.js -155 bytes 240.96kB -0.06%
static/chunks/app/[[...path]]/page-*.js 161 bytes 78.94kB 0.2%
static/chunks/4335.*.js (New) 71.94kB 71.94kB 100.0% 🚀
app-*.json -1 bytes 4.18kB -0.02%
static/PFA833dYektKkATx31jiB/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/PFA833dYektKkATx31jiB/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/chunks/4335-*.js (Deleted) -247.57kB 0 bytes -100.0% 🗑️
static/chunks/6716.*.js (Deleted) -71.94kB 0 bytes -100.0% 🗑️
static/3Ntq54ZJ3Z9j-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
static/3Ntq54ZJ3Z9j-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️

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

  • ./src/components/sdkDefinition/style.module.scss → Total Size: 232 bytes
view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.58MB -0.0%
2637.js (New) 1.04MB 1.04MB 100.0% 🚀
../instrumentation.js -3 bytes 911.63kB -0.0%
9523.js -3 bytes 887.68kB -0.0%
../app/[[...path]]/page.js 19.45kB 559.42kB 3.6%
../app/[[...path]]/page.js.nft.json 56 bytes 383.64kB 0.01%
../app/platform-redirect/page.js.nft.json 56 bytes 383.56kB 0.01%
../app/sitemap.xml/route.js.nft.json 56 bytes 381.53kB 0.01%
2065.js 32 bytes 82.48kB 0.04%
4899.js (Deleted) -1.04MB 0 bytes -100.0% 🗑️

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

  • ./src/components/sdkDefinition/style.module.scss → Total Size: 214 bytes

  • ./src/components/sdkApi.tsx → Total Size: 6.55kB

  • ./src/components/sdkDefinition/index.tsx → Total Size: 3.33kB

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

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

  • ./src/components/apiExamples/apiExamples.tsx → Total Size: 471 bytes

Files in 2065.js:

  • ./src/docTree.ts → Total Size: 10.9kB

  • ./src/components/callout/styles.scss → Total Size: 1 bytes

  • ./src/components/callout/styles.scss → Total Size: 1 bytes

App Routes Affected:

App Route Size Change Total Size Change (%)
/[[...path]] 19.45kB 3.11MB 0.63%

@philipphofmann
Copy link
Member

I think it would be better to change the parameters to use the full width and have the object description below them. Now we have plenty of unused space and the object parameters could use the full width instead.

CleanShot 2025-02-07 at 10 19 30@2x

Instead of

breadcrumb description
hint description

Do this

breadcrumb
description
hint
description

How does that sound?

@timfish
Copy link
Collaborator

timfish commented Feb 7, 2025

Oooh, nice!

Don't forget dark mode:

image

@mydea
Copy link
Member Author

mydea commented Feb 7, 2025

I think it would be better to change the parameters to use the full width and have the object description below them. Now we have plenty of unused space and the object parameters could use the full width instead.

Yeah, I think that makes sense. I agree it is a bit wasteful as-is. This is really an early draft so def. needs some more love :D Also re: dark mode, this def. needs to be done, true!

@mydea
Copy link
Member Author

mydea commented Mar 26, 2025

I have re-vamped the design completely now:

Screen.Recording.2025-03-26.at.14.22.47.mov

(it should also work in dark mode now)

@mydea mydea requested a review from inventarSarah April 1, 2025 14:03
Copy link
Collaborator

@inventarSarah inventarSarah left a comment

Choose a reason for hiding this comment

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

Love the page!
I believe many users will find this overview page helpful for accessing basic information quickly without reading through extensive documentation. I will use this page a loooot!

Copy link
Collaborator

Choose a reason for hiding this comment

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

General question: will this page have a higher relevance for search? For example, when I look for "addIntegration", it would be great to have this page listed in the results somewhere near the top

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a question for @chargome when he's back :D but it's a valid point!


The started span will automatically be ended when the callback returns, and will thus measure the duration of the callback. The callback cann also be an async function.

<Expandable title='Examples'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like how you've used the Expandable component throughout the page – it makes the site look very neat! The consistency in use is also great and helps users find their way around 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: How do you currently decide which function to add an example to?

I'm just wondering if it would make sense to add more? I understand that some will not really need one, though

Copy link
Member Author

Choose a reason for hiding this comment

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

really very much a gut-feeling thing, where I feel the API is more complex/harder to understand without an example 😅 We can def. add more where we feel like it!

sidebar_order: 3
---

This page shows all available to-level APIs of the SDK. You can use them like this:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could add a bit more information here at the top (e.g., very briefly explain the purpose of these APIs).
It could also be good to use the word "function" to make it clear that these are SDK APIs and not REST APIs (something like "... the primary functions provided by the SDK for interacting with ...").

Let me know if I can support you with this :)

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, will add a bit more context here!


## Available Options

<TableOfContents ignoreIds={["available-options"]} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note, probably not a topic right now:
When you open the page you see two ToC's - one in the center and one to the right.
I can imagine that users gravitate towards the ToC in the center to find the API they're looking for (it is more eye-catching than the ToC in the sidebar). So, it is definitely valuable and needs to be here!
Still, I wish we could toggle the ToC (visible by default); especially considering that the list will become longer rather than shorter in the future 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, I get what you mean. What would you propose (for a follow up):

  1. allow to toggle the TOC in the main page?
  2. Do not show the TOC in the sidebar?
  3. Something else...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposition:
3. allow to toggle the second level of list elements in the main area (default: hidden)

Core APIs >
Capturing Events >
Enriching Events v
setTag
setTags

I understand if this is too extra :D

@mydea
Copy link
Member Author

mydea commented Apr 2, 2025

I made a (final?) round of updates based on feedback, feel free to give it another look, if nothing else comes up I'll merge this tomorrow!

@mydea mydea merged commit 28ad795 into master Apr 3, 2025
13 checks passed
@mydea mydea deleted the fn/js-apis branch April 3, 2025 09:04
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 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.

7 participants