-
Notifications
You must be signed in to change notification settings - Fork 1
/
crashlytics.ts
60 lines (40 loc) · 1.73 KB
/
crashlytics.ts
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
import {logger} from "firebase-functions/v2";
import {crashlytics} from "firebase-functions/v2/alerts";
import {AppCrash} from "../models/app-crash";
import {ApiService} from "../services/chat.service";
import { EnvConfig } from "../utils/env-config";
const functionOpts = {
region: process.env.LOCATION,
secrets: ["WEBHOOK_URL"],
};
export const anr =
crashlytics.onNewAnrIssuePublished(functionOpts, async (event) => {
logger.debug("onNewAnrIssuePublished", event);
const appCrash = AppCrash.fromCrashlytics(event);
appCrash.tags.push("critical");
const apiService = new ApiService(EnvConfig.webhook);
return apiService.sendCrashlyticsMessage(appCrash);
});
export const fatal =
crashlytics.onNewFatalIssuePublished(functionOpts, async (event) => {
logger.debug("onNewFatalIssuePublished", event);
const appCrash = AppCrash.fromCrashlytics(event);
appCrash.tags.push("critical");
const apiService = new ApiService(EnvConfig.webhook);
return apiService.sendCrashlyticsMessage(appCrash);
});
export const nonfatal =
crashlytics.onNewNonfatalIssuePublished(functionOpts, async (event) => {
logger.debug("onNewNonfatalIssuePublished", event);
const appCrash = AppCrash.fromCrashlytics(event);
const apiService = new ApiService(EnvConfig.webhook);
return apiService.sendCrashlyticsMessage(appCrash);
});
export const regression =
crashlytics.onRegressionAlertPublished(functionOpts, async (event) => {
logger.debug("onRegressionAlertPublished", event);
const appCrash = AppCrash.fromCrashlytics(event);
appCrash.tags.push("regression");
const apiService = new ApiService(EnvConfig.webhook);
return apiService.sendCrashlyticsMessage(appCrash);
});