Skip to content

Commit 65d5cd3

Browse files
authored
feat(perf): Use @sentry/status-page-list for domain status link (#68899)
Use [`@sentry/domain-status-list`](https://github.com/getsentry/status-page-list), which is where we're going to keep a domain --> status page lookup. Load the library async when the component is rendered so we don't increase everyone's bundle. Right now it's about 14KB. - Add package - Use `status-page-list` library
1 parent 0eeffcc commit 65d5cd3

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@sentry/node": "^7.109.0",
6363
"@sentry/react": "^7.109.0",
6464
"@sentry/release-parser": "^1.3.1",
65+
"@sentry/status-page-list": "^0.0.1",
6566
"@sentry/types": "^7.109.0",
6667
"@sentry/utils": "^7.109.0",
6768
"@spotlightjs/spotlight": "^1.2.13",

static/app/views/performance/http/domainStatusLink.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import ExternalLink from 'sentry/components/links/externalLink';
44
import {IconOpen} from 'sentry/icons';
55
import {t} from 'sentry/locale';
66
import {space} from 'sentry/styles/space';
7-
import {DOMAIN_STATUS_PAGE_URLS} from 'sentry/views/performance/http/domainStatusPageURLs';
7+
import {useStatusPageList} from 'sentry/views/performance/http/useStatusPageList';
88

99
interface Props {
1010
domain?: string;
1111
}
1212

1313
export function DomainStatusLink({domain}: Props) {
14+
const statusPageList = useStatusPageList();
15+
1416
if (!domain) {
1517
return null;
1618
}
1719

20+
const statusPageURL = statusPageList?.domainToStatusPageUrls?.[domain];
21+
22+
if (!statusPageURL) {
23+
return null;
24+
}
25+
1826
return (
19-
<ExternalDomainLink href={DOMAIN_STATUS_PAGE_URLS[domain]}>
27+
<ExternalDomainLink href={statusPageURL}>
2028
{t('Status')}
2129
<IconOpen />
2230
</ExternalDomainLink>

static/app/views/performance/http/domainStatusPageURLs.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {useCallback, useEffect, useState} from 'react';
2+
3+
import {useIsMountedRef} from 'sentry/utils/useIsMountedRef';
4+
5+
export function useStatusPageList() {
6+
const isMountedRef = useIsMountedRef();
7+
const [mod, setMod] = useState<any>({});
8+
9+
const loader = useCallback(async () => {
10+
const loaded = await import('@sentry/status-page-list');
11+
12+
if (isMountedRef.current) {
13+
setMod(loaded);
14+
}
15+
}, [isMountedRef]);
16+
17+
useEffect(() => {
18+
loader();
19+
}, [loader]);
20+
21+
return mod;
22+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,11 @@
30793079
"@sentry/types" "7.109.0"
30803080
"@sentry/utils" "7.109.0"
30813081

3082+
"@sentry/status-page-list@^0.0.1":
3083+
version "0.0.1"
3084+
resolved "https://registry.yarnpkg.com/@sentry/status-page-list/-/status-page-list-0.0.1.tgz#fb65dc67496067798dcd9b3285589ded63f0ecd1"
3085+
integrity sha512-LQSBWck49vqHdnt9gGKshlwtzhHLqTCAc7H1AIOF66BMmEkpsOzXjhloE7tJ8ufbuIHnPGvBseydA2CcSzwQTQ==
3086+
30823087
"@sentry/types@7.109.0", "@sentry/types@^7.109.0":
30833088
version "7.109.0"
30843089
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.109.0.tgz#d8778358114ed05be734661cc9e1e261f4494947"

0 commit comments

Comments
 (0)