promptIsDismissed.tsx 836 B

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