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(nuxt): Improve logs about adding Node option 'import' #13726

Merged
merged 4 commits into from
Sep 19, 2024

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Sep 19, 2024

Adding the node option can be a confusing step. This adds a log output which already includes the correct file path to add. It looks like this:

[Sentry] Using your sentry.server.config.ts file for the server-side Sentry configuration. 
Make sure to add the Node option import to the Node command where you deploy and/or run your application. 
This preloads the Sentry configuration at server startup. You can do this via a 
command-line flag (node --import ./.output/server/sentry.server.config.mjs [...]) or via 
an environment variable (NODE_OPTIONS='--import ./.output/server/sentry.server.config.mjs' node [...]).

@s1gr1d s1gr1d requested review from a team, Lms24 and AbhiPrasad and removed request for a team September 19, 2024 10:05
@@ -59,3 +59,29 @@ describe('findDefaultSdkInitFile', () => {
expect(result).toBe('sentry.server.config.js');
});
});

describe('getStringDiff', () => {
Copy link
Member

Choose a reason for hiding this comment

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

l:

Suggested change
describe('getStringDiff', () => {
describe('getStringSuffixDiff', () => {

expect(getStringSuffixDiff('', 'abc')).toBe('');
});

it('should return the suffix of the longer string when the shorter string is a prefix', () => {
Copy link
Member

Choose a reason for hiding this comment

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

l (no action required): what happens if the longer string is shorter (but not empty) that the shorter string param? 😅

`[Sentry] Using your \`${serverConfigFile}\` file for the server-side Sentry configuration. In case you have a \`public/instrument.server\` file, the \`public/instrument.server\` file will be ignored. Make sure the file path in your node \`--import\` option matches the Sentry server config file in your \`.output\` folder and has a \`.mjs\` extension.`,
);
});
const serverConfigRelativePath = `.${getStringSuffixDiff(serverConfigPath, nitro.options.rootDir)}`;
Copy link
Member

Choose a reason for hiding this comment

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

no strong opinions but shouldn't path.relative basically do what you're trying to do here? (I might be missing something though)

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually yes 😅

@s1gr1d s1gr1d requested a review from Lms24 September 19, 2024 12:15
);
});
// For the default nitro node-preset build output this relative path would be: ./.output/server/sentry.server.config.mjs
const serverConfigRelativePath = `./${path.relative(nitro.options.rootDir, serverConfigPath)}`;
Copy link
Member

Choose a reason for hiding this comment

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

Let's use path.join instead of ./ as the / separator does not work in windows. In this case doesn't matter a ton, but always good to it consistent.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch with windows! I could not use path.join in this case as this would not keep the folder name with the dot (.output). But I was able to achieve this with .${path.sep}${path.relative(...)}

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.

:shipit:

@s1gr1d s1gr1d self-assigned this Sep 19, 2024
@s1gr1d s1gr1d merged commit 336a236 into develop Sep 19, 2024
101 checks passed
@s1gr1d s1gr1d deleted the sig/improve-console-messages branch September 19, 2024 15:11
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.

3 participants