React.js

For OpsAI to suggest better RCA for frontend errors it is necessary to have unminified code. For that you need to upload sourcemap, so when viewing stacktrace OpsAI can show you where exactly the error is your code.

🛠️ Using Webpack upload sourcemap

You can upload sourcemap using Webpack plugin, available in @middleware.io/sourcemap-uploader/dist/webpack-plugin package.

To use the plugin, edit your webpack.config.js to include a new entry in the plugins array at the top level of the file, e.g.

Webpack plugin options

Webpack plugin offers serveral options to configure searching sourcemaps and build artifacts on disk & configuring upload paths based on project structure.

FieldTypeDescription
apiKeystringA unique key used to authenticate and authorize the upload of source maps to your server or API.
appVersionstringThe version of your application (e.g., 1.2.0, v3.1-beta) tied to the uploaded source maps.
pathstringThe absolute or relative file path where the source map file is located locally during upload.
basePathstringThe root path in your codebase or build output. It defines where the original source files live, helping map source maps correctly at runtime.
deleteAfterUploadbooleanThis deletes the sourcemap files from local ensures that sourcemap are not exposed to internet.

This makes it clear that path is where you're uploading from, while basePath determines how the source maps will resolve original source file locations during error unminification.

Webpack plugin uploads sourcemaps to the workspace associated with your API key, and automatically matches up sourcemaps with the build artifacts in a error tracking screen when you debug it.

⚙️ VCS Metadata Configuration (Recommended)

If your app is containerized or does not have a .git directory, You can set VCS configuration from installation page of your project in real user monitoring page to send VCS info to OpsAI (this helps generate solution PRs):

VCS Information

If your app has a .git directory, you can set repository URL, commit SHA, and other metadata for OpsAI using environment variables. This is how you can set environment variables -

Then, use this environment variables in Middleware.track function as follows -