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

Allow disabling New Relic dependency at build-time #235

Open
arbrandes opened this issue Mar 11, 2022 · 3 comments
Open

Allow disabling New Relic dependency at build-time #235

arbrandes opened this issue Mar 11, 2022 · 3 comments

Comments

@arbrandes
Copy link
Contributor

(This is a synthesis of the original report in the forum.)

It turns out that that @newrelic/publish-sourcemap is not distributed with a open-source-compatible license, and thus can't be distributed legally. From its package.json:

"license": "New Relic proprietary"

While #215 introduced an ENABLE_NEW_RELIC runtime environment variable, it only configures whether the services will be used; New Relic is still baked into the build. If the build is then distributed as part of an image (say, a Tutor or Bitnami image), this becomes a potential legal problem.

We need to find a reasonable way to make the @newrelic/publish-sourcemap dependency optional.

@ghassanmas
Copy link
Member

ghassanmas commented Oct 27, 2022

I can suggest the following (not tested though)

  1. Add the depenecy to optionaldependencies in package.josn
  2. When intsalling use the flag npm install --omit=optional
  3. Any app/lib depends on frontend-build once it uses the version after step 2, then it will not have it.

However this might break, the workflow of 2U, since then need to be manualy installed to use @edx/new-relic-source-map-webpack-plugin . A workaround of this can be:

  1. To release two sub versions of each frontend-build release, one with it and one without it.
  2. To modifiy the codebase of @edx/new-relic-source-map-webpack-plugin so that its doesn't use new relic library, rather it uploads the assets using native API, or any library that is FOSS.

@Mashal-m
Copy link
Contributor

Mashal-m commented Oct 19, 2023

We have implemented these suggestions and implemented code change suggestions given in the form.
Installing dependency as an optional dependency generates an error in frontend-build while running build or test and every MFE is using frontend-build.

@ghassanmas
Copy link
Member

ghassanmas commented Oct 20, 2023

@Mashal-m I think an alternative approach could be to upload source map using native API:

https://docs.newrelic.com/docs/browser/new-relic-browser/browser-pro-features/upload-source-maps-api/#curl-post
Newrelic has an example about using curl linked above

curl -H "Api-Key: YOUR_NEW_RELIC_USER_API_KEY" \ 
    -F "sourcemap=@SOURCE_MAP_PATH" \ 
    -F "javascriptUrl=JS_URL" \ 
    -F "releaseId=YOUR_RELEASE_ID" \ 
    -F "releaseName=YOUR_UI_PAGE" \
    -F "repoUrl=GITHUB_REPOSITORY_URL" \
    -F "buildCommit=GIT_BUILD_COMMIT_HASH" \

https://sourcemaps.service.newrelic.com/v2/applications/YOUR_NEW_RELIC_APP_ID/sourcemaps

Which to me looks like what @newrelic/publish-sourcemap is doing here

        publishSourcemap(
            {
                sourcemapPath,
                javascriptUrl,
                applicationId,
                apiKey,
                releaseName,
                releaseId,
            },

ref

I think there must many libraries or even a native module in NodeJS that could replicate curl.

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

No branches or pull requests

3 participants