Skip to content

Commit 754e914

Browse files
committed
✨ feat: add github domain checker
1 parent ee6bf77 commit 754e914

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

docs/organization/integrations/source-code-mgmt/github/index.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ There are two types of GitHub integrations, so make sure you're choosing the cor
1212
- `https://ghe.example.com/`
1313

1414
For these accounts, follow the '[Installing GitHub Enterprise](#installing-github-enterprise)' instructions.
15+
16+
17+
### To determine which integration to use, enter your GitHub domain below:
18+
19+
<GitHubDomainChecker />
20+
21+
<br />
1522

1623
<Alert>
1724

1825
Sentry owner, manager, or admin permissions, and GitHub owner permissions are required to install this integration.
1926

2027
</Alert>
2128

29+
## Installing GitHub
30+
2231
1. Navigate to **Settings > Integrations > [GitHub](https://sentry.io/orgredirect/organizations/:orgslug/settings/integrations/github)**.
2332

2433
![Install GitHub integration](./img/github-install-page.png)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
'use client';
2+
3+
import {useState} from 'react';
4+
5+
const MAX_COMPONENTS_ON_PAGE = 100;
6+
7+
export function GitHubDomainChecker() {
8+
const [domain, setDomain] = useState('');
9+
const [isValidDomain, setIsValidDomain] = useState(false);
10+
11+
const isGitHubCom = domain.toLowerCase().trim() === 'github.com' || domain.toLowerCase().trim() === 'https://github.com';
12+
const hasInput = domain.trim().length > 0;
13+
14+
// Validate domain format
15+
const validateDomain = (inputDomain: string) => {
16+
const trimmedDomain = inputDomain.trim();
17+
if (!trimmedDomain) {
18+
setIsValidDomain(false);
19+
return;
20+
}
21+
22+
// Check if it's github.com (valid)
23+
if (trimmedDomain.toLowerCase() === 'github.com' || trimmedDomain.toLowerCase() === 'https://github.com') {
24+
setIsValidDomain(true);
25+
return;
26+
}
27+
28+
// For enterprise, check if it's a valid URL or domain format
29+
const urlPattern = /^(https?:\/\/)?([\w\-\.]+\.[\w]{2,})(\/.*)?$/;
30+
const isValidUrl = urlPattern.test(trimmedDomain);
31+
setIsValidDomain(isValidUrl);
32+
};
33+
34+
const handleDomainChange = (ev) => {
35+
const newDomain = ev.target.value;
36+
setDomain(newDomain);
37+
validateDomain(newDomain);
38+
};
39+
40+
const inputClassName =
41+
'form-input w-full rounded-md border-[1.5px] focus:ring-2 focus:ring-accent-purple/20 border-gray-200';
42+
43+
// This is to avoid in case multiple instances of this component are used on the page
44+
const randomCounter = Math.round(Math.random() * MAX_COMPONENTS_ON_PAGE);
45+
46+
return (
47+
<div className="space-y-4 p-6 border border-gray-100 rounded">
48+
<div className="flex w-full">
49+
<div className="flex items-center min-w-[16ch] px-4">
50+
<label htmlFor={`gh-domain-${randomCounter}`} className="text-nowrap">
51+
GitHub Domain
52+
</label>
53+
</div>
54+
<input
55+
id={`gh-domain-${randomCounter}`}
56+
value={domain}
57+
placeholder="https://github.com or https://ghe.example.com"
58+
className={inputClassName}
59+
onChange={handleDomainChange}
60+
/>
61+
</div>
62+
63+
{hasInput && (
64+
<div className="mt-4 p-4 rounded-md border">
65+
<div className="text-sm font-medium mb-2">
66+
Recommended Installation:
67+
</div>
68+
{isValidDomain ? (
69+
isGitHubCom ? (
70+
<div className="text-green-700 bg-green-50 p-3 rounded-md">
71+
<div className="mb-2">
72+
<strong>GitHub</strong> - Use the standard GitHub integration for github.com
73+
</div>
74+
</div>
75+
) : (
76+
<div className="text-blue-700 bg-blue-50 p-3 rounded-md">
77+
<div className="mb-2">
78+
<strong>GitHub Enterprise</strong> - Use GitHub Enterprise integration for your domain
79+
</div>
80+
</div>
81+
)
82+
) : (
83+
<div className="text-red-700 bg-red-50 p-3 rounded-md">
84+
<strong>Invalid Domain</strong> - Please enter a valid GitHub domain or URL
85+
</div>
86+
)}
87+
</div>
88+
)}
89+
</div>
90+
);
91+
}

src/mdxComponents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {DefinitionList} from './components/definitionList';
1313
import {DevDocsCardGrid} from './components/devDocsCardGrid';
1414
import DocImage from './components/docImage';
1515
import {Expandable} from './components/expandable';
16+
import {GitHubDomainChecker} from './components/githubDomainChecker';
1617
import {GuideGrid} from './components/guideGrid';
1718
import {JsBundleList} from './components/jsBundleList';
1819
import {LambdaLayerDetail} from './components/lambdaLayerDetail';
@@ -60,6 +61,7 @@ export function mdxComponents(
6061
SdkApi,
6162
TableOfContents,
6263
CreateGitHubAppForm,
64+
GitHubDomainChecker,
6365
ConfigValue,
6466
DefinitionList,
6567
Expandable,

0 commit comments

Comments
 (0)