Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm test
# Lint (ESLint + Prettier check)
npm run lint

# Auto-format with Prettier
# Auto-format with ESLint fixes followed by Prettier
npm run format

# Clean all build outputs
Expand Down Expand Up @@ -107,7 +107,7 @@ All framework packages (`react`, `vue`, `angularjs`) depend on `browser`, which

### Style & Formatting

- Run `npm run format` (Prettier) to auto-format code
- Run `npm run format` (ESLint fixes followed by Prettier) to auto-format code
- Run `npm run lint` (ESLint + Prettier check) to verify
- Match existing file style; minimize diffs
- No code comments unless necessary—code should be self-explanatory
Expand Down
61 changes: 58 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import eslint from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import { defineConfig } from "eslint/config";
import eslintConfigPrettier from "eslint-config-prettier";
import vitest from "@vitest/eslint-plugin";
import tseslint from "typescript-eslint";

export default defineConfig(
{ ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"] },
{
ignores: ["**/dist/", "**/node_modules/", ".agents/", "example/", "**/expo-plugin/", "**/react-native.config.*"]
},
eslint.configs.recommended,
{
extends: tseslint.configs.recommendedTypeChecked,
Expand All @@ -27,11 +30,63 @@ export default defineConfig(
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true }],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }]
"@typescript-eslint/no-unused-expressions": [
"error",
{
allowShortCircuit: true
}
],
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: false
}
]
}
},
{
files: ["scripts/**/*.mjs"],
...tseslint.configs.disableTypeChecked,
languageOptions: {
...tseslint.configs.disableTypeChecked.languageOptions,
globals: {
console: "readonly",
process: "readonly"
}
}
},
eslintConfigPrettier,
{
plugins: {
"@stylistic": stylistic
},
rules: {
curly: ["error", "all"],
"@stylistic/object-curly-newline": [
"error",
{
ObjectExpression: {
Comment thread
niemyjski marked this conversation as resolved.
minProperties: 1
}
Comment thread
niemyjski marked this conversation as resolved.
}
],
"@stylistic/brace-style": [
"error",
"1tbs",
{
allowSingleLine: false
}
],
"padding-line-between-statements": [
"error",
{
blankLine: "always",
prev: "block-like",
next: ["if", "while", "for", "do"]
}
]
}
},
{
files: ["**/test/**/*.ts"],
plugins: vitest.configs.recommended.plugins,
Expand Down
53 changes: 53 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint:eslint": "eslint .",
"lint:prettier": "prettier --check .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format": "npm run lint:fix && prettier --write .",
"test": "vitest run",
"test:watch": "vitest",
"version": "npm --no-git-tag-version --workspaces=true version",
Expand All @@ -30,6 +30,7 @@
],
"devDependencies": {
"@eslint/js": "^10.0.1",
"@stylistic/eslint-plugin": "^5.10.0",
"@vitest/eslint-plugin": "^1.6.19",
"eslint": "^10.4.1",
"eslint-config-prettier": "^10.1.8",
Expand Down
4 changes: 3 additions & 1 deletion packages/browser/src/plugins/BrowserErrorPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export class BrowserErrorPlugin implements IEventPlugin {

const items: ParameterInfo[] = [];
for (const param of params) {
items.push({ name: param });
items.push({
name: param
});
}

return items;
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/plugins/BrowserGlobalHandlerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
if (errorName) {
name = errorName;
}

if (errorMessage) {
msg = errorMessage;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/browser/test/plugins/BrowserErrorPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ describe("BrowserErrorPlugin", () => {
const error = {
someProperty: "Test"
};
await processError(new Error("Error With Cause", { cause: error }));
await processError(
new Error("Error With Cause", {
cause: error
})
);
const additionalData = getAdditionalData(context.event);
expect(additionalData).not.toBeNull();
expect(additionalData?.cause).toStrictEqual(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ describe("BrowserIgnoreExtensionErrorsPlugin", () => {
const eventContext = new EventContext();
eventContext.setException(error);

const context = new EventPluginContext(client, { type: "error" }, eventContext);
const context = new EventPluginContext(
client,
{
type: "error"
},
eventContext
);

await plugin.run(context);
return context;
Expand Down
16 changes: 13 additions & 3 deletions packages/core/src/EventBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ export class EventBuilder {
public setUserIdentity(identity: string): EventBuilder;
public setUserIdentity(identity: string, name: string): EventBuilder;
public setUserIdentity(userInfoOrIdentity: UserInfo | string, name?: string): EventBuilder {
const userInfo = typeof userInfoOrIdentity !== "string" ? userInfoOrIdentity : { identity: userInfoOrIdentity, name };
const userInfo =
typeof userInfoOrIdentity !== "string"
? userInfoOrIdentity
: {
identity: userInfoOrIdentity,
name
};
if (!userInfo || (!userInfo.identity && !userInfo.name)) {
return this;
}
Expand Down Expand Up @@ -121,7 +127,9 @@ export class EventBuilder {
*/
public setManualStackingInfo(signatureData: Record<string, string>, title?: string): EventBuilder {
if (signatureData) {
const stack: ManualStackingInfo = { signature_data: signatureData };
const stack: ManualStackingInfo = {
signature_data: signatureData
};
if (title) {
stack.title = title;
}
Expand All @@ -139,7 +147,9 @@ export class EventBuilder {
*/
public setManualStackingKey(manualStackingKey: string, title?: string): EventBuilder {
if (manualStackingKey) {
const data = { ManualStackingKey: manualStackingKey };
const data = {
ManualStackingKey: manualStackingKey
};
this.setManualStackingInfo(data, title);
}

Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/ExceptionlessClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ export class ExceptionlessClient {
}

public createEvent(context?: EventContext): EventBuilder {
return new EventBuilder({ date: new Date() }, this, context);
return new EventBuilder(
{
date: new Date()
},
this,
context
);
}

/**
Expand Down Expand Up @@ -264,7 +270,10 @@ export class ExceptionlessClient {
return;
}

const userDescription: UserDescription = { email_address: email, description };
const userDescription: UserDescription = {
email_address: email,
description
};
const response = await this.config.services.submissionClient.submitUserDescription(referenceId, userDescription);
if (!response.success) {
this.config.services.log.error(`Failed to submit user email and description for event "${referenceId}": ${response.status} ${response.message}`);
Expand Down
16 changes: 14 additions & 2 deletions packages/core/src/configuration/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,13 @@ export class Configuration {
*/
public addPlugin(name: string | undefined, priority: number, pluginAction: (context: EventPluginContext) => Promise<void>): void;
public addPlugin(pluginOrName: IEventPlugin | string | undefined, priority?: number, pluginAction?: (context: EventPluginContext) => Promise<void>): void {
const plugin: IEventPlugin = pluginAction ? <IEventPlugin>{ name: pluginOrName as string, priority, run: pluginAction } : (pluginOrName as IEventPlugin);
const plugin: IEventPlugin = pluginAction
? <IEventPlugin>{
name: pluginOrName as string,
priority,
run: pluginAction
}
: (pluginOrName as IEventPlugin);

if (!plugin || !(plugin.startup || plugin.run)) {
this.services.log.error("Add plugin failed: startup or run method not defined");
Expand Down Expand Up @@ -442,7 +448,13 @@ export class Configuration {
public setUserIdentity(identity: string): void;
public setUserIdentity(identity: string, name: string): void;
public setUserIdentity(userInfoOrIdentity: UserInfo | string, name?: string): void {
const userInfo: UserInfo = typeof userInfoOrIdentity !== "string" ? userInfoOrIdentity : <UserInfo>{ identity: userInfoOrIdentity, name };
const userInfo: UserInfo =
typeof userInfoOrIdentity !== "string"
? userInfoOrIdentity
: <UserInfo>{
identity: userInfoOrIdentity,
name
};

const shouldRemove: boolean = !userInfo || (!userInfo.identity && !userInfo.name);
if (shouldRemove) {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/plugins/EventPluginContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export class EventPluginContext {
public event: Event,
public eventContext: EventContext
) {
if (!this.eventContext) this.eventContext = new EventContext();
if (!this.eventContext) {
this.eventContext = new EventContext();
}
}

public get log(): ILog {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/plugins/default/DuplicateCheckerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DuplicateCheckerPlugin implements IEventPlugin {
if (error.message && error.message.length) {
hash += (hash * 397) ^ getHashCode(error.message);
}

if (error.stack_trace && error.stack_trace.length) {
hash += (hash * 397) ^ getHashCode(JSON.stringify(error.stack_trace));
}
Expand Down Expand Up @@ -70,7 +71,10 @@ export class DuplicateCheckerPlugin implements IEventPlugin {

if (!context.cancelled) {
context.log.trace(`Enqueueing event with hash: ${hashCode} to cache`);
this._processedHashCodes.push({ hash: hashCode, timestamp: now });
this._processedHashCodes.push({
hash: hashCode,
timestamp: now
});

// Only keep the last 50 recent errors.
while (this._processedHashCodes.length > 50) {
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/queue/DefaultEventQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ export class DefaultEventQueue implements IEventQueue {
for (const file of files) {
if (file?.startsWith(this.QUEUE_PREFIX)) {
const json = await storage.getItem(file);
if (json) this._queue.push({ file, event: JSON.parse(json) as Event });
if (json) {
this._queue.push({
file,
event: JSON.parse(json) as Event
});
}
}
}
} catch (ex) {
Expand All @@ -280,7 +285,12 @@ export class DefaultEventQueue implements IEventQueue {

const { log, storage } = this.config.services;
const useStorage: boolean = this.config.usePersistedQueueStorage;
if (this._queue.push({ file, event }) > this.maxItems) {
if (
this._queue.push({
file,
event
}) > this.maxItems
) {
log.trace("Removing oldest queue entry: maxItems exceeded");
const item = this._queue.shift();
if (useStorage && item) {
Expand Down
Loading
Loading