### Install @bugsnag/source-maps Globally Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/README.md Install the CLI tool globally on your system using npm or yarn. ```sh npm install --global @bugsnag/source-maps ``` ```sh yarn global add @bugsnag/source-maps ``` -------------------------------- ### Install @bugsnag/source-maps Locally Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/README.md Install the package as a development dependency using npm or yarn. ```sh npm install --save-dev @bugsnag/source-maps ``` ```sh yarn add --dev @bugsnag/source-maps ``` -------------------------------- ### Run @bugsnag/source-maps CLI Locally Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/README.md Execute the CLI commands using npx or yarn run after local installation. ```sh npx bugsnag-source-maps [...args] ``` ```sh yarn run bugsnag-source-maps [...args] ``` -------------------------------- ### Install @bugsnag/source-maps CLI Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Install the package locally as a development dependency or globally for command-line access. ```sh npm install --save-dev @bugsnag/source-maps yarn add --dev @bugsnag/source-maps ``` ```sh npm install --global @bugsnag/source-maps ``` -------------------------------- ### Programmatic Browser Source Map Upload with Bundle Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload a single browser source map programmatically using the `browser.uploadOne` function. This example includes the optional minified bundle file and specifies project root and logger. ```ts import { browser } from '@bugsnag/source-maps' import consola from 'consola' // Single upload with bundle file included async function uploadSourceMap() { try { await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', // relative to projectRoot bundleUrl: 'https://cdn.example.com/assets/main.js', bundle: 'dist/main.js', // optional: include minified bundle appVersion: '1.2.3', overwrite: true, projectRoot: '/home/ci/myapp', logger: consola, // optional: use your own logger }) console.log('Upload successful') } catch (err) { // err is a NetworkError with a .code (NetworkErrorCode) and .responseText console.error('Upload failed:', err.message) process.exit(1) } } ``` -------------------------------- ### reactNative.fetchAndUploadOne Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Fetches the bundle and source map live from a running Metro bundler (via HTTP GET) and uploads them immediately. Useful during development or in CI environments where the Metro server is available. ```APIDOC ## Programmatic API — `reactNative.fetchAndUploadOne` Fetches the bundle and source map live from a running Metro bundler (via HTTP GET) and uploads them immediately. Useful during development or in CI environments where the Metro server is available. ```ts import { reactNative } from '@bugsnag/source-maps' // Fetch from default Metro server (localhost:8081, entry point index.js) await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', // Fetches: http://localhost:8081/index.js.map?platform=ios&dev=false // and http://localhost:8081/index.bundle?platform=ios&dev=false }) // Custom bundler URL and entry point await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'android', appVersion: '2.1.0', bundlerUrl: 'http://localhost:8082', bundlerEntryPoint: 'src/App.js', dev: false, idleTimeout: 15, }) // OTA / CodePush with codeBundleId await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', codeBundleId: 'v2.1.0-ota-3', bundlerUrl: 'http://localhost:8081', bundlerEntryPoint: 'index.js', }) ``` ``` -------------------------------- ### Fetch and upload single React Native source map (default Metro) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Fetches the bundle and source map live from a running Metro bundler (via HTTP GET) and uploads them immediately. Useful during development or in CI environments. Fetches from default Metro server (localhost:8081, entry point index.js). ```typescript import { reactNative } from '@bugsnag/source-maps' // Fetch from default Metro server (localhost:8081, entry point index.js) await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', }) ``` -------------------------------- ### Fetch and upload single React Native source map (custom Metro) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Fetches the bundle and source map live from a running Metro bundler (via HTTP GET) and uploads them immediately. Useful during development or in CI environments. Allows custom bundler URL and entry point, and specifies development mode. ```typescript // Custom bundler URL and entry point await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'android', appVersion: '2.1.0', bundlerUrl: 'http://localhost:8082', bundlerEntryPoint: 'src/App.js', dev: false, idleTimeout: 15, }) ``` -------------------------------- ### Fetch and upload single React Native source map (OTA/CodePush) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Fetches the bundle and source map live from a running Metro bundler (via HTTP GET) and uploads them immediately. Useful during development or in CI environments. Supports OTA/CodePush with codeBundleId. ```typescript // OTA / CodePush with codeBundleId await reactNative.fetchAndUploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', codeBundleId: 'v2.1.0-ota-3', bundlerUrl: 'http://localhost:8081', bundlerEntryPoint: 'index.js', }) ``` -------------------------------- ### Publish New Version to npm Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/CONTRIBUTING.md Command to publish the newly versioned package to the npm registry. ```bash npm publish ``` -------------------------------- ### Upload Browser Source Maps (Multiple) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively scan a directory for all `.map` files and upload them. Requires a base URL for the assets. Supports overwriting existing uploads and custom endpoints. ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --directory dist \ --base-url "https://cdn.example.com/assets/" ``` -------------------------------- ### Source Map Transformations Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Demonstrates how to use the `addSources` and `stripProjectRoot` transformations programmatically. These functions are exported for direct use, allowing custom manipulation of source maps before upload. ```APIDOC ## Source Map Transformations Two transformations are automatically applied before every upload. `AddSources` reads each source file referenced in the map's `sources` array and populates `sourcesContent` — enabling Bugsnag to display original source code in error reports without requiring a separate file upload. `StripProjectRoot` rewrites each source path to be relative to the project root, ensuring paths are portable across machines. ```ts // Transformations are applied internally by all uploaders, but the // individual transformer functions are also exported for direct use: import addSources from '@bugsnag/source-maps/dist/transformers/AddSources' import stripProjectRoot from '@bugsnag/source-maps/dist/transformers/StripProjectRoot' import consola from 'consola' const fs = require('fs') const sourceMapJson = JSON.parse(fs.readFileSync('dist/main.js.map', 'utf-8')) // Step 1: populate sourcesContent from disk const withSources = await addSources( '/home/ci/myapp/dist/main.js.map', // absolute path to the .map file sourceMapJson, '/home/ci/myapp', // projectRoot consola ) // Step 2: strip absolute project root from each source path const ready = await stripProjectRoot( '/home/ci/myapp/dist/main.js.map', withSources, '/home/ci/myapp', consola ) // ready.sources entries are now relative, e.g. ["src/index.ts", "src/lib/a.ts"] // ready.sourcesContent contains the file contents as strings console.log(ready.sources) // => ['src/components/App.tsx', 'src/utils/helpers.ts', ...] ``` ``` -------------------------------- ### browser.uploadMultiple Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively scans a directory for all *.map files (excluding *.css.map) and uploads each one. For each map, the corresponding bundle is inferred by stripping the .map extension. ```APIDOC ## Programmatic API — `browser.uploadMultiple` Recursively scans a directory for all `*.map` files (excluding `*.css.map`) and uploads each one. For each map, the corresponding bundle is inferred by stripping the `.map` extension. ```ts import { browser } from '@bugsnag/source-maps' await browser.uploadMultiple({ apiKey: 'YOUR_API_KEY', baseUrl: 'https://cdn.example.com/assets/', directory: 'dist', // relative to projectRoot appVersion: '1.2.3', overwrite: false, projectRoot: '/home/ci/myapp', idleTimeout: 10, // 10-minute HTTP idle timeout }) // Expected: uploads dist/main.js.map (+ dist/main.js if found), // dist/vendor.js.map (+ dist/vendor.js if found), etc. // minifiedUrl for each file = `${baseUrl}/${bundleRelativePath}` ``` ``` -------------------------------- ### Upload Node.js Source Maps (Multiple) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively scan a directory for Node.js source maps and upload them. Auto-detects the application version from package.json. Supports custom project roots and overwriting. ```sh bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --detect-app-version \ --directory build ``` -------------------------------- ### Programmatic Browser Source Map Upload with Auto-Detected Version Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload a browser source map programmatically, automatically detecting the application version from the nearest `package.json` file. Requires specifying the source map path, bundle URL, and project root. ```ts // Auto-detect version from package.json await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/assets/main.js', detectAppVersion: true, // reads version from nearest package.json projectRoot: process.cwd(), }) ``` -------------------------------- ### Upload Browser Source Maps (Single) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload a single browser source map and bundle. Specify the application version explicitly or auto-detect it from package.json. Supports overwriting existing uploads and custom endpoints. ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/assets/main.js" \ --bundle dist/main.js \ --overwrite ``` ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --detect-app-version \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/assets/main.js" ``` ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --code-bundle-id "bundle-42" \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/assets/main.js" ``` ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/main.js" \ --endpoint https://bugsnag.my-company.com/ ``` ```sh bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/assets/*" ``` -------------------------------- ### Build Source Maps Package Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/TESTING.md Build the JavaScript package 'bugsnag-source-maps.tgz' which is required for test fixtures. This command should be run before executing the tests. ```shell docker-compose run packager ``` -------------------------------- ### Bugsnag Source Maps CLI Help Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/README.md Display the help message for the bugsnag-source-maps CLI, showing available commands and options. ```sh bugsnag-source-maps --help bugsnag-source-maps Available commands upload-browser upload-node upload-react-native Options -h, --help show this message --version output the version of the CLI module ``` -------------------------------- ### Upload Node.js Source Maps (Single) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload a single Node.js source map and bundle. Specify the application version and optionally the project root. Supports overwriting existing uploads. ```sh bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --app-version 3.0.1 \ --source-map build/server.js.map \ --bundle build/server.js ``` ```sh bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --app-version 3.0.1 \ --source-map build/server.js.map \ --bundle build/server.js \ --project-root /home/ci/myapp \ --overwrite ``` -------------------------------- ### Apply Source Map Transformations Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Use `addSources` to populate `sourcesContent` and `stripProjectRoot` to make source paths relative. These are applied sequentially to prepare source maps for upload. ```typescript import addSources from '@bugsnag/source-maps/dist/transformers/AddSources' import stripProjectRoot from '@bugsnag/source-maps/dist/transformers/StripProjectRoot' import consola from 'consola' const fs = require('fs') const sourceMapJson = JSON.parse(fs.readFileSync('dist/main.js.map', 'utf-8')) // Step 1: populate sourcesContent from disk const withSources = await addSources( '/home/ci/myapp/dist/main.js.map', // absolute path to the .map file sourceMapJson, '/home/ci/myapp', // projectRoot consola ) // Step 2: strip absolute project root from each source path const ready = await stripProjectRoot( '/home/ci/myapp/dist/main.js.map', withSources, '/home/ci/myapp', consola ) // ready.sources entries are now relative, e.g. ["src/index.ts", "src/lib/a.ts"] // ready.sourcesContent contains the file contents as strings console.log(ready.sources) // => ['src/components/App.tsx', 'src/utils/helpers.ts', ...] ``` -------------------------------- ### Bump Version and Push Tag Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/CONTRIBUTING.md Use this command to update the package version and push the new commit and tag to the repository. ```bash npm version git push origin main git push --tags ``` -------------------------------- ### node.uploadMultiple Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively finds all `*.map` files in the given directory (ignoring `node_modules`). The `minifiedUrl` for each file is the path relative to `projectRoot`. ```APIDOC ## Programmatic API — `node.uploadMultiple` Recursively finds all `*.map` files in the given directory (ignoring `node_modules`). The `minifiedUrl` for each file is the path relative to `projectRoot`. ```ts import { node } from '@bugsnag/source-maps' await node.uploadMultiple({ apiKey: 'YOUR_API_KEY', directory: 'build', appVersion: '3.0.1', projectRoot: '/home/ci/myserver', overwrite: false, }) // Each source map's minifiedUrl = path.relative(projectRoot, absoluteBundlePath) // e.g. "build/server.js", "build/worker.js" ``` ``` -------------------------------- ### node.uploadOne Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads a single Node.js source map. The `minifiedUrl` sent to Bugsnag is the bundle path with `\` path separators normalized to `/`. ```APIDOC ## Programmatic API — `node.uploadOne` Uploads a single Node.js source map. The `minifiedUrl` sent to Bugsnag is the bundle path with `\` path separators normalized to `/`. ```ts import { node } from '@bugsnag/source-maps' try { await node.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'build/server.js.map', bundle: 'build/server.js', appVersion: '3.0.1', overwrite: true, projectRoot: process.cwd(), }) } catch (err) { console.error(err.message) process.exitCode = 1 } // With detectAppVersion await node.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'build/server.js.map', bundle: 'build/server.js', detectAppVersion: true, }) ``` ``` -------------------------------- ### Update and Push Next Branch Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/CONTRIBUTING.md Commands to update the 'next' branch with changes from 'main' and push the updates. ```bash git checkout next git merge main git push ``` -------------------------------- ### Configure Retry Interval and Timeout Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Set environment variables to override the default retry interval between upload attempts and the default HTTP timeout for network requests. ```shell # Override the retry interval between upload attempts (default: 1000ms) BUGSNAG_RETRY_INTERVAL_MS=2000 # Override the default HTTP timeout (default: 60000ms = 1 minute) BUGSNAG_TIMEOUT_MS=300000 ``` -------------------------------- ### browser.uploadOne Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Programmatically uploads a single browser source map. This function reads source maps and bundles from disk, applies transformations, and POSTs to the Bugsnag upload API. ```APIDOC ## browser.uploadOne ### Description Uploads a single browser source map programmatically. Reads the source map and optional bundle from disk, applies `AddSources` and `StripProjectRoot` transformations, then POSTs to the Bugsnag upload API. ### Method Programmatic API (TypeScript/JavaScript) ### Endpoint N/A (Programmatic API) ### Parameters - `apiKey` (string) - Your Bugsnag API key. - `sourceMap` (string) - Path to the source map file (relative to `projectRoot`). - `bundleUrl` (string) - The public URL where the bundle will be served. - `bundle` (string, optional) - Path to the minified bundle file. - `appVersion` (string, optional) - The application version string. - `detectAppVersion` (boolean, optional) - If true, reads the version from the nearest `package.json`. - `codeBundleId` (string, optional) - A unique identifier for the code bundle (mutually exclusive with `appVersion`). - `overwrite` (boolean, optional) - Whether to replace existing uploads (defaults to `true`). - `projectRoot` (string) - The root directory of the project. - `logger` (object, optional) - A logger instance (e.g., from `consola`). ### Request Example ```ts import { browser } from '@bugsnag/source-maps' import consola from 'consola' // Single upload with bundle file included async function uploadSourceMap() { try { await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/assets/main.js', bundle: 'dist/main.js', appVersion: '1.2.3', overwrite: true, projectRoot: '/home/ci/myapp', logger: consola, }) console.log('Upload successful') } catch (err) { console.error('Upload failed:', err.message) process.exit(1) } } // Auto-detect version from package.json await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/assets/main.js', detectAppVersion: true, projectRoot: process.cwd(), }) // With code bundle ID (mutually exclusive with appVersion) await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/assets/main.js', codeBundleId: 'bundle-42', }) ``` ### Response - **Success Response**: The function returns a Promise that resolves on successful upload. - **Error Response**: The Promise rejects with a `NetworkError` object containing a `.code` (NetworkErrorCode) and `.responseText`. ``` -------------------------------- ### Upload multiple Node.js source maps Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively finds all *.map files in the given directory (ignoring node_modules). The minifiedUrl for each file is the path relative to projectRoot. ```typescript import { node } from '@bugsnag/source-maps' await node.uploadMultiple({ apiKey: 'YOUR_API_KEY', directory: 'build', appVersion: '3.0.1', projectRoot: '/home/ci/myserver', overwrite: false, }) ``` -------------------------------- ### Upload multiple browser source maps Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Recursively scans a directory for *.map files (excluding *.css.map) and uploads each one. The corresponding bundle is inferred by stripping the .map extension. Sets an HTTP idle timeout. ```typescript import { browser } from '@bugsnag/source-maps' await browser.uploadMultiple({ apiKey: 'YOUR_API_KEY', baseUrl: 'https://cdn.example.com/assets/', directory: 'dist', appVersion: '1.2.3', overwrite: false, projectRoot: '/home/ci/myapp', idleTimeout: 10, }) ``` -------------------------------- ### Run End-to-End Tests with Debug Output Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/TESTING.md Run the end-to-end tests with additional debug information enabled. This is useful for troubleshooting test failures. ```shell DEBUG=true docker-compose run --use-aliases maze-runner ``` -------------------------------- ### CLI - upload-browser Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload one or more browser JavaScript source maps to Bugsnag. Supports single mode (one source map/bundle pair) and multiple mode (recursively scans a directory). ```APIDOC ## upload-browser ### Description Upload one or more browser JavaScript source maps to Bugsnag. Supports a **single** mode (one source map / bundle pair) and a **multiple** mode (recursively scans a directory for all `*.map` files, skipping `*.css.map`). ### Method POST ### Endpoint https://upload.bugsnag.com ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body Multipart form data containing source map and bundle information. ### Request Example ```sh # Single upload — explicit app version bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --source-map dist/main.js.map \ --bundle-url "https://cdn.example.com/assets/main.js" \ --bundle dist/main.js \ --overwrite # Multiple upload — scans dist/ for all *.map files bugsnag-source-maps upload-browser \ --api-key YOUR_API_KEY \ --app-version 1.2.3 \ --directory dist \ --base-url "https://cdn.example.com/assets/" ``` ### Options: | Flag | Description | |---|---| | `--api-key` | Bugsnag project API key (**required**) | | `--source-map` | Path to the `.map` file (**required** in single mode) | | `--bundle-url` | Public URL of the minified bundle (**required** in single mode; supports `*`) | | `--bundle` | Path to the minified bundle file (optional in single mode) | | `--directory` | Directory to search for `*.map` files (**required** in multiple mode) | | `--base-url` | Base URL of the JS files directory (**required** in multiple mode; supports `*`) | | `--app-version` | Application version string | | `--code-bundle-id` | Code bundle ID (mutually exclusive with `--app-version`) | | `--detect-app-version` | Read version from nearest `package.json` | | `--overwrite` / `--no-overwrite` | Replace or protect existing uploads | | `--project-root` | Top-level project directory (defaults to `cwd`) | | `--endpoint` | Custom upload URL for Bugsnag On-Premise | | `--idle-timeout` | HTTP idle timeout in minutes | | `--quiet` | Suppress info/debug log output | ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/TESTING.md Execute all end-to-end tests using the Maze Runner test harness. This command invokes the test suite against the Source Maps CLI. ```shell docker-compose run --use-aliases maze-runner ``` -------------------------------- ### CLI - upload-node Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload source maps for server-side Node.js bundles. Supports single and multiple upload modes. ```APIDOC ## upload-node ### Description Upload source maps for server-side Node.js bundles. Supports the same single / multiple modes as `upload-browser`; in multiple mode the `minifiedUrl` in the upload is computed as the relative path from the project root. ### Method POST ### Endpoint https://upload.bugsnag.com ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body Multipart form data containing source map and bundle information. ### Request Example ```sh # Single upload bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --app-version 3.0.1 \ --source-map build/server.js.map \ --bundle build/server.js # Multiple upload — scans build/ recursively bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --detect-app-version \ --directory build ``` ### Options: | Flag | Description | |---|---| | `--api-key` | Bugsnag project API key (**required**) | | `--source-map` | Path to the `.map` file (**required** in single mode) | | `--bundle` | Path to the minified bundle file | | `--directory` | Directory to search for `*.map` files (**required** in multiple mode) | | `--app-version` | Application version string | | `--code-bundle-id` | Code bundle ID (mutually exclusive with `--app-version`) | | `--detect-app-version` | Read version from nearest `package.json` | | `--overwrite` / `--no-overwrite` | Replace or protect existing uploads | | `--project-root` | Top-level project directory | | `--endpoint` | Custom upload URL for Bugsnag On-Premise | | `--idle-timeout` | HTTP idle timeout in minutes | | `--quiet` | Suppress info/debug log output | ``` -------------------------------- ### Configure Bugsnag On-Premise Endpoint Source: https://github.com/bugsnag/bugsnag-source-maps/blob/next/README.md When using Bugsnag On-premise, specify the upload server URL using the --endpoint option. ```sh bugsnag-source-maps upload-browser \ --endpoint https://bugsnag.my-company.com/ \ # ... other options ``` -------------------------------- ### Programmatic Browser Source Map Upload with Code Bundle ID Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload a browser source map programmatically using a code bundle ID. This option is mutually exclusive with `appVersion`. Ensure you provide the API key, source map path, and bundle URL. ```ts // With code bundle ID (mutually exclusive with appVersion) await browser.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/assets/main.js', codeBundleId: 'bundle-42', }) ``` -------------------------------- ### Upload single Node.js source map Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads a single Node.js source map. The minifiedUrl sent to Bugsnag is the bundle path with \ path separators normalized to /. Handles errors by logging and setting process exit code. ```typescript import { node } from '@bugsnag/source-maps' try { await node.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'build/server.js.map', bundle: 'build/server.js', appVersion: '3.0.1', overwrite: true, projectRoot: process.cwd(), }) } catch (err) { console.error(err.message) process.exitCode = 1 } ``` ```typescript await node.uploadOne({ apiKey: 'YOUR_API_KEY', sourceMap: 'build/server.js.map', bundle: 'build/server.js', detectAppVersion: true, }) ``` -------------------------------- ### Upload Node.js Source Maps with Code Bundle ID Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Use this command to upload source maps for Node.js applications, specifying a code bundle ID for OTA updates. Ensure you provide the API key, code bundle ID, and paths to the source map and bundle files. ```sh bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --code-bundle-id "release-2024-03-15" \ --source-map build/server.js.map \ --bundle build/server.js ``` -------------------------------- ### reactNative.uploadOne Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads a pre-built React Native source map and bundle pair. Handles platform-specific version fields (`appVersionCode` for Android, `appBundleVersion` for iOS). ```APIDOC ## Programmatic API — `reactNative.uploadOne` Uploads a pre-built React Native source map and bundle pair. Handles platform-specific version fields (`appVersionCode` for Android, `appBundleVersion` for iOS). ```ts import { reactNative } from '@bugsnag/source-maps' // iOS release await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', appBundleVersion: '210', sourceMap: 'ios/build/main.jsbundle.map', bundle: 'ios/build/main.jsbundle', overwrite: true, projectRoot: process.cwd(), }) // Android release await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'android', appVersion: '2.1.0', appVersionCode: '21', sourceMap: 'android/build/index.android.bundle.map', bundle: 'android/build/index.android.bundle', }) // Debug/dev build await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', sourceMap: 'ios/build/main.jsbundle.map', bundle: 'ios/build/main.jsbundle', dev: true, }) ``` ``` -------------------------------- ### Upload React Native Source Maps (Provide Mode - iOS) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload source maps for an iOS React Native release build by providing the paths to the source map and bundle files. This is used in 'provide' mode. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --app-version 2.1.0 \ --app-bundle-version 210 \ --source-map ios/build/main.jsbundle.map \ --bundle ios/build/main.jsbundle ``` -------------------------------- ### Upload React Native Source Maps (Provide Mode - Android) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload source maps for an Android React Native release build by providing the paths to the source map and bundle files. This is used in 'provide' mode. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform android \ --app-version 2.1.0 \ --app-version-code 21 \ --source-map android/build/index.android.bundle.map \ --bundle android/build/index.android.bundle ``` -------------------------------- ### Upload React Native Source Maps (Fetch Mode - Custom URL) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Fetch source maps from a custom Metro bundler URL and specify a custom entry point for an Android React Native application. This uses fetch mode. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform android \ --app-version 2.1.0 \ --fetch \ --bundler-url http://localhost:8082 \ --bundler-entry-point src/App.js ``` -------------------------------- ### Upload React Native Source Maps (Provide Mode - Dev Build) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload source maps for a development build of a React Native iOS application. This command includes the `--dev` flag to indicate it's a debug build. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --app-version 2.1.0 \ --source-map ios/build/main.jsbundle.map \ --bundle ios/build/main.jsbundle \ --dev ``` -------------------------------- ### Upload single React Native source map (Android) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads a pre-built React Native source map and bundle pair for Android. Handles platform-specific version fields. ```typescript // Android release await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'android', appVersion: '2.1.0', appVersionCode: '21', sourceMap: 'android/build/index.android.bundle.map', bundle: 'android/build/index.android.bundle', }) ``` -------------------------------- ### Upload single React Native source map (iOS) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads a pre-built React Native source map and bundle pair for iOS. Handles platform-specific version fields. Supports debug/dev builds. ```typescript import { reactNative } from '@bugsnag/source-maps' // iOS release await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', appBundleVersion: '210', sourceMap: 'ios/build/main.jsbundle.map', bundle: 'ios/build/main.jsbundle', overwrite: true, projectRoot: process.cwd(), }) ``` ```typescript // Debug/dev build await reactNative.uploadOne({ apiKey: 'YOUR_API_KEY', platform: 'ios', appVersion: '2.1.0', sourceMap: 'ios/build/main.jsbundle.map', bundle: 'ios/build/main.jsbundle', dev: true, }) ``` -------------------------------- ### bugsnag-source-maps upload-react-native Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads source maps for React Native applications. Supports both providing pre-built files and fetching from a live bundler server. ```APIDOC ## upload-react-native ### Description Uploads source maps for React Native apps. Supports two retrieval strategies: **provide** (supply pre-built files) and **fetch** (pull live files from the React Native bundler server). ### Method CLI Command ### Endpoint N/A (CLI Tool) ### Parameters #### Common Flags - `--api-key` (string) - Your Bugsnag API key. - `--platform` (string) - The platform, either `"ios"` or `"android"` (required). - `--app-version` (string) - The application version string. - `--app-version-code` (integer) - Android `versionCode` (mutually exclusive with `--app-bundle-version`). - `--app-bundle-version` (integer) - iOS `CFBundleVersion` (mutually exclusive with `--app-version-code`). - `--code-bundle-id` (string) - Code bundle ID for OTA updates. - `--dev` (boolean) - Flag as a debug/development build. - `--no-overwrite` (boolean) - Prevent replacing existing uploads. #### Provide Mode Flags - `--source-map` (string) - Path to the source map (required in provide mode). - `--bundle` (string) - Path to the JS bundle (required in provide mode). #### Fetch Mode Flags - `--fetch` (boolean) - Enable fetch mode (pulls from bundler server). - `--bundler-url` (string) - Metro bundler URL (default: `http://localhost:8081`). - `--bundler-entry-point` (string) - Entry point file (default: `index.js`). ### Request Example ```sh # Provide mode — iOS release build bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --app-version 2.1.0 \ --app-bundle-version 210 \ --source-map ios/build/main.jsbundle.map \ --bundle ios/build/main.jsbundle # Fetch mode — pulls from running Metro bundler (localhost:8081) bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --app-version 2.1.0 \ --fetch # Using code bundle ID (for OTA/CodePush) bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --code-bundle-id "v2.1.0-ota-3" \ --source-map ios/build/main.jsbundle.map \ --bundle ios/build/main.jsbundle ``` ### Response N/A (CLI Tool output) ``` -------------------------------- ### Network Error Handling Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Illustrates how to catch and handle `NetworkError` exceptions thrown by upload functions. The `NetworkErrorCode` enum helps identify specific failure types for targeted actions. ```APIDOC ## Error Handling — `NetworkError` All upload functions throw a `NetworkError` on failure. The `.code` property (a `NetworkErrorCode` enum) identifies the specific failure type so callers can take targeted action. ```ts import { browser } from '@bugsnag/source-maps' import { NetworkError, NetworkErrorCode } from '@bugsnag/source-maps/dist/NetworkError' try { await browser.uploadOne({ apiKey: 'INVALID_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/main.js', appVersion: '1.0.0', }) } catch (err) { if (err instanceof NetworkError) { switch (err.code) { case NetworkErrorCode.INVALID_API_KEY: console.error('Bad API key — check your Bugsnag project settings') break case NetworkErrorCode.DUPLICATE: console.warn('Source map already exists; use overwrite: true to replace it') break case NetworkErrorCode.TIMEOUT: console.error('Request timed out — consider increasing idleTimeout') break case NetworkErrorCode.EMPTY_FILE: console.error('The source map file was empty') break case NetworkErrorCode.SERVER_ERROR: console.error('Bugsnag server error:', err.responseText) break default: console.error('Unexpected error:', err.message) } } process.exitCode = 1 } // NetworkErrorCode enum values: // UNKNOWN | DUPLICATE | TIMEOUT | MISC_BAD_REQUEST | EMPTY_FILE // INVALID_API_KEY | SERVER_ERROR | CONNECTION_REFUSED | NOT_FOUND ``` ``` -------------------------------- ### bugsnag-source-maps upload-node Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Uploads source maps for Node.js applications. This command is used to upload source maps and bundles, particularly useful when using code bundle IDs for OTA updates. ```APIDOC ## upload-node ### Description Uploads source maps for Node.js applications. ### Method CLI Command ### Endpoint N/A (CLI Tool) ### Parameters #### Common Flags - `--api-key` (string) - Your Bugsnag API key. - `--code-bundle-id` (string) - A unique identifier for the code bundle, useful for OTA updates. - `--source-map` (string) - Path to the `.map` file (required in single mode). - `--bundle` (string) - Path to the minified bundle (required in single mode). - `--directory` (string) - Directory to search for `*.map` files (required in multiple mode). ### Request Example ```sh bugsnag-source-maps upload-node \ --api-key YOUR_API_KEY \ --code-bundle-id "release-2024-03-15" \ --source-map build/server.js.map \ --bundle build/server.js ``` ### Response N/A (CLI Tool output) ``` -------------------------------- ### Upload React Native Source Maps (Fetch Mode - iOS) Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Enable fetch mode to automatically pull source maps from a running Metro bundler for an iOS React Native application. The default bundler URL is localhost:8081. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --app-version 2.1.0 \ --fetch ``` -------------------------------- ### Handle Network Errors During Upload Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Catch `NetworkError` exceptions thrown by upload functions. Use the `.code` property to identify specific failure types like invalid API keys, duplicates, or timeouts, and take appropriate action. ```typescript import { browser } from '@bugsnag/source-maps' import { NetworkError, NetworkErrorCode } from '@bugsnag/source-maps/dist/NetworkError' try { await browser.uploadOne({ apiKey: 'INVALID_KEY', sourceMap: 'dist/main.js.map', bundleUrl: 'https://cdn.example.com/main.js', appVersion: '1.0.0', }) } catch (err) { if (err instanceof NetworkError) { switch (err.code) { case NetworkErrorCode.INVALID_API_KEY: console.error('Bad API key — check your Bugsnag project settings') break case NetworkErrorCode.DUPLICATE: console.warn('Source map already exists; use overwrite: true to replace it') break case NetworkErrorCode.TIMEOUT: console.error('Request timed out — consider increasing idleTimeout') break case NetworkErrorCode.EMPTY_FILE: console.error('The source map file was empty') break case NetworkErrorCode.SERVER_ERROR: console.error('Bugsnag server error:', err.responseText) break default: console.error('Unexpected error:', err.message) } } process.exitCode = 1 } // NetworkErrorCode enum values: // UNKNOWN | DUPLICATE | TIMEOUT | MISC_BAD_REQUEST | EMPTY_FILE // INVALID_API_KEY | SERVER_ERROR | CONNECTION_REFUSED | NOT_FOUND ``` -------------------------------- ### Upload React Native Source Maps with Code Bundle ID Source: https://context7.com/bugsnag/bugsnag-source-maps/llms.txt Upload source maps for a React Native iOS application using a code bundle ID, which is useful for Over-The-Air (OTA) updates or CodePush. This is mutually exclusive with `appVersion`. ```sh bugsnag-source-maps upload-react-native \ --api-key YOUR_API_KEY \ --platform ios \ --code-bundle-id "v2.1.0-ota-3" \ --source-map ios/build/main.jsbundle.map \ --bundle ios/build/main.jsbundle ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.