Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(onboarding): Consolidate Manual button in integrations #77795

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions static/app/gettingStartedDocs/node/awslambda.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
import type {
BasePlatformOptions,
Docs,
DocsParams,
OnboardingConfig,
Expand All @@ -12,9 +13,33 @@ import {
} from 'sentry/components/onboarding/gettingStartedDoc/utils/feedbackOnboarding';
import {getJSServerMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
import {t, tct} from 'sentry/locale';
import {trackAnalytics} from 'sentry/utils/analytics';
import {getInstallConfig, getSdkInitSnippet} from 'sentry/utils/gettingStartedDocs/node';

type Params = DocsParams;
export enum InstallationMode {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this repetition very verbose and have the feeling we could make it more reusable 🤔

AUTO = 'auto',
MANUAL = 'manual',
}

const platformOptions = {
installationMode: {
label: t('Installation Mode'),
items: [
{
label: t('Auto'),
value: InstallationMode.AUTO,
},
{
label: t('Manual'),
value: InstallationMode.MANUAL,
},
],
defaultValue: InstallationMode.AUTO,
},
} satisfies BasePlatformOptions;

type PlatformOptions = typeof platformOptions;
type Params = DocsParams<PlatformOptions>;

const getSdkSetupSnippet = (params: Params) => `
// IMPORTANT: Make sure to import and initialize Sentry at the top of your file.
Expand All @@ -39,7 +64,7 @@ Sentry.init({
// },
});`;

const onboarding: OnboardingConfig = {
const onboarding: OnboardingConfig<PlatformOptions> = {
install: params => [
{
type: StepType.INSTALL,
Expand Down Expand Up @@ -87,9 +112,21 @@ const onboarding: OnboardingConfig = {
],
},
],
onPlatformOptionsChange(params) {
return option => {
if (option.installationMode === InstallationMode.MANUAL) {
trackAnalytics('integrations.switch_manual_sdk_setup', {
integration_type: 'first_party',
integration: 'aws_lambda',
view: 'onboarding',
organization: params.organization,
});
}
};
},
};

const customMetricsOnboarding: OnboardingConfig = {
const customMetricsOnboarding: OnboardingConfig<PlatformOptions> = {
install: params => [
{
type: StepType.INSTALL,
Expand Down Expand Up @@ -122,7 +159,7 @@ const customMetricsOnboarding: OnboardingConfig = {
verify: getJSServerMetricsOnboarding().verify,
};

const crashReportOnboarding: OnboardingConfig = {
const crashReportOnboarding: OnboardingConfig<PlatformOptions> = {
introduction: () => getCrashReportModalIntroduction(),
install: (params: Params) => getCrashReportJavaScriptInstallStep(params),
configure: () => [
Expand All @@ -137,10 +174,11 @@ const crashReportOnboarding: OnboardingConfig = {
nextSteps: () => [],
};

const docs: Docs = {
const docs: Docs<PlatformOptions> = {
onboarding,
customMetricsOnboarding,
crashReportOnboarding,
platformOptions,
};

export default docs;
44 changes: 41 additions & 3 deletions static/app/gettingStartedDocs/python/awslambda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Alert from 'sentry/components/alert';
import ExternalLink from 'sentry/components/links/externalLink';
import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
import {
type BasePlatformOptions,
type Docs,
DocsPageLocation,
type DocsParams,
Expand All @@ -13,8 +14,32 @@ import {getPythonMetricsOnboarding} from 'sentry/components/onboarding/gettingSt
import {crashReportOnboardingPython} from 'sentry/gettingStartedDocs/python/python';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {trackAnalytics} from 'sentry/utils/analytics';

type Params = DocsParams;
export enum InstallationMode {
AUTO = 'auto',
MANUAL = 'manual',
}

const platformOptions = {
installationMode: {
label: t('Installation Mode'),
items: [
{
label: t('Auto'),
value: InstallationMode.AUTO,
},
{
label: t('Manual'),
value: InstallationMode.MANUAL,
},
],
defaultValue: InstallationMode.AUTO,
},
} satisfies BasePlatformOptions;

type PlatformOptions = typeof platformOptions;
type Params = DocsParams<PlatformOptions>;

const getInstallSnippet = () => `pip install --upgrade sentry-sdk`;

Expand Down Expand Up @@ -53,7 +78,7 @@ sentry_sdk.init(
],
)`;

const onboarding: OnboardingConfig = {
const onboarding: OnboardingConfig<PlatformOptions> = {
introduction: () =>
tct(
'Create a deployment package on your local machine and install the required dependencies in the deployment package. For more information, see [link:AWS Lambda deployment package in Python].',
Expand Down Expand Up @@ -146,14 +171,27 @@ const onboarding: OnboardingConfig = {
},
],
verify: () => [],
onPlatformOptionsChange(params) {
return option => {
if (option.installationMode === InstallationMode.MANUAL) {
trackAnalytics('integrations.switch_manual_sdk_setup', {
integration_type: 'first_party',
integration: 'aws_lambda',
view: 'onboarding',
organization: params.organization,
});
}
};
},
};

const docs: Docs = {
const docs: Docs<PlatformOptions> = {
onboarding,
customMetricsOnboarding: getPythonMetricsOnboarding({
installSnippet: getInstallSnippet(),
}),
crashReportOnboarding: crashReportOnboardingPython,
platformOptions,
};

export default docs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function AddInstallationInstructions() {
</p>
<p>
{tct(
'If you don’t want to add CloudFormation stack to your AWS environment, press the [manualSetup] button instead.',
{manualSetup: <strong>{t('Manual Setup')}</strong>}
'If you don’t want to add CloudFormation stack to your AWS environment, press the [manual] button above instead.',
{manual: <strong>{t('Manual')}</strong>}
)}
</p>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import {useCallback} from 'react';

import {decodeBoolean, decodeList} from 'sentry/utils/queryString';
import {decodeBoolean, decodeList, decodeScalar} from 'sentry/utils/queryString';
import useLocationQuery from 'sentry/utils/url/useLocationQuery';
import {useLocation} from 'sentry/utils/useLocation';
import {useNavigate} from 'sentry/utils/useNavigate';

type QueryValues = {
/**
* Used to show the installation mode for certain platforms, e.g. manual or auto.
* This is defined inside of a platform file
*/
installationMode: string;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more refactoring is needed, I would like to get this from the hook useLoadGettingStarted but added this here for now.

/**
* Used to show product selection (error monitoring, tracing, profiling and session replay) for certain platforms, e.g. javascript-react
*/
Expand All @@ -31,6 +36,7 @@ export function useOnboardingQueryParams(): [
product: decodeList,
showLoader: decodeBoolean,
showManualSetup: decodeBoolean,
installationMode: decodeScalar,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also it would be better to return MANUAL or AUTO from an enum but I did not want to add a custom decode here now

},
});

Expand Down
Loading
Loading