Skip to content

Commit cb91621

Browse files
committed
Do not load Sentry on localhost
1 parent 14c6b02 commit cb91621

File tree

1 file changed

+56
-46
lines changed

1 file changed

+56
-46
lines changed

src/ui/layouts/Layout.astro

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,67 @@
22
// import '../styles/index.css'
33
44
interface Props {
5-
title: string
6-
bg?: boolean
5+
title: string
6+
bg?: boolean
77
}
88
99
const {title} = Astro.props
1010
---
1111

1212
<!doctype html>
1313
<html lang="en">
14-
<head>
15-
<meta charset="utf-8" />
16-
<title>{title}</title>
17-
<meta name="description" content="A video card game for the web" />
18-
<meta
19-
name="viewport"
20-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover"
21-
/>
22-
<meta name="mobile-web-app-capable" content="yes" />
23-
<meta name="theme-color" content="#116f54" />
24-
<meta name="msapplication-TileColor" content="#116f54" />
25-
<link rel="icon" type="image/png" href="/images/favicons/favicon-512.png" sizes="512x512" />
26-
<link rel="shortcut icon" href="/images/favicons/favicon.ico" />
27-
<link rel="apple-touch-icon" href="/images/favicon-512.png" />
28-
<link
29-
rel="preload"
30-
href="https://assets.slaytheweb.cards/fonts/heliotrope/heliotrope_4_regular.woff2"
31-
as="font"
32-
type="font/woff2"
33-
crossorigin
34-
/>
35-
<link
36-
rel="preload"
37-
href="https://assets.slaytheweb.cards/fonts/heliotrope/heliotrope_4_bold.woff2"
38-
as="font"
39-
type="font/woff2"
40-
crossorigin
41-
/>
42-
<script>
43-
const environment = import.meta.env.PROD ? 'production' : 'development'
44-
const pkgVersion = import.meta.env.PUBLIC_VERSION
45-
window.sentryOnLoad = function() {
46-
Sentry.init({
47-
environment,
48-
release: "slaytheweb@" + pkgVersion
49-
})
50-
}
51-
</script>
52-
<script src="https://js.sentry-cdn.com/8dfaea3ae774cfc8d9a79fdac78b2c5d.min.js" crossorigin="anonymous"
53-
></script>
54-
</head>
55-
<body>
56-
<slot />
57-
</body>
14+
<head>
15+
<meta charset="utf-8" />
16+
<title>{title}</title>
17+
<meta name="description" content="A video card game for the web" />
18+
<meta
19+
name="viewport"
20+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, viewport-fit=cover"
21+
/>
22+
<meta name="mobile-web-app-capable" content="yes" />
23+
<meta name="theme-color" content="#116f54" />
24+
<meta name="msapplication-TileColor" content="#116f54" />
25+
<link rel="icon" type="image/png" href="/images/favicons/favicon-512.png" sizes="512x512" />
26+
<link rel="shortcut icon" href="/images/favicons/favicon.ico" />
27+
<link rel="apple-touch-icon" href="/images/favicon-512.png" />
28+
<link
29+
rel="preload"
30+
href="https://assets.slaytheweb.cards/fonts/heliotrope/heliotrope_4_regular.woff2"
31+
as="font"
32+
type="font/woff2"
33+
crossorigin
34+
/>
35+
<link
36+
rel="preload"
37+
href="https://assets.slaytheweb.cards/fonts/heliotrope/heliotrope_4_bold.woff2"
38+
as="font"
39+
type="font/woff2"
40+
crossorigin
41+
/>
42+
<script>
43+
// Load Sentry if not on localhost.
44+
const environment = import.meta.env.PROD ? 'production' : 'development'
45+
const pkgVersion = import.meta.env.PUBLIC_VERSION
46+
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
47+
if (!isLocalhost) {
48+
// @ts-ignore
49+
window.sentryOnLoad = function () {
50+
// @ts-ignore
51+
Sentry.init({
52+
environment,
53+
release: 'slaytheweb@' + pkgVersion,
54+
})
55+
}
56+
57+
// Dynamically load the Sentry script
58+
const sentryScript = document.createElement('script')
59+
sentryScript.src = 'https://js.sentry-cdn.com/8dfaea3ae774cfc8d9a79fdac78b2c5d.min.js'
60+
sentryScript.crossOrigin = 'anonymous'
61+
document.head.appendChild(sentryScript)
62+
}
63+
</script>
64+
</head>
65+
<body>
66+
<slot />
67+
</body>
5868
</html>

0 commit comments

Comments
 (0)