Skip to content

Client 2.0 (workspaces, esm and more) #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 145 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
0f9fdce
moved src folder to packages\core\src
niemyjski Jan 16, 2021
e9d19cd
Moved tests into test folders and split out code into packages
niemyjski Jan 16, 2021
b490d93
WIP - more workspace changes
niemyjski Jan 20, 2021
608a2b6
WIP - More tsconfig changes
niemyjski Jan 21, 2021
8fb23c6
Resolved some workspace build issues
niemyjski Jan 27, 2021
89cf8cb
Fixed npm run build
niemyjski Jan 30, 2021
a3b74d6
Fixed package name
niemyjski Jan 30, 2021
b7a6939
WIP - cjs and esm builds
niemyjski Feb 9, 2021
db332fb
Updates to node imports
niemyjski Feb 9, 2021
f3412f7
Fixed build
niemyjski Feb 10, 2021
0af4355
Updates to build
niemyjski Feb 15, 2021
c68287e
Simplified build
niemyjski Feb 16, 2021
651b124
Convert to jest.
niemyjski Feb 17, 2021
94be13d
Removed cjs build. We can use esbuild later if needed
niemyjski Feb 17, 2021
e8aee10
Fixed module imports & ensure all imports have a .js extension
niemyjski Feb 17, 2021
f9fc327
Build updates
niemyjski Feb 18, 2021
c88163e
Updates to linting
niemyjski Feb 18, 2021
6688540
Added esbuild for bundle
niemyjski Feb 20, 2021
eb9775b
WIP - Express ESM Sample
niemyjski Feb 24, 2021
21de909
Removed yarn lock
niemyjski Feb 24, 2021
76fc217
Updated build
niemyjski Feb 24, 2021
5ffdeb4
Update deps
niemyjski Feb 24, 2021
4d5de7b
Browser sourcemaps + async plugins
niemyjski Feb 25, 2021
270a9e0
WIP - Submission client refactor (tests still need to be refactored)
niemyjski Feb 25, 2021
031dc2f
More test updates for new submission impl
niemyjski Feb 26, 2021
27afb31
Change models to classes and re-arrange folder structure (#96)
ejsmith Feb 26, 2021
b8a0ba6
Converted single quotes to double.
niemyjski Feb 26, 2021
c77f593
Fixed unit tests
niemyjski Feb 26, 2021
d1a74f1
Removed default client instance, Identified some perf issues via PERF…
niemyjski Mar 4, 2021
18c89b5
WIP Client bootstrapping.
niemyjski Mar 10, 2021
e4c8607
fixed unit tests
niemyjski Mar 11, 2021
3f7d82d
WIP - Reworked startup and WIP plugins.
niemyjski Mar 15, 2021
317d751
Fixed build
niemyjski Mar 15, 2021
6a9737e
WIP - Ability to suspend/resume all client timers and plugins.
niemyjski Mar 16, 2021
16213d5
Moved config services, removed node storage prefix and more
niemyjski Mar 17, 2021
fd65666
WIP Unit Test Updates
niemyjski Mar 17, 2021
0aefeca
Fixed unit tests
niemyjski Mar 18, 2021
02853cb
WIP - Simplified configuration handlers via proxies, start of integra…
niemyjski Mar 22, 2021
667c771
WIP Browser plugins
niemyjski Mar 23, 2021
b7c280c
Removed bower from readme
niemyjski Mar 23, 2021
4d4ce33
Added browser plugins
niemyjski Mar 23, 2021
9f5adcc
Added node plugins
niemyjski Mar 23, 2021
dea2976
Configuration improvements: proxy subscribers and version property
niemyjski Mar 23, 2021
dbde875
Updated extensions
niemyjski Mar 24, 2021
2fbe321
WIP - Samples
niemyjski Mar 24, 2021
8a47f13
Cleaned up configuration
niemyjski Mar 24, 2021
7415c31
Dropped lage, using npm 7.7
niemyjski Mar 24, 2021
3055cf2
Fixed browser build
niemyjski Mar 26, 2021
b1782a2
Fixed the browser and node submission client auth
niemyjski Mar 30, 2021
b0f0d55
Updated the browser sample
niemyjski Mar 30, 2021
384c386
Added support for logging client self log to text area
niemyjski Mar 30, 2021
076b715
Renamed logger
niemyjski Mar 31, 2021
13cdcaa
Fixed fetch implementation, added rate limit header support.
niemyjski Mar 31, 2021
f66a4a4
Renamed build:watch task to watch
niemyjski Mar 31, 2021
9b09259
Fixed a bug with adding plugins that only had a startup method
niemyjski Mar 31, 2021
6c4912a
Improved log messages and log levels
niemyjski Mar 31, 2021
7ec9586
Improved rate limiting to suspend until the next 15 minute time perio…
niemyjski Mar 31, 2021
af003c5
Fixed an issue with the settings manager not properly handling 304 se…
niemyjski Mar 31, 2021
4782b04
Use modern error handlers and WIP on processing string errors.
niemyjski Mar 31, 2021
7e9069a
WIP Node fixes + start of storage refactor
niemyjski Apr 2, 2021
53e5799
WIP - Simplified storage
niemyjski Apr 6, 2021
521a334
Fixed storage, improved settings management
niemyjski Apr 7, 2021
779b28b
Queue now respects max items.
niemyjski Apr 9, 2021
417d58a
Added default react native expo sample
niemyjski Apr 14, 2021
1eb7fde
Updated deps
niemyjski Apr 14, 2021
b094845
package updates
niemyjski Apr 15, 2021
6b7ab5b
updated expo
niemyjski Apr 15, 2021
9abfa38
Added react package
niemyjski Apr 15, 2021
790f6c0
react package and start of example
polluterofminds Apr 16, 2021
28f253f
Deleted react-native sample. fixed deps
niemyjski Apr 16, 2021
913549c
updated react example and changed export paradigm in react package
polluterofminds Apr 20, 2021
38a7d31
Updated package version, run workspace examples after client build, l…
niemyjski Apr 21, 2021
dacadcf
read me updates and react sample
polluterofminds Apr 21, 2021
03a6227
Removed extra config from readme.
niemyjski Apr 21, 2021
6b588bb
Updated recommended extensions
niemyjski Apr 21, 2021
dd10080
added readmes
polluterofminds Apr 22, 2021
bb91924
WIP - Updated workflow to lint + push ci packages.
niemyjski Apr 22, 2021
ff1286a
added additional examples
polluterofminds Apr 27, 2021
30182b1
fixed browser example path
polluterofminds May 4, 2021
4b19c12
uncommented custom server url for express example
polluterofminds May 4, 2021
117f6b6
start of angular example
polluterofminds May 5, 2021
7ecbf50
Target ES2019 for react-native / angular
niemyjski May 6, 2021
cd31068
vue example and angular start:
polluterofminds May 6, 2021
6c9996b
Fixed issues with node-stack-trace
niemyjski May 7, 2021
7e42a13
vue error boundary work --- in progress
polluterofminds May 7, 2021
25be1f6
can't import vue package yet
polluterofminds May 7, 2021
f46477c
Add typing for event data known keys
ejsmith May 13, 2021
68a07f1
Fixed build errors, updated vue package to use global error handler.
niemyjski May 17, 2021
006f1df
removed angular 11.x sample
niemyjski May 17, 2021
e3214b1
Fixed vue example
niemyjski May 17, 2021
fe09288
removed example test
niemyjski May 17, 2021
c3f0235
Update version on build
niemyjski May 18, 2021
bbd0b7c
bring back lage for build step (build by dep order)
niemyjski May 19, 2021
84d3725
possible version fix
niemyjski May 19, 2021
86884a8
try using min version build step
niemyjski May 19, 2021
12618b3
specify github action min ver version
niemyjski May 19, 2021
4f8b061
show npm version
niemyjski May 19, 2021
19153c5
install latest npm for workspace publish support
niemyjski May 19, 2021
7c9cdf1
use 2.0 as min ver
niemyjski May 19, 2021
fcbeb4b
Attempt to publish to github registry
niemyjski May 19, 2021
5a3929a
fixed min-ver (bad docs)
niemyjski May 19, 2021
2821b5c
try to push to to gpr
niemyjski May 19, 2021
ae0be11
attempt 6
niemyjski May 19, 2021
4fcc9cf
attempt 7
niemyjski May 19, 2021
532fe4b
attempt 8
niemyjski May 19, 2021
656351d
attempt 9
niemyjski May 19, 2021
59a81eb
wip authenticating to gpr
niemyjski May 20, 2021
ec7c57a
use workflow actions to configure node.
niemyjski May 20, 2021
f16db3f
Fixed yaml
niemyjski May 20, 2021
f492ef2
Added publish section to examples
niemyjski May 20, 2021
14b2f5c
Updated deps
niemyjski May 21, 2021
4cb5b4d
Moved module service to browser plugin and cached it.
niemyjski May 21, 2021
4624236
Added simple error interface
niemyjski May 21, 2021
c7d7675
Fixed a compiler error with isolated modules.
niemyjski May 21, 2021
2f9a787
Removed request info service into plugin
niemyjski May 21, 2021
8390927
Removed environment info collector service.
niemyjski May 21, 2021
bce0746
cache node environment info
niemyjski May 21, 2021
dca4aa1
Change core client to be functional and expect fetch and localStorage…
ejsmith May 22, 2021
b533be7
Fix tests
ejsmith May 22, 2021
32deb33
Fix browser test script
ejsmith May 23, 2021
33021ec
Some build and watch changes
ejsmith May 23, 2021
df7a047
Adding node polyfills for fetch and storage
ejsmith May 23, 2021
0b6c4d7
Fix linting issues
ejsmith May 23, 2021
674dd60
Fix tests. Refactor event context.
ejsmith May 23, 2021
9ad0d13
Removed example settings
niemyjski May 24, 2021
d6fe7c6
WIP - Removed error parser service, Added default plugin for Simple E…
niemyjski May 24, 2021
3d0e9e3
Removed IEventQueue
niemyjski May 24, 2021
63efde5
Revert "Removed IEventQueue"
niemyjski May 24, 2021
48972ae
Updated deps
niemyjski May 25, 2021
42c6596
Fixed tests
niemyjski May 26, 2021
96373fc
compile with strict mode
niemyjski Jun 2, 2021
1a27422
Turned on noImplicitAny noImplicitThis noImplicitReturns noUnusedLoca…
niemyjski Jun 7, 2021
48a0b59
Turned on more linting rules + fixes
niemyjski Jun 7, 2021
7702b45
Fixed node runtime issue with calling c.useLocalStorage() on startup
niemyjski Jun 8, 2021
41cbbca
Fixed browser submission error: Failed to execute 'fetch' on 'Window…
niemyjski Jun 9, 2021
fd59c33
removed extra overload definition
niemyjski Jun 9, 2021
8e63aaf
Fixed a bug where simple error and error error plugins would be added.
niemyjski Jun 9, 2021
12ded8e
Fixed vue example
niemyjski Jun 9, 2021
c72f6a8
Fixed unit test failures when fetch is undefined
niemyjski Jun 9, 2021
eb8dd87
Temp fix for npm version --workspaces not updating package deps
niemyjski Jun 14, 2021
384ff6b
updated user agent to match package versions
niemyjski Jun 14, 2021
14c2802
Updated deps
niemyjski Jun 14, 2021
26778b0
rework build steps
niemyjski Jun 14, 2021
010d4e8
Tweaked angularjs package
niemyjski Jun 15, 2021
8ea1a1d
fixed linting issue
niemyjski Jun 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP - Simplified storage
  • Loading branch information
niemyjski committed Apr 6, 2021
commit 53e57999007fdbb293a9724a6973c29e98934867
8 changes: 6 additions & 2 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@
"scripts": {
"build": "tsc -p tsconfig.json && esbuild src/index.ts --bundle --minify --sourcemap --target=es2020 --format=esm --outfile=dist/index.min.js",
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput",
"test": ""
"test": "jest"
},
"sideEffects": [
"dist/index.js"
],
"devDependencies": {
"esbuild": "0.8.49"
"@jest/globals": "26.6.2",
"esbuild": "0.8.49",
"jest": "26.6.3",
"jest-ts-webcompat-resolver": "1.0.0",
"ts-jest": "26.5.1"
},
"dependencies": {
"@exceptionless/core": "2.0.0-pre",
Expand Down
22 changes: 11 additions & 11 deletions packages/browser/src/BrowserExceptionlessClient.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { ExceptionlessClient } from "@exceptionless/core";
import {
Configuration,
ExceptionlessClient
} from "@exceptionless/core";

import { BrowserConfiguration } from "./configuration/BrowserConfiguration.js";
import { BrowserGlobalHandlerPlugin } from "./plugins/BrowserGlobalHandlerPlugin.js";
import { BrowserLifeCyclePlugin } from "./plugins/BrowserLifeCyclePlugin.js";
import { BrowserWrapFunctions } from "./plugins/BrowserWrapFunctions.js";
import { BrowserErrorParser } from "./services/BrowserErrorParser.js";
import { BrowserModuleCollector } from "./services/BrowserModuleCollector.js";
import { BrowserRequestInfoCollector } from "./services/BrowserRequestInfoCollector.js";
import { BrowserLocalStorage } from "./storage/BrowserLocalStorage.js";
import { BrowserFetchSubmissionClient } from "./submission/BrowserFetchSubmissionClient.js";

export class BrowserExceptionlessClient extends ExceptionlessClient {
constructor() {
super(new BrowserConfiguration());
}

public async startup(configurationOrApiKey?: (config: BrowserConfiguration) => void | string): Promise<void> {
public async startup(configurationOrApiKey?: (config: Configuration) => void | string): Promise<void> {
const config = this.config;
if (configurationOrApiKey) {
config.addPlugin(new BrowserGlobalHandlerPlugin());
config.addPlugin(new BrowserLifeCyclePlugin());
config.addPlugin(new BrowserWrapFunctions());

config.services.storage = new BrowserLocalStorage();
config.services.errorParser = new BrowserErrorParser();
config.services.moduleCollector = new BrowserModuleCollector();
config.services.requestInfoCollector = new BrowserRequestInfoCollector();
config.services.submissionClient = new BrowserFetchSubmissionClient(config);

config.addPlugin(new BrowserGlobalHandlerPlugin());
config.addPlugin(new BrowserLifeCyclePlugin());
config.addPlugin(new BrowserWrapFunctions());
}

await super.startup(configurationOrApiKey);
Expand Down
12 changes: 0 additions & 12 deletions packages/browser/src/configuration/BrowserConfiguration.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
export { BrowserConfiguration } from "./configuration/BrowserConfiguration.js";
export { BrowserGlobalHandlerPlugin } from "./plugins/BrowserGlobalHandlerPlugin.js";
export { BrowserLifeCyclePlugin } from "./plugins/BrowserLifeCyclePlugin.js";
export { BrowserWrapFunctions } from "./plugins/BrowserWrapFunctions.js";
export { BrowserErrorParser } from "./services/BrowserErrorParser.js";
export { BrowserModuleCollector } from "./services/BrowserModuleCollector.js";
export { BrowserRequestInfoCollector } from "./services/BrowserRequestInfoCollector.js";
export { BrowserLocalStorage } from "./storage/BrowserLocalStorage.js";
export { BrowserLocalStorageProvider as BrowserStorageProvider } from "./storage/BrowserLocalStorageProvider.js";
export { BrowserFetchSubmissionClient } from "./submission/BrowserFetchSubmissionClient.js";
export { BrowserExceptionlessClient } from "./BrowserExceptionlessClient.js";

Expand Down
64 changes: 33 additions & 31 deletions packages/browser/src/storage/BrowserLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
import { KeyValueStorageBase } from "@exceptionless/core";

export class BrowserLocalStorage extends KeyValueStorageBase {
private prefix: string;

public static isAvailable(): boolean {
try {
const storage = window.localStorage;
const x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (e) {
return false;
}
import { IStorage } from "@exceptionless/core";

export class BrowserLocalStorage implements IStorage {
constructor(private prefix: string = "exceptionless:") { }

public length(): Promise<number> {
return Promise.resolve(this.getKeys().length);
}

constructor(namespace: string, prefix: string = "com.exceptionless.", maxItems: number = 20) {
super(maxItems);
public clear(): Promise<void> {
for (const key of this.getKeys()) {
window.localStorage.removeItem(key);
}

return Promise.resolve();
}

this.prefix = prefix + namespace + "-";
public getItem(key: string): Promise<string> {
return Promise.resolve(window.localStorage.getItem(this.getKey(key)));
}

public writeValue(key: string, value: string): void {
window.localStorage.setItem(key, value);
public key(index: number): Promise<string> {
const keys = this.getKeys();
return Promise.resolve(keys[index]);
}

public readValue(key: string): string {
return window.localStorage.getItem(key);
public keys(): Promise<string[]> {
return Promise.resolve(this.getKeys());
}

public removeValue(key: string): void {
window.localStorage.removeItem(key);
public removeItem(key: string): Promise<void> {
window.localStorage.removeItem(this.getKey(key));
return Promise.resolve();
}

public getAllKeys(): string[] {
return Object.keys(window.localStorage)
.filter((key) => key.indexOf(this.prefix) === 0);
public setItem(key: string, value: string): Promise<void> {
window.localStorage.setItem(this.getKey(key), value);
return Promise.resolve();
}

public getKey(timestamp: number): string {
return this.prefix + timestamp;
private getKeys(): string[] {
return Object.keys(window.localStorage)
.filter(key => key.startsWith(this.prefix))
.map(key => key?.substr(this.prefix.length));
}

public getTimestamp(key: string): number {
return parseInt(key.substr(this.prefix.length), 10);
private getKey(key: string): string {
return this.prefix + key;
}
}
16 changes: 0 additions & 16 deletions packages/browser/src/storage/BrowserLocalStorageProvider.ts

This file was deleted.

14 changes: 14 additions & 0 deletions packages/browser/test/storage/BrowserLocalStorage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describeStorage } from "@exceptionless/core/test/storage/InMemoryStorage.test";
import { IStorage } from "@exceptionless/core/src/storage/IStorage";
import { BrowserLocalStorage } from "../../src/storage/BrowserLocalStorage.js";

function resetLocalStorage() {
localStorage.clear();
}

describeStorage(
"BrowserLocalStorage",
(): IStorage => new BrowserLocalStorage(),
resetLocalStorage,
resetLocalStorage
);
4 changes: 2 additions & 2 deletions packages/core/src/ExceptionlessClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ExceptionlessClient {
configurationOrApiKey(this.config);
}

this.config.services.queue.onEventsPosted(() => this.updateSettingsTimer());
this.config.services.queue.onEventsPosted(() => Promise.resolve(this.updateSettingsTimer()));
}

this.updateSettingsTimer(configurationOrApiKey ? 5000 : 0);
Expand Down Expand Up @@ -208,7 +208,7 @@ export class ExceptionlessClient {
ev.date = new Date();
}

config.services.queue.enqueue(ev);
await config.services.queue.enqueue(ev);

if (ev.reference_id && ev.reference_id.length > 0) {
context.log.info(`Setting last reference id "${ev.reference_id}"`);
Expand Down
79 changes: 14 additions & 65 deletions packages/core/src/configuration/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,26 @@ export class Configuration {
/**
* The API key that will be used when sending events to the server.
* @type {string}
* @private
*/
private _apiKey: string;
public apiKey: string;

/**
* The server url that all events will be sent to.
* @type {string}
* @private
*/
private _serverUrl: string = "https://collector.exceptionless.io";

/**
* The config server url that all configuration will be retrieved from.
* @type {string}
* @private
*/
private _configServerUrl: string = "https://config.exceptionless.io";
public configServerUrl: string = "https://config.exceptionless.io";

/**
* The heartbeat server url that all heartbeats will be sent to.
* @type {string}
* @private
*/
private _heartbeatServerUrl: string = "https://heartbeat.exceptionless.io";
public heartbeatServerUrl: string = "https://heartbeat.exceptionless.io";

/**
* How often the client should check for updated server settings when idle. The default is every 2 minutes.
Expand Down Expand Up @@ -153,22 +149,6 @@ export class Configuration {
*/
private _subscribers: Array<(config: Configuration) => void> = [];

/**
* The API key that will be used when sending events to the server.
* @returns {string}
*/
public get apiKey(): string {
return this._apiKey;
}

/**
* The API key that will be used when sending events to the server.
* @param value
*/
public set apiKey(value: string) {
this._apiKey = value || null;
}

/**
* Returns true if the apiKey is valid.
* @returns {boolean}
Expand All @@ -192,44 +172,8 @@ export class Configuration {
public set serverUrl(value: string) {
if (value) {
this._serverUrl = value;
this._configServerUrl = value;
this._heartbeatServerUrl = value;
}
}

/**
* The config server url that all configuration will be retrieved from.
* @returns {string}
*/
public get configServerUrl(): string {
return this._configServerUrl;
}

/**
* The config server url that all configuration will be retrieved from.
* @param value
*/
public set configServerUrl(value: string) {
if (value) {
this._configServerUrl = value;
}
}

/**
* The heartbeat server url that all heartbeats will be sent to.
* @returns {string}
*/
public get heartbeatServerUrl(): string {
return this._heartbeatServerUrl;
}

/**
* The heartbeat server url that all heartbeats will be sent to.
* @param value
*/
public set heartbeatServerUrl(value: string) {
if (value) {
this._heartbeatServerUrl = value;
this.configServerUrl = value;
this.heartbeatServerUrl = value;
}
}

Expand Down Expand Up @@ -546,10 +490,7 @@ export class Configuration {
public setUserIdentity(userInfo: UserInfo): void;
public setUserIdentity(identity: string): void;
public setUserIdentity(identity: string, name: string): void;
public setUserIdentity(
userInfoOrIdentity: UserInfo | string,
name?: string,
): void {
public setUserIdentity(userInfoOrIdentity: UserInfo | string, name?: string): void {
const userInfo: UserInfo = typeof userInfoOrIdentity !== "string"
? userInfoOrIdentity
: { identity: userInfoOrIdentity, name };
Expand Down Expand Up @@ -589,6 +530,14 @@ export class Configuration {
this.addPlugin(new ReferenceIdPlugin());
}


/**
* Writes events to storage on enqueue and removes them when submitted. (Defaults to false)
* This setting only works in environments that supports persisted storage.
* There is also a performance penalty of extra IO/serialization.
*/
public usePersistedQueueStorage: boolean = false;

// TODO: Support a min log level.
public useDebugLogger(): void {
this.services.log = new ConsoleLog();
Expand Down
Loading