Skip to content

sdk-core: use core client as event emitter, send reports from database via client #290

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 4 commits into from
Oct 1, 2024

Conversation

perf2711
Copy link
Contributor

@perf2711 perf2711 commented Sep 10, 2024

This PR adds event support for client directly.

Client events

You can attach to before-skip, before-send, and after-send events on client instance:

const client = BacktraceClient.initialize({ ... });
client.on('after-send', (report, data, attachments, result) => { ... });

This is required for me to use in smoketests, so I know if after-send is executed after e.g. an exception is thrown.

Database events

BacktraceDatabase now emits events of it's own:

type BacktraceDatabaseEvents = {
    added: [record: BacktraceDatabaseRecord];
    removed: [record: BacktraceDatabaseRecord];
    'before-send': [record: BacktraceDatabaseRecord];
    'after-send': [
        record: BacktraceDatabaseRecord,
        result: BacktraceReportSubmissionResult<BacktraceSubmissionResponse>,
    ];
};

@perf2711 perf2711 added the enhancement New feature or request label Sep 10, 2024
@perf2711 perf2711 self-assigned this Sep 10, 2024
Copy link
Collaborator

@konraddysput konraddysput left a comment

Choose a reason for hiding this comment

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

since this is the internal api, maybe we can drop the deprecated field once we update all SDKs?

@perf2711 perf2711 force-pushed the feature/sdk-core-events branch from 7ab43df to 7f2983a Compare September 11, 2024 16:26
@perf2711 perf2711 changed the title sdk-core: use core client as event emitter sdk-core: use core client as event emitter, send reports from database via client Sep 11, 2024
@perf2711
Copy link
Contributor Author

since this is the internal api, maybe we can drop the deprecated field once we update all SDKs?

It turned out that this was only used in sdk-core. I removed this altogether.

@perf2711 perf2711 force-pushed the feature/sdk-core-events branch from d97d89e to a90d155 Compare September 12, 2024 11:38
@perf2711 perf2711 merged commit c5ee428 into main Oct 1, 2024
5 checks passed
@perf2711 perf2711 deleted the feature/sdk-core-events branch October 1, 2024 14:26
@perf2711 perf2711 mentioned this pull request Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants