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() - Track actions with numeric values
- tode.isReady - Check if ready to track
- Best Practices - Naming conventions and tips