Quick Start
Anvil is easy to add to your driver. Install the agent, add the client library and configure your driver in under 5 minutes to start seeing real time information about your driver.
Prerequisites
- The Anvil Agent installed and authenticated on your controller (setup guide)
- A project created in Anvil
1. Download the Anvil SDK
Download the latest Anvil SDK and place the contents in your driver's vendor/ directory.
2. Add vendor directory to your .c4zproj manifest
Make sure the vendor directory is included in your manifest:
<Item type="dir" c4zDir="vendor" name="vendor" recurse="true" exclude="false"/>
If your project uses a squishy file, you can bundle the SDK into your squished driver instead of shipping the vendor directory:
Module "vendor.anvil-sdk" "vendor/anvil-sdk.lua"
The require('vendor.anvil-sdk') call in the next step is the same either
way — squish satisfies it from the bundle; otherwise Director resolves the
vendored file from your packaged driver.
3. Initialize Anvil in OnDriverInit
Update your OnDriverInit function to load the SDK and initialize it with your API key (from Settings > API Keys in Anvil):
function OnDriverInit(strDIR)
require('vendor.anvil-sdk')
Anvil:Init("YOUR_API_KEY", C4:GetDriverFileName())
Anvil:OnDriverInit(function(strDIR)
-- Your existing OnDriverInit code goes here
end, strDIR)
end
OnDriverInit is a special case — it runs before the SDK can auto-instrument, so it needs the explicit Anvil:OnDriverInit wrapper. All other lifecycle methods (OnDriverLateInit, OnPropertyChanged, etc.) are automatically instrumented — just write them normally.
4. Build and deploy
Build your driver and load it onto your controller. Events will start streaming to Anvil immediately.
5. View your data in Anvil
Open your project in Anvil to see data flowing in real time. The Events page shows every handler call as it happens, Logs shows your driver's log output, and Errors surfaces any exceptions with full stack traces. Interact with your driver in a navigator or Composer to see events appear instantly.
Next Steps
- Learn about automatic event capture
- See how to capture timer and URL callback errors
- Review the API reference
- Read the detailed Installation guide for advanced configuration