Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support external configuration in form of *.ts (#639)
- Loading branch information
Showing
23 changed files
with
502 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const SentryModule = require('../..') | ||
|
||
/** @type {import('@nuxt/types').NuxtConfig} */ | ||
const config = { | ||
rootDir: __dirname, | ||
telemetry: false, | ||
modules: [ | ||
/** @type {import('@nuxt/types').Module} */(/** @type {unknown} */(SentryModule)), | ||
], | ||
sentry: { | ||
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779', | ||
clientIntegrations: { | ||
// Integration from @Sentry/browser package. | ||
TryCatch: { eventTarget: false }, | ||
Replay: {}, | ||
}, | ||
|
||
}, | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<div> | ||
<h3>Server-side</h3> | ||
<span id="server-side">{{ serverSentryPresent ? 'Works!' : '$sentry object is missing!' }}</span> | ||
<h3>Client-side</h3> | ||
<span id="client-side">{{ clientSentryPresent ? 'Works!' : '$sentry object is missing!' }}</span> | ||
<p> | ||
<button id="crash-button" @click="crash_me()"> | ||
crash me | ||
</button> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
asyncData ({ $sentry }) { | ||
if (process.server) { | ||
return { | ||
serverSentryPresent: Boolean($sentry?.captureException), | ||
} | ||
} | ||
}, | ||
data () { | ||
return { | ||
clientSentryPresent: false, | ||
serverSentryPresent: false, | ||
} | ||
}, | ||
created () { | ||
if (process.client) { | ||
this.clientSentryPresent = Boolean(this.$sentry?.captureException) | ||
} | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ModuleOptions } from 'src/types' | ||
|
||
export default function (): ModuleOptions['serverConfig'] { | ||
return { | ||
beforeSend (event, _hint) { | ||
event.extra = { | ||
foo: '1', | ||
} | ||
return event | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import initJiti from 'jiti' | ||
import type { NuxtConfig } from '@nuxt/types' | ||
|
||
const jiti = initJiti(fileURLToPath(import.meta.url)) | ||
|
||
const config: NuxtConfig = { | ||
rootDir: __dirname, | ||
telemetry: false, | ||
buildModules: [ | ||
'@nuxt/typescript-build', | ||
], | ||
modules: [ | ||
jiti.resolve('../..'), | ||
], | ||
sentry: { | ||
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779', | ||
}, | ||
typescript: { | ||
typeCheck: false, | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<template> | ||
<div> | ||
<h3>Server-side</h3> | ||
<span id="server-side">{{ serverSentryPresent ? 'Works!' : '$sentry object is missing!' }}</span> | ||
<h3>Client-side</h3> | ||
<span id="client-side">{{ clientSentryPresent ? 'Works!' : '$sentry object is missing!' }}</span> | ||
<p> | ||
<button id="crash-button" @click="crash_me()"> | ||
crash me | ||
</button> | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue' | ||
export default defineComponent({ | ||
asyncData ({ $sentry, query }) { | ||
if (query.crashOnLoad) { | ||
// @ts-ignore forces a crash | ||
// eslint-disable-next-line no-undef | ||
crashOnLoad() | ||
} | ||
if (process.server) { | ||
return { | ||
serverSentryPresent: Boolean($sentry?.captureException), | ||
} | ||
} | ||
}, | ||
data () { | ||
return { | ||
clientSentryPresent: false, | ||
serverSentryPresent: false, | ||
} | ||
}, | ||
created () { | ||
if (process.client) { | ||
this.clientSentryPresent = Boolean(this.$sentry?.captureException) | ||
} | ||
}, | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"types": [ | ||
"@nuxt/typescript-build", | ||
] | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Context } from '@nuxt/types' | ||
import type { ModuleOptions } from 'src/types' | ||
|
||
export default function (_context: Context): ModuleOptions['clientIntegrations'] { | ||
return {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ModuleOptions } from 'src/types' | ||
|
||
export default function (): ModuleOptions['serverConfig'] { | ||
return { | ||
beforeSend (event, _hint) { | ||
event.extra = { | ||
foo: '1', | ||
} | ||
return event | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import initJiti from 'jiti' | ||
import type { NuxtConfig } from '@nuxt/types' | ||
|
||
const jiti = initJiti(fileURLToPath(import.meta.url)) | ||
|
||
const config: NuxtConfig = { | ||
rootDir: __dirname, | ||
telemetry: false, | ||
build: { | ||
terser: false, | ||
}, | ||
render: { | ||
resourceHints: false, | ||
}, | ||
buildModules: [ | ||
'@nuxt/typescript-build', | ||
], | ||
modules: [ | ||
jiti.resolve('../../..'), | ||
], | ||
sentry: { | ||
dsn: 'https://fe8b7df6ea7042f69d7a97c66c2934f7@sentry.io.nuxt/1429779', | ||
clientIntegrations: { | ||
// Integration from @Sentry/browser package. | ||
TryCatch: { eventTarget: false }, | ||
Replay: {}, | ||
}, | ||
clientConfig: { | ||
// This sets the sample rate to be 10%. You may want this to be 100% while | ||
// in development and sample at a lower rate in production | ||
replaysSessionSampleRate: 0.1, | ||
// If the entire session is not sampled, use the below sample rate to sample | ||
// sessions when an error occurs. | ||
replaysOnErrorSampleRate: 1.0, | ||
}, | ||
customClientIntegrations: '~/config/custom-client-integrations.ts', | ||
serverConfig: '~/config/server.config', | ||
tracing: true, | ||
}, | ||
typescript: { | ||
typeCheck: false, | ||
}, | ||
} | ||
|
||
export default config |
Oops, something went wrong.