dataConsentPriorityLearnMore.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {useEffect} from 'react';
  2. import styled from '@emotion/styled';
  3. import bannerStar from 'sentry-images/spot/banner-star.svg';
  4. import {usePrompt} from 'sentry/actionCreators/prompts';
  5. import {Button} from 'sentry/components/button';
  6. import {IconClose} from 'sentry/icons';
  7. import {t} from 'sentry/locale';
  8. import {space} from 'sentry/styles/space';
  9. import {defined} from 'sentry/utils';
  10. import getOrganizationAge from 'sentry/utils/getOrganizationAge';
  11. import useOrganization from 'sentry/utils/useOrganization';
  12. import {openDataConsentModal} from 'getsentry/actionCreators/modal';
  13. import withSubscription from 'getsentry/components/withSubscription';
  14. import type {Subscription} from 'getsentry/types';
  15. import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics';
  16. function DataConsentPriorityLearnMore({subscription}: {subscription?: Subscription}) {
  17. const organization = useOrganization();
  18. const hasBillingAccess = organization.access.includes('org:billing');
  19. const {isLoading, isError, isPromptDismissed, dismissPrompt} = usePrompt({
  20. feature: 'data_consent_priority',
  21. organization,
  22. });
  23. const organizationAge = getOrganizationAge(organization);
  24. const hideDataConsentBanner =
  25. isLoading ||
  26. isError ||
  27. isPromptDismissed ||
  28. organization.aggregatedDataConsent ||
  29. !hasBillingAccess ||
  30. !subscription ||
  31. (defined(subscription.msaUpdatedForDataConsent)
  32. ? !subscription.msaUpdatedForDataConsent
  33. : false) ||
  34. organizationAge < 60 ||
  35. organizationAge > 120;
  36. useEffect(() => {
  37. if (!hideDataConsentBanner) {
  38. trackGetsentryAnalytics('data_consent_priority.viewed', {organization});
  39. }
  40. }, [hideDataConsentBanner, organization]);
  41. if (hideDataConsentBanner) {
  42. return null;
  43. }
  44. return (
  45. <LearnMoreWrapper>
  46. <BannerStar1 src={bannerStar} />
  47. <BannerStar2 src={bannerStar} />
  48. <BannerStar3 src={bannerStar} />
  49. <p>
  50. <strong>{t('Want better priority?')}</strong>
  51. </p>
  52. <p>{t('Help us improve models that better predict the priority of issues.')}</p>
  53. <LearnMoreButton
  54. analyticsEventKey="data_consent_priority.learn_more"
  55. analyticsEventName="Data Consent Priority: Learn More"
  56. onClick={() => openDataConsentModal()}
  57. size="xs"
  58. >
  59. {t('Learn More')}
  60. </LearnMoreButton>
  61. <DismissButton
  62. analyticsEventKey="data_consent_priority.dismiss"
  63. analyticsEventName="Data Consent Priority: Dismiss"
  64. size="zero"
  65. borderless
  66. icon={<IconClose size="xs" />}
  67. aria-label={t('Dismiss')}
  68. onClick={() => dismissPrompt()}
  69. />
  70. </LearnMoreWrapper>
  71. );
  72. }
  73. export default withSubscription(DataConsentPriorityLearnMore);
  74. const LearnMoreWrapper = styled('div')`
  75. position: relative;
  76. max-width: 230px;
  77. color: ${p => p.theme.textColor};
  78. font-size: ${p => p.theme.fontSizeSmall};
  79. padding: ${space(1.5)};
  80. border-top: 1px solid ${p => p.theme.innerBorder};
  81. border-radius: 0 0 ${p => p.theme.borderRadius} ${p => p.theme.borderRadius};
  82. overflow: hidden;
  83. background: linear-gradient(
  84. 269.35deg,
  85. ${p => p.theme.backgroundTertiary} 0.32%,
  86. rgba(245, 243, 247, 0) 99.69%
  87. );
  88. p {
  89. margin: 0 0 ${space(0.5)} 0;
  90. }
  91. `;
  92. const DismissButton = styled(Button)`
  93. position: absolute;
  94. top: ${space(1)};
  95. right: ${space(1.5)};
  96. color: ${p => p.theme.subText};
  97. `;
  98. const BannerStar1 = styled('img')`
  99. position: absolute;
  100. bottom: 10px;
  101. right: 100px;
  102. `;
  103. const BannerStar2 = styled('img')`
  104. position: absolute;
  105. top: 10px;
  106. right: 60px;
  107. transform: rotate(-20deg) scale(0.8);
  108. `;
  109. const BannerStar3 = styled('img')`
  110. position: absolute;
  111. bottom: 30px;
  112. right: 20px;
  113. transform: rotate(60deg) scale(0.85);
  114. `;
  115. const LearnMoreButton = styled(Button)`
  116. margin-top: 2px;
  117. `;