Skip to content

Commit 24cc1bb

Browse files
feat: onboarding options on getting started pages (#10130)
* feat: onboarding options on getting started pages * better node filter * a faster node filter * denser options UI * fix: don't copy lines with `display: none;` * add Golang/gin performance onboarding option example * adjust option checkbox size * gain more vertical space around onboarding options buttons * document option `id` * feat: onboarding options tooltips * skip formatting codeblocks with onboarding options * sticky onboarding option buttons * move onboarding option buttons immediately bellow ##install * rename OnboardingOptionButtons component (remove double plural) * change accidental h1 into h2 * fix sticky element top distance * refactor: simplify option syntax * default onboarding options to checked * adjust option buttons sticky position * tooltip styles * wrap option buttons on mobile * add docs * make onboarding options syntax play nice with other elements on code block metadata * better Regex for onboarding options meta data * [getsentry/action-github-commit] Auto commit * full width/bigger option buttons on mobile * add note about option id with a hyphen * use JSON syntax for onboarding options metadata * update example in module doc * animate onboarding options into view * disable `error-monitoring` option by default * fix typo * update docs --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent c583d75 commit 24cc1bb

File tree

12 files changed

+663
-14
lines changed

12 files changed

+663
-14
lines changed

docs/contributing/pages/components.mdx

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,110 @@ Attributes:
242242
- `supported` (string[])
243243
- `notSupported` (string[])
244244
- `noGuides` (boolean) - hide this on all guides (takes precedence over `supported`/`notSupported`)
245+
246+
## Onboarding Options
247+
248+
If you're writing product feature specific docs, you can specify code block `onboardingOptions` metadata:
249+
250+
````markdown
251+
```go {"onboardingOptions": {"performance": "13-17"}}
252+
// your code here
253+
```
254+
````
255+
256+
the general syntax is `{"onboardingOptions": {"feature": "range"}}` where `feature` is the feature id
257+
and `range` is the corresponding line range (similar to the line highlighting syntax).
258+
259+
You can specify multiple features by separating them with a comma:
260+
261+
`{"onboardingOptions": {"performance": "13-17", "profiling": "5-6"}}`
262+
263+
The range visibility will be controlled by the `OnboardingOptionButtons` component:
264+
265+
````jsx diff
266+
<OnboardingOptionButtons
267+
options={[
268+
'error-monitoring',
269+
"performance"
270+
]}
271+
/>
272+
````
273+
274+
- `options` can either be either an object of this shape:
275+
276+
```typescript
277+
{
278+
id: 'error-monitoring' | 'performance' | 'profiling' | 'session-replay',
279+
disabled: boolean,
280+
checked: boolean
281+
}
282+
```
283+
or a string (one of these `id`s 👆) for convenience when using defaults.
284+
285+
<Alert level="warning" title="Important">
286+
The underlying implementation relies on the `onboardingOptions` metadata in the code blocks to be valid JSON syntax.
287+
</Alert>
288+
289+
- default values: `checked: false` and `disabled: false` (`true` for `error-monitoring`).
290+
291+
Example (output of the above):
292+
293+
<OnboardingOptionButtons
294+
options={[
295+
{id: 'error-monitoring', disabled: true},
296+
"performance"
297+
]}
298+
dontStick
299+
/>
300+
301+
```go {"onboardingOptions": {"performance": "13-17"}}
302+
import (
303+
"fmt"
304+
"net/http"
305+
306+
"github.com/getsentry/sentry-go"
307+
sentrygin "github.com/getsentry/sentry-go/gin"
308+
"github.com/gin-gonic/gin"
309+
)
310+
311+
// To initialize Sentry's handler, you need to initialize Sentry itself beforehand
312+
if err := sentry.Init(sentry.ClientOptions{
313+
Dsn: "___PUBLIC_DSN___",
314+
EnableTracing: true,
315+
// Set TracesSampleRate to 1.0 to capture 100%
316+
// of transactions for performance monitoring.
317+
// We recommend adjusting this value in production,
318+
TracesSampleRate: 1.0,
319+
}); err != nil {
320+
fmt.Printf("Sentry initialization failed: %v\n", err)
321+
}
322+
323+
// Then create your app
324+
app := gin.Default()
325+
326+
// Once it's done, you can attach the handler as one of your middleware
327+
app.Use(sentrygin.New(sentrygin.Options{}))
328+
329+
// Set up routes
330+
app.GET("/", func(ctx *gin.Context) {
331+
ctx.String(http.StatusOK, "Hello world!")
332+
})
333+
334+
// And run it
335+
app.Run(":3000")
336+
```
337+
338+
You can conditionally render content based on the selected onboarding options using the
339+
`OnboardingOption` component
340+
341+
Example (toggle the `performance` option above to see the effect):
342+
343+
<OnboardingOption optionId="performance">
344+
345+
```jsx
346+
<OnboardingOption optionId="performance">
347+
This code block is wrapped in a `OnboardingOption` component and will only
348+
be rendered when the `performance` option is selected.
349+
</OnboardingOption>
350+
```
351+
</OnboardingOption>

docs/platforms/go/guides/gin/index.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ For a quick reference, there is a [complete example](https://github.com/getsentr
99

1010
## Install
1111

12+
<OnboardingOptionButtons
13+
options={[
14+
'error-monitoring',
15+
'performance',
16+
]}
17+
/>
18+
1219
```bash
1320
go get github.com/getsentry/sentry-go/gin
1421
```
@@ -17,7 +24,7 @@ go get github.com/getsentry/sentry-go/gin
1724

1825
<SignInNote />
1926

20-
```go
27+
```go {"onboardingOptions": {"performance": "13-17"}}
2128
import (
2229
"fmt"
2330
"net/http"

docs/platforms/php/index.mdx

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ This Sentry PHP SDK provides support for PHP 7.2 or later. If you are using our
2121

2222
## Install
2323

24+
<OnboardingOptionButtons
25+
options={[
26+
'error-monitoring',
27+
'performance',
28+
'profiling',
29+
]}
30+
/>
31+
2432
Sentry captures data by using an SDK within your application’s runtime. These are platform-specific and allow Sentry to have a deep understanding of how your application works.
2533

2634
Install the SDK using [Composer](https://getcomposer.org/).
@@ -29,24 +37,42 @@ Install the SDK using [Composer](https://getcomposer.org/).
2937
composer require sentry/sentry
3038
```
3139

32-
## Configure
40+
<OnboardingOption optionId="profiling">
41+
42+
Install the Excimer extension via PECL:
43+
44+
```bash
45+
pecl install excimer
46+
```
3347

34-
After you’ve completed setting up a project in Sentry, Sentry will give you a value which we call a DSN or Data Source Name. It looks a lot like a standard URL, but it’s just a representation of the configuration required by the Sentry SDKs. It consists of a few pieces, including the protocol, public key, the server address, and the project identifier.
48+
The Excimer PHP extension supports PHP 7.2 and up. Excimer requires Linux or macOS and doesn't support Windows. For additional ways to install Excimer, [see docs](/platforms/php/profiling/#installation).
49+
50+
</OnboardingOption>
51+
52+
## Configure
3553

3654
To capture all errors, even the one during the startup of your application, you should initialize the Sentry PHP SDK as soon as possible.
3755

3856
<SignInNote />
3957

40-
```php
41-
\Sentry\init(['dsn' => '___PUBLIC_DSN___' ]);
58+
```php {"onboardingOptions": {"performance": "3-4", "profiling": "5-6"}}
59+
\Sentry\init([
60+
'dsn' => '___PUBLIC_DSN___' ,
61+
// Specify a fixed sample rate
62+
'traces_sample_rate' => 1.0,
63+
// Set a sampling rate for profiling - this is relative to traces_sample_rate
64+
'profiles_sample_rate' => 1.0,
65+
]);
4266
```
4367

44-
## Usage
68+
## Verify
69+
70+
In PHP you can either capture a caught exception or capture the last error with captureLastError.
4571

4672
```php
4773
try {
48-
$this->functionFailsForSure();
74+
$this->functionFailsForSure();
4975
} catch (\Throwable $exception) {
50-
\Sentry\captureException($exception);
76+
\Sentry\captureException($exception);
5177
}
5278
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"next-auth": "^4.24.5",
6868
"next-mdx-remote": "^4.4.1",
6969
"nextjs-toploader": "^1.6.6",
70+
"parse-numeric-range": "^1.3.0",
7071
"platformicons": "^5.10.9",
7172
"prism-sentry": "^1.0.2",
7273
"prismjs": "^1.27.0",

src/components/codeBlock/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
3030
return;
3131
}
3232

33-
let code =
34-
codeRef.current.textContent || codeRef.current.innerText.replace(/\n\n/g, '\n');
33+
let code = codeRef.current.innerText.replace(/\n\n/g, '\n');
3534

3635
// don't copy leading prompt for bash
3736
if (language === 'bash' || language === 'shell') {

src/components/docPage/type.scss

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.prose {
2-
32
h1,
43
h2,
54
h3,
@@ -140,9 +139,54 @@
140139
}
141140
}
142141

143-
dt+dd {
142+
dt + dd {
144143
margin-bottom: var(--paragraph-margin-bottom);
145144
}
145+
146+
[data-onboarding-option].hidden {
147+
display: none;
148+
}
149+
[data-onboarding-option].animate-line {
150+
animation:
151+
slideLeft 0.2s ease-out forwards,
152+
highlight 1.2s forwards;
153+
}
154+
[data-onboarding-option].animate-content {
155+
animation: slideDown 0.2s ease-out forwards;
156+
}
157+
}
158+
159+
@keyframes slideDown {
160+
from {
161+
transform: translateY(-12px);
162+
}
163+
to {
164+
transform: translateY(0);
165+
}
166+
}
167+
168+
@keyframes slideLeft {
169+
from {
170+
transform: translateX(-1ch);
171+
}
172+
to {
173+
transform: translateX(0);
174+
}
175+
}
176+
177+
@keyframes highlight {
178+
0% {
179+
background-color: rgba(255, 255, 255, 0);
180+
}
181+
10% {
182+
background-color: rgba(255, 255, 255, 0.15);
183+
}
184+
80% {
185+
background-color: rgba(255, 255, 255, 0.15);
186+
}
187+
100% {
188+
background-color: rgba(255, 255, 255, 0);
189+
}
146190
}
147191

148192
.sidebar {
@@ -164,7 +208,7 @@ h3.config-key {
164208
// <p>This paragraph has a normal bottom margin</p>
165209
// <p>This paragraph does not have a bottom margin</p>
166210
// </.content-flush-bottom>
167-
.content-flush-bottom>*:last-child {
211+
.content-flush-bottom > *:last-child {
168212
margin-bottom: 0 !important;
169213
}
170214

0 commit comments

Comments
 (0)