Skip to content

Commit d80ddcb

Browse files
committed
Finished updating listing settings
1 parent a33191c commit d80ddcb

23 files changed

+84
-81
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"gulp-tslint": "8.0.0",
5353
"gulp-uglify": "2.1.2",
5454
"gulp-wrap-umd": "0.2.1",
55-
"jshint": "^2.9.4",
55+
"jshint": "2.9.4",
5656
"mock-fs": "4.2.0",
5757
"path": "0.12.7",
5858
"requirejs": "2.3.3",

src/EventBuilder.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export class EventBuilder {
8484
return this;
8585
}
8686

87-
public setUserIdentity(userInfo: IUserInfo | string): EventBuilder;
87+
public setUserIdentity(userInfo: IUserInfo): EventBuilder;
88+
public setUserIdentity(identity: string): EventBuilder;
8889
public setUserIdentity(identity: string, name: string): EventBuilder;
8990
public setUserIdentity(userInfoOrIdentity: IUserInfo | string, name?: string): EventBuilder {
9091
const userInfo = typeof userInfoOrIdentity !== 'string' ? userInfoOrIdentity : { identity: userInfoOrIdentity, name };

src/Utils.ts

+16-15
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export class Utils {
88
return target;
99
}
1010

11-
for (let index = 0; index < values.length; index++) {
12-
if (values[index] && target.indexOf(values[index]) < 0) {
13-
target.push(values[index]);
11+
for (const value of values) {
12+
if (value && target.indexOf(value) < 0) {
13+
target.push(value);
1414
}
1515
}
1616

@@ -32,12 +32,12 @@ export class Utils {
3232
return hash;
3333
}
3434

35-
public static getCookies(cookies: string, exclusions?: string[]): Object {
36-
const result: Object = {};
35+
public static getCookies(cookies: string, exclusions?: string[]): object {
36+
const result: object = {};
3737

3838
const parts: string[] = (cookies || '').split('; ');
39-
for (let index = 0; index < parts.length; index++) {
40-
const cookie: string[] = parts[index].split('=');
39+
for (const part of parts) {
40+
const cookie: string[] = part.split('=');
4141
if (!Utils.isMatch(cookie[0], exclusions)) {
4242
result[cookie[0]] = cookie[1];
4343
}
@@ -54,8 +54,9 @@ export class Utils {
5454
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
5555
}
5656

57+
// tslint:disable-next-line:ban-types
5758
public static merge(defaultValues: Object, values: Object) {
58-
const result: Object = {};
59+
const result: object = {};
5960

6061
for (const key in defaultValues || {}) {
6162
if (!!defaultValues[key]) {
@@ -96,11 +97,11 @@ export class Utils {
9697
return null;
9798
}
9899

99-
const result: Object = {};
100-
for (let index = 0; index < pairs.length; index++) {
101-
const pair = pairs[index].split('=');
102-
if (!Utils.isMatch(pair[0], exclusions)) {
103-
result[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
100+
const result: object = {};
101+
for (const pair of pairs) {
102+
const parts = pair.split('=');
103+
if (!Utils.isMatch(parts[0], exclusions)) {
104+
result[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
104105
}
105106
}
106107

@@ -160,7 +161,7 @@ export class Utils {
160161
});
161162
}
162163

163-
public static isEmpty(input: Object) {
164+
public static isEmpty(input: object) {
164165
return input === null || (typeof (input) === 'object' && Object.keys(input).length === 0);
165166
}
166167

@@ -181,7 +182,7 @@ export class Utils {
181182
public static stringify(data: any, exclusions?: string[], maxDepth?: number): string {
182183
function stringifyImpl(obj: any, excludedKeys: string[]): string {
183184
const cache: string[] = [];
184-
return JSON.stringify(obj, function(key: string, value: any) {
185+
return JSON.stringify(obj, (key: string, value: any) => {
185186
if (Utils.isMatch(key, excludedKeys)) {
186187
return;
187188
}

src/configuration/Configuration.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Configuration implements IConfigurationSettings {
4646
*
4747
* @type {{}}
4848
*/
49-
public defaultData: Object = {};
49+
public defaultData: object = {};
5050

5151
/**
5252
* Whether the client is currently enabled or not. If it is disabled,
@@ -74,7 +74,7 @@ export class Configuration implements IConfigurationSettings {
7474
* Contains a dictionary of custom settings that can be used to control
7575
* the client and will be automatically updated from the server.
7676
*/
77-
public settings: Object = {};
77+
public settings: object = {};
7878

7979
public storage: IStorageProvider;
8080

@@ -134,7 +134,7 @@ export class Configuration implements IConfigurationSettings {
134134
* @type {Array}
135135
* @private
136136
*/
137-
private _handlers: Array<{ (config: Configuration): void }> = [];
137+
private _handlers: Array<(config: Configuration) => void> = [];
138138

139139
constructor(configSettings?: IConfigurationSettings) {
140140
function inject(fn: any) {
@@ -349,8 +349,8 @@ export class Configuration implements IConfigurationSettings {
349349

350350
let pluginExists: boolean = false;
351351
const plugins = this._plugins; // optimization for minifier.
352-
for (let index = 0; index < plugins.length; index++) {
353-
if (plugins[index].name === plugin.name) {
352+
for (const p of plugins) {
353+
if (p.name === plugin.name) {
354354
pluginExists = true;
355355
break;
356356
}
@@ -371,7 +371,6 @@ export class Configuration implements IConfigurationSettings {
371371
* Remove an plugin by key from this configuration.
372372
* @param name
373373
*/
374-
public removePlugin(name: string): void;
375374
public removePlugin(pluginOrName: IEventPlugin | string): void {
376375
const name: string = typeof pluginOrName === 'string' ? pluginOrName : pluginOrName.name;
377376
if (!name) {
@@ -454,9 +453,9 @@ export class Configuration implements IConfigurationSettings {
454453

455454
private changed() {
456455
const handlers = this._handlers; // optimization for minifier.
457-
for (let index = 0; index < handlers.length; index++) {
456+
for (const handler of handlers) {
458457
try {
459-
handlers[index](this);
458+
handler(this);
460459
} catch (ex) {
461460
this.log.error(`Error calling onChanged handler: ${ex}`);
462461
}

src/configuration/SettingsManager.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class SettingsManager {
1313
* @type {Array}
1414
* @private
1515
*/
16-
private static _handlers: Array<{ (config: Configuration): void }> = [];
16+
private static _handlers: Array<(config: Configuration) => void> = [];
1717

1818
public static onChanged(handler: (config: Configuration) => void) {
1919
!!handler && this._handlers.push(handler);
@@ -54,7 +54,7 @@ export class SettingsManager {
5454
return;
5555
}
5656

57-
let unableToUpdateMessage = 'Unable to update settings';
57+
const unableToUpdateMessage = 'Unable to update settings';
5858
if (!config.isValid) {
5959
config.log.error(`${unableToUpdateMessage}: ApiKey is not set.`);
6060
return;
@@ -98,9 +98,9 @@ export class SettingsManager {
9898

9999
private static changed(config: Configuration) {
100100
const handlers = this._handlers; // optimization for minifier.
101-
for (let index = 0; index < handlers.length; index++) {
101+
for (const handler of handlers) {
102102
try {
103-
handlers[index](config);
103+
handler(config);
104104
} catch (ex) {
105105
config.log.error(`Error calling onChanged handler: ${ex}`);
106106
}

src/exceptionless.node.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ function onUncaughtException(callback: (error: Error) => void) {
5050
};
5151
}
5252

53-
onUncaughtException(function(error: Error) {
53+
onUncaughtException((error: Error) => {
5454
ExceptionlessClient.default.submitUnhandledException(error, UNCAUGHT_EXCEPTION);
5555
});
5656

5757
/*
5858
* We cannot hijack SIGINT, so if there are no other handlers,
5959
* we just reproduce default Node.js behavior by exiting.
6060
*/
61-
process.on(SIGINT, function() {
61+
process.on(SIGINT, () => {
6262
if (getListenerCount(process, SIGINT) <= 1) {
6363
process.exit(128 + SIGINT_CODE);
6464
}
6565
});
6666

67-
process.on(EXIT, function(code: number) {
67+
process.on(EXIT, (code: number) => {
6868
/**
6969
* exit codes: https://nodejs.org/api/process.html#process_event_exit
7070
* From now on, only synchronous code may run. As soon as this method
@@ -125,4 +125,4 @@ process.on(EXIT, function(code: number) {
125125
// Application will now exit.
126126
});
127127

128-
(<any>Error).stackTraceLimit = Infinity;
128+
(Error as any).stackTraceLimit = Infinity;

src/exceptionless.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function getDefaultsSettingsFromScriptTag(): IConfigurationSettings {
1717
}
1818

1919
const scripts = document.getElementsByTagName('script');
20+
// tslint:disable-next-line:prefer-for-of
2021
for (let index = 0; index < scripts.length; index++) {
2122
if (scripts[index].src && scripts[index].src.indexOf('/exceptionless') > -1) {
2223
return Utils.parseQueryString(scripts[index].src.split('?').pop());
@@ -79,6 +80,7 @@ TraceKit.extendToAsynchronousCallbacks();
7980
// $(document).ajaxError(processJQueryAjaxError);
8081
// }
8182

82-
(<any>Error).stackTraceLimit = Infinity;
83+
(Error as any).stackTraceLimit = Infinity;
8384

85+
// tslint:disable-next-line:prefer-const
8486
declare var $;

src/integrations/angular.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ declare var exceptionless;
44

55
angular.module('exceptionless', [])
66
.constant('$ExceptionlessClient', exceptionless.ExceptionlessClient.default)
7-
.factory('exceptionlessHttpInterceptor', ['$q', '$ExceptionlessClient', function($q, $ExceptionlessClient) {
7+
.factory('exceptionlessHttpInterceptor', ['$q', '$ExceptionlessClient', ($q, $ExceptionlessClient) => {
88
return {
99
responseError: function responseError(rejection) {
1010
if (rejection.status === 404) {
@@ -21,28 +21,29 @@ angular.module('exceptionless', [])
2121
}
2222
};
2323
}])
24-
.config(['$httpProvider', '$provide', '$ExceptionlessClient', function($httpProvider, $provide, $ExceptionlessClient) {
24+
.config(['$httpProvider', '$provide', '$ExceptionlessClient', ($httpProvider, $provide, $ExceptionlessClient) => {
2525
$httpProvider.interceptors.push('exceptionlessHttpInterceptor');
26-
$provide.decorator('$exceptionHandler', ['$delegate', function($delegate) {
27-
return function(exception, cause) {
26+
$provide.decorator('$exceptionHandler', ['$delegate', ($delegate) => {
27+
return (exception, cause) => {
2828
$delegate(exception, cause);
2929
$ExceptionlessClient.createUnhandledException(exception, '$exceptionHandler').setMessage(cause).submit();
3030
};
3131
}]);
32-
$provide.decorator('$log', ['$delegate', function($delegate) {
32+
$provide.decorator('$log', ['$delegate', ($delegate) => {
3333
function decorateRegularCall(property, logLevel) {
3434
const previousFn = $delegate[property];
35-
return $delegate[property] = function() {
35+
return $delegate[property] = (...args) => {
3636
if (angular.mock) {
3737
// Needed to support angular-mocks.
3838
$delegate[property].logs = [];
3939
}
40-
previousFn.apply(null, arguments);
41-
if (arguments[0] && arguments[0].length > 0) {
42-
$ExceptionlessClient.submitLog(null, arguments[0], logLevel);
40+
previousFn.apply(null, args);
41+
if (args[0] && args[0].length > 0) {
42+
$ExceptionlessClient.submitLog(null, args[0], logLevel);
4343
}
4444
};
4545
}
46+
4647
$delegate.log = decorateRegularCall('log', 'Trace');
4748
$delegate.info = decorateRegularCall('info', 'Info');
4849
$delegate.warn = decorateRegularCall('warn', 'Warn');
@@ -51,8 +52,8 @@ angular.module('exceptionless', [])
5152
return $delegate;
5253
}]);
5354
}])
54-
.run(['$rootScope', '$ExceptionlessClient', function($rootScope, $ExceptionlessClient) {
55-
$rootScope.$on('$routeChangeSuccess', function(event, next, current) {
55+
.run(['$rootScope', '$ExceptionlessClient', ($rootScope, $ExceptionlessClient) => {
56+
$rootScope.$on('$routeChangeSuccess', (event, next, current) => {
5657
if (!current) {
5758
return;
5859
}
@@ -63,14 +64,14 @@ angular.module('exceptionless', [])
6364
.submit();
6465
});
6566

66-
$rootScope.$on('$routeChangeError', function(event, current, previous, rejection) {
67+
$rootScope.$on('$routeChangeError', (event, current, previous, rejection) => {
6768
$ExceptionlessClient.createUnhandledException(new Error(rejection), '$routeChangeError')
6869
.setProperty('current', current)
6970
.setProperty('previous', previous)
7071
.submit();
7172
});
7273

73-
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
74+
$rootScope.$on('$stateChangeSuccess', (event, toState, toParams, fromState, fromParams) => {
7475
if (!toState || toState.name === 'otherwise') {
7576
return;
7677
}
@@ -83,7 +84,7 @@ angular.module('exceptionless', [])
8384
.submit();
8485
});
8586

86-
$rootScope.$on('$stateNotFound', function(event, unfoundState, fromState, fromParams) {
87+
$rootScope.$on('$stateNotFound', (event, unfoundState, fromState, fromParams) => {
8788
if (!unfoundState) {
8889
return;
8990
}
@@ -95,8 +96,8 @@ angular.module('exceptionless', [])
9596
.submit();
9697
});
9798

98-
let stateChangeError = '$stateChangeError';
99-
$rootScope.$on(stateChangeError, function(event, toState, toParams, fromState, fromParams, error) {
99+
const stateChangeError = '$stateChangeError';
100+
$rootScope.$on(stateChangeError, (event, toState, toParams, fromState, fromParams, error) => {
100101
if (!error) {
101102
return;
102103
}
@@ -111,7 +112,7 @@ angular.module('exceptionless', [])
111112
.submit();
112113
});
113114

114-
$rootScope.$on('$destroy', function() {
115+
$rootScope.$on('$destroy', () => {
115116
$ExceptionlessClient.config.queue.process();
116117
});
117118
}]);

src/logging/ConsoleLog.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ConsoleLog implements ILog {
1919

2020
private log(level: string, message: string) {
2121
if (console) {
22-
let msg = `[${level}] Exceptionless: ${message}`;
22+
const msg = `[${level}] Exceptionless: ${message}`;
2323

2424
if (console[level]) {
2525
console[level](msg);

src/plugins/EventPluginManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IEventPlugin } from './IEventPlugin';
1212

1313
export class EventPluginManager {
1414
public static run(context: EventPluginContext, callback: (context?: EventPluginContext) => void): void {
15-
const wrap = function(plugin: IEventPlugin, next?: () => void): () => void {
15+
const wrap = (plugin: IEventPlugin, next?: () => void): () => void => {
1616
return () => {
1717
try {
1818
if (!context.cancelled) {
@@ -30,7 +30,7 @@ export class EventPluginManager {
3030
};
3131

3232
const plugins: IEventPlugin[] = context.client.config.plugins; // optimization for minifier.
33-
const wrappedPlugins: { (): void }[] = [];
33+
const wrappedPlugins: Array<() => void> = [];
3434
if (!!callback) {
3535
wrappedPlugins[plugins.length] = wrap({ name: 'cb', priority: 9007199254740992, run: callback }, null);
3636
}

src/plugins/default/ConfigurationDefaultsPlugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export class ConfigurationDefaultsPlugin implements IEventPlugin {
99
public run(context: EventPluginContext, next?: () => void): void {
1010
const config = context.client.config;
1111
const defaultTags: string[] = config.defaultTags || [];
12-
for (let index = 0; index < defaultTags.length; index++) {
13-
const tag = defaultTags[index];
12+
for (const tag of defaultTags) {
1413
if (!!tag && context.event.tags.indexOf(tag) < 0) {
1514
context.event.tags.push(tag);
1615
}
1716
}
1817

19-
const defaultData: object = config.defaultData || {};
18+
// tslint:disable-next-line:ban-types
19+
const defaultData: Object = config.defaultData || {};
2020
for (const key in defaultData) {
2121
if (!!defaultData[key]) {
2222
const result = JSON.parse(Utils.stringify(defaultData[key], config.dataExclusions));

src/plugins/default/EventExclusionPlugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class EventExclusionPlugin implements IEventPlugin {
3939
return getLogLevel(getTypeAndSourceSetting(settings, 'log', loggerName, 'Trace') + '');
4040
}
4141

42-
function getTypeAndSourceSetting(settings: object = {}, type: string, source: string, defaultValue: string|boolean = undefined): string|boolean {
42+
// tslint:disable-next-line:ban-types
43+
function getTypeAndSourceSetting(settings: Object = {}, type: string, source: string, defaultValue?: string|boolean): string|boolean {
4344
if (!type) {
4445
return defaultValue;
4546
}

0 commit comments

Comments
 (0)