forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnvironmentInfoPlugin.ts
More file actions
23 lines (20 loc) · 1013 Bytes
/
EnvironmentInfoPlugin.ts
File metadata and controls
23 lines (20 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { EnvironmentInfo } from "../../models/data/EnvironmentInfo.js";
import { KnownEventDataKeys } from "../../models/Event.js";
import { EventPluginContext } from "../EventPluginContext.js";
import { IEventPlugin } from "../IEventPlugin.js";
export class EnvironmentInfoPlugin implements IEventPlugin {
public priority: number = 80;
public name: string = "EnvironmentInfoPlugin";
public run(context: EventPluginContext): Promise<void> {
// TODO: Discus if we can get rid of collectors and just add them per integration.
// PERF: Ensure module info is cached and rework below statement.
const collector = context.client.config.services.environmentInfoCollector;
if (!context.event.data[KnownEventDataKeys.EnvironmentInfo] && collector) {
const environmentInfo: EnvironmentInfo = collector.getEnvironmentInfo(context);
if (environmentInfo) {
context.event.data[KnownEventDataKeys.EnvironmentInfo] = environmentInfo;
}
}
return Promise.resolve();
}
}