Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(nuxt): Add instument.server.mjs to preview script #38

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions apps/nuxt/components/ErrorButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup>
const triggerError = () => {
throw new Error('Nuxt Button Error');
};
</script>

<template>
<button id="errorBtn" @click="triggerError">Trigger Error</button>
</template>
8 changes: 8 additions & 0 deletions apps/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ['@sentry/nuxt/module'],
sentry:{
debug: false,
sourceMapsUploadOptions: {
org: "org",
project: "proj",
authToken: process.env.SENTRY_AUTH_TOKEN,
},
},
debug: false,
});
6 changes: 4 additions & 2 deletions apps/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"preview": "NODE_OPTIONS='--import ./public/instrument.server.mjs' nuxt preview",
"postinstall": "nuxt prepare",
"clean": "npx nuxi cleanup"
},
"dependencies": {
"@sentry/nuxt": "8.17.0",
"@sentry/nuxt": "8.20.0",
"nuxt": "^3.12.2"
},
"//": {
Expand All @@ -20,6 +20,8 @@
"@sentry/core": "file:.yalc/@sentry/core",
"@sentry/node": "file:.yalc/@sentry/node",
"@sentry/nuxt": "file:.yalc/@sentry/nuxt",
"@sentry/opentelemetry": "file:.yalc/@sentry/opentelemetry",
"@sentry/types": "file:.yalc/@sentry/types",
"@sentry/utils": "file:.yalc/@sentry/utils",
"@sentry/vue": "file:.yalc/@sentry/vue"
}
Expand Down
7 changes: 7 additions & 0 deletions apps/nuxt/pages/client-error.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script setup>
import ErrorButton from '../components/ErrorButton.vue';
</script>

<template>
<ErrorButton />
</template>
14 changes: 2 additions & 12 deletions apps/nuxt/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<template>
<div><button @click="triggerError">Trigger Error</button><br /></div>
</template>

<script>
export default {
methods: {
triggerError() {
throw new Error('This is a test error for Sentry');
},
},
};
</script>
<h1>Hello!</h1>
</template>
1 change: 1 addition & 0 deletions apps/nuxt/pages/test-param/[param].vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<template>
<p>{{ $route.params.param }} - {{ $route.params.param }}</p>
<ErrorButton />
</template>
9 changes: 9 additions & 0 deletions apps/nuxt/public/instrument.server.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as Sentry from '@sentry/nuxt';

if(process.env.SENTRY_DSN) {
Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1,
debug: true,
});
}
3 changes: 1 addition & 2 deletions apps/nuxt/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ import * as Sentry from '@sentry/nuxt';
Sentry.init({
dsn: 'your-dsn',
debug: true,
tracesSampleRate: 1,
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1
});
7 changes: 0 additions & 7 deletions apps/nuxt/sentry.server.config.js

This file was deleted.

Loading
Loading