Skip to content

Commit

Permalink
Merge pull request binaryoverload#3 from binaryoverload/0.4-new-integ…
Browse files Browse the repository at this point in the history
…ration-config

0.4 - New integration config
  • Loading branch information
binaryoverload authored May 8, 2024
2 parents 5c49c16 + 034830c commit e7304b2
Show file tree
Hide file tree
Showing 9 changed files with 720 additions and 504 deletions.
68 changes: 19 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default defineNuxtConfig({
})
```

> [!NOTE]
> You can also use environment variables to set the DSN using `NUXT_PUBLIC_SENTRY_DSN`
That's it! You can now use Nuxt Sentry in your Nuxt app ✨
Expand All @@ -48,7 +47,7 @@ The module can be configured by providing a `sentry` key in the `public` section

The `clientSdk` object is passed directly to the Sentry SDK. It consists of the properties specified in the [Sentry documentation here](https://docs.sentry.io/platforms/javascript/configuration/options/).

The `disableIntegrations` object takes a key of the integration name and a boolean value to enable or disable the integration. [See more details here](#disabling-integrations)
The `clientIntegrations` object takes a key of the integration name and either a boolean value or the integration configuration. [See more details here](#configuring-integrations)

Runtime config:

Expand All @@ -57,7 +56,7 @@ sentry: {
enabled?: boolean // Default: Enabled in production
dsn: string,
clientSdk?: SdkConfig
disableIntegrations?: Record<string, boolean>
clientIntegrations?: ClientIntegrationConfig
}
```

Expand All @@ -66,43 +65,16 @@ App config:
```ts
sentry: {
clientSdk?: (app: NuxtApp) => SdkConfig | SdkConfig
clientIntegrations?: ClientIntegrationConfig
}
```

### Configuring Integrations
If you would like to enable or configure specific integrations or you would like to create custom integrations, you can do so by providing a `integrations` array in the `clientSdk` object in the `appConfig`. It's important to use the `appConfig` for this as integrations are not serializable and cannot be passed through the `runtimeConfig`.

The list of integrations is deduplicated based on the `name` property of the integration so you can configure the default integrations by adding them to the list with the desired configuration.

See the example below for adding and configuring integrations:

```ts
import { breadcrumbsIntegration } from "@sentry/vue"

defineNuxtConfig({
appConfig: {
sentry: {
clientSdk: {
integrations: [
// Configure the default Breadcrumbs integration
breadcrumbIntegration({
console: true,
// Other options
}),
// Add a custom integration
new MyAwesomeIntegration()
],
},
},
},
})
```

### Disabling Integrations
If you would like to disable specific integrations, you can do so by providing a `disableIntegrations` object in the `runtimeConfig`. The key should be the name of the integration and the value should be a boolean to enable or disable the integration. The key is case-insensitive.
If you would like to enable or configure specific integrations, you can do so by providing a `clientIntegrations` object in either `appConfig` or `runtimeConfig`. The key should be the name of the integration and the value should be either a boolean to enable or disable the integration or an object to configure the integration.

The default integrations that are enabled are:
- Breadcrumbs
- BrowserTracing
- Dedupe
- FunctionToString
- GlobalHandlers
Expand All @@ -111,28 +83,26 @@ The default integrations that are enabled are:
- LinkedErrors
- TryCatch

See the example below for disabling the default Breadcrumbs integration:
See the example below for adding and configuring integrations (You can also use `runtimeConfig` for this):

```ts
import { breadcrumbsIntegration } from "@sentry/vue"

defineNuxtConfig({
runtimeConfig: {
public: {
sentry: {
disableIntegrations: {
Breadcrumbs: true
}
}
}
}
appConfig: {
sentry: {
clientIntegrations: {
Breadcrumbs: false, // Disable the default Breadcrumbs integration
Debug: {
stringify: true, // Configure the Debug integration
},
HttpClient: true, // Enable the HttpClient integration
},
},
},
})
```

or using environment variables:

```bash
NUXT_PUBLIC_SENTRY_DISABLE_INTEGRATIONS_BREADCRUMBS=true
```

## Development

```bash
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@binaryoverload/nuxt-sentry",
"version": "0.3.3",
"version": "0.4.0",
"description": "Nuxt 3 module for Sentry",
"repository": "https://github.com/binaryoverload/nuxt-sentry",
"license": "MIT",
Expand Down Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@nuxt/kit": "^3.11.2",
"@sentry/vite-plugin": "^2.16.1",
"@sentry/vue": "^7.113.0",
"@sentry/vue": "^7.114.0",
"defu": "^6.1.4"
},
"devDependencies": {
Expand All @@ -39,7 +39,7 @@
"@nuxt/module-builder": "^0.6.0",
"@nuxt/schema": "^3.11.2",
"@nuxt/test-utils": "^3.12.1",
"@types/node": "^20.12.8",
"@types/node": "^20.12.10",
"changelogen": "^0.5.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
Loading

0 comments on commit e7304b2

Please sign in to comment.