onboarding.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 {Organization} from './organization';
  6. import type {PlatformIntegration, PlatformKey, Project} from './project';
  7. import type {AvatarUser} from './user';
  8. export enum OnboardingTaskGroup {
  9. GETTING_STARTED = 'getting_started',
  10. BEYOND_BASICS = 'beyond_basics',
  11. }
  12. export enum OnboardingTaskKey {
  13. FIRST_PROJECT = 'create_project',
  14. FIRST_EVENT = 'send_first_event',
  15. INVITE_MEMBER = 'invite_member',
  16. SECOND_PLATFORM = 'setup_second_platform',
  17. RELEASE_TRACKING = 'setup_release_tracking',
  18. SOURCEMAPS = 'setup_sourcemaps',
  19. ALERT_RULE = 'setup_alert_rules',
  20. FIRST_TRANSACTION = 'setup_transactions',
  21. REAL_TIME_NOTIFICATIONS = 'setup_real_time_notifications',
  22. LINK_SENTRY_TO_SOURCE_CODE = 'link_sentry_to_source_code',
  23. SESSION_REPLAY = 'setup_session_replay',
  24. /// Demo New Walkthrough Tasks
  25. SIDEBAR_GUIDE = 'sidebar_guide',
  26. ISSUE_GUIDE = 'issue_guide',
  27. RELEASE_GUIDE = 'release_guide',
  28. PERFORMANCE_GUIDE = 'performance_guide',
  29. }
  30. export type OnboardingSupplementComponentProps = {
  31. task: OnboardingTask;
  32. onCompleteTask?: () => void;
  33. };
  34. export type OnboardingCustomComponentProps = {
  35. onboardingContext: OnboardingContextProps;
  36. organization: Organization;
  37. projects: Project[];
  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. * 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. * The group that this task belongs to, e.g. basic and level up
  58. */
  59. group?: OnboardingTaskGroup;
  60. pendingTitle?: string;
  61. /**
  62. * Joins with this task id for server-side onboarding state.
  63. * This allows you to create alias for exising onboarding tasks or create multiple
  64. * tasks for the same server-side task.
  65. */
  66. serverTask?: string;
  67. }
  68. interface OnboardingTypeDescriptorWithAction extends OnboardingTaskDescriptorBase {
  69. action: (props: InjectedRouter) => void;
  70. actionType: 'action';
  71. }
  72. interface OnboardingTypeDescriptorWithExternal extends OnboardingTaskDescriptorBase {
  73. actionType: 'external';
  74. location: string;
  75. }
  76. interface OnboardingTypeDescriptorWithAppLink extends OnboardingTaskDescriptorBase {
  77. actionType: 'app';
  78. location: string | {pathname: string; query?: Query};
  79. }
  80. export type OnboardingTaskDescriptor =
  81. | OnboardingTypeDescriptorWithAction
  82. | OnboardingTypeDescriptorWithExternal
  83. | OnboardingTypeDescriptorWithAppLink;
  84. export interface OnboardingTaskStatus {
  85. status: 'skipped' | 'pending' | 'complete';
  86. task: OnboardingTaskKey;
  87. completionSeen?: string | boolean;
  88. data?: {[key: string]: string};
  89. dateCompleted?: string;
  90. user?: AvatarUser | null;
  91. }
  92. interface OnboardingTaskWithAction
  93. extends OnboardingTaskStatus,
  94. OnboardingTypeDescriptorWithAction {}
  95. interface OnboardingTaskWithExternal
  96. extends OnboardingTaskStatus,
  97. OnboardingTypeDescriptorWithExternal {}
  98. interface OnboardingTaskWithAppLink
  99. extends OnboardingTaskStatus,
  100. OnboardingTypeDescriptorWithAppLink {}
  101. export type OnboardingTask =
  102. | OnboardingTaskWithAction
  103. | OnboardingTaskWithExternal
  104. | OnboardingTaskWithAppLink;
  105. export interface UpdatedTask extends Partial<Pick<OnboardingTask, 'status' | 'data'>> {
  106. task: OnboardingTask['task'];
  107. /**
  108. * Marks completion seen. This differs from the OnboardingTask
  109. * completionSeen type as that returns the date completion was seen.
  110. */
  111. completionSeen?: boolean;
  112. }
  113. export enum OnboardingProjectStatus {
  114. WAITING = 'waiting',
  115. PROCESSING = 'processing',
  116. PROCESSED = 'processed',
  117. }
  118. export interface OnboardingSelectedSDK
  119. extends Pick<PlatformIntegration, 'language' | 'link' | 'name' | 'type'> {
  120. category: Category;
  121. key: PlatformKey;
  122. }
  123. export type OnboardingRecentCreatedProject = {
  124. isProjectActive: boolean | undefined;
  125. project: Project | undefined;
  126. };
  127. export type OnboardingPlatformDoc = {html: string; link: string};