Skip to content

Commit

Permalink
Update to TypeScript 4.x && Resolve Log Level Issues (#91)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
niemyjski authored Nov 9, 2020
1 parent 93a0c49 commit e9a795e
Show file tree
Hide file tree
Showing 75 changed files with 4,039 additions and 13,866 deletions.
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"ignorePatterns": [
"node_modules",
"dist"
],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off"
}
};
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"hbenl.vscode-mocha-test-adapter",
"hbenl.vscode-test-explorer",
"juancasanova.awesometypescriptproblemmatcher",
"ryanluker.vscode-coverage-gutters",
"streetsidesoftware.code-spell-checker"
]
}
23 changes: 14 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"version": "0.1.0",
"version": "0.2.0",
"configurations": [
{
"name": "Test",
"request": "launch",
"type": "node",
"type": "pwa-node",
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
"args": [
"${workspaceRoot}/dist/temp/exceptionless-spec.js"
"--colors",
"-u", "tdd",
"--timeout", "999999",
"${workspaceFolder}/src/**/*-spec.ts"
],
"runtimeArgs": [
"--nolazy"
"--require",
"ts-node/register"
],
"sourceMaps": false,
"cwd": "${workspaceRoot}",
"outDir": "${workspaceRoot}/dist"
"internalConsoleOptions": "openOnSessionStart",
"sourceMaps": true,
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!**/node_modules/**"
]
},
{
"name": "Express",
Expand All @@ -26,15 +33,13 @@
],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"outDir": "${workspaceRoot}/dist"
},
{
"name": "Attach",
"request": "attach",
"type": "node",
"port": 5858,
"sourceMaps": true,
"outDir": "${workspaceRoot}/dist/"
}
]
}
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"files.insertFinalNewline": true,
"typescript.tsdk": "./node_modules/typescript/lib",
"cSpell.words": [
"bootstrapcdn",
"configversion",
"maxcdn",
"systemjs",
"tracekit",
"tsfmt",
"tsproject"
]
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
}
}
]
}
}
123 changes: 69 additions & 54 deletions dist/exceptionless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export declare class ConsoleLog implements ILog {
info(message: string): void;
warn(message: string): void;
error(message: string): void;
private log(level, message);
private log;
}
export declare class NullLog implements ILog {
trace(message: string): void;
Expand Down Expand Up @@ -52,7 +52,7 @@ export declare class EventPluginContext {
event: IEvent;
contextData: ContextData;
constructor(client: ExceptionlessClient, event: IEvent, contextData?: ContextData);
readonly log: ILog;
get log(): ILog;
}
export declare class EventPluginManager {
static run(context: EventPluginContext, callback: (context?: EventPluginContext) => void): void;
Expand All @@ -75,13 +75,13 @@ export declare class DefaultEventQueue implements IEventQueue {
process(isAppExiting?: boolean): void;
suspendProcessing(durationInMinutes?: number, discardFutureQueuedItems?: boolean, clearQueue?: boolean): void;
onEventsPosted(handler: (events: IEvent[], response: SubmissionResponse) => void): void;
private eventsPosted(events, response);
private areQueuedItemsDiscarded();
private ensureQueueTimer();
private isQueueProcessingSuspended();
private onProcessQueue();
private processSubmissionResponse(response, events);
private removeEvents(events);
private eventsPosted;
private areQueuedItemsDiscarded;
private ensureQueueTimer;
private isQueueProcessingSuspended;
private onProcessQueue;
private processSubmissionResponse;
private removeEvents;
}
export interface IEventQueue {
enqueue(event: IEvent): void;
Expand All @@ -96,7 +96,7 @@ export interface IErrorParser {
parse(context: EventPluginContext, exception: Error): IError;
}
export interface IModuleCollector {
getModules(context: EventPluginContext): IModule[];
getModules(): IModule[];
}
export interface IRequestInfoCollector {
getRequestInfo(context: EventPluginContext): IRequestInfo;
Expand All @@ -116,8 +116,8 @@ export declare class DefaultSubmissionClient implements ISubmissionClient {
postUserDescription(referenceId: string, description: IUserDescription, config: Configuration, callback: (response: SubmissionResponse) => void): void;
getSettings(config: Configuration, version: number, callback: (response: SettingsResponse) => void): void;
sendHeartbeat(sessionIdOrUserId: string, closeSession: boolean, config: Configuration): void;
private createRequest(config, method, url, data?);
private createSubmissionCallback(config, callback);
private createRequest;
private createSubmissionCallback;
}
export interface ISubmissionAdapter {
sendRequest(request: SubmissionRequest, callback?: SubmissionCallback, isAppExiting?: boolean): void;
Expand All @@ -131,14 +131,14 @@ export interface ISubmissionClient {
export declare class Utils {
static addRange<T>(target: T[], ...values: T[]): T[];
static getHashCode(source: string): number;
static getCookies(cookies: string, exclusions?: string[]): object;
static getCookies(cookies: string, exclusions?: string[]): Record<string, string>;
static guid(): string;
static merge(defaultValues: Object, values: Object): object;
static merge<T>(defaultValues: T, values: T): T;
static parseVersion(source: string): string;
static parseQueryString(query: string, exclusions?: string[]): object;
static parseQueryString(query: string, exclusions?: string[]): Record<string, string>;
static randomNumber(): number;
static isMatch(input: string, patterns: string[], ignoreCase?: boolean): boolean;
static isEmpty(input: object): boolean;
static isEmpty(input: Record<string, unknown>): boolean;
static startsWith(input: string, prefix: string): boolean;
static endsWith(input: string, suffix: string): boolean;
static stringify(data: any, exclusions?: string[], maxDepth?: number): string;
Expand Down Expand Up @@ -171,8 +171,8 @@ export declare class SettingsManager {
static getVersion(config: Configuration): number;
static checkVersion(version: number, config: Configuration): void;
static updateSettings(config: Configuration, version?: number): void;
private static changed(config);
private static getSavedServerSettings(config);
private static changed;
private static getSavedServerSettings;
}
export interface IEvent {
type?: string;
Expand Down Expand Up @@ -228,15 +228,15 @@ export declare class ExceptionlessClient {
submitEvent(event: IEvent, pluginContextData?: ContextData, callback?: (context: EventPluginContext) => void): void;
updateUserEmailAndDescription(referenceId: string, email: string, description: string, callback?: (response: SubmissionResponse) => void): void;
getLastReferenceId(): string;
private updateSettingsTimer(initialDelay?);
static readonly default: ExceptionlessClient;
private updateSettingsTimer;
static get default(): ExceptionlessClient;
}
export declare class ContextData {
setException(exception: Error): void;
readonly hasException: boolean;
get hasException(): boolean;
getException(): Error;
markAsUnhandledError(): void;
readonly isUnhandledError: boolean;
get isUnhandledError(): boolean;
setSubmissionMethod(method: string): void;
getSubmissionMethod(): string;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ export interface IStorage {
remove(timestamp: number): void;
clear(): void;
}
export declare type SubmissionCallback = (status: number, message: string, data?: string, headers?: object) => void;
export declare type SubmissionCallback = (status: number, message: string, data?: string, headers?: any) => void;
export interface SubmissionRequest {
apiKey: string;
userAgent: string;
Expand All @@ -336,7 +336,7 @@ export interface SubmissionRequest {
export declare class Configuration implements IConfigurationSettings {
private static _defaultSettings;
defaultTags: string[];
defaultData: object;
defaultData: Record<string, unknown>;
enabled: boolean;
environmentInfoCollector: IEnvironmentInfoCollector;
errorParser: IErrorParser;
Expand All @@ -347,7 +347,7 @@ export declare class Configuration implements IConfigurationSettings {
submissionBatchSize: number;
submissionAdapter: ISubmissionAdapter;
submissionClient: ISubmissionClient;
settings: object;
settings: Record<string, string>;
storage: IStorageProvider;
queue: IEventQueue;
private _apiKey;
Expand All @@ -367,39 +367,51 @@ export declare class Configuration implements IConfigurationSettings {
private _plugins;
private _handlers;
constructor(configSettings?: IConfigurationSettings);
apiKey: string;
readonly isValid: boolean;
serverUrl: string;
configServerUrl: string;
heartbeatServerUrl: string;
updateSettingsWhenIdleInterval: number;
readonly dataExclusions: string[];
get apiKey(): string;
set apiKey(value: string);
get isValid(): boolean;
get serverUrl(): string;
set serverUrl(value: string);
get configServerUrl(): string;
set configServerUrl(value: string);
get heartbeatServerUrl(): string;
set heartbeatServerUrl(value: string);
get updateSettingsWhenIdleInterval(): number;
set updateSettingsWhenIdleInterval(value: number);
get dataExclusions(): string[];
addDataExclusions(...exclusions: string[]): void;
includePrivateInformation: boolean;
includeUserName: boolean;
includeMachineName: boolean;
includeIpAddress: boolean;
includeCookies: boolean;
includePostData: boolean;
includeQueryString: boolean;
readonly userAgentBotPatterns: string[];
get includePrivateInformation(): boolean;
set includePrivateInformation(value: boolean);
get includeUserName(): boolean;
set includeUserName(value: boolean);
get includeMachineName(): boolean;
set includeMachineName(value: boolean);
get includeIpAddress(): boolean;
set includeIpAddress(value: boolean);
get includeCookies(): boolean;
set includeCookies(value: boolean);
get includePostData(): boolean;
set includePostData(value: boolean);
get includeQueryString(): boolean;
set includeQueryString(value: boolean);
get userAgentBotPatterns(): string[];
addUserAgentBotPatterns(...userAgentBotPatterns: string[]): void;
readonly plugins: IEventPlugin[];
get plugins(): IEventPlugin[];
addPlugin(plugin: IEventPlugin): void;
addPlugin(name: string, priority: number, pluginAction: (context: EventPluginContext, next?: () => void) => void): void;
removePlugin(plugin: IEventPlugin): void;
setVersion(version: string): void;
setUserIdentity(userInfo: IUserInfo): void;
setUserIdentity(identity: string): void;
setUserIdentity(identity: string, name: string): void;
readonly userAgent: string;
get userAgent(): string;
useSessions(sendHeartbeats?: boolean, heartbeatInterval?: number): void;
useReferenceIds(): void;
useLocalStorage(): void;
useDebugLogger(): void;
onChanged(handler: (config: Configuration) => void): void;
private changed();
static readonly defaults: IConfigurationSettings;
private changed;
static get defaults(): IConfigurationSettings;
}
export interface IUserDescription {
email_address?: string;
Expand Down Expand Up @@ -430,15 +442,15 @@ export declare class EventBuilder {
setUserIdentity(identity: string): EventBuilder;
setUserIdentity(identity: string, name: string): EventBuilder;
setUserDescription(emailAddress: string, description: string): EventBuilder;
setManualStackingInfo(signatureData: any, title?: string): this;
setManualStackingInfo(signatureData: any, title?: string): EventBuilder;
setManualStackingKey(manualStackingKey: string, title?: string): EventBuilder;
setValue(value: number): EventBuilder;
addTags(...tags: string[]): EventBuilder;
setProperty(name: string, value: any, maxDepth?: number, excludedPropertyNames?: string[]): EventBuilder;
markAsCritical(critical: boolean): EventBuilder;
addRequestInfo(request: object): EventBuilder;
addRequestInfo(request: IRequestInfo): EventBuilder;
submit(callback?: (context: EventPluginContext) => void): void;
private isValidIdentifier(value);
private isValidIdentifier;
}
export interface IManualStackingInfo {
title?: string;
Expand Down Expand Up @@ -473,6 +485,9 @@ export declare class EventExclusionPlugin implements IEventPlugin {
priority: number;
name: string;
run(context: EventPluginContext, next?: () => void): void;
getLogLevel(level: string): number;
getMinLogLevel(configSettings: Record<string, string>, source: any): number;
private getTypeAndSourceSetting;
}
export declare class ModuleInfoPlugin implements IEventPlugin {
priority: number;
Expand Down Expand Up @@ -500,15 +515,15 @@ export declare class InMemoryStorage implements IStorage {
clear(): void;
}
export interface IClientConfiguration {
settings: object;
settings: Record<string, string>;
version: number;
}
export declare abstract class KeyValueStorageBase implements IStorage {
private maxItems;
private items;
private lastTimestamp;
constructor(maxItems: any);
save(value: any, single?: boolean): number;
constructor(maxItems: number);
save(value: any): number;
get(limit?: number): IStorageItem[];
remove(timestamp: number): void;
clear(): void;
Expand All @@ -518,9 +533,9 @@ export declare abstract class KeyValueStorageBase implements IStorage {
protected abstract delete(key: string): any;
protected abstract getKey(timestamp: number): string;
protected abstract getTimestamp(key: string): number;
private ensureIndex();
private safeDelete(key);
private createIndex();
private ensureIndex;
private safeDelete;
private createIndex;
}
export declare class BrowserStorage extends KeyValueStorageBase {
private prefix;
Expand All @@ -537,7 +552,7 @@ export declare class DefaultErrorParser implements IErrorParser {
parse(context: EventPluginContext, exception: Error): IError;
}
export declare class DefaultModuleCollector implements IModuleCollector {
getModules(context: EventPluginContext): IModule[];
getModules(): IModule[];
}
export declare class DefaultRequestInfoCollector implements IRequestInfoCollector {
getRequestInfo(context: EventPluginContext): IRequestInfo;
Expand Down
Loading

0 comments on commit e9a795e

Please sign in to comment.