# tode.trackActionWithMetric()

Track an action with an associated numeric value for Figma plugin analytics.

## Usage

```typescript
// Track item count
tode.trackActionWithMetric('items_exported', 42);

// Track processing time
tode.trackActionWithMetric('render_time_ms', 1523);

// Track file size
tode.trackActionWithMetric('file_size_kb', 256);
```

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `actionName` | `string` | Yes | Identifier for the action |
| `value` | `number` | Yes | Numeric value to track |
| `options.eventSource` | `'plugin' \| 'ui'` | No | Override where the event is reported from. Defaults to where the code runs |
| `options.signal` | `AbortSignal` | No | Cancel the request early. Ignored in `code.ts`, where Figma has no `AbortController` |

## Returns

`Promise<void>`. It never rejects: failures are logged to the console.

## Use Cases

- **Count of items** - Number of layers, elements, or items processed
- **Processing duration** - Time taken for operations in milliseconds
- **File sizes** - Size of exported files in KB or bytes
- **Quantities** - Any numeric metric relevant to your plugin

## Examples

### Track export count

```typescript
const handleExport = async (items: any[]) => {
  // Perform export logic...

  tode.trackActionWithMetric('items_exported', items.length);
};
```

### Track processing time

```typescript
const processLayers = async (layers: any[]) => {
  const startTime = Date.now();

  // Process layers...

  const duration = Date.now() - startTime;
  tode.trackActionWithMetric('processing_time_ms', duration);
};
```

### Track before Tode is ready

```typescript
// Held and sent once Tode is ready, with the original time
tode.trackActionWithMetric('file_size_kb', fileSize);
```

## See Also

- [tode.trackAction()](https://docs.usetode.dev/api/track-action) - Track simple actions without values
- [tode.isReady](https://docs.usetode.dev/api/is-ready) - Check if ready to track
- [Best Practices](https://docs.usetode.dev/best-practices) - Naming conventions and tips

Source: https://docs.usetode.dev/api/track-action-with-metric
