In this guide, we’ll walk you through the process of sending your first event and reading it back using the Trench Cloud API.
The example uses the Trench JavaScript client, but the same can be achieved by calling the Events API directly.
After installing the client, you need to initialize it with your API key. Replace YOUR_API_KEY and YOUR_SERVER_URL with the actual API key and server URL you received:
import Trench from 'trench-js'const trench = new Trench({ publicApiKey: 'YOUR_PUBLIC_API_KEY', serverUrl: 'YOUR_SERVER_URL'});
Optionally, you can identify a user with the identify method:
trench.identify('user-id', { email: 'test@example.com', // Add any other traits you want to associate with the user})
4
Send a Sample Event
Now you can send a sample event to Trench Cloud. Here is an example of how to send an event:
trench.track("Test Event");
This will send an event with the name Test Event.
5
Verify the Event
You can verify that the event was received by opening the Events tab in the Trench Cloud dashboard.