TodeTodeDocs
Browse the docs

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

OptionTypeRequiredDescription
apiKeystringYesYour Tode API key
debugbooleanNoEnable debug logging (default: false)
apiUrlstringNoHTTP endpoint for events (default: https://processing.usetode.dev)
wsUrlstringNoWebSocket endpoint for sessions (default: wss://processing.usetode.dev)
signalAbortSignalNoCancel 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 figma global is available), not from the UI
  • Events tracked before init() finishes are held (up to 50) and sent when it does; await it before figma.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

Track your Figma plugin

Sign up to get your API key and start collecting analytics in minutes.

Get your API key