tode.init()
Initialize Tode in your Figma plugin's controller code (code.ts). Nothing is sent until it has run.
Usage
code.ts
import { tode } from '@tode-sdk/core';
await tode.init({
apiKey: 'your-api-key',
debug: false
});Parameters
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your Tode API key |
debug | boolean | No | Enable debug logging (default: false) |
apiUrl | string | No | HTTP endpoint for events (default: https://processing.usetode.dev) |
wsUrl | string | No | WebSocket endpoint for sessions (default: wss://processing.usetode.dev) |
signal | AbortSignal | No | Cancel init() early. Requests time out after 10 seconds on their own |
Returns
Promise<void>
Notes
- This method must be called from the plugin controller (where
figmaglobal is available), not from the UI - Events tracked before
init()finishes are held (up to 50) and sent when it does;awaitit beforefigma.closePlugin()so they get out - Never throws: called from the UI by mistake, it logs an error and returns
- Only call once per plugin session
Example
code.ts
import { tode } from '@tode-sdk/core';
// Show your UI
figma.showUI(__html__, { width: 400, height: 600 });
// Initialize Tode
await tode.init({ apiKey: 'your-api-key' });
// Now you can track actions
tode.trackAction('plugin_opened');See Also
- tode.trackAction() - Track simple actions
- tode.isReady - Check initialization status