Skip to content

Commit

Permalink
feat(profiling): add continuous profiling toggle to notification sett…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
brendanhsentry committed Oct 16, 2024
1 parent ca4f5d1 commit d11a70d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions static/app/views/settings/account/notifications/fields2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ export const QUOTA_FIELDS = [
['never', t('Off')],
] as const,
},
{
name: 'quotaProfileDuration',
label: t('Continuous Profiling'),
help: tct(
'Receive notifications about your continuous profiling quota. [learnMore:Learn more]',
{
learnMore: <ExternalLink href={getDocsLinkForEventType('profileDuration')} />,
}
),
choices: [
['always', t('On')],
['never', t('Off')],
] as const,
},
{
name: 'quotaSpendAllocations',
label: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ describe('NotificationSettingsByType', function () {
expect(screen.getByText('Replays')).toBeInTheDocument();
expect(screen.getByText('Attachments')).toBeInTheDocument();
expect(screen.getByText('Spend Allocations')).toBeInTheDocument();
expect(screen.getByText('Continuous Profiling')).toBeInTheDocument();
expect(screen.queryByText('Transactions')).not.toBeInTheDocument();

const editSettingMock = MockApiClient.addMockResponse({
Expand Down Expand Up @@ -382,6 +383,28 @@ describe('NotificationSettingsByType', function () {
expect(screen.getByText('Attachments')).toBeInTheDocument();
expect(screen.getByText('Spend Allocations')).toBeInTheDocument();
expect(screen.getByText('Transactions')).toBeInTheDocument();
expect(screen.getByText('Continuous Profiling')).toBeInTheDocument();
});

it('spend notifications on org with am1 org only', async function () {
const organization = OrganizationFixture();
organization.features.push('spend-visibility-notifications');
organization.features.push('am1-tier');
const otherOrganization = OrganizationFixture();
renderComponent({
notificationType: 'quota',
organizations: [organization, otherOrganization],
});

expect(await screen.getAllByText('Spend Notifications').length).toEqual(2);

expect(screen.getByText('Errors')).toBeInTheDocument();
expect(screen.getByText('Replays')).toBeInTheDocument();
expect(screen.getByText('Attachments')).toBeInTheDocument();
expect(screen.getByText('Spend Allocations')).toBeInTheDocument();
expect(screen.getByText('Transactions')).toBeInTheDocument();
expect(screen.queryByText('Continuous Profiling')).not.toBeInTheDocument();
expect(screen.queryByText('Spans')).not.toBeInTheDocument();
});

it('spend notifications on org with am3 without spend visibility notifications', async function () {
Expand All @@ -400,6 +423,7 @@ describe('NotificationSettingsByType', function () {
expect(screen.getByText('Replays')).toBeInTheDocument();
expect(screen.getByText('Attachments')).toBeInTheDocument();
expect(screen.getByText('Spend Allocations')).toBeInTheDocument();
expect(screen.getByText('Continuous Profiling')).toBeInTheDocument();
expect(screen.queryByText('Transactions')).not.toBeInTheDocument();

const editSettingMock = MockApiClient.addMockResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const typeMappedChildren = {
'quotaAttachments',
'quotaReplays',
'quotaMonitorSeats',
'quotaProfileDuration',
'quotaWarnings',
'quotaSpendAllocations',
'quotaSpans',
Expand Down Expand Up @@ -202,8 +203,14 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
organization => !organization.features?.includes('am3-tier')
);

// at least one org exists with am2 tier plan
const hasOrgWithAm2 = organizations.some(organization =>
organization.features?.includes('am2-tier')
);

const excludeTransactions = hasOrgWithAm3 && !hasOrgWithoutAm3;
const includeSpans = hasOrgWithAm3;
const includeProfileDuration = hasOrgWithAm2 || hasOrgWithAm3;

// if a quota notification is not disabled, add in our dependent fields
// but do not show the top level controller
Expand All @@ -221,6 +228,9 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
if (field.name === 'quotaTransactions' && excludeTransactions) {
return false;
}
if (field.name === 'quotaProfileDuration' && !includeProfileDuration) {
return false;
}
return true;
}).map(field => ({
...field,
Expand All @@ -245,6 +255,9 @@ class NotificationSettingsByTypeV2 extends DeprecatedAsyncComponent<Props, State
if (field.name === 'quotaTransactions' && excludeTransactions) {
return false;
}
if (field.name === 'quotaProfileDuration' && !includeProfileDuration) {
return false;
}
return true;
}).map(field => ({
...field,
Expand Down

0 comments on commit d11a70d

Please sign in to comment.