|
@@ -10,6 +10,13 @@ import {
|
|
|
|
|
|
type Config = Record<IssueCategory, IssueCategoryConfigMapping>;
|
|
|
|
|
|
+type IssueCategoryAndType = {
|
|
|
+ issueCategory: IssueCategory;
|
|
|
+ issueType?: IssueType;
|
|
|
+};
|
|
|
+
|
|
|
+type GetConfigForIssueTypeParams = {eventOccurrenceType: number} | IssueCategoryAndType;
|
|
|
+
|
|
|
const BASE_CONFIG: IssueTypeConfig = {
|
|
|
actions: {
|
|
|
delete: {enabled: false},
|
|
@@ -35,18 +42,35 @@ const issueTypeConfig: Config = {
|
|
|
[IssueCategory.PROFILE]: profileConfig,
|
|
|
};
|
|
|
|
|
|
+const eventOccurrenceTypeToIssueCategory = (eventOccurrenceType: number) => {
|
|
|
+ if (eventOccurrenceType >= 2000) {
|
|
|
+ return IssueCategory.PROFILE;
|
|
|
+ }
|
|
|
+ if (eventOccurrenceType >= 1000) {
|
|
|
+ return IssueCategory.PERFORMANCE;
|
|
|
+ }
|
|
|
+ return IssueCategory.ERROR;
|
|
|
+};
|
|
|
+
|
|
|
+export const getIssueCategoryAndTypeFromOccurrenceType = (
|
|
|
+ eventOccurrenceType: number
|
|
|
+): IssueCategoryAndType => {
|
|
|
+ return {
|
|
|
+ issueCategory: eventOccurrenceTypeToIssueCategory(eventOccurrenceType),
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* Given an issue category and optional issue type, returns the corresponding config.
|
|
|
* If an entry is not found in the issue type config, it looks in the default category
|
|
|
* configuration. If not found there, it takes from the base config.
|
|
|
*/
|
|
|
-export const getConfigForIssueType = ({
|
|
|
- issueCategory,
|
|
|
- issueType,
|
|
|
-}: {
|
|
|
- issueCategory: IssueCategory;
|
|
|
- issueType?: IssueType;
|
|
|
-}) => {
|
|
|
+export const getConfigForIssueType = (params: GetConfigForIssueTypeParams) => {
|
|
|
+ const {issueCategory, issueType} =
|
|
|
+ 'eventOccurrenceType' in params
|
|
|
+ ? getIssueCategoryAndTypeFromOccurrenceType(params.eventOccurrenceType)
|
|
|
+ : params;
|
|
|
+
|
|
|
const categoryMap = issueTypeConfig[issueCategory];
|
|
|
|
|
|
if (!categoryMap) {
|