Skip to content

Commit fa2defb

Browse files
author
Elias Hussary
authored
feat(profiling): profiling onboarding sidebar (#41322)
## Summary **Important:** This PR depends on: getsentry/sentry-docs#5778 Adds the new profiling onboarding sidebar behind a `profiling-onboarding-checklist` feature flag. Examples: ![image](https://user-images.githubusercontent.com/7349258/201730207-8f81480b-258c-4808-8545-3ef5f3684d81.png) ![image](https://user-images.githubusercontent.com/7349258/201730239-9678f3f3-9f3d-43a4-ab45-7ab8a8fb8123.png)
1 parent 418b319 commit fa2defb

File tree

13 files changed

+471
-38
lines changed

13 files changed

+471
-38
lines changed

build-utils/integration-docs-fetch-plugin.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
/* eslint import/no-nodejs-modules:0 */
33

44
import fs from 'fs';
5+
import http from 'http';
56
import https from 'https';
67
import path from 'path';
8+
import url from 'url';
79

810
import webpack from 'webpack';
911

10-
const PLATFORMS_URL = 'https://docs.sentry.io/_platforms/_index.json';
12+
const INTEGRATIONS_DOC_URL =
13+
process.env.INTEGRATION_DOCS_URL || 'https://docs.sentry.io/_platforms/';
14+
const PLATFORMS_URL = INTEGRATIONS_DOC_URL + '_index.json';
1115
const DOCS_INDEX_PATH = 'src/sentry/integration-docs/_platforms.json';
1216

1317
const alphaSortFromKey =
@@ -68,8 +72,13 @@ class IntegrationDocsFetchPlugin {
6872
fetch: Parameters<webpack.Compiler['hooks']['beforeRun']['tapAsync']>[1] = (
6973
_compilation,
7074
callback
71-
) =>
72-
https
75+
) => {
76+
let httpClient = https;
77+
if (url.parse(PLATFORMS_URL).protocol === 'http:') {
78+
// @ts-ignore
79+
httpClient = http;
80+
}
81+
return httpClient
7382
.get(PLATFORMS_URL, res => {
7483
res.setEncoding('utf8');
7584
let buffer = '';
@@ -88,6 +97,7 @@ class IntegrationDocsFetchPlugin {
8897
);
8998
})
9099
.on('error', callback);
100+
};
91101

92102
apply(compiler: webpack.Compiler) {
93103
compiler.hooks.beforeRun.tapAsync('IntegrationDocsFetchPlugin', this.fetch);

src/sentry/utils/integrationdocs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Platform(TypedDict):
3535
integrations: list[dict[str, str]]
3636

3737

38-
BASE_URL = "https://docs.sentry.io/_platforms/{}"
38+
INTEGRATION_DOCS_URL = os.environ.get("INTEGRATION_DOCS_URL", "https://docs.sentry.io/_platforms/")
39+
BASE_URL = INTEGRATION_DOCS_URL + "{}"
3940

4041
# Also see INTEGRATION_DOC_FOLDER in setup.py
4142
DOC_FOLDER = os.environ.get("INTEGRATION_DOC_FOLDER") or os.path.abspath(

static/app/components/onboardingWizard/useOnboardingDocs.spec.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
generateDocKeys,
77
isPlatformSupported,
88
} from 'sentry/components/performanceOnboarding/utils';
9+
import {PlatformIntegration} from 'sentry/types';
910
import {OrganizationContext} from 'sentry/views/organizationContext';
1011

1112
describe('useOnboardingDocs', function () {
@@ -39,7 +40,13 @@ describe('useOnboardingDocs', function () {
3940
});
4041

4142
const {result, waitForNextUpdate} = reactHooks.renderHook(useOnboardingDocs, {
42-
initialProps: {project, generateDocKeys, isPlatformSupported},
43+
initialProps: {
44+
project,
45+
docKeys,
46+
isPlatformSupported: isPlatformSupported({
47+
id: project.platform,
48+
} as PlatformIntegration),
49+
},
4350
wrapper,
4451
});
4552
await waitForNextUpdate();
@@ -87,7 +94,13 @@ describe('useOnboardingDocs', function () {
8794
});
8895

8996
const {result} = reactHooks.renderHook(useOnboardingDocs, {
90-
initialProps: {project, generateDocKeys, isPlatformSupported},
97+
initialProps: {
98+
project,
99+
docKeys,
100+
isPlatformSupported: isPlatformSupported({
101+
id: project.platform,
102+
} as PlatformIntegration),
103+
},
91104
wrapper,
92105
});
93106
const {docContents, isLoading, hasOnboardingContents} = result.current;
@@ -130,7 +143,13 @@ describe('useOnboardingDocs', function () {
130143
});
131144

132145
const {result} = reactHooks.renderHook(useOnboardingDocs, {
133-
initialProps: {project, generateDocKeys, isPlatformSupported},
146+
initialProps: {
147+
project,
148+
docKeys,
149+
isPlatformSupported: isPlatformSupported({
150+
id: project.platform,
151+
} as PlatformIntegration),
152+
},
134153
wrapper,
135154
});
136155
const {docContents, isLoading, hasOnboardingContents} = result.current;

static/app/components/onboardingWizard/useOnboardingDocs.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ import {useEffect, useState} from 'react';
22
import * as Sentry from '@sentry/react';
33

44
import {loadDocs} from 'sentry/actionCreators/projects';
5-
import {PlatformKey} from 'sentry/data/platformCategories';
65
import platforms from 'sentry/data/platforms';
7-
import {PlatformIntegration, Project} from 'sentry/types';
6+
import {Project} from 'sentry/types';
87
import useApi from 'sentry/utils/useApi';
98
import useOrganization from 'sentry/utils/useOrganization';
109

1110
const INITIAL_LOADING_DOCS = {};
1211
const INITIAL_DOC_CONTENTS = {};
1312

1413
type Options = {
15-
generateDocKeys: (platform: PlatformKey) => string[];
16-
isPlatformSupported: (platform: undefined | PlatformIntegration) => boolean;
14+
docKeys: string[];
15+
isPlatformSupported: boolean;
1716
project: Project;
1817
};
1918

20-
function useOnboardingDocs({generateDocKeys, isPlatformSupported, project}: Options) {
19+
function useOnboardingDocs({docKeys, isPlatformSupported, project}: Options) {
2120
const organization = useOrganization();
2221
const api = useApi();
2322

@@ -30,11 +29,8 @@ function useOnboardingDocs({generateDocKeys, isPlatformSupported, project}: Opti
3029
? platforms.find(p => p.id === project.platform)
3130
: undefined;
3231

33-
const isSupported = isPlatformSupported(currentPlatform);
34-
const docKeys = currentPlatform && generateDocKeys(currentPlatform.id);
35-
3632
useEffect(() => {
37-
if (!isSupported) {
33+
if (!isPlatformSupported) {
3834
if (loadingDocs !== INITIAL_LOADING_DOCS) {
3935
setLoadingDocs(INITIAL_LOADING_DOCS);
4036
}
@@ -44,7 +40,7 @@ function useOnboardingDocs({generateDocKeys, isPlatformSupported, project}: Opti
4440
return;
4541
}
4642

47-
docKeys?.forEach(docKey => {
43+
docKeys.forEach(docKey => {
4844
if (docKey in loadingDocs) {
4945
// If a documentation content is loading, we should not attempt to fetch it again.
5046
// otherwise, if it's not loading, we should only fetch at most once.
@@ -91,15 +87,15 @@ function useOnboardingDocs({generateDocKeys, isPlatformSupported, project}: Opti
9187
}, [
9288
currentPlatform,
9389
docKeys,
94-
isSupported,
90+
isPlatformSupported,
9591
api,
9692
loadingDocs,
9793
organization.slug,
9894
project.slug,
9995
docContents,
10096
]);
10197

102-
if (!currentPlatform || !isSupported) {
98+
if (!currentPlatform || !isPlatformSupported) {
10399
return {
104100
isLoading: false,
105101
hasOnboardingContents: false,
@@ -121,6 +117,7 @@ function useOnboardingDocs({generateDocKeys, isPlatformSupported, project}: Opti
121117
);
122118

123119
return {
120+
docKeys,
124121
isLoading,
125122
hasOnboardingContents,
126123
docContents,

static/app/components/performanceOnboarding/sidebar.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,21 @@ function OnboardingContent({currentProject}: {currentProject: Project}) {
179179
}
180180
}, [previousProject.id, currentProject.id]);
181181

182+
const currentPlatform = currentProject.platform
183+
? platforms.find(p => p.id === currentProject.platform)
184+
: undefined;
185+
186+
const docKeys = currentPlatform ? generateDocKeys(currentPlatform.id) : [];
182187
const {docContents, isLoading, hasOnboardingContents} = useOnboardingDocs({
183188
project: currentProject,
184-
generateDocKeys,
185-
isPlatformSupported,
189+
docKeys,
190+
isPlatformSupported: isPlatformSupported(currentPlatform),
186191
});
187192

188193
if (isLoading) {
189194
return <LoadingIndicator />;
190195
}
191196

192-
const currentPlatform = currentProject.platform
193-
? platforms.find(p => p.id === currentProject.platform)
194-
: undefined;
195-
196197
const doesNotSupportPerformance = currentProject.platform
197198
? withoutPerformanceSupport.has(currentProject.platform)
198199
: false;
@@ -237,8 +238,6 @@ function OnboardingContent({currentProject}: {currentProject: Project}) {
237238
);
238239
}
239240

240-
const docKeys = generateDocKeys(currentPlatform.id);
241-
242241
return (
243242
<Fragment>
244243
<div>

0 commit comments

Comments
 (0)