Skip to content

Prevent usage of node or browser APIs in @segment/analytics-core and @segment/analytics-node#846

Merged
silesky merged 8 commits intomasterfrom
improve-core-type-safety
Apr 24, 2023
Merged

Prevent usage of node or browser APIs in @segment/analytics-core and @segment/analytics-node#846
silesky merged 8 commits intomasterfrom
improve-core-type-safety

Conversation

@silesky
Copy link
Copy Markdown
Contributor

@silesky silesky commented Apr 23, 2023

  1. Remove isOffline() from core
  2. eslint error if any native node modules are used.
  3. eslint error any of the following are used in source code of core/node (since isomorphic):
    'document',
    'window',
    'self',
    'process',
    'global',
    'navigator',

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 23, 2023

🦋 Changeset detected

Latest commit: 02c7ebf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@segment/analytics-core Patch
@segment/analytics-next Patch
@segment/analytics-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@silesky silesky changed the title Improve core type safety Do not allow any node or browser APIs in @segment/analytics-core and @segment/analytics-node Apr 24, 2023
@silesky silesky changed the title Do not allow any node or browser APIs in @segment/analytics-core and @segment/analytics-node Ban usage of node or browser APIs in @segment/analytics-core and @segment/analytics-node Apr 24, 2023
@silesky silesky changed the title Ban usage of node or browser APIs in @segment/analytics-core and @segment/analytics-node Prevent usage of node or browser APIs in @segment/analytics-core and @segment/analytics-node Apr 24, 2023
Copy link
Copy Markdown
Contributor

@oscb oscb left a comment

Choose a reason for hiding this comment

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

This lgtm.

Correct me if I'm getting this wrong: packages/core is the isomorphic core whereas browser/core will retain the browser specific implementation, right?

@silesky
Copy link
Copy Markdown
Contributor Author

silesky commented Apr 24, 2023

This lgtm.

Correct me if I'm getting this wrong: packages/core is the isomorphic core whereas browser/core will retain the browser specific implementation, right?

Yep. and Analytics-node (despite the name) is also isomorphic.

Also some background: I plan to change the name from browser/core to browser/domain or something, since it's easy to find yourself in the wrong file when searching.

@silesky silesky merged commit 7dcafa2 into master Apr 24, 2023
@silesky silesky deleted the improve-core-type-safety branch April 24, 2023 19:37
@github-actions github-actions bot mentioned this pull request Apr 24, 2023
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