Sentry: Easily upload source maps from a nested directory structure

I am currently developing a NextJs/ReactJs application using Typescript and I am facing an issue with uploading sourcemaps to Sentry artefacts.

Unlike traditional builds, the output folder structure of this app mirrors the NextJs pages structure, creating a tree-like layout:

.next
|__ static
   |__ buildId
      |__ app.js
      |__ _app.js.map
      |__ index.js
      |__ index.js.map
      |__ customer
         |__ [customerId]
            |__ details.js
            |__ details.js.map
            |__ sub folder 1
            |__ sub folder 2

Each .js file references a corresponding .map file. For instance, in /.next/static/buildId/index.js, you will find

//# sourceMappingURL=index.js.map
on the last line.

To upload these sourcemaps to Sentry, I execute the following command:

docker exec -it wtr-admin_app_container yarn sentry-cli 
  --auth-token=${SENTRY_AUTH_TOKEN} releases
  --org=${SENTRY_ORGANIZATION}
  --project=${SENTRY_PROJECT} files ${VERSION} upload-sourcemaps "./src/.next/static/" 
  --url-prefix "~/_next/static/" 
  --no-rewrite

The challenge lies in defining the correct --url-prefix value. It should be ~/_next/static/buildId/ for the /.next/static/buildId/index.js file, while it needs to be

~/_next/static/buildId/customer/[customerId]/
for the
/.next/static/buildId/customer/[customerId]/details.js
file.

Uploading all files under a single url-prefix causes issues with proper associations between .js and .map files.


Is there a solution to properly upload this tree structure where each .js file is correctly linked to its .map file?

Could utilizing RewriteFrames help resolve this issue?


Answer №1

I devised a clever workaround that enabled me to resolve this issue and successfully upload the complete tree of my minified .js files to Sentry along with their corresponding source map files.

Here's How I Solved It:

I opted to loop through all the files I needed to upload, one by one, uploading each (.js and .map file) while setting their individual "--url-prefix".

For each pair of .js and .map files, I executed something similar to this:

sentry-cli --auth-token=${SENTRY_AUTH_TOKEN} releases --org=${SENTRY_ORGANIZATION} --project=${SENTRY_PROJECT} files ${RELEASE_ID} upload-sourcemaps /folder_1/folder_2/file.min.js /folder_1/folder_2/file.min.js.map --url-prefix '~/folder_1/folder_2'

The Outcome:

Upon completion, I triggered an error in my application and examined the details of the issue on Sentry. This allowed me to view the entire stack trace of the error and access the original/unminified code.

Additional Info:

I performed this process (looping through files and uploading them) using a shell script file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize import and export statements to transfer an HTML tag between two JavaScript files

I have two HTML files linked to two JS files. I want to save an HTML tag from HTML1 with JS1 in a Variable and export it. Then import it in the JS2 file and use it in HTML2 I have tried many ways but nothing seems to work, something as simple as this Exp ...

Troubleshooting a Cache Issue in Your Next.js Application

Whenever I attempt to run 'npm run build', an error crops up that seems to be linked to the css and fonts. Unfortunately, I am unsure of how to tackle this problem. It's perplexing as the app functions perfectly fine in development mode. Th ...

Iterate through nested objects in Javascript

I am having trouble extracting only the word from each new instance of the newEntry object. It shows up in the console every time I add a new word, but not when I assign it to .innerHTML. Can someone assist me with this issue? Full code: <style ty ...

Troubleshooting the issue with the HTTPClient get method error resolution

Currently, I am attempting to capture errors in the HTTP get request within my service file. Below is the code snippet: import { Injectable } from '@angular/core'; import { PortfolioEpicModel, PortfolioUpdateStatus } from '../models/portfol ...

Help Needed: Adding a Simple Element to jQuery Tabs Script

I recently came across a fantastic jQuery tabs script on a website called Tutorialzine. The link to the article can be found here. As I was implementing this script, I realized I needed to customize it by adding specific classes to certain tabs. Specifica ...

Avoiding repetitive logic in both parent and child components in Angular 8

In my parent controller, I have common requests and I also read router params for those requests. However, for the child components, I have different requests but still need to extract the same parameters from the router - resulting in duplicate code. For ...

Determine characteristics of object given to class constructor (typescript)

My current scenario involves the following code: abstract class A { obj; constructor(obj:{[index:string]:number}) { this.obj = obj; } } class B extends A { constructor() { super({i:0}) } method() { //I wan ...

Pattern for identifying JavaScript import declarations

My task involves using node to read the contents of a file. Specifically, I am looking to identify and extract a particular import statement within the file that includes the "foo-bar" package. The goal is to match only the line or lines that contain the ...

Navigating the way: Directing all TypeScript transpiled files to the build folder

I am currently working on a project using Angular2/Typescript, and I have the tsconfig.js file below: { "compilerOptions": { "module": "commonjs", "moduleResolution": "node", "target": "es5", "sourceMap": true, ...

Custom Sign-in features in NextJS now direct users to the default form for entering login

I have been working on a web app that requires authentication using NextJS default auth middleware. However, whenever I try to log in, the app redirects me to the default NextJS form component at the URL /api/auth/signin?error=CredentialsSignin. Even thou ...

How can you generate a Ref in React without utilizing the constructor by using React.createRef?

In the past, I relied on using constructor in React for just three specific purposes: 1. Initializing state as shown below: class App extends React.Component { constructor(props) { super(props); this.state = { counter: 0 }; } } H ...

parsing a TypeScript query

Is there a simpler way to convert a query string into an object while preserving the respective data types? Let me provide some context: I utilize a table from an external service that generates filters as I add them. The challenge arises when I need to en ...

A guide to resolving cross-origin resource sharing issues using a reverse proxy

After creating a JavaScript web application for processing documents, I am now looking to integrate with web services like NLTK-server, TIKA-server, and SOLR for further analysis. While I can successfully access the REST endpoints of these services using c ...

How come the mouseover effect on the div remains even after the mouse has been removed?

How can I keep the original CSS class when the mouse moves away? function highlight( x, y) { var sel=document.getElementById(y); sel.style.borderBottom= "2px solid "+x; sel.style.opacity="1"; sel.style.transition="all eas ...

Checking for mobile SSR in a ReactJS applicationUncover the signs of mobile

I recently integrated the mobile-detect library into my project following this informative tutorial: link /src/utiles/isMobile.tsx: import MobileDetect from "mobile-detect"; import { GetServerSidePropsContext } from "next"; export co ...

Explain the functioning of the Node.js event loop and its ability to manage numerous requests simultaneously

Recently, I delved into testing asynchronous code in node.js. From what I understand, when there is an asynchronous operation taking place, Node.js should be able to handle new requests. Below is a snippet of code I wrote using express and axios: app.get(& ...

AngularJSError

I am completely new to AngularJS and I've been tasked with debugging someone else's code. While debugging in Google Chrome, I encountered the following error: TypeError: accountService.logIn(...).success is not a function. The issue lies with ...

Tricks to access value from a Nativescript array of Switch elements when tapping a Button

Scenario: In my project, I am using Nativescript 5.0 with Angular. The data is fetched from an API and displayed in customers.component.ts I am successfully rendering the elements based on the received IDs in customers.component.html When the user inter ...

What does {``} denote in react-native programming?

During my participation in a collaborative project, I noticed that there is a significant amount of {' '} being used. For instance: <Text> {' '} {constant.Messages.PointText.hey} {this._user.first_name || this._user ...

Include a search button within the search box of the Custom Search Engine

Can anyone help me with adding a search button to my HTML code? I've tried implementing it, but when I try to search something on a website like YouTube, the results show up without displaying my search query. How can I fix this issue and what changes ...