onboarding.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import {RouteContextInterface} from 'react-router';
  2. import {Organization, Project} from 'sentry/types';
  3. import {OnboardingState} from 'sentry/views/onboarding/types';
  4. import type {AvatarUser} from './user';
  5. export enum OnboardingTaskKey {
  6. FIRST_PROJECT = 'create_project',
  7. FIRST_EVENT = 'send_first_event',
  8. INVITE_MEMBER = 'invite_member',
  9. SECOND_PLATFORM = 'setup_second_platform',
  10. USER_CONTEXT = 'setup_user_context',
  11. RELEASE_TRACKING = 'setup_release_tracking',
  12. SOURCEMAPS = 'setup_sourcemaps',
  13. USER_REPORTS = 'setup_user_reports',
  14. ISSUE_TRACKER = 'setup_issue_tracker',
  15. ALERT_RULE = 'setup_alert_rules',
  16. FIRST_TRANSACTION = 'setup_transactions',
  17. METRIC_ALERT = 'setup_metric_alert_rules',
  18. USER_SELECTED_PROJECTS = 'setup_userselected_projects',
  19. /// Customized card that shows the selected integrations during onboarding
  20. INTEGRATIONS = 'integrations',
  21. /// Regular card that tells the user to setup integrations if no integrations were selected during onboarding
  22. FIRST_INTEGRATION = 'setup_integrations',
  23. /// Demo New Walkthrough Tasks
  24. SIDEBAR_GUIDE = 'sidebar_guide',
  25. ISSUE_GUIDE = 'issue_guide',
  26. RELEASE_GUIDE = 'release_guide',
  27. PERFORMANCE_GUIDE = 'performance_guide',
  28. }
  29. export type OnboardingSupplementComponentProps = {
  30. onCompleteTask: () => void;
  31. task: OnboardingTask;
  32. };
  33. export type OnboardingCustomComponentProps = {
  34. onboardingState: OnboardingState | null;
  35. organization: Organization;
  36. projects: Project[];
  37. setOnboardingState: (state: OnboardingState | null) => void;
  38. task: OnboardingTask;
  39. };
  40. interface OnboardingTaskDescriptorBase {
  41. description: string;
  42. /**
  43. * Should the onboarding task currently be displayed
  44. */
  45. display: boolean;
  46. /**
  47. * A list of require task keys that must have been completed before these
  48. * tasks may be completed.
  49. */
  50. requisites: OnboardingTaskKey[];
  51. /**
  52. * Can this task be skipped?
  53. */
  54. skippable: boolean;
  55. task: OnboardingTaskKey;
  56. title: string;
  57. /**
  58. * An extra component that may be rendered within the onboarding task item.
  59. */
  60. SupplementComponent?: React.ComponentType<OnboardingSupplementComponentProps>;
  61. /**
  62. * If a render function was provided, it will be used to render the entire card,
  63. * and the card will be rendered before any other cards regardless of completion status.
  64. * the render function is therefore responsible for determining the completion status
  65. * of the card by returning null when it's completed.
  66. *
  67. * Note that this should not be given a react component.
  68. */
  69. renderCard?: (props: OnboardingCustomComponentProps) => JSX.Element | null;
  70. /**
  71. * Joins with this task id for server-side onboarding state.
  72. * This allows you to create alias for exising onboarding tasks or create multiple
  73. * tasks for the same server-side task.
  74. */
  75. serverTask?: string;
  76. }
  77. interface OnboardingTypeDescriptorWithAction extends OnboardingTaskDescriptorBase {
  78. action: (props: RouteContextInterface) => void;
  79. actionType: 'action';
  80. }
  81. interface OnboardingTypeDescriptorWithExternal extends OnboardingTaskDescriptorBase {
  82. actionType: 'app' | 'external';
  83. location: string;
  84. }
  85. export type OnboardingTaskDescriptor =
  86. | OnboardingTypeDescriptorWithAction
  87. | OnboardingTypeDescriptorWithExternal;
  88. export interface OnboardingTaskStatus {
  89. status: 'skipped' | 'pending' | 'complete';
  90. task: OnboardingTaskKey;
  91. completionSeen?: string | boolean;
  92. data?: {[key: string]: string};
  93. dateCompleted?: string;
  94. user?: AvatarUser | null;
  95. }
  96. interface OnboardingTaskWithAction
  97. extends OnboardingTaskStatus,
  98. OnboardingTypeDescriptorWithAction {
  99. /**
  100. * Onboarding tasks that are currently incomplete and must be completed
  101. * before this task should be completed.
  102. */
  103. requisiteTasks: OnboardingTaskDescriptor[];
  104. }
  105. interface OnboardingTaskWithExternal
  106. extends OnboardingTaskStatus,
  107. OnboardingTypeDescriptorWithExternal {
  108. /**
  109. * Onboarding tasks that are currently incomplete and must be completed
  110. * before this task should be completed.
  111. */
  112. requisiteTasks: OnboardingTaskDescriptor[];
  113. }
  114. export type OnboardingTask = OnboardingTaskWithAction | OnboardingTaskWithExternal;