Skip to content
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

chore: Convert ErrorReporting to a Service to use DI. Add some tests (no-changelog) #11279

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

netroy
Copy link
Member

@netroy netroy commented Oct 16, 2024

PAY-2113

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Tests included.

@netroy netroy requested a review from ivov October 16, 2024 09:49
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Oct 16, 2024
Copy link
Contributor

@ivov ivov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏🏻

import { Service } from 'typedi';

@Service()
export class ErrorReporting {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
export class ErrorReporting {
export class ErrorReporter {


import { ErrorReporting } from '../error-reporting';

describe('ErrorReporting', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
describe('ErrorReporting', () => {
describe('ErrorReporter', () => {

) {}

async init() {
if (this.initialized) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw instead? We should prevent multiple init calls from existing.


initialized = true;
};
beforeSend(event: ErrorEvent, { originalException }: EventHint) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
beforeSend(event: ErrorEvent, { originalException }: EventHint) {
private beforeSend(event: ErrorEvent, { originalException }: EventHint) {

export class ErrorReporting {
private initialized = false;

private seenErrors = new Set<string>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private seenErrors = new Set<string>();
/** Hashes of error stack traces, to deduplicate error reports. */
private readonly seenErrors = new Set<string>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants