-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
setup-sentry-mobile.js
58 lines (53 loc) · 1.63 KB
/
setup-sentry-mobile.js
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
// SPDX-FileCopyrightText: 2022 The Manyverse Authors
//
// SPDX-License-Identifier: MPL-2.0
import * as Sentry from '@sentry/react-native';
const path = require('path');
import FS from 'react-native-fs';
import versionName from './lib/frontend/versionName';
export default function setupSentryMobile() {
const settingsFile = path.join(
FS.DocumentDirectoryPath,
'.ssb',
'manyverse-settings.json',
);
FS.readFile(settingsFile, 'utf8').then(
(json) => {
if (!json) return;
let settings = {};
try {
settings = JSON.parse(json);
} catch (err) {
return;
}
if (!settings.allowCrashReports) return;
Sentry.init({
dsn: 'https://f0ac0805d95145e9aeb98ecd42d3ed4b@o1400646.ingest.sentry.io/6730238',
release: versionName,
sendDefaultPii: false,
beforeSend(ev) {
delete ev.user;
delete ev.breadcrumbs;
if (ev.contexts?.culture) delete ev.contexts.culture;
if (ev.contexts?.device?.timezone) delete ev.contexts.device.timezone;
if (ev.contexts?.device?.language) delete ev.contexts.device.language;
if (ev.contexts?.device?.locale) delete ev.contexts.device.locale;
ev.tags = ev.tags || {};
ev.tags.side = 'frontend';
ev.tags.platform = 'mobile';
return ev;
},
beforeBreadcrumb(breadcrumb) {
return null;
},
});
Sentry.setUser(null);
},
(err) => {
if (err.code !== 'ENOENT') {
console.log('Error loading settings file for allowCrashReports:');
console.error(err);
}
},
);
}