forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurationDefaultsPlugin.ts
More file actions
31 lines (27 loc) · 1 KB
/
ConfigurationDefaultsPlugin.ts
File metadata and controls
31 lines (27 loc) · 1 KB
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
import { IEventPlugin } from '../IEventPlugin';
import { EventPluginContext } from '../EventPluginContext';
import { Utils } from '../../Utils';
export class ConfigurationDefaultsPlugin implements IEventPlugin {
public priority: number = 10;
public name: string = 'ConfigurationDefaultsPlugin';
public run(context: EventPluginContext, next?: () => void): void {
let config = context.client.config;
let defaultTags: string[] = config.defaultTags || [];
for (let index = 0; index < defaultTags.length; index++) {
let tag = defaultTags[index];
if (!!tag && context.event.tags.indexOf(tag) < 0) {
context.event.tags.push(tag);
}
}
let defaultData: Object = config.defaultData || {};
for (let key in defaultData) {
if (!!defaultData[key]) {
let result = JSON.parse(Utils.stringify(defaultData[key], config.dataExclusions));
if (!Utils.isEmpty(result)) {
context.event.data[key] = result;
}
}
}
next && next();
}
}