Skip to content

Commit 17b2988

Browse files
Brian Vaughnkoto
Brian Vaughn
authored andcommitted
Add GitHub API query to bug report template (facebook#21421)
This may help debug why sometimes the GitHub API search seems to not find a match when it should.
1 parent 8b83403 commit 17b2988

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ReportNewIssue.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import * as React from 'react';
1111
import Icon from '../Icon';
12+
import {searchGitHubIssuesURL} from './githubAPI';
1213
import styles from './shared.css';
1314

1415
function encodeURIWrapper(string: string): string {
@@ -31,6 +32,9 @@ export default function ReportNewIssue({
3132
return null;
3233
}
3334

35+
const gitHubAPISearch =
36+
errorMessage !== null ? searchGitHubIssuesURL(errorMessage) : '(none)';
37+
3438
const title = `Error: "${errorMessage || ''}"`;
3539
const labels = ['Component: Developer Tools', 'Status: Unconfirmed'];
3640

@@ -57,10 +61,13 @@ If possible, please describe how to reproduce this bug on the website or app men
5761
DevTools version: ${process.env.DEVTOOLS_VERSION || ''}
5862
5963
Call stack:
60-
${callStack || '(not available)'}
64+
${callStack || '(none)'}
6165
6266
Component stack:
63-
${componentStack || '(not available)'}
67+
${componentStack || '(none)'}
68+
69+
GitHub URL search query:
70+
${gitHubAPISearch}
6471
`;
6572

6673
bugURL += `/issues/new?labels=${encodeURIWrapper(

packages/react-devtools-shared/src/devtools/views/ErrorBoundary/githubAPI.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export type GitHubIssue = {|
1414

1515
const GITHUB_ISSUES_API = 'https://api.github.com/search/issues';
1616

17-
export async function searchGitHubIssues(
18-
message: string,
19-
): Promise<GitHubIssue | null> {
17+
export function searchGitHubIssuesURL(message: string): string {
2018
// Remove Fiber IDs from error message (as those will be unique).
2119
message = message.replace(/"[0-9]+"/g, '');
2220

@@ -29,13 +27,19 @@ export async function searchGitHubIssues(
2927
'repo:facebook/react',
3028
];
3129

32-
const response = await fetch(
30+
return (
3331
GITHUB_ISSUES_API +
34-
'?q=' +
35-
encodeURIComponent(message) +
36-
'%20' +
37-
filters.map(encodeURIComponent).join('%20'),
32+
'?q=' +
33+
encodeURIComponent(message) +
34+
'%20' +
35+
filters.map(encodeURIComponent).join('%20')
3836
);
37+
}
38+
39+
export async function searchGitHubIssues(
40+
message: string,
41+
): Promise<GitHubIssue | null> {
42+
const response = await fetch(searchGitHubIssuesURL(message));
3943
const data = await response.json();
4044
if (data.items.length > 0) {
4145
const item = data.items[0];

0 commit comments

Comments
 (0)