promptIsDismissed.tsx 875 B

12345678910111213141516171819202122232425262728293031323334
  1. import {PromptData} from 'sentry/actionCreators/prompts';
  2. import {snoozedDays} from './promptsActivity';
  3. export const DEFAULT_SNOOZE_PROMPT_DAYS = 14;
  4. export const promptIsDismissed = (
  5. prompt: PromptData,
  6. daysToSnooze: number = DEFAULT_SNOOZE_PROMPT_DAYS
  7. ): boolean => {
  8. if (typeof prompt?.dismissedTime === 'number') {
  9. return true;
  10. }
  11. if (typeof prompt?.snoozedTime === 'number') {
  12. return snoozedDays(prompt.snoozedTime) < daysToSnooze;
  13. }
  14. return false;
  15. };
  16. export function promptCanShow(prompt: string, uuid: string): boolean {
  17. /**
  18. * This is to ensure that only one of suspect_commits
  19. * or distributed_tracing is shown at a given time.
  20. */
  21. const x = (parseInt(uuid.charAt(0), 16) || 0) % 2;
  22. if (prompt === 'suspect_commits') {
  23. return x === 1;
  24. }
  25. if (prompt === 'distributed_tracing') {
  26. return x === 0;
  27. }
  28. return true;
  29. }