Skip to content

Commit 7a6d357

Browse files
mydeas1gr1d
andauthored
feat(js): Update enriching events page (#13237)
--------- Co-authored-by: Sigrid Huemer <[email protected]>
1 parent 8ed8244 commit 7a6d357

File tree

8 files changed

+194
-207
lines changed

8 files changed

+194
-207
lines changed

docs/platforms/javascript/common/apis.mdx

Lines changed: 92 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,17 @@ client enabled for continued use.
111111
promise, but it is recommended to use this only when necessary as it slows
112112
down event processing.
113113

114-
<PlatformCategorySection notSupported={['server', 'serverless']}>
115-
Event processors added via `Sentry.addEventProcessor()` will be applied to all events in your application.
116-
If you want to add an event processor that only applies to certain events, you can also add one to a scope as follows:
117-
</PlatformCategorySection>
114+
<PlatformCategorySection notSupported={["server", "serverless"]}>
115+
Event processors added via `Sentry.addEventProcessor()` will be applied to all
116+
events in your application. If you want to add an event processor that only
117+
applies to certain events, you can also add one to a scope as follows:
118+
</PlatformCategorySection>
118119

119120
<PlatformCategorySection supported={['server', 'serverless']}>
120121
Event processors added via `Sentry.addEventProcessor()` will be applied to all events in your current request.
121-
If you want to add an event processor that only applies to certain events, you can also add one to a scope as follows:
122+
123+
If you want to add an event processor that only applies to certain events, you can also add one to a scope as follows:
124+
122125
</PlatformCategorySection>
123126

124127
```javascript
@@ -136,6 +139,7 @@ Sentry.withScope((scope) => {
136139
`beforeSend` and `beforeSendTransaction` are guaranteed to be run last, after all other event processors, (which means they get the final version of the event right before it's sent, hence the name). Event processors added with `addEventProcessor` are run in an undetermined order, which means changes to the event may still be made after the event processor runs.
137140

138141
There can only be a single `beforeSend` / `beforeSendTransaction` processor, but you can add multiple event processors via `addEventProcessor()`.
142+
139143
</Expandable>
140144
</SdkApi>
141145

@@ -322,7 +326,30 @@ Messages show up as issues on your issue stream, with the message as the issue n
322326
signature="function setContext(name: string, context: Record<string, unknown>): void"
323327
parameters={[]}
324328
>
325-
Set a context to be sent with Sentry events.
329+
Set a context to be sent with Sentry events. Custom contexts allow you to attach arbitrary data to an event.
330+
You cannot search these, but they are viewable on the issue page - if you
331+
need to be able to filter for certain data, use [tags](./#setTag) instead.
332+
333+
There are no restrictions on context name. In the context object, all keys are allowed except for `type`, which is used internally.
334+
335+
By default, Sentry SDKs normalize nested structured context data up to three levels deep.
336+
Any data beyond this depth will be trimmed and marked using its type instead.
337+
To adjust this default, use the <PlatformLink to="/configuration/options#normalize-depth">`normalizeDepth`</PlatformLink> SDK option.
338+
339+
Learn more about conventions for common contexts in the [contexts interface developer documentation](https://develop.sentry.dev/sdk/data-model/event-payloads/contexts/).
340+
341+
<Expandable title='Example'>
342+
Context data is structured and can contain any data you want:
343+
344+
```javascript
345+
Sentry.setContext("character", {
346+
name: "Mighty Fighter",
347+
age: 19,
348+
attack_type: "melee",
349+
});
350+
```
351+
</Expandable>
352+
326353
</SdkApi>
327354

328355
<SdkApi
@@ -350,16 +377,70 @@ Messages show up as issues on your issue stream, with the message as the issue n
350377
type: {
351378
name: "User",
352379
properties: [
353-
{ name: "id", type: "string | number" },
354-
{ name: "email", type: "string" },
355-
{ name: "ip_address", type: "string" },
356-
{ name: "username", type: "string" },
380+
{
381+
name: "id",
382+
type: "string | number",
383+
description: "Your internal identifier for the user",
384+
},
385+
{
386+
name: "email",
387+
type: "string",
388+
description:
389+
"Sentry is aware of email addresses and can display things such as Gravatars and unlock messaging capabilities",
390+
},
391+
{
392+
name: "username",
393+
type: "string",
394+
description:
395+
"Typically used as a better label than the internal id",
396+
},
397+
{
398+
name: "ip_address",
399+
type: "string",
400+
description:
401+
"The user's IP address. If the user is unauthenticated, Sentry uses the IP address as a unique identifier for the user",
402+
},
357403
],
358404
},
359405
},
360406
]}
361407
>
362-
Set a user to be sent with Sentry events. Set to `null` to unset the user.
408+
Set a user to be sent with Sentry events. Set to `null` to unset the user. In
409+
addition to the specified properties of the `User` object, you can also add
410+
additional arbitrary key/value pairs.
411+
412+
<Expandable title="Capturing User IP-Addresses">
413+
<PlatformCategorySection supported={['server', 'serverless']}>
414+
On the server, the IP address will be inferred from the incoming HTTP request, if available.
415+
This is automatically done if you have configured `sendDefaultPii: true` in your <PlatformLink to="/configuration/options/#sendDefaultPii">SDK configuration</PlatformLink>.
416+
</PlatformCategorySection>
417+
418+
<PlatformCategorySection supported={["browser"]}>
419+
On the browser, if the users' `ip_address` is set to `"{{ auto }}"`, Sentry
420+
will infer the IP address from the connection between your app and Sentrys'
421+
server. `{{auto}}` is automatically set if you have configured `sendDefaultPii:
422+
true` in your <PlatformLink to="/configuration/options/#sendDefaultPii">SDK configuration</PlatformLink>.
423+
</PlatformCategorySection>
424+
425+
To ensure your users' IP addresses are never stored in your event data, you can go to your project settings, click on "Security & Privacy", and enable "Prevent Storing of IP Addresses" or use Sentry's [server-side data scrubbing](/security-legal-pii/scrubbing/) to remove `$user.ip_address`. Adding such a rule ultimately overrules any other logic.
426+
427+
</Expandable>
428+
429+
430+
<PlatformCategorySection supported={["server"]}>
431+
<Expandable title="Setting The User For the Current Request ">
432+
<PlatformSection notSupported={['javascript.bun', 'javascript.cloudflare', 'javascript.deno', 'javascript.react-router', 'javascript.aws-lambda', 'javascript.azure-functions', 'javascript.gcp-functions']}>
433+
`Sentry.setUser()` will set the user for the currently active request - see <PlatformLink to="/enriching-events/request-isolation">Request Isolation</PlatformLink> for more information. For example, if you want to set the user for a single request, you can do this like this:
434+
</PlatformSection>
435+
<PlatformContent includePath="enriching-events/set-user-request" />
436+
437+
Or if you want to set the user for all requests, you could use a middleware like this:
438+
439+
<PlatformContent includePath="enriching-events/set-user-middleware" />
440+
441+
</Expandable>
442+
</PlatformCategorySection>
443+
363444
</SdkApi>
364445

365446
<SdkApi

docs/platforms/javascript/common/configuration/options.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ sidebar_order: 1
1212
## Core Options
1313

1414
<SdkOption name='dsn' type='string' envVar='SENTRY_DSN'>
15-
The DSN tells the SDK where to send the events. If this is not set, the SDK will not send any events. Learn more about [DSN utilization](/product/sentry-basics/dsn-explainer/#dsn-utilization).
16-
17-
<PlatformContent includePath="configuration/dsn" />
15+
The DSN tells the SDK where to send the events. If this is not set, the SDK will not send any events.
16+
Learn more about [DSN utilization](/product/sentry-basics/dsn-explainer/#dsn-utilization).
17+
<PlatformContent includePath="configuration/dsn" />
1818

1919
</SdkOption>
2020

@@ -63,6 +63,12 @@ Sets the URL that will be used to transport captured events. This can be used to
6363

6464
</SdkOption>
6565

66+
<SdkOption name="sendDefaultPii" type='boolean' defaultValue='false'>
67+
68+
Set this option to `true` to send default PII data to Sentry. Among other things, enabling this will enable automatic IP address collection on events.
69+
70+
</SdkOption>
71+
6672
<SdkOption name="maxBreadcrumbs" type='number' defaultValue="100">
6773

6874
This variable controls the total amount of breadcrumbs that should be captured. You should be aware that Sentry has a [maximum payload size](https://develop.sentry.dev/sdk/data-model/envelopes/#size-limits) and any events exceeding that payload size will be dropped.
@@ -305,8 +311,9 @@ When enabled, all props of the Vue component where the error was thrown in are a
305311
to capture Vue exceptions and report them to Sentry.
306312
When `attachErrorHandler` is set to `false`, automatic error reporting is disabled.
307313

308-
Usually, this option should stay enabled, unless you want to set up Sentry error reporting yourself.
309-
For example, the Sentry Nuxt SDK does not attach an error handler as it's capturing errors through the error hooks provided by Nuxt.
314+
Usually, this option should stay enabled, unless you want to set up Sentry error reporting yourself.
315+
For example, the Sentry Nuxt SDK does not attach an error handler as it's capturing errors through the error hooks provided by Nuxt.
316+
310317
</SdkOption>
311318

312319
</PlatformSection>

docs/platforms/javascript/common/enriching-events/context/index.mdx

Lines changed: 0 additions & 132 deletions
This file was deleted.

docs/platforms/javascript/common/enriching-events/identify-user/index.mdx

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)