Pārlūkot izejas kodu

Refactor Sentry configuration and clean up .gitignore

- Updated Sentry import statements to use single quotes for consistency.
- Removed unnecessary entries from .gitignore related to Sentry configuration.
- Cleaned up formatting in sentry.client.config.ts and sentry.server.config.ts for improved readability.
- Enhanced code formatting in sentry-example-page.vue for better maintainability.
0es 3 mēneši atpakaļ
vecāks
revīzija
e9c3a5789c

+ 0 - 3
.gitignore

@@ -22,6 +22,3 @@ logs
 .env
 .env.*
 !.env.example
-
-# Sentry Config File
-.env.sentry-build-plugin

+ 70 - 47
app/pages/sentry-example-page.vue

@@ -4,45 +4,46 @@ Feel free to delete this file.
 -->
 
 <script setup>
-  import * as Sentry from '@sentry/nuxt';
+import * as Sentry from '@sentry/nuxt'
 
-  class SentryExampleFrontendError extends Error {
-    constructor(message) {
-      super(message);
-      this.name = "SentryExampleFrontendError";
-    }
+class SentryExampleFrontendError extends Error {
+  constructor(message) {
+    super(message)
+    this.name = 'SentryExampleFrontendError'
   }
+}
 
-  const hasSentError = ref(false);
-  const isConnected = ref(true);
-  
-  onMounted(async () => {
-    try {
-      const result = await Sentry.diagnoseSdkConnectivity();
-      isConnected.value = result !== 'sentry-unreachable';
-    } catch (error) {
-      isConnected.value = false;
-    }
-  });
-  
-  async function getSentryData() {
-    await Sentry.startSpan(
-      {
-        name: 'Example Frontend Span',
-        op: 'test'
-      },
-      async () => {
-        const res = await $fetch('/api/sentry-example-api', { 
-          method: 'GET',
-          ignoreResponseError: true 
-        }).catch(() => null);
-        if (!res) {
-          hasSentError.value = true;
-        }
-      }
-    );
-    throw new SentryExampleFrontendError("This error is raised on the frontend of the example page.");
+const hasSentError = ref(false)
+const isConnected = ref(true)
+
+onMounted(async () => {
+  try {
+    const result = await Sentry.diagnoseSdkConnectivity()
+    isConnected.value = result !== 'sentry-unreachable'
   }
+  catch (error) {
+    isConnected.value = false
+  }
+})
+
+async function getSentryData() {
+  await Sentry.startSpan(
+    {
+      name: 'Example Frontend Span',
+      op: 'test',
+    },
+    async () => {
+      const res = await $fetch('/api/sentry-example-api', {
+        method: 'GET',
+        ignoreResponseError: true,
+      }).catch(() => null)
+      if (!res) {
+        hasSentError.value = true
+      }
+    },
+  )
+  throw new SentryExampleFrontendError('This error is raised on the frontend of the example page.')
+}
 </script>
 
 <template>
@@ -50,35 +51,58 @@ Feel free to delete this file.
   <div>
     <main>
       <div class="flex-spacer" />
-      <svg height="40" width="40" fill="none" xmlns="http://www.w3.org/2000/svg">
-        <path d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z" fill="currentcolor"/>
+      <svg
+        height="40"
+        width="40"
+        fill="none"
+        xmlns="http://www.w3.org/2000/svg"
+      >
+        <path
+          d="M21.85 2.995a3.698 3.698 0 0 1 1.353 1.354l16.303 28.278a3.703 3.703 0 0 1-1.354 5.053 3.694 3.694 0 0 1-1.848.496h-3.828a31.149 31.149 0 0 0 0-3.09h3.815a.61.61 0 0 0 .537-.917L20.523 5.893a.61.61 0 0 0-1.057 0l-3.739 6.494a28.948 28.948 0 0 1 9.63 10.453 28.988 28.988 0 0 1 3.499 13.78v1.542h-9.852v-1.544a19.106 19.106 0 0 0-2.182-8.85 19.08 19.08 0 0 0-6.032-6.829l-1.85 3.208a15.377 15.377 0 0 1 6.382 12.484v1.542H3.696A3.694 3.694 0 0 1 0 34.473c0-.648.17-1.286.494-1.849l2.33-4.074a8.562 8.562 0 0 1 2.689 1.536L3.158 34.17a.611.611 0 0 0 .538.917h8.448a12.481 12.481 0 0 0-6.037-9.09l-1.344-.772 4.908-8.545 1.344.77a22.16 22.16 0 0 1 7.705 7.444 22.193 22.193 0 0 1 3.316 10.193h3.699a25.892 25.892 0 0 0-3.811-12.033 25.856 25.856 0 0 0-9.046-8.796l-1.344-.772 5.269-9.136a3.698 3.698 0 0 1 3.2-1.849c.648 0 1.285.17 1.847.495Z"
+          fill="currentcolor"
+        />
       </svg>
       <h1>
         sentry-example-page
       </h1>
 
       <p class="description">
-        Click the button below, and view the sample error on the Sentry <a target="_blank" href="https://gamivip.sentry.io/issues/?project=4510503931346944">Issues Page</a>.
-        For more details about setting up Sentry, <a target="_blank" href="https://docs.sentry.io/platforms/javascript/guides/nuxt/">read our docs</a>.
+        Click the button below, and view the sample error on the Sentry <a
+          target="_blank"
+          href="https://gamivip.sentry.io/issues/?project=4510503931346944"
+        >Issues Page</a>.
+        For more details about setting up Sentry, <a
+          target="_blank"
+          href="https://docs.sentry.io/platforms/javascript/guides/nuxt/"
+        >read our docs</a>.
       </p>
 
       <button
         type="button"
-        @click="getSentryData"
         :disabled="!isConnected"
+        @click="getSentryData"
       >
         <span>
           Throw Sample Error
         </span>
       </button>
 
-      <p v-if="hasSentError" class="success">
+      <p
+        v-if="hasSentError"
+        class="success"
+      >
         Sample error was sent to Sentry.
       </p>
-      <div v-else-if="!isConnected" class="connectivity-error">
+      <div
+        v-else-if="!isConnected"
+        class="connectivity-error"
+      >
         <p>It looks like network requests to Sentry are being blocked, which will prevent errors from being captured. Try disabling your ad-blocker to complete the test.</p>
       </div>
-      <div v-else class="success_placeholder" />
+      <div
+        v-else
+        class="success_placeholder"
+      />
 
       <div class="flex-spacer" />
     </main>
@@ -158,7 +182,7 @@ Feel free to delete this file.
     }
 
     &:active > span {
-      transform: translateY(0); 
+      transform: translateY(0);
     }
 
     &:disabled {
@@ -201,7 +225,7 @@ Feel free to delete this file.
   .success_placeholder {
     height: 46px;
   }
-  
+
   .connectivity-error {
     padding: 12px 16px;
     background-color: #E50045;
@@ -212,10 +236,9 @@ Feel free to delete this file.
     text-align: center;
     margin: 0;
   }
-  
+
   .connectivity-error a {
     color: #FFFFFF;
     text-decoration: underline;
   }
 </style>
-

+ 5 - 5
sentry.client.config.ts

@@ -1,9 +1,9 @@
-import * as Sentry from "@sentry/nuxt";
+import * as Sentry from '@sentry/nuxt'
 
 Sentry.init({
   // If set up, you can use your runtime config here
   // dsn: useRuntimeConfig().public.sentry.dsn,
-  dsn: "https://5a42d73350e084df0891c0c7e0e5ba3a@o4510503923220480.ingest.us.sentry.io/4510503931346944",
+  dsn: 'https://5a42d73350e084df0891c0c7e0e5ba3a@o4510503923220480.ingest.us.sentry.io/4510503931346944',
 
   // We recommend adjusting this value in production, or using tracesSampler
   // for finer control
@@ -12,11 +12,11 @@ Sentry.init({
   // 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,
-  
+
   // If you don't want to use Session Replay, just remove the line below:
   integrations: [Sentry.replayIntegration()],
 
@@ -29,4 +29,4 @@ Sentry.init({
 
   // Setting this option to true will print useful information to the console while you're setting up Sentry.
   debug: false,
-});
+})

+ 4 - 4
sentry.server.config.ts

@@ -1,7 +1,7 @@
-import * as Sentry from "@sentry/nuxt";
- 
+import * as Sentry from '@sentry/nuxt'
+
 Sentry.init({
-  dsn: "https://5a42d73350e084df0891c0c7e0e5ba3a@o4510503923220480.ingest.us.sentry.io/4510503931346944",
+  dsn: 'https://5a42d73350e084df0891c0c7e0e5ba3a@o4510503923220480.ingest.us.sentry.io/4510503931346944',
 
   // We recommend adjusting this value in production, or using tracesSampler
   // for finer control
@@ -16,4 +16,4 @@ Sentry.init({
 
   // Setting this option to true will print useful information to the console while you're setting up Sentry.
   debug: false,
-});
+})

+ 7 - 0
server/api/sentry-example-api.ts

@@ -0,0 +1,7 @@
+// This is just a very simple API route that throws an example error.
+// Feel free to delete this file.
+import { defineEventHandler } from '#imports'
+
+export default defineEventHandler(() => {
+  throw new Error('Sentry Example API Route Error')
+})