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: adding a source map upload CLI package #102

Merged
merged 10 commits into from
Mar 11, 2025
Merged

Conversation

eskirk
Copy link
Collaborator

@eskirk eskirk commented Mar 10, 2025

solving #103

what

this PR adds a package for uploading source maps via CLI and provides an option to disable uploading from the bundler plugins

why

this feature has been requested to enable the ability to decouple the upload process from the build pipeline. this should enable more use cases and provide more flexibility to those who want to upload their source maps in a more customizable way.

@eskirk eskirk requested review from kpelelis and codecapitano March 11, 2025 00:20
@@ -16,7 +16,7 @@ jobs:
- name: Setup NPM
uses: actions/setup-node@v3
with:
node-version: 19.x
node-version: 20.x
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (for a separate task):
Let's test with the recent node versions like we are doing is for Faro.
We support the current active version till the oldest maintenance version.
For versions which reached ool we do not provide support.

Example:
https://github.com/grafana/faro-web-sdk/blob/0eac402d422ef19ca52fa9f4870e0590c37034b3/.github/workflows/pull-request.yml#L12

Copy link
Contributor

@codecapitano codecapitano left a comment

Choose a reason for hiding this comment

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

Please add tests for the important logic.

@@ -134,3 +135,93 @@ The following options are available for the Faro JavaScript bundler plugins:
After initial configuration, the Faro JavaScript bundler plugins automatically uploads your source maps to Grafana Cloud when you build your application. You can verify that the source maps upload successfully by in the "Settings" -> "Source Maps" tab in the Frontend Observability plugin. From there you are able to see the source maps that you have uploaded.

After you have completed all the required steps, you have finished - the Faro Collector begins processing your source maps and associating them with your telemetry data. The portions of your stack traces with source maps uploaded to the Faro Collector are automatically de-obfuscated and displayed in the Frontend Observability plugin when viewing your error data.

## CLI for Sourcemap Uploads
Copy link
Contributor

@codecapitano codecapitano Mar 11, 2025

Choose a reason for hiding this comment

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

Let's also add this to the cloud docs as well

Copy link

@kpelelis kpelelis left a comment

Choose a reason for hiding this comment

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

All in all LGTM. I left some comments regarding the use cURL directly from the command line and some other nitpicks.

options.gzipPayload
);

console.log(curlCommand);

Choose a reason for hiding this comment

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

nit: Maybe add a message here that this is a curl command. Although I guess the API is pretty self explanatory 🤷‍♂️


try {
// Execute curl command to upload the file
success = executeCurl(

Choose a reason for hiding this comment

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

Out of curiosity, is there a reason to using curl over the command line instead of using native http requests or axios or even bindings to libcurl?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a user recently express that their CI pipeline's proxy configuration caused fetch to fail and they needed to resort to cURL. turns out there is a whole proxy agent config that we can pass along to fetch/axios and I felt like this would be simpler in the long run.

};

/**
* Uploads multiple sourcemap files compressed as a tarball to the Faro API using cURL

Choose a reason for hiding this comment

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

very nitpicky: Technically speaking tarball is not compressed but rather a gzipped tarball

@@ -26,11 +27,17 @@ export default function faroUploader(
keepSourcemaps,
gzipContents,
verbose,
skipUpload,

Choose a reason for hiding this comment

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

Nice! I like this option

@eskirk eskirk merged commit 59e16c4 into main Mar 11, 2025
5 checks passed
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