onboarding.tsx 3.2 KB

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