Skip to content

Commit a2fc9c6

Browse files
committed
Fixed an issue where server settings were not being properly converted to boolean values.
1 parent 8d8319d commit a2fc9c6

9 files changed

+76
-23
lines changed

dist/exceptionless.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export declare class Utils {
189189
static startsWith(input: string, prefix: string): boolean;
190190
static endsWith(input: string, suffix: string): boolean;
191191
static stringify(data: any, exclusions?: string[], maxDepth?: number): string;
192+
static toBoolean(input: any): boolean;
192193
}
193194
export declare class Configuration implements IConfigurationSettings {
194195
private static _defaultSettings;

dist/exceptionless.js

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,16 @@ export class Utils {
225225

226226
return stringifyImpl(data, exclusions);
227227
}
228+
229+
public static toBoolean(input): boolean {
230+
if (!input || !input.toLowerCase) {
231+
return !!input;
232+
}
233+
234+
switch (input.toLowerCase().trim()) {
235+
case 'true': case 'yes': case '1': return true;
236+
case 'false': case 'no': case '0': case null: return false;
237+
default: return Boolean(input);
238+
}
239+
}
228240
}

src/plugins/default/EventExclusionPlugin.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,44 +38,48 @@ export class EventExclusionPlugin implements IEventPlugin {
3838
return defaultValue;
3939
}
4040

41+
let isLog = type === 'log';
4142
let sourcePrefix = `@@${type}:`;
42-
if (settings[sourcePrefix + source]) {
43-
return settings[sourcePrefix + source];
43+
44+
let value = settings[sourcePrefix + source];
45+
if (value) {
46+
return !isLog ? Utils.toBoolean(value) : value;
4447
}
4548

4649
// check for wildcard match
4750
for (let key in settings) {
4851
if (Utils.startsWith(key.toLowerCase(), sourcePrefix.toLowerCase()) && Utils.isMatch(source, [key.substring(sourcePrefix.length)])) {
49-
return settings[key];
52+
return !isLog ? Utils.toBoolean(settings[key]) : settings[key];
5053
}
5154
}
5255

5356
return defaultValue;
5457
}
5558

5659
let ev = context.event;
60+
let log = context.log;
5761
let settings = context.client.config.settings;
5862

5963
if (ev.type === 'log') {
6064
let minLogLevel = getMinLogLevel(settings, ev.source);
6165
let logLevel = getLogLevel(ev.data['@level']);
6266

6367
if (logLevel >= 0 && (logLevel > 5 || logLevel < minLogLevel)) {
64-
context.log.info('Cancelling log event due to minimum log level.');
68+
log.info('Cancelling log event due to minimum log level.');
6569
context.cancelled = true;
6670
}
6771
} else if (ev.type === 'error') {
6872
let error: IInnerError = ev.data['@error'];
6973
while (!context.cancelled && error) {
7074
if (getTypeAndSourceSetting(settings, ev.type, error.type, true) === false) {
71-
context.log.info(`Cancelling error from excluded exception type: ${error.type}`);
75+
log.info(`Cancelling error from excluded exception type: ${error.type}`);
7276
context.cancelled = true;
7377
}
7478

7579
error = error.inner;
7680
}
7781
} else if (getTypeAndSourceSetting(settings, ev.type, ev.source, true) === false) {
78-
context.log.info(`Cancelling event from excluded type: ${ev.type} and source: ${ev.source}`);
82+
log.info(`Cancelling event from excluded type: ${ev.type} and source: ${ev.source}`);
7983
context.cancelled = true;
8084
}
8185

0 commit comments

Comments
 (0)