onboarding.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import {RouteContextInterface} from 'react-router';
  2. import {Organization, Project} from 'sentry/types';
  3. import {OnboardingState} from 'sentry/views/onboarding/targetedOnboarding/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. }
  24. export type OnboardingSupplementComponentProps = {
  25. onCompleteTask: () => void;
  26. task: OnboardingTask;
  27. };
  28. export type OnboardingCustomComponentProps = {
  29. onboardingState: OnboardingState | null;
  30. organization: Organization;
  31. projects: Project[];
  32. setOnboardingState: (state: OnboardingState | null) => void;
  33. task: OnboardingTask;
  34. };
  35. export type OnboardingTaskDescriptor = {
  36. description: string;
  37. /**
  38. * Should the onboarding task currently be displayed
  39. */
  40. display: boolean;
  41. /**
  42. * A list of require task keys that must have been completed before these
  43. * tasks may be completed.
  44. */
  45. requisites: OnboardingTaskKey[];
  46. /**
  47. * Can this task be skipped?
  48. */
  49. skippable: boolean;
  50. task: OnboardingTaskKey;
  51. title: string;
  52. /**
  53. * An extra component that may be rendered within the onboarding task item.
  54. */
  55. SupplementComponent?: React.ComponentType<OnboardingSupplementComponentProps>;
  56. /**
  57. * If a render function was provided, it will be used to render the entire card,
  58. * and the card will be rendered before any other cards regardless of completion status.
  59. * the render function is therefore responsible for determining the completion status
  60. * of the card by returning null when it's completed.
  61. *
  62. * Note that this should not be given a react component.
  63. */
  64. renderCard?: (props: OnboardingCustomComponentProps) => JSX.Element | null;
  65. /**
  66. * Joins with this task id for server-side onboarding state.
  67. * This allows you to create alias for exising onboarding tasks or create multiple
  68. * tasks for the same server-side task.
  69. */
  70. serverTask?: string;
  71. } & (
  72. | {
  73. actionType: 'app' | 'external';
  74. location: string;
  75. }
  76. | {
  77. action: (props: RouteContextInterface) => void;
  78. actionType: 'action';
  79. }
  80. );
  81. export type OnboardingTaskStatus = {
  82. status: 'skipped' | 'pending' | 'complete';
  83. task: OnboardingTaskKey;
  84. completionSeen?: string;
  85. data?: {[key: string]: string};
  86. dateCompleted?: string;
  87. user?: AvatarUser | null;
  88. };
  89. export type OnboardingTask = OnboardingTaskStatus &
  90. OnboardingTaskDescriptor & {
  91. /**
  92. * Onboarding tasks that are currently incomplete and must be completed
  93. * before this task should be completed.
  94. */
  95. requisiteTasks: OnboardingTask[];
  96. };