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: v3 Refactor #361

Merged
merged 20 commits into from
Oct 7, 2021
Merged

Feat: v3 Refactor #361

merged 20 commits into from
Oct 7, 2021

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Aug 6, 2021

This PR refactors the Electron SDK into thin layers on top of the browser and node SDKs.
Electron functionality is added via optional integrations.

This PR:

  • Completely refactors the entire SDK into thinner layers on top of the browser/node SDKs with all features as integrations
    • See tracking issue Electron SDK v3 Proposal #360 for details of all the new integrations.
    • CommonJs build now outputs into the root directory so @sentry/electron/main, @sentry/electron/preload and @sentry/electron/renderer work
    • Added package.json exports key so modern bundlers can find ESM output via sub-module imports
    • Preloads scripts are pre-bundled so they work in sandboxed renderers
  • Default session tracking
    • Added session support to the transport
    • Default session integration (MainProcessSession) tracks the lifetime of the main process
  • Works with BrowserTracing and transactions
  • Improved tests
    • Re-added store endpoint to test server for testing sending from the browser SDK
    • Add session supports to test server
    • Added tests for sessions/transactions
    • Added a lot of extra checks to all tests

Other Considerations...

  • The docs were already out-of-date but this will require almost a complete rewrite
  • This will require some beta releases to get feedback and confirm I haven't broken anything

Closes:
#360, #356, #355, #352, #351, #268, #254, #91

@timfish timfish force-pushed the feat/v3-refactor branch 2 times, most recently from e2587e5 to e8d20de Compare August 6, 2021 12:22
@timfish timfish changed the title Feat: Major refactor for v3 Feat: v3 Refactor Aug 8, 2021
@timfish timfish force-pushed the feat/v3-refactor branch 7 times, most recently from ea682b8 to e09800e Compare August 9, 2021 22:05
@timfish timfish force-pushed the feat/v3-refactor branch 10 times, most recently from 15d80ac to 464ea56 Compare August 12, 2021 22:13
@timfish timfish marked this pull request as ready for review August 12, 2021 22:59
@timfish timfish requested review from HazAT and jan-auer August 12, 2021 22:59
@HazAT
Copy link
Member

HazAT commented Sep 23, 2021

@timfish can we bring this to a resolution and maybe ship a beta release so users can start trying it out?

@timfish
Copy link
Collaborator Author

timfish commented Sep 26, 2021

Fixes #249

.github/workflows/build.yml Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
scripts/build-preload.js Show resolved Hide resolved
scripts/build-preload.js Show resolved Hide resolved
src/integrations.ts Outdated Show resolved Hide resolved
src/integrations.ts Outdated Show resolved Hide resolved
src/main/context.ts Outdated Show resolved Hide resolved
@timfish
Copy link
Collaborator Author

timfish commented Sep 30, 2021

I think this might be ready for a beta!

@AbhiPrasad
Copy link
Member

Can we create a new GH issue that covers a brief migration guide for the beta? We can then start iterating on that.

We need to update changelog as well?

@timfish timfish mentioned this pull request Oct 3, 2021
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

We can do the changelog in another commit or include it here - up to you. Thanks for the migration guide.

I think we good to :shipit:

@timfish
Copy link
Collaborator Author

timfish commented Oct 4, 2021

I've still got a little bit left to add to the migration guide. I'll finish it off and add a link to the changelog in this PR.

@timfish
Copy link
Collaborator Author

timfish commented Oct 5, 2021

Other than updating the changelog, these final changes change all integration constructor options from arguments into options objects. This improves readability and allows for additions and modifications later without introducing breaking changes.

For example:

new ElectronEvents(false);
// becomes
new ElectronEvents({ unresponsive: false })

"rootDir": "src",
"target": "es5"
"target": "es6"
Copy link
Member

Choose a reason for hiding this comment

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

Last minute double check - we good to change the target from es5 to es6?

Copy link
Collaborator Author

@timfish timfish Oct 6, 2021

Choose a reason for hiding this comment

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

I suppose I could be relying on the e2e tests too much here! They pass with Electron v2 so assumed everything is ok but we don't actually test all SDK features in the e2e tests yet 🤔

These changes make the minimum supported Electron version v2 which was node v8.9.3 and Chrome v61.

Apparently node 6.4.0 included almost all of ES2015 apart from proper tail call optimisation: https://node.green/

Chrome has supported the same since v51:
https://caniuse.com/es6

A quick search suggests v8 still doesn't support tail call optimisation so ES6 was essentially fully supported at these points for all intents and purposes 🤷‍♂️

Copy link
Collaborator Author

@timfish timfish Oct 6, 2021

Choose a reason for hiding this comment

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

This completely passed me by but v8 decided not to ship tail call optimisation so never technically supported full ES6:
https://v8.dev/blog/modern-javascript?m=1#proper-tail-calls

This means "ES6" has been supported since Electron v1.3.7 which means we could have targeted it before when the minimum Electron version was v1.6.

Copy link
Member

Choose a reason for hiding this comment

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

Ok gotcha. Do we need to write down the minimum version for electron somewhere then?

Also we can probably catch this quickly on a beta release if something goes wrong, so fine to bump this here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Minimum Electron version has been bumped to v2 in the readme

@timfish timfish merged commit 3ec9d8a into getsentry:master Oct 7, 2021
@timfish timfish deleted the feat/v3-refactor branch October 9, 2021 11:21
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.

5 participants