Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

feat: Add transform to extract node config into separate file #41

Merged
merged 7 commits into from
May 13, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented May 7, 2024

This transform will try to detect Sentry.init() when using @sentry/node, and extract it into a separate file instrument.js that is required/imported at the very top of the file.

@mydea mydea requested review from HazAT, lforst, s1gr1d and andreiborza May 7, 2024 12:14
@mydea mydea self-assigned this May 7, 2024
@Lms24 Lms24 force-pushed the fn/instrument-js branch from 05bae32 to 9028cf3 Compare May 13, 2024 08:06
* Whether the transformer requires user input to run
* If true, the transformer won't show a spinner to avoid cluttering the spinner with user prompts.
*/
requiresUserInput?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

This was necessary b/c otherwise the spinner would show while the user input prompt was showing and the process is waiting for user input. This would severely decrease UX because users might see the spinner as a sign that something is still loading or already going on, not making it clear that they actually need to provide input.

Comment on lines +18 to +19
'@sentry/deno',
'@sentry/bun',
Copy link
Member

Choose a reason for hiding this comment

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

sneaking this into the PR, we should add Deno and Bun to this list

@Lms24
Copy link
Member

Lms24 commented May 13, 2024

UPDATE: This is no longer the end result; just leaving this here for context

Here's a screenshot of the transform for the TS path with CLI arg flags

image

@Lms24
Copy link
Member

Lms24 commented May 13, 2024

After revisiting the CLI arg decision, we're now back to no prompts:

image

After you've done that, remove import of ${chalk.cyan('instrument.js')} from your file(s).

This only applies if you are actually using ESM natively with Node.
If you use ${chalk.gray('import')} syntax but transpile to CommonJS (e.g. TypeScript), you're all set up already!
Copy link
Member Author

Choose a reason for hiding this comment

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

👍 nice!

@Lms24 Lms24 merged commit 449bef0 into main May 13, 2024
2 checks passed
@Lms24 Lms24 deleted the fn/instrument-js branch May 13, 2024 12:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants