Skip to content

Commit 02b14b1

Browse files
committed
Merge remote-tracking branch 'origin/master' into feature/storage
Conflicts: package.json
2 parents 018a209 + ed51418 commit 02b14b1

14 files changed

+167
-25
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 1.3.{build}
22

33
install:
4-
- ps: Install-Product node 4
4+
- ps: Install-Product node 5
55
- npm install -g tsd
66
- npm install -g gulp
77
- npm install -g bower

dist/exceptionless.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ export declare class Configuration implements IConfigurationSettings {
198198
private _serverUrl;
199199
serverUrl: string;
200200
private _dataExclusions;
201+
private _userAgentBotPatterns;
201202
dataExclusions: string[];
202203
addDataExclusions(...exclusions: string[]): void;
204+
userAgentBotPatterns: string[];
205+
addUserAgentBotPatterns(...userAgentBotPatterns: string[]): void;
203206
plugins: IEventPlugin[];
204207
addPlugin(plugin: IEventPlugin): void;
205208
addPlugin(name: string, priority: number, pluginAction: (context: EventPluginContext, next?: () => void) => void): void;
@@ -230,6 +233,8 @@ export declare class EventBuilder {
230233
setUserIdentity(userInfo: IUserInfo): EventBuilder;
231234
setUserIdentity(identity: string): EventBuilder;
232235
setUserIdentity(identity: string, name: string): EventBuilder;
236+
setUserDescription(emailAddress: string, description: string): EventBuilder;
237+
setManualStackingKey(manualStackingKey: string): EventBuilder;
233238
setValue(value: number): EventBuilder;
234239
addTags(...tags: string[]): EventBuilder;
235240
setProperty(name: string, value: any, maxDepth?: number, excludedPropertyNames?: string[]): EventBuilder;

dist/exceptionless.js

Lines changed: 40 additions & 4 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: 42 additions & 7 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.

dist/submitSync.js

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/submitSync.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.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"url": "git://github.com/exceptionless/Exceptionless.JavaScript.git"
2727
},
2828
"devDependencies": {
29-
"chai": "3.4.1",
29+
"chai": "3.5.0",
3030
"del": "2.2.0",
31-
"es5-shim": "4.5.0",
31+
"es5-shim": "4.5.2",
3232
"es6-shim": "0.34.2",
3333
"gulp": "3.9.0",
3434
"gulp-concat": "2.6.0",
@@ -42,9 +42,9 @@
4242
"rimraf": "2.5.1",
4343
"source-map-support": "0.4.0",
4444
"mock-fs": "3.6.0",
45-
"tracekit": "0.3.1",
45+
"tracekit": "0.3.2",
4646
"tslint": "3.3.0",
47-
"tsproject": "1.2.0-rc.4",
47+
"tsproject": "1.2.0-rc.8",
4848
"typescript": "1.7.5",
4949
"typescript-formatter": "1.2.0"
5050
},

src/EventBuilder.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class EventBuilder {
4747
* Allows you to reference a parent event by its ReferenceId property. This allows you to have parent and child relationships.
4848
* @param name Reference name
4949
* @param id The reference id that points to a specific event
50+
* @returns {EventBuilder}
5051
*/
5152
public setEventReference(name: string, id: string): EventBuilder {
5253
if (!name) {
@@ -95,6 +96,34 @@ export class EventBuilder {
9596
return this;
9697
}
9798

99+
/**
100+
* Sets the user's description of the event.
101+
*
102+
* @param emailAddress The email address
103+
* @param description The user's description of the event.
104+
* @returns {EventBuilder}
105+
*/
106+
public setUserDescription(emailAddress: string, description: string): EventBuilder {
107+
if (emailAddress && description) {
108+
this.setProperty('@user_description', { email_address: emailAddress, description: description });
109+
}
110+
111+
return this;
112+
}
113+
114+
/**
115+
* Changes default stacking behavior by setting the stacking key.
116+
* @param manualStackingKey The manual stacking key.
117+
* @returns {EventBuilder}
118+
*/
119+
public setManualStackingKey(manualStackingKey: string): EventBuilder {
120+
if (manualStackingKey) {
121+
this.setProperty('@manual_stacking_key', manualStackingKey);
122+
}
123+
124+
return this;
125+
}
126+
98127
public setValue(value: number): EventBuilder {
99128
if (!!value) {
100129
this.target.value = value;

src/configuration/Configuration.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ export class Configuration implements IConfigurationSettings {
178178
*/
179179
private _dataExclusions: string[] = [];
180180

181+
/**
182+
* A list of user agent patterns.
183+
* @type {Array}
184+
* @private
185+
*/
186+
private _userAgentBotPatterns: string[] = [];
187+
181188
/**
182189
* A list of exclusion patterns that will automatically remove any data that
183190
* matches them from any data submitted to the server.
@@ -205,6 +212,29 @@ export class Configuration implements IConfigurationSettings {
205212
this._dataExclusions = Utils.addRange<string>(this._dataExclusions, ...exclusions);
206213
}
207214

215+
/**
216+
* A list of user agent patterns that will cause any event with a matching user agent to not be submitted.
217+
*
218+
* For example, entering *Bot* will cause any events that contains a user agent of Bot will not be submitted.
219+
*
220+
* @returns {string[]}
221+
*/
222+
public get userAgentBotPatterns(): string[] {
223+
let patterns: string = this.settings['@@UserAgentBotPatterns'];
224+
return this._userAgentBotPatterns.concat(patterns && patterns.split(',') || []);
225+
}
226+
227+
/**
228+
* Add items to the list of user agent patterns that will cause any event with a matching user agent to not be submitted.
229+
*
230+
* For example, entering *Bot* will cause any events that contains a user agent of Bot will not be submitted.
231+
*
232+
* @param userAgentBotPatterns
233+
*/
234+
public addUserAgentBotPatterns(...userAgentBotPatterns: string[]) {
235+
this._userAgentBotPatterns = Utils.addRange<string>(this._userAgentBotPatterns, ...userAgentBotPatterns);
236+
}
237+
208238
/**
209239
* The list of plugins that will be used in this configuration.
210240
* @returns {IEventPlugin[]}

src/plugins/default/RequestInfoPlugin.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IEventPlugin } from '../IEventPlugin';
22
import { EventPluginContext } from '../EventPluginContext';
33
import { IRequestInfo } from '../../models/IRequestInfo';
4+
import { Utils } from '../../Utils';
45

56
export class RequestInfoPlugin implements IEventPlugin {
67
public priority: number = 70;
@@ -9,11 +10,17 @@ export class RequestInfoPlugin implements IEventPlugin {
910
public run(context: EventPluginContext, next?: () => void): void {
1011
const REQUEST_KEY: string = '@request'; // optimization for minifier.
1112

12-
let collector = context.client.config.requestInfoCollector;
13+
let config = context.client.config;
14+
let collector = config.requestInfoCollector;
1315
if (!context.event.data[REQUEST_KEY] && !!collector) {
1416
let requestInfo: IRequestInfo = collector.getRequestInfo(context);
1517
if (!!requestInfo) {
16-
context.event.data[REQUEST_KEY] = requestInfo;
18+
if (Utils.isMatch(requestInfo.user_agent, config.userAgentBotPatterns)) {
19+
context.log.info('Cancelling event as the request user agent matches a known bot pattern');
20+
context.cancelled = true;
21+
} else {
22+
context.event.data[REQUEST_KEY] = requestInfo;
23+
}
1724
}
1825
}
1926

0 commit comments

Comments
 (0)