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

feat(electron): Use page title/window location for default context in renderers #1402

Merged

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented May 12, 2021

Goal

Renderer events should have a default context.

Design

This implementation takes the page title, and falls back to the window location.

Changeset

Since the amount of logic required was so small I felt comfortable augmenting the renderer event data plugin, rather than creating an entire new plugin.

For packaged apps, window.location.pathname is an absolute file path (like stacktraces). I tweaked logic for stackframe project root stripping so it could be referenced from the renderer event plugin rather than duplicated.

Testing

End to end tests added for all the cases I could think of. config.context and setContext() should take precedence.

@bengourley bengourley requested a review from kattrali May 12, 2021 15:42
@github-actions
Copy link

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.87 kB 12.62 kB
After 40.87 kB 12.62 kB
± No change No change

code coverage diff

Ok File Lines Branches Functions Statements
/home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-electron-renderer-event-data/renderer-event-data.js 89.47%
(+1.97%)
81.25%
(+4.33%)
100%
(+0%)
90.48%
(+1.59%)
🔴 /home/runner/work/bugsnag-js/bugsnag-js/packages/plugin-electron-renderer-strip-project-root/strip-project-root.js 84.21%
(+4.21%)
58.33%
(-8.34%)
100%
(+0%)
86.36%
(+3.03%)

Total:

Lines Branches Functions Statements
82.47%(+0.03%) 72.08%(-0.01%) 83.48%(+0.03%) 81.5%(+0.03%)

Generated by 🚫 dangerJS against 3cc5ab2

@bengourley bengourley merged commit a9233a6 into kattrali/add-electron-support May 13, 2021
@bengourley bengourley deleted the bengourley/electron-context branch May 13, 2021 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants