Skip to content

Commit 475781d

Browse files
committed
Merge branch 'smi/sveltekit/clean-up-manual-qs-instrumentation' of github.com:getsentry/sentry-docs into smi/sveltekit/clean-up-manual-qs-instrumentation
2 parents 5bccb63 + 7c2f2e7 commit 475781d

File tree

6 files changed

+32
-63
lines changed

6 files changed

+32
-63
lines changed

docs/platforms/javascript/common/apis.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ Wraps a callback with a cron monitor check in. The check in will be sent to Sent
10831083
</PlatformCategorySection>
10841084

10851085
<PlatformSection supported={["javascript.sveltekit"]}>
1086-
## Load Function Instrumentation
1086+
## Instrumenting Load Functions
10871087

10881088
SvelteKit's universal and server `load` functions are instrumented automatically by default. If you don't want to use `load` auto-instrumentation, you can [disable it](/platforms/javascript/guides/sveltekit/configuration/build/#auto-instrumentation-options) and manually instrument specific `load` functions using the following function wrappers:
10891089

@@ -1131,7 +1131,7 @@ export const load = wrapServerLoadWithSentry(({ fetch }) => {
11311131

11321132
</SdkApi>
11331133

1134-
## Server Routes Instrumentation
1134+
## Instrumenting Server Routes
11351135

11361136
<SdkApi
11371137
name="wrapServerRouteWithSentry"

docs/platforms/javascript/guides/sveltekit/configuration/build/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Disable automatic source maps upload by setting `autoUploadSourceMaps` to `false
6060

6161
</SdkOption>
6262

63-
## Auto-instrumentation Options
63+
## Auto-Instrumentation Options
6464

6565
The SDK primarily uses [SvelteKit's hooks](https://kit.svelte.dev/docs/hooks) to collect error and performance data. However, SvelteKit doesn't yet offer a hook for universal or server-only `load` function calls. Therefore, the SDK uses a Vite plugin to auto-instrument `load` functions so that you don't have to manually add a Sentry wrapper to each function.
6666

docs/platforms/native/common/configuration/filtering.mdx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ All Sentry SDKs support the <PlatformIdentifier name="before-send" /> callback m
2222

2323
Note also that breadcrumbs can be filtered, as discussed in [our Breadcrumbs documentation](/product/error-monitoring/breadcrumbs/).
2424

25-
#### Event Hints
26-
27-
The <PlatformIdentifier name="before-send" /> callback is passed both the `event` and a second argument, `hint`, that holds one or more hints.
28-
29-
Typically, a `hint` holds the original exception so that additional data can be extracted or grouping is affected. In this example, the fingerprint is forced to a common value if an exception of a certain type has been caught:
30-
31-
<PlatformContent includePath="configuration/before-send-hint" />
32-
33-
When the SDK creates an event or breadcrumb for transmission, that transmission is typically created from some sort of source object. For instance, an error event is typically created from a log record or exception instance. For better customization, SDKs send these objects to certain callbacks (<PlatformIdentifier name="before-send" />, <PlatformIdentifier name="before-breadcrumb" /> or the event processor system in the SDK).
34-
35-
3625
## Filtering Transaction Events
3726

3827
To prevent certain transactions from being reported to Sentry, use the <PlatformIdentifier name="traces-sampler" /> or <PlatformIdentifier name="before-send-transaction" /> configuration option, which allows you to provide a function to evaluate the current transaction and drop it if it's not one you want.

platform-includes/configuration/before-send-hint/native.mdx

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

platform-includes/configuration/before-send/native.mdx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
```c
22
#include <sentry.h>
33

4-
sentry_value_t strip_sensitive_data(sentry_value_t event, void *hint) {
5-
/* modify event here or return NULL to discard the event */
6-
return event;
4+
sentry_value_t strip_sensitive_data(sentry_value_t event, void *hint, void *user_data) {
5+
(void)hint; // unlike in other SDKs, `hint` currently contains no data.
6+
// to get more crash context into a callback, use the `on_crash` hook instead.
7+
8+
if (strcmp(sentry_value_as_string(sentry_value_get_by_key(event, "level")), "info") == 0) {
9+
// remove the user data from "info" level events
10+
sentry_value_remove_by_key(event, "user");
11+
// make our mark on the event
12+
sentry_value_t tags = sentry_value_get_by_key(event, "tags");
13+
if (!sentry_value_is_null(tags)) {
14+
sentry_value_set_by_key(tags, "info", sentry_value_new_string((char*) user_data));
15+
}
16+
}
17+
18+
// return the modified event, or discard it by freeing it and returning `null`
19+
// sentry_value_decref(event);
20+
// return sentry_value_new_null();
21+
return event;
722
}
823

924
int main(void) {
1025
sentry_options_t *options = sentry_options_new();
11-
sentry_options_set_before_send(options, strip_sensitive_data, NULL);
26+
sentry_options_set_before_send(options, strip_sensitive_data, "anonymized");
1227
sentry_init(options);
1328

1429
/* ... */
@@ -25,14 +40,17 @@ The `before_send` callback implementation in `sentry-native` makes it hard to di
2540
#include <sentry.h>
2641
2742
static sentry_value_t
28-
crash_cleanup(
43+
on_crash_callback(
2944
const sentry_ucontext_t *uctx, // provides the user-space context of the crash
30-
sentry_value_t event, // used the same way as in `before_send`
31-
void *closure // user-data that you can provide at configuration time
45+
sentry_value_t event, // used the same way as in `before_send`; mostly empty for minidump-generating backends (crashpad, breakpad)
46+
void *user_data // user-data that you can provide at configuration time
3247
)
3348
{
34-
// Do contextual clean-up before the crash is sent to sentry's backend infrastructure
35-
49+
// Enrich an event before the crash is sent to sentry's backend infrastructure
50+
sentry_value_t tags = sentry_value_get_by_key(event, "tags");
51+
if (!sentry_value_is_null(tags)) {
52+
sentry_value_set_by_key(tags, "crash_hook", sentry_value_new_string("invoked"));
53+
}
3654
/* ... */
3755
3856
// tell the backend to retain the event (+ dump)
@@ -44,7 +62,7 @@ crash_cleanup(
4462
4563
int main(void) {
4664
sentry_options_t *options = sentry_options_new();
47-
sentry_options_set_on_crash(options, crash_cleanup, NULL);
65+
sentry_options_set_on_crash(options, on_crash_callback, NULL);
4866
sentry_init(options);
4967
5068
/* ... */

platform-includes/getting-started-config/javascript.nestjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
```typescript {filename: instrument.ts}
2-
const Sentry = require("@sentry/nestjs");
2+
import * as Sentry from "@sentry/nestjs";
33
// ___PRODUCT_OPTION_START___ profiling
44
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
55
// ___PRODUCT_OPTION_END___ profiling

0 commit comments

Comments
 (0)