onboarding.tsx 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import type {Query} from 'history';
  2. import type {OnboardingContextProps} from 'sentry/components/onboarding/onboardingContext';
  3. import type {Category} from 'sentry/components/platformPicker';
  4. import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
  5. import type {Group} from './group';
  6. import type {Organization} from './organization';
  7. import type {PlatformIntegration, PlatformKey, Project} from './project';
  8. import type {AvatarUser} from './user';
  9. export enum OnboardingTaskGroup {
  10. GETTING_STARTED = 'getting_started',
  11. BEYOND_BASICS = 'beyond_basics',
  12. }
  13. export enum OnboardingTaskKey {
  14. FIRST_PROJECT = 'create_project',
  15. FIRST_EVENT = 'send_first_event',
  16. INVITE_MEMBER = 'invite_member',
  17. SECOND_PLATFORM = 'setup_second_platform',
  18. USER_CONTEXT = 'setup_user_context',
  19. RELEASE_TRACKING = 'setup_release_tracking',
  20. SOURCEMAPS = 'setup_sourcemaps',
  21. USER_REPORTS = 'setup_user_reports',
  22. ALERT_RULE = 'setup_alert_rules',
  23. FIRST_TRANSACTION = 'setup_transactions',
  24. METRIC_ALERT = 'setup_metric_alert_rules',
  25. USER_SELECTED_PROJECTS = 'setup_userselected_projects',
  26. REAL_TIME_NOTIFICATIONS = 'setup_real_time_notifications',
  27. LINK_SENTRY_TO_SOURCE_CODE = 'link_sentry_to_source_code',
  28. /// Customized card that shows the selected integrations during onboarding
  29. INTEGRATIONS = 'integrations',
  30. /// Regular card that tells the user to setup integrations if no integrations were selected during onboarding
  31. FIRST_INTEGRATION = 'setup_integrations',
  32. SESSION_REPLAY = 'setup_session_replay',
  33. /// Demo New Walkthrough Tasks
  34. SIDEBAR_GUIDE = 'sidebar_guide',
  35. ISSUE_GUIDE = 'issue_guide',
  36. RELEASE_GUIDE = 'release_guide',
  37. PERFORMANCE_GUIDE = 'performance_guide',
  38. }
  39. export type OnboardingSupplementComponentProps = {
  40. onCompleteTask: () => void;
  41. task: OnboardingTask;
  42. };
  43. export type OnboardingCustomComponentProps = {
  44. onboardingContext: OnboardingContextProps;
  45. organization: Organization;
  46. projects: Project[];
  47. task: OnboardingTask;
  48. };
  49. interface OnboardingTaskDescriptorBase {
  50. description: string;
  51. /**
  52. * Should the onboarding task currently be displayed
  53. */
  54. display: boolean;
  55. /**
  56. * A list of require task keys that must have been completed before these
  57. * tasks may be completed.
  58. */
  59. requisites: OnboardingTaskKey[];
  60. /**
  61. * Can this task be skipped?
  62. */
  63. skippable: boolean;
  64. task: OnboardingTaskKey;
  65. title: string;
  66. /**
  67. * An extra component that may be rendered within the onboarding task item.
  68. */
  69. SupplementComponent?: React.ComponentType<OnboardingSupplementComponentProps>;
  70. /**
  71. * The group that this task belongs to, e.g. basic and level up
  72. */
  73. group?: OnboardingTaskGroup;
  74. /**
  75. * If a render function was provided, it will be used to render the entire card,
  76. * and the card will be rendered before any other cards regardless of completion status.
  77. * the render function is therefore responsible for determining the completion status
  78. * of the card by returning null when it's completed.
  79. *
  80. * Note that this should not be given a react component.
  81. */
  82. renderCard?: (props: OnboardingCustomComponentProps) => JSX.Element | null;
  83. /**
  84. * Joins with this task id for server-side onboarding state.
  85. * This allows you to create alias for exising onboarding tasks or create multiple
  86. * tasks for the same server-side task.
  87. */
  88. serverTask?: string;
  89. }
  90. interface OnboardingTypeDescriptorWithAction extends OnboardingTaskDescriptorBase {
  91. action: (props: InjectedRouter) => void;
  92. actionType: 'action';
  93. }
  94. interface OnboardingTypeDescriptorWithExternal extends OnboardingTaskDescriptorBase {
  95. actionType: 'external';
  96. location: string;
  97. }
  98. interface OnboardingTypeDescriptorWithAppLink extends OnboardingTaskDescriptorBase {
  99. actionType: 'app';
  100. location: string | {pathname: string; query?: Query};
  101. }
  102. export type OnboardingTaskDescriptor =
  103. | OnboardingTypeDescriptorWithAction
  104. | OnboardingTypeDescriptorWithExternal
  105. | OnboardingTypeDescriptorWithAppLink;
  106. export interface OnboardingTaskStatus {
  107. status: 'skipped' | 'pending' | 'complete';
  108. task: OnboardingTaskKey;
  109. completionSeen?: string | boolean;
  110. data?: {[key: string]: string};
  111. dateCompleted?: string;
  112. user?: AvatarUser | null;
  113. }
  114. interface OnboardingTaskWithAction
  115. extends OnboardingTaskStatus,
  116. OnboardingTypeDescriptorWithAction {
  117. /**
  118. * Onboarding tasks that are currently incomplete and must be completed
  119. * before this task should be completed.
  120. */
  121. requisiteTasks: OnboardingTaskDescriptor[];
  122. }
  123. interface OnboardingTaskWithExternal
  124. extends OnboardingTaskStatus,
  125. OnboardingTypeDescriptorWithExternal {
  126. /**
  127. * Onboarding tasks that are currently incomplete and must be completed
  128. * before this task should be completed.
  129. */
  130. requisiteTasks: OnboardingTaskDescriptor[];
  131. }
  132. interface OnboardingTaskWithAppLink
  133. extends OnboardingTaskStatus,
  134. OnboardingTypeDescriptorWithAppLink {
  135. requisiteTasks: OnboardingTaskDescriptor[];
  136. }
  137. export type OnboardingTask =
  138. | OnboardingTaskWithAction
  139. | OnboardingTaskWithExternal
  140. | OnboardingTaskWithAppLink;
  141. export enum OnboardingProjectStatus {
  142. WAITING = 'waiting',
  143. PROCESSING = 'processing',
  144. PROCESSED = 'processed',
  145. }
  146. export type OnboardingSelectedSDK = {
  147. category: Category;
  148. key: PlatformKey;
  149. language: PlatformIntegration['language'];
  150. type: PlatformIntegration['type'];
  151. };
  152. export type OnboardingRecentCreatedProject = Project & {
  153. firstError: boolean;
  154. firstTransaction: boolean;
  155. hasReplays: boolean;
  156. hasSessions: boolean;
  157. olderThanOneHour: boolean;
  158. firstIssue?: Group;
  159. };
  160. export type OnboardingPlatformDoc = {html: string; link: string};