Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6fcfd42

Browse files
committedNov 18, 2015
Updates to the tests
1 parent eaa2418 commit 6fcfd42

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed
 

‎src/EventBuilder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ export class EventBuilder {
116116
this.target.data = {};
117117
}
118118

119-
this.target.data[name] = JSON.parse(Utils.stringify(value, this.client.config.dataExclusions.concat(excludedPropertyNames || []), maxDepth));
119+
let result = JSON.parse(Utils.stringify(value, this.client.config.dataExclusions.concat(excludedPropertyNames || []), maxDepth));
120+
if (!Utils.isEmpty(result)) {
121+
this.target.data[name] = result;
122+
}
123+
120124
return this;
121125
}
122126

‎src/Utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class Utils {
4343
}
4444
}
4545

46-
return result;
46+
return !Utils.isEmpty(result) ? result : null;
4747
}
4848

4949
public static guid(): string {
@@ -104,7 +104,7 @@ export class Utils {
104104
}
105105
}
106106

107-
return result;
107+
return !Utils.isEmpty(result) ? result : null;
108108
}
109109

110110
public static randomNumber(): number {
@@ -160,6 +160,10 @@ export class Utils {
160160
});
161161
}
162162

163+
public static isEmpty(input:Object) {
164+
return input === null || (typeof(input) === 'object' && Object.keys(input).length === 0);
165+
}
166+
163167
/**
164168
* Stringifys an object with optional exclusions and max depth.
165169
* @param data The data object to add.

‎src/plugins/default/ConfigurationDefaultsPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export class ConfigurationDefaultsPlugin implements IEventPlugin {
1919
let defaultData:Object = config.defaultData || {};
2020
for (let key in defaultData) {
2121
if (!!defaultData[key]) {
22-
context.event.data[key] = JSON.parse(Utils.stringify(defaultData[key], config.dataExclusions));
22+
let result = JSON.parse(Utils.stringify(defaultData[key], config.dataExclusions));
23+
if (!Utils.isEmpty(result)) {
24+
context.event.data[key] = result;
25+
}
2326
}
2427
}
2528

‎src/plugins/default/ErrorPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class ErrorPlugin implements IEventPlugin {
4141
let result = parser.parse(context, exception);
4242
if (!!result) {
4343
let additionalData = JSON.parse(Utils.stringify(exception, config.dataExclusions.concat(this.ignoredProperties)));
44-
if (!!additionalData) {
44+
if (!Utils.isEmpty(additionalData)) {
4545
if (!result.data) {
4646
result.data = {};
4747
}

0 commit comments

Comments
 (0)
Please sign in to comment.