-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathutils.tsx
73 lines (67 loc) · 2.8 KB
/
utils.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {DataCategoryExact} from 'sentry/types/core';
import type {OrganizationSummary} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {NOTIFICATION_SETTINGS_PATHNAMES} from 'sentry/views/settings/account/notifications/constants';
/**
* Which fine-tuning parts are grouped by project
*/
const notificationsByProject = ['alerts', 'email', 'workflow', 'spikeProtection'];
export const isGroupedByProject = (notificationType: string): boolean =>
notificationsByProject.includes(notificationType);
export const getParentKey = (notificationType: string): string => {
return isGroupedByProject(notificationType) ? 'project' : 'organization';
};
export const groupByOrganization = (
projects: Project[]
): Record<string, {organization: OrganizationSummary; projects: Project[]}> => {
return projects.reduce<
Record<string, {organization: OrganizationSummary; projects: Project[]}>
>((acc, project) => {
const orgSlug = project.organization.slug;
if (acc.hasOwnProperty(orgSlug)) {
acc[orgSlug]!.projects.push(project);
} else {
acc[orgSlug] = {
organization: project.organization,
projects: [project],
};
}
return acc;
}, {});
};
/**
* Returns a link to docs on explaining how to manage quotas for that event type
*/
export function getDocsLinkForEventType(
event: DataCategoryExact | string // TODO(isabella): get rid of strings after removing need for backward compatibility on gs
) {
switch (event) {
case DataCategoryExact.TRANSACTION:
// For pre-AM3 plans prior to June 11th, 2024
return 'https://docs.sentry.io/pricing/quotas/legacy-manage-transaction-quota/';
case DataCategoryExact.SPAN:
case DataCategoryExact.SPAN_INDEXED:
case 'span_indexed':
// For post-AM3 plans after June 11th, 2024
return 'https://docs.sentry.io/pricing/quotas/manage-transaction-quota/';
case DataCategoryExact.ATTACHMENT:
return 'https://docs.sentry.io/product/accounts/quotas/manage-attachments-quota/#2-rate-limiting';
case DataCategoryExact.REPLAY:
return 'https://docs.sentry.io/product/session-replay/';
case DataCategoryExact.MONITOR_SEAT:
return 'https://docs.sentry.io/product/crons/';
case DataCategoryExact.PROFILE_DURATION:
return 'https://docs.sentry.io/product/explore/profiling/';
default:
return 'https://docs.sentry.io/product/accounts/quotas/manage-event-stream-guide/#common-workflows-for-managing-your-event-stream';
}
}
/**
* Returns the corresponding notification type name from the router path name
*/
export function getNotificationTypeFromPathname(routerPathname: string) {
const result = Object.entries(NOTIFICATION_SETTINGS_PATHNAMES).find(
([_, pathname]) => pathname === routerPathname
) ?? [routerPathname];
return result[0];
}