Skip to content

Commit e9a795e

Browse files
authored
Update to TypeScript 4.x && Resolve Log Level Issues (#91)
* TypeScript 4.0 required src changes * Update to latest tsproject and typescript * npm install ts2js --save-dev * Resolve tsproject upgrade errors ToddThomson/tsproject#105 * Updated to latest beta * Revert "Resolve tsproject upgrade errors" This reverts commit dc61860. * Cleanup tsconfig * Updated packages * Updated dist * Upgraded to eslint * Fixed eslint errors * Added default exts * Updates to how we run unit tests * Added failing unit tests for resolving log levels based on settings order and null/empty sources * Got the vs code test code runner working! * Fixed unit test asserts for deep equality * Fixed some unit test issues. * Fixed several issues with resolving log levels and pattern matching * set plugin context cancelled to default to false instead of undefined. * Cleanup and update deps * Update dist * Fix quote
1 parent 93a0c49 commit e9a795e

File tree

75 files changed

+4039
-13866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4039
-13866
lines changed

.eslintrc.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"mocha": true,
6+
"node": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
],
12+
"globals": {
13+
"Atomics": "readonly",
14+
"SharedArrayBuffer": "readonly"
15+
},
16+
"parser": "@typescript-eslint/parser",
17+
"parserOptions": {
18+
"ecmaVersion": 2018,
19+
"sourceType": "module"
20+
},
21+
"plugins": [
22+
"@typescript-eslint"
23+
],
24+
"ignorePatterns": [
25+
"node_modules",
26+
"dist"
27+
],
28+
"rules": {
29+
"@typescript-eslint/explicit-module-boundary-types": "off",
30+
"@typescript-eslint/no-empty-function": "off",
31+
"@typescript-eslint/no-explicit-any": "off",
32+
"@typescript-eslint/no-inferrable-types": "off"
33+
}
34+
};

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"hbenl.vscode-mocha-test-adapter",
5+
"hbenl.vscode-test-explorer",
6+
"juancasanova.awesometypescriptproblemmatcher",
7+
"ryanluker.vscode-coverage-gutters",
8+
"streetsidesoftware.code-spell-checker"
9+
]
10+
}

.vscode/launch.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
{
2-
"version": "0.1.0",
2+
"version": "0.2.0",
33
"configurations": [
44
{
55
"name": "Test",
66
"request": "launch",
7-
"type": "node",
7+
"type": "pwa-node",
88
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
99
"args": [
10-
"${workspaceRoot}/dist/temp/exceptionless-spec.js"
10+
"--colors",
11+
"-u", "tdd",
12+
"--timeout", "999999",
13+
"${workspaceFolder}/src/**/*-spec.ts"
1114
],
1215
"runtimeArgs": [
13-
"--nolazy"
16+
"--require",
17+
"ts-node/register"
1418
],
15-
"sourceMaps": false,
16-
"cwd": "${workspaceRoot}",
17-
"outDir": "${workspaceRoot}/dist"
19+
"internalConsoleOptions": "openOnSessionStart",
20+
"sourceMaps": true,
21+
"resolveSourceMapLocations": [
22+
"${workspaceFolder}/**",
23+
"!**/node_modules/**"
24+
]
1825
},
1926
{
2027
"name": "Express",
@@ -26,15 +33,13 @@
2633
],
2734
"sourceMaps": true,
2835
"cwd": "${workspaceRoot}",
29-
"outDir": "${workspaceRoot}/dist"
3036
},
3137
{
3238
"name": "Attach",
3339
"request": "attach",
3440
"type": "node",
3541
"port": 5858,
3642
"sourceMaps": true,
37-
"outDir": "${workspaceRoot}/dist/"
3843
}
3944
]
4045
}

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
"files.insertFinalNewline": true,
44
"typescript.tsdk": "./node_modules/typescript/lib",
55
"cSpell.words": [
6+
"bootstrapcdn",
7+
"configversion",
8+
"maxcdn",
69
"systemjs",
710
"tracekit",
11+
"tsfmt",
812
"tsproject"
913
]
10-
}
14+
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
}
6262
}
6363
]
64-
}
64+
}

dist/exceptionless.d.ts

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export declare class ConsoleLog implements ILog {
2020
info(message: string): void;
2121
warn(message: string): void;
2222
error(message: string): void;
23-
private log(level, message);
23+
private log;
2424
}
2525
export declare class NullLog implements ILog {
2626
trace(message: string): void;
@@ -52,7 +52,7 @@ export declare class EventPluginContext {
5252
event: IEvent;
5353
contextData: ContextData;
5454
constructor(client: ExceptionlessClient, event: IEvent, contextData?: ContextData);
55-
readonly log: ILog;
55+
get log(): ILog;
5656
}
5757
export declare class EventPluginManager {
5858
static run(context: EventPluginContext, callback: (context?: EventPluginContext) => void): void;
@@ -75,13 +75,13 @@ export declare class DefaultEventQueue implements IEventQueue {
7575
process(isAppExiting?: boolean): void;
7676
suspendProcessing(durationInMinutes?: number, discardFutureQueuedItems?: boolean, clearQueue?: boolean): void;
7777
onEventsPosted(handler: (events: IEvent[], response: SubmissionResponse) => void): void;
78-
private eventsPosted(events, response);
79-
private areQueuedItemsDiscarded();
80-
private ensureQueueTimer();
81-
private isQueueProcessingSuspended();
82-
private onProcessQueue();
83-
private processSubmissionResponse(response, events);
84-
private removeEvents(events);
78+
private eventsPosted;
79+
private areQueuedItemsDiscarded;
80+
private ensureQueueTimer;
81+
private isQueueProcessingSuspended;
82+
private onProcessQueue;
83+
private processSubmissionResponse;
84+
private removeEvents;
8585
}
8686
export interface IEventQueue {
8787
enqueue(event: IEvent): void;
@@ -96,7 +96,7 @@ export interface IErrorParser {
9696
parse(context: EventPluginContext, exception: Error): IError;
9797
}
9898
export interface IModuleCollector {
99-
getModules(context: EventPluginContext): IModule[];
99+
getModules(): IModule[];
100100
}
101101
export interface IRequestInfoCollector {
102102
getRequestInfo(context: EventPluginContext): IRequestInfo;
@@ -116,8 +116,8 @@ export declare class DefaultSubmissionClient implements ISubmissionClient {
116116
postUserDescription(referenceId: string, description: IUserDescription, config: Configuration, callback: (response: SubmissionResponse) => void): void;
117117
getSettings(config: Configuration, version: number, callback: (response: SettingsResponse) => void): void;
118118
sendHeartbeat(sessionIdOrUserId: string, closeSession: boolean, config: Configuration): void;
119-
private createRequest(config, method, url, data?);
120-
private createSubmissionCallback(config, callback);
119+
private createRequest;
120+
private createSubmissionCallback;
121121
}
122122
export interface ISubmissionAdapter {
123123
sendRequest(request: SubmissionRequest, callback?: SubmissionCallback, isAppExiting?: boolean): void;
@@ -131,14 +131,14 @@ export interface ISubmissionClient {
131131
export declare class Utils {
132132
static addRange<T>(target: T[], ...values: T[]): T[];
133133
static getHashCode(source: string): number;
134-
static getCookies(cookies: string, exclusions?: string[]): object;
134+
static getCookies(cookies: string, exclusions?: string[]): Record<string, string>;
135135
static guid(): string;
136-
static merge(defaultValues: Object, values: Object): object;
136+
static merge<T>(defaultValues: T, values: T): T;
137137
static parseVersion(source: string): string;
138-
static parseQueryString(query: string, exclusions?: string[]): object;
138+
static parseQueryString(query: string, exclusions?: string[]): Record<string, string>;
139139
static randomNumber(): number;
140140
static isMatch(input: string, patterns: string[], ignoreCase?: boolean): boolean;
141-
static isEmpty(input: object): boolean;
141+
static isEmpty(input: Record<string, unknown>): boolean;
142142
static startsWith(input: string, prefix: string): boolean;
143143
static endsWith(input: string, suffix: string): boolean;
144144
static stringify(data: any, exclusions?: string[], maxDepth?: number): string;
@@ -171,8 +171,8 @@ export declare class SettingsManager {
171171
static getVersion(config: Configuration): number;
172172
static checkVersion(version: number, config: Configuration): void;
173173
static updateSettings(config: Configuration, version?: number): void;
174-
private static changed(config);
175-
private static getSavedServerSettings(config);
174+
private static changed;
175+
private static getSavedServerSettings;
176176
}
177177
export interface IEvent {
178178
type?: string;
@@ -228,15 +228,15 @@ export declare class ExceptionlessClient {
228228
submitEvent(event: IEvent, pluginContextData?: ContextData, callback?: (context: EventPluginContext) => void): void;
229229
updateUserEmailAndDescription(referenceId: string, email: string, description: string, callback?: (response: SubmissionResponse) => void): void;
230230
getLastReferenceId(): string;
231-
private updateSettingsTimer(initialDelay?);
232-
static readonly default: ExceptionlessClient;
231+
private updateSettingsTimer;
232+
static get default(): ExceptionlessClient;
233233
}
234234
export declare class ContextData {
235235
setException(exception: Error): void;
236-
readonly hasException: boolean;
236+
get hasException(): boolean;
237237
getException(): Error;
238238
markAsUnhandledError(): void;
239-
readonly isUnhandledError: boolean;
239+
get isUnhandledError(): boolean;
240240
setSubmissionMethod(method: string): void;
241241
getSubmissionMethod(): string;
242242
}
@@ -325,7 +325,7 @@ export interface IStorage {
325325
remove(timestamp: number): void;
326326
clear(): void;
327327
}
328-
export declare type SubmissionCallback = (status: number, message: string, data?: string, headers?: object) => void;
328+
export declare type SubmissionCallback = (status: number, message: string, data?: string, headers?: any) => void;
329329
export interface SubmissionRequest {
330330
apiKey: string;
331331
userAgent: string;
@@ -336,7 +336,7 @@ export interface SubmissionRequest {
336336
export declare class Configuration implements IConfigurationSettings {
337337
private static _defaultSettings;
338338
defaultTags: string[];
339-
defaultData: object;
339+
defaultData: Record<string, unknown>;
340340
enabled: boolean;
341341
environmentInfoCollector: IEnvironmentInfoCollector;
342342
errorParser: IErrorParser;
@@ -347,7 +347,7 @@ export declare class Configuration implements IConfigurationSettings {
347347
submissionBatchSize: number;
348348
submissionAdapter: ISubmissionAdapter;
349349
submissionClient: ISubmissionClient;
350-
settings: object;
350+
settings: Record<string, string>;
351351
storage: IStorageProvider;
352352
queue: IEventQueue;
353353
private _apiKey;
@@ -367,39 +367,51 @@ export declare class Configuration implements IConfigurationSettings {
367367
private _plugins;
368368
private _handlers;
369369
constructor(configSettings?: IConfigurationSettings);
370-
apiKey: string;
371-
readonly isValid: boolean;
372-
serverUrl: string;
373-
configServerUrl: string;
374-
heartbeatServerUrl: string;
375-
updateSettingsWhenIdleInterval: number;
376-
readonly dataExclusions: string[];
370+
get apiKey(): string;
371+
set apiKey(value: string);
372+
get isValid(): boolean;
373+
get serverUrl(): string;
374+
set serverUrl(value: string);
375+
get configServerUrl(): string;
376+
set configServerUrl(value: string);
377+
get heartbeatServerUrl(): string;
378+
set heartbeatServerUrl(value: string);
379+
get updateSettingsWhenIdleInterval(): number;
380+
set updateSettingsWhenIdleInterval(value: number);
381+
get dataExclusions(): string[];
377382
addDataExclusions(...exclusions: string[]): void;
378-
includePrivateInformation: boolean;
379-
includeUserName: boolean;
380-
includeMachineName: boolean;
381-
includeIpAddress: boolean;
382-
includeCookies: boolean;
383-
includePostData: boolean;
384-
includeQueryString: boolean;
385-
readonly userAgentBotPatterns: string[];
383+
get includePrivateInformation(): boolean;
384+
set includePrivateInformation(value: boolean);
385+
get includeUserName(): boolean;
386+
set includeUserName(value: boolean);
387+
get includeMachineName(): boolean;
388+
set includeMachineName(value: boolean);
389+
get includeIpAddress(): boolean;
390+
set includeIpAddress(value: boolean);
391+
get includeCookies(): boolean;
392+
set includeCookies(value: boolean);
393+
get includePostData(): boolean;
394+
set includePostData(value: boolean);
395+
get includeQueryString(): boolean;
396+
set includeQueryString(value: boolean);
397+
get userAgentBotPatterns(): string[];
386398
addUserAgentBotPatterns(...userAgentBotPatterns: string[]): void;
387-
readonly plugins: IEventPlugin[];
399+
get plugins(): IEventPlugin[];
388400
addPlugin(plugin: IEventPlugin): void;
389401
addPlugin(name: string, priority: number, pluginAction: (context: EventPluginContext, next?: () => void) => void): void;
390402
removePlugin(plugin: IEventPlugin): void;
391403
setVersion(version: string): void;
392404
setUserIdentity(userInfo: IUserInfo): void;
393405
setUserIdentity(identity: string): void;
394406
setUserIdentity(identity: string, name: string): void;
395-
readonly userAgent: string;
407+
get userAgent(): string;
396408
useSessions(sendHeartbeats?: boolean, heartbeatInterval?: number): void;
397409
useReferenceIds(): void;
398410
useLocalStorage(): void;
399411
useDebugLogger(): void;
400412
onChanged(handler: (config: Configuration) => void): void;
401-
private changed();
402-
static readonly defaults: IConfigurationSettings;
413+
private changed;
414+
static get defaults(): IConfigurationSettings;
403415
}
404416
export interface IUserDescription {
405417
email_address?: string;
@@ -430,15 +442,15 @@ export declare class EventBuilder {
430442
setUserIdentity(identity: string): EventBuilder;
431443
setUserIdentity(identity: string, name: string): EventBuilder;
432444
setUserDescription(emailAddress: string, description: string): EventBuilder;
433-
setManualStackingInfo(signatureData: any, title?: string): this;
445+
setManualStackingInfo(signatureData: any, title?: string): EventBuilder;
434446
setManualStackingKey(manualStackingKey: string, title?: string): EventBuilder;
435447
setValue(value: number): EventBuilder;
436448
addTags(...tags: string[]): EventBuilder;
437449
setProperty(name: string, value: any, maxDepth?: number, excludedPropertyNames?: string[]): EventBuilder;
438450
markAsCritical(critical: boolean): EventBuilder;
439-
addRequestInfo(request: object): EventBuilder;
451+
addRequestInfo(request: IRequestInfo): EventBuilder;
440452
submit(callback?: (context: EventPluginContext) => void): void;
441-
private isValidIdentifier(value);
453+
private isValidIdentifier;
442454
}
443455
export interface IManualStackingInfo {
444456
title?: string;
@@ -473,6 +485,9 @@ export declare class EventExclusionPlugin implements IEventPlugin {
473485
priority: number;
474486
name: string;
475487
run(context: EventPluginContext, next?: () => void): void;
488+
getLogLevel(level: string): number;
489+
getMinLogLevel(configSettings: Record<string, string>, source: any): number;
490+
private getTypeAndSourceSetting;
476491
}
477492
export declare class ModuleInfoPlugin implements IEventPlugin {
478493
priority: number;
@@ -500,15 +515,15 @@ export declare class InMemoryStorage implements IStorage {
500515
clear(): void;
501516
}
502517
export interface IClientConfiguration {
503-
settings: object;
518+
settings: Record<string, string>;
504519
version: number;
505520
}
506521
export declare abstract class KeyValueStorageBase implements IStorage {
507522
private maxItems;
508523
private items;
509524
private lastTimestamp;
510-
constructor(maxItems: any);
511-
save(value: any, single?: boolean): number;
525+
constructor(maxItems: number);
526+
save(value: any): number;
512527
get(limit?: number): IStorageItem[];
513528
remove(timestamp: number): void;
514529
clear(): void;
@@ -518,9 +533,9 @@ export declare abstract class KeyValueStorageBase implements IStorage {
518533
protected abstract delete(key: string): any;
519534
protected abstract getKey(timestamp: number): string;
520535
protected abstract getTimestamp(key: string): number;
521-
private ensureIndex();
522-
private safeDelete(key);
523-
private createIndex();
536+
private ensureIndex;
537+
private safeDelete;
538+
private createIndex;
524539
}
525540
export declare class BrowserStorage extends KeyValueStorageBase {
526541
private prefix;
@@ -537,7 +552,7 @@ export declare class DefaultErrorParser implements IErrorParser {
537552
parse(context: EventPluginContext, exception: Error): IError;
538553
}
539554
export declare class DefaultModuleCollector implements IModuleCollector {
540-
getModules(context: EventPluginContext): IModule[];
555+
getModules(): IModule[];
541556
}
542557
export declare class DefaultRequestInfoCollector implements IRequestInfoCollector {
543558
getRequestInfo(context: EventPluginContext): IRequestInfo;

0 commit comments

Comments
 (0)