Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d4883bc
feat: onboarding options on getting started pages
a-hariti May 23, 2024
4313c73
better node filter
a-hariti May 23, 2024
a60795d
a faster node filter
a-hariti May 23, 2024
7d28ae0
denser options UI
a-hariti May 23, 2024
a3ea62f
fix: don't copy lines with `display: none;`
a-hariti May 23, 2024
eb6a2b4
add Golang/gin performance onboarding option example
a-hariti May 23, 2024
a3343cd
adjust option checkbox size
a-hariti May 23, 2024
43ff7e5
gain more vertical space around onboarding options buttons
a-hariti May 23, 2024
60f906c
document option `id`
a-hariti May 23, 2024
a0bf950
feat: onboarding options tooltips
a-hariti May 23, 2024
e42fc83
skip formatting codeblocks with onboarding options
a-hariti May 24, 2024
800b681
sticky onboarding option buttons
a-hariti May 24, 2024
bf2fde2
move onboarding option buttons immediately bellow ##install
a-hariti May 24, 2024
4822764
rename OnboardingOptionButtons component (remove double plural)
a-hariti May 24, 2024
7d1e6db
change accidental h1 into h2
a-hariti May 24, 2024
c3a1149
fix sticky element top distance
a-hariti May 24, 2024
e51ab52
refactor: simplify option syntax
a-hariti May 24, 2024
58b30a9
default onboarding options to checked
a-hariti May 24, 2024
9fea723
adjust option buttons sticky position
a-hariti May 24, 2024
d4bf577
tooltip styles
a-hariti May 24, 2024
51a6f24
wrap option buttons on mobile
a-hariti May 24, 2024
31dfcf2
add docs
a-hariti May 24, 2024
1dc0401
make onboarding options syntax play nice with other elements on
a-hariti May 24, 2024
3b9d5e2
better Regex for onboarding options meta data
a-hariti May 24, 2024
f8925bc
[getsentry/action-github-commit] Auto commit
getsantry[bot] May 24, 2024
05da74e
full width/bigger option buttons on mobile
a-hariti May 24, 2024
7c31f9f
add note about option id with a hyphen
a-hariti May 24, 2024
54758c9
use JSON syntax for onboarding options metadata
a-hariti May 27, 2024
763b14e
update example in module doc
a-hariti May 27, 2024
f0727d7
animate onboarding options into view
a-hariti May 27, 2024
2f01f69
disable `error-monitoring` option by default
a-hariti May 27, 2024
ea71368
fix typo
a-hariti May 27, 2024
4cab2d0
udpate docs
a-hariti May 27, 2024
cf847ea
vanity
a-hariti May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions docs/contributing/pages/components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,110 @@ Attributes:
- `supported` (string[])
- `notSupported` (string[])
- `noGuides` (boolean) - hide this on all guides (takes precedence over `supported`/`notSupported`)

## Onboarding Options

If you're writing product feature specific docs, you can specify code block `onboardingOptions` metadata:

````markdown
```go {"onboardingOptions": {"performance": "13-17"}}
// your code here
```
````

the general syntax is `{"onboardingOptions": {"feature": "range"}}` where `feature` is the feature id
and `range` is the corresponding line range (similar to the line highlighting syntax).

You can specify multiple features by separating them with a comma:

`{"onboardingOptions": {"performance": "13-17", "profiling": "5-6"}}`

The range visibility will be controlled by the `OnboardingOptionButtons` component:

````jsx diff
<OnboardingOptionButtons
options={[
'error-monitoring',
"performance"
]}
/>
````

- `options` can either be either an object of this shape:

```typescript
{
id: 'error-monitoring' | 'performance' | 'profiling' | 'session-replay',
disabled: boolean,
checked: boolean
}
```
or a string (one of these `id`s 👆) for convenience when using defaults.

<Alert level="warning" title="Important">
The underlying implementation relies on the `onboardingOptions` metadata in the code blocks to be valid JSON syntax.
</Alert>

- default values: `checked: false` and `disabled: false` (`true` for `error-monitoring`).

Example (output of the above):

<OnboardingOptionButtons
options={[
{id: 'error-monitoring', disabled: true},
"performance"
]}
dontStick
/>

```go {"onboardingOptions": {"performance": "13-17"}}
import (
"fmt"
"net/http"

"github.com/getsentry/sentry-go"
sentrygin "github.com/getsentry/sentry-go/gin"
"github.com/gin-gonic/gin"
)

// To initialize Sentry's handler, you need to initialize Sentry itself beforehand
if err := sentry.Init(sentry.ClientOptions{
Dsn: "___PUBLIC_DSN___",
EnableTracing: true,
// Set TracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production,
TracesSampleRate: 1.0,
}); err != nil {
fmt.Printf("Sentry initialization failed: %v\n", err)
}

// Then create your app
app := gin.Default()

// Once it's done, you can attach the handler as one of your middleware
app.Use(sentrygin.New(sentrygin.Options{}))

// Set up routes
app.GET("/", func(ctx *gin.Context) {
ctx.String(http.StatusOK, "Hello world!")
})

// And run it
app.Run(":3000")
```

You can conditionally render content based on the selected onboarding options using the
`OnboardingOption` component

Example (toggle the `performance` option above to see the effect):

<OnboardingOption optionId="performance">

```jsx
<OnboardingOption optionId="performance">
This code block is wrapped in a `OnboardingOption` component and will only
be rendered when the `performance` option is selected.
</OnboardingOption>
```
</OnboardingOption>
9 changes: 8 additions & 1 deletion docs/platforms/go/guides/gin/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ For a quick reference, there is a [complete example](https://github.com/getsentr

## Install

<OnboardingOptionButtons
options={[
'error-monitoring',
'performance',
]}
/>

```bash
go get github.com/getsentry/sentry-go/gin
```
Expand All @@ -17,7 +24,7 @@ go get github.com/getsentry/sentry-go/gin

<SignInNote />

```go
```go {"onboardingOptions": {"performance": "13-17"}}
import (
"fmt"
"net/http"
Expand Down
40 changes: 33 additions & 7 deletions docs/platforms/php/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ This Sentry PHP SDK provides support for PHP 7.2 or later. If you are using our

## Install

<OnboardingOptionButtons
options={[
'error-monitoring',
'performance',
'profiling',
]}
/>

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.

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

## Configure
<OnboardingOption optionId="profiling">

Install the Excimer extension via PECL:

```bash
pecl install excimer
```

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.
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).

</OnboardingOption>

## Configure

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

<SignInNote />

```php
\Sentry\init(['dsn' => '___PUBLIC_DSN___' ]);
```php {"onboardingOptions": {"performance": "3-4", "profiling": "5-6"}}
\Sentry\init([
'dsn' => '___PUBLIC_DSN___' ,
// Specify a fixed sample rate
'traces_sample_rate' => 1.0,
// Set a sampling rate for profiling - this is relative to traces_sample_rate
'profiles_sample_rate' => 1.0,
]);
```

## Usage
## Verify

In PHP you can either capture a caught exception or capture the last error with captureLastError.

```php
try {
$this->functionFailsForSure();
$this->functionFailsForSure();
} catch (\Throwable $exception) {
\Sentry\captureException($exception);
\Sentry\captureException($exception);
}
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"next-auth": "^4.24.5",
"next-mdx-remote": "^4.4.1",
"nextjs-toploader": "^1.6.6",
"parse-numeric-range": "^1.3.0",
"platformicons": "^5.10.9",
"prism-sentry": "^1.0.2",
"prismjs": "^1.27.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/codeBlock/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
return;
}

let code =
codeRef.current.textContent || codeRef.current.innerText.replace(/\n\n/g, '\n');
let code = codeRef.current.innerText.replace(/\n\n/g, '\n');

// don't copy leading prompt for bash
if (language === 'bash' || language === 'shell') {
Expand Down
50 changes: 47 additions & 3 deletions src/components/docPage/type.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.prose {

h1,
h2,
h3,
Expand Down Expand Up @@ -140,9 +139,54 @@
}
}

dt+dd {
dt + dd {
margin-bottom: var(--paragraph-margin-bottom);
}

[data-onboarding-option].hidden {
display: none;
}
[data-onboarding-option].animate-line {
animation:
slideLeft 0.2s ease-out forwards,
highlight 1.2s forwards;
}
[data-onboarding-option].animate-content {
animation: slideDown 0.2s ease-out forwards;
}
}

@keyframes slideDown {
from {
transform: translateY(-12px);
}
to {
transform: translateY(0);
}
}

@keyframes slideLeft {
from {
transform: translateX(-1ch);
}
to {
transform: translateX(0);
}
}

@keyframes highlight {
0% {
background-color: rgba(255, 255, 255, 0);
}
10% {
background-color: rgba(255, 255, 255, 0.15);
}
80% {
background-color: rgba(255, 255, 255, 0.15);
}
100% {
background-color: rgba(255, 255, 255, 0);
}
}

.sidebar {
Expand All @@ -164,7 +208,7 @@ h3.config-key {
// <p>This paragraph has a normal bottom margin</p>
// <p>This paragraph does not have a bottom margin</p>
// </.content-flush-bottom>
.content-flush-bottom>*:last-child {
.content-flush-bottom > *:last-child {
margin-bottom: 0 !important;
}

Expand Down
Loading