Skip to content
Draft
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
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: {
minProperties: 1
}
}
],
"@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.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 12 additions & 2 deletions packages/angularjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ angular
"$ExceptionlessClient",
($location: ng.ILocationService, $q: ng.IQService, $ExceptionlessClient: BrowserExceptionlessClient) => {
return {
responseError: function responseError(response: ng.IHttpResponse<{ Message?: string }>) {
responseError: function responseError(
response: ng.IHttpResponse<{
Message?: string;
}>
) {
if (response.status === 404) {
void $ExceptionlessClient.submitNotFound(response.config.url);
} else if (response.status !== 401) {
Expand Down Expand Up @@ -48,7 +52,13 @@ angular
function decorateRegularCall(property: string, logLevel: string) {
const previousFn = $delegate[property];
return ($delegate[property] = (...args: string[]) => {
if ((angular as { mock?: unknown }).mock) {
if (
(
angular as {
mock?: unknown;
}
).mock
) {
$delegate[property].logs = [];
}

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
65 changes: 49 additions & 16 deletions packages/browser/src/plugins/BrowserGlobalHandlerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import { ExceptionlessClient, IEventPlugin, PluginContext, toError } from "@exce

declare let $: (document: Document) => {
ajaxError: {
(document: (event: Event, xhr: { responseText: string; status: number }, settings: { data: unknown; url: string }, error: string) => void): void;
(
document: (
event: Event,
xhr: {
responseText: string;
status: number;
},
settings: {
data: unknown;
url: string;
},
error: string
) => void
): void;
};
};

Expand All @@ -29,7 +42,13 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
if (!(reason instanceof Error)) {
try {
// Check for reason in legacy CustomEvents (https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)
const detailReason = (<{ detail?: { reason: string } }>event).detail?.reason;
const detailReason = (<
{
detail?: {
reason: string;
};
}
>event).detail?.reason;
if (detailReason) {
reason = detailReason;
}
Expand All @@ -54,21 +73,34 @@ export class BrowserGlobalHandlerPlugin implements IEventPlugin {
});

if (typeof $ !== "undefined" && $(document)) {
$(document).ajaxError((_: Event, xhr: { responseText: string; status: number }, settings: { data: unknown; url: string }, error: string) => {
if (xhr.status === 404) {
// TODO: Handle async
void this._client?.submitNotFound(settings.url);
} else if (xhr.status !== 401) {
// TODO: Handle async
void this._client
?.createUnhandledException(toError(error), "JQuery.ajaxError")
.setSource(settings.url)
.setProperty("status", xhr.status)
.setProperty("request", settings.data)
.setProperty("response", xhr.responseText?.slice(0, 1024))
.submit();
$(document).ajaxError(
(
_: Event,
xhr: {
responseText: string;
status: number;
},
settings: {
data: unknown;
url: string;
},
error: string
) => {
if (xhr.status === 404) {
// TODO: Handle async
void this._client?.submitNotFound(settings.url);
} else if (xhr.status !== 401) {
// TODO: Handle async
void this._client
?.createUnhandledException(toError(error), "JQuery.ajaxError")
.setSource(settings.url)
.setProperty("status", xhr.status)
.setProperty("request", settings.data)
.setProperty("response", xhr.responseText?.slice(0, 1024))
.submit();
}
}
});
);
}

return Promise.resolve();
Expand All @@ -90,6 +122,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
Loading