Skip to main content
For programmatic trace uploads from your Node.js or browser applications, Flamedeck provides the @flamedeck/upload NPM package. This library offers a convenient function to send trace data directly to the Flamedeck API.

Installation

You can install the package using npm or yarn:

Basic Usage

The core of the library is the uploadTraceToApi function. You’ll need to import it along with the necessary types.

Prerequisites

Requirements:
  • API Key: You need a Flamedeck API key with trace:upload scope
  • Trace Data: Your trace data should be a File or Blob object when used in the browser, or an ArrayBuffer (e.g., from reading a file) when used in Node.js
  • Filename: The original filename for the trace

Example (Node.js)

Here’s a TypeScript example demonstrating how to upload a trace file from a Node.js environment:

Example (Browser)

When using in a browser environment (e.g., from a file input):

UploadOptions Interface

The uploadTraceToApi function accepts an options object conforming to the UploadOptions interface:
apiKey
string
required
Your Flamedeck API key.
traceData
Blob | ArrayBuffer
required
The content of the trace file. Use File/Blob for browser, ArrayBuffer for Node.js.
fileName
string
required
The original filename.
scenario
string
required
A descriptive name for the trace.
commitSha
string
The Git commit SHA associated with this trace.
branch
string
The Git branch name associated with this trace.
notes
string
Free-form text notes to attach to the trace.
folderId
string
The UUID of an existing folder to upload the trace into.
public
boolean
default:"false"
Set to true to make the trace publicly accessible. Defaults to false (private).
metadata
Record<string, unknown> | string
Custom key-value metadata to associate with the trace.
supabaseFunctionsUrl
string
Override the default Supabase functions base URL (for self-hosted or testing).
For detailed descriptions of optional fields like commitSha, branch, notes, folderId, and metadata, please refer to the CLI Upload documentation, as they serve the same purpose.

Error Handling

The uploadTraceToApi function will throw an UploadError if the upload fails. This custom error object contains:
  • status: HTTP status code (if applicable)
  • message: Error message
  • details: Additional error information from the API
Always wrap your upload calls in try-catch blocks to handle potential errors gracefully.