forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleInfoPlugin.ts
More file actions
22 lines (19 loc) · 913 Bytes
/
ModuleInfoPlugin.ts
File metadata and controls
22 lines (19 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { ModuleInfo } from "../../models/data/ModuleInfo.js";
import { KnownEventDataKeys } from "../../models/Event.js";
import { EventPluginContext } from "../EventPluginContext.js";
import { IEventPlugin } from "../IEventPlugin.js";
export class ModuleInfoPlugin implements IEventPlugin {
public priority: number = 50;
public name: string = "ModuleInfoPlugin";
public run(context: EventPluginContext): Promise<void> {
const collector = context.client.config.moduleCollector;
// PERF: Ensure module info is cached and rework below statement.
if (context.event.data[KnownEventDataKeys.Error] && !context.event.data[KnownEventDataKeys.Error]?.modules && collector) {
const modules: ModuleInfo[] = collector.getModules();
if (modules && modules.length > 0) {
context.event.data[KnownEventDataKeys.Error].modules = modules;
}
}
return Promise.resolve();
}
}