otherSetup.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import 'prism-sentry/index.css';
  2. import {Fragment} from 'react';
  3. import styled from '@emotion/styled';
  4. import {motion} from 'framer-motion';
  5. import {Client} from 'sentry/api';
  6. import Alert from 'sentry/components/alert';
  7. import AsyncComponent from 'sentry/components/asyncComponent';
  8. import ExternalLink from 'sentry/components/links/externalLink';
  9. import {t, tct} from 'sentry/locale';
  10. import {Organization} from 'sentry/types';
  11. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  12. import getDynamicText from 'sentry/utils/getDynamicText';
  13. import withApi from 'sentry/utils/withApi';
  14. import withOrganization from 'sentry/utils/withOrganization';
  15. import {ProjectKey} from 'sentry/views/settings/project/projectKeys/types';
  16. import FirstEventFooter from './components/firstEventFooter';
  17. import FullIntroduction from './components/fullIntroduction';
  18. import {StepProps} from './types';
  19. type Props = StepProps & {
  20. api: Client;
  21. organization: Organization;
  22. } & AsyncComponent['props'];
  23. type State = {
  24. keyList: Array<ProjectKey> | null;
  25. } & AsyncComponent['state'];
  26. class OtherSetup extends AsyncComponent<Props, State> {
  27. getDefaultState() {
  28. return {
  29. ...super.getDefaultState(),
  30. keyList: null,
  31. };
  32. }
  33. getEndpoints(): ReturnType<AsyncComponent['getEndpoints']> {
  34. const {organization, project} = this.props;
  35. return [['keyList', `/projects/${organization.slug}/${project?.slug}/keys/`]];
  36. }
  37. handleFullDocsClick = () => {
  38. const {organization} = this.props;
  39. trackAdvancedAnalyticsEvent('growth.onboarding_view_full_docs', {organization});
  40. };
  41. render() {
  42. const {organization, project} = this.props;
  43. const {keyList} = this.state;
  44. const currentPlatform = 'other';
  45. const blurb = (
  46. <Fragment>
  47. <p>
  48. {tct(`Prepare the SDK for your language following this [docsLink:guide].`, {
  49. docsLink: <ExternalLink href="https://develop.sentry.dev/sdk/overview/" />,
  50. })}
  51. </p>
  52. <p>
  53. {t('Once your SDK is set up, use the following DSN and send your first event!')}
  54. </p>
  55. <p>{tct('Here is the DSN: [DSN]', {DSN: <b> {keyList?.[0].dsn.public}</b>})}</p>
  56. </Fragment>
  57. );
  58. const docs = (
  59. <DocsWrapper>
  60. {blurb}
  61. {project && (
  62. <FirstEventFooter
  63. project={project}
  64. organization={organization}
  65. docsLink="https://develop.sentry.dev/sdk"
  66. docsOnClick={this.handleFullDocsClick}
  67. />
  68. )}
  69. </DocsWrapper>
  70. );
  71. const testOnlyAlert = (
  72. <Alert type="warning">
  73. Platform documentation is not rendered in for tests in CI
  74. </Alert>
  75. );
  76. return (
  77. <Fragment>
  78. <FullIntroduction currentPlatform={currentPlatform} />
  79. {getDynamicText({
  80. value: docs,
  81. fixed: testOnlyAlert,
  82. })}
  83. </Fragment>
  84. );
  85. }
  86. }
  87. const DocsWrapper = styled(motion.div)``;
  88. DocsWrapper.defaultProps = {
  89. initial: {opacity: 0, y: 40},
  90. animate: {opacity: 1, y: 0},
  91. exit: {opacity: 0},
  92. };
  93. export default withOrganization(withApi(OtherSetup));