# tode.trackAction()

Track a simple user action in your Figma plugin or widget.

## Usage

```typescript
tode.trackAction('export_clicked');
tode.trackAction('settings_opened');
tode.trackAction('layer_renamed');
```

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `actionName` | `string` | Yes | Identifier for the action. A non-empty string, at most 500 characters |
| `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 resolves when the request finishes, or right away if the event was held because Tode is not ready yet. It never rejects: failures are logged to the console.

## Best Practices

Use descriptive snake_case names:

```typescript
// Good - clear and descriptive
tode.trackAction('export_to_png');
tode.trackAction('layer_renamed');
tode.trackAction('settings_opened');

// Bad - too vague
tode.trackAction('click');
tode.trackAction('action1');
```

## Examples

### Track button clicks

```typescript
const handleExport = () => {
  // Perform export logic...
  tode.trackAction('export_clicked');
};
```

### Track feature usage

```typescript
const openSettings = () => {
  tode.trackAction('settings_opened');
  // Show settings UI...
};
```

### Track before Tode is ready

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

Up to 50 events tracked before `isReady` are kept. Later ones are dropped until Tode is ready.

## See Also

- [tode.trackActionWithMetric()](https://docs.usetode.dev/api/track-action-with-metric) - Track actions with numeric 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
