-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.es
62 lines (57 loc) · 1.43 KB
/
index.es
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
import * as Sentry from '@sentry/electron'
import semver from 'semver'
import { init } from './sentry'
if (
process.env.NODE_ENV === 'production' &&
semver.lte(window.POI_VERSION, '10.6.0') &&
config.get('poi.misc.exceptionReporting')
) {
init({
build: window.LATEST_COMMIT,
paths: [window.ROOT, window.APPDATA_PATH],
})
}
import {
QuestReporter,
CreateShipReporter,
CreateItemReporter,
DropShipReporter,
NightContactReportor,
RemodelRecipeReporter,
AACIReporter,
NightBattleCIReporter,
ShipStatReporter,
} from './reporters'
let reporters = []
const handleResponse = e => {
const { method, path, body, postBody, time = Date.now() } = e.detail
for (const reporter of reporters) {
try {
reporter.handle(method, path, body, postBody, time)
} catch (err) {
Sentry.captureException(err, {
area: 'poi-plugin-report',
path,
})
console.error(err.stack)
}
}
}
export const show = false
export const pluginDidLoad = e => {
reporters = [
new QuestReporter(),
new CreateShipReporter(),
new CreateItemReporter(),
new DropShipReporter(),
new NightContactReportor(),
new RemodelRecipeReporter(),
new AACIReporter(),
new NightBattleCIReporter(),
new ShipStatReporter(),
]
window.addEventListener('game.response', handleResponse)
}
export const pluginWillUnload = e => {
window.removeEventListener('game.response', handleResponse)
}