Skip to content

Preserve event type if event has error #122

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 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1>Log Submission</h1>
<button class="submit-log" data-level="info">Submit info log event</button>
<button class="submit-log" data-level="warn">Submit warn log event</button>
<button class="submit-log" data-level="error">Submit error log event</button>
<button id="submit-error-log-with-error">Submit error log event with real error</button>

<h1>Diagnostics</h1>
<button id="config-settings-log">Log Client Configuration Settings (settings sent from server)</button>
Expand Down
8 changes: 8 additions & 0 deletions example/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ document.addEventListener("DOMContentLoaded", () => {
});
}

document
.querySelector("#submit-error-log-with-error")
.addEventListener("click", async () => {
const builder = Exceptionless.createLog("Button Click", "Error Log with Error");
builder.context.setException(new Error("test"));
await builder.submit();
});

document
.querySelector("#throw-custom-error")
.addEventListener("click", () => {
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 @@ -22,7 +22,9 @@ export class BrowserErrorPlugin implements IEventPlugin {
public async run(context: EventPluginContext): Promise<void> {
const exception = context.eventContext.getException();
if (exception) {
context.event.type = "error";
if (!context.event.type) {
context.event.type = "error";
}

if (context.event.data && !context.event.data[KnownEventDataKeys.Error]) {
const result = await this.parse(exception);
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/plugins/default/SimpleErrorPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class SimpleErrorPlugin implements IEventPlugin {
public async run(context: EventPluginContext): Promise<void> {
const exception = context.eventContext.getException();
if (exception) {
context.event.type = "error";
if (!context.event.type) {
context.event.type = "error";
}

if (context.event.data && !context.event.data[KnownEventDataKeys.SimpleError]) {
const error = <SimpleError>{
Expand Down
4 changes: 3 additions & 1 deletion packages/node/src/plugins/NodeErrorPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export class NodeErrorPlugin implements IEventPlugin {
public async run(context: EventPluginContext): Promise<void> {
const exception = context.eventContext.getException();
if (exception) {
context.event.type = "error";
if (!context.event.type) {
context.event.type = "error";
}

if (context.event.data && !context.event.data[KnownEventDataKeys.Error]) {
const result = await this.parse(exception);
Expand Down