Skip to content

Commit 8cad62a

Browse files
authored
feat(nuxt): add bad connection detection to example page (#966)
1 parent aefa4a2 commit 8cad62a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- feat(nextjs): Add connectivity check to example page([#951](https://github.com/getsentry/sentry-wizard/pull/951))
88
- feat(nextjs): Improve error names in example page to better differentiate between frontend and API errors ([#944](https://github.com/getsentry/sentry-wizard/pull/944))
99
- fix(remix): linting issues in generated client init code ([#949](https://github.com/getsentry/sentry-wizard/pull/949))
10+
- feat(nuxt): Add connectivity check to example page ([#966](https://github.com/getsentry/sentry-wizard/pull/966))
1011
- feat(remix): Add connectivity check to example page([#967](https://github.com/getsentry/sentry-wizard/pull/967))
1112

1213
## 4.7.0

src/nuxt/templates.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ Feel free to delete this file.
158158
import { useFetch} from '#imports'
159159
160160
const hasSentError = ref(false);
161+
const isConnected = ref(true);
162+
163+
onMounted(async () => {
164+
try {
165+
const result = await Sentry.diagnoseSdkConnectivity();
166+
isConnected.value = result !== 'sentry-unreachable';
167+
} catch (error) {
168+
isConnected.value = false;
169+
}
170+
});
161171
162172
function getSentryData() {
163173
Sentry.startSpan(
@@ -205,6 +215,9 @@ Feel free to delete this file.
205215
<p v-if="hasSentError" class="success">
206216
Sample error was sent to Sentry.
207217
</p>
218+
<div v-else-if="!isConnected" class="connectivity-error">
219+
<p>The Sentry SDK is not able to reach Sentry right now - this may be due to an adblocker. For more information, see <a target="_blank" href="https://docs.sentry.io/platforms/javascript/guides/nuxt/troubleshooting/#the-sdk-is-not-sending-any-data">the troubleshooting guide</a>.</p>
220+
</div>
208221
<div v-else class="success_placeholder" />
209222
210223
<div class="flex-spacer" />
@@ -321,7 +334,24 @@ Feel free to delete this file.
321334
.success_placeholder {
322335
height: 46px;
323336
}
337+
338+
.connectivity-error {
339+
padding: 12px 16px;
340+
background-color: #E50045;
341+
border-radius: 8px;
342+
width: 500px;
343+
color: #FFFFFF;
344+
border: 1px solid #A80033;
345+
text-align: center;
346+
margin: 0;
347+
}
348+
349+
.connectivity-error a {
350+
color: #FFFFFF;
351+
text-decoration: underline;
352+
}
324353
</style>
354+
325355
`;
326356
}
327357

0 commit comments

Comments
 (0)