Client Setup
Initialize the Node SDK client and user data
Before sending any events, you need to create a client instance with your API key and base URL, and prepare the user data object.
import { Client, UserData } from "audiencelab_nodejs_sdk";
const client = new Client({
apiKey: "<YOUR_API_TOKEN>",
baseUrl: "https://api.yourservice.com",
});
const userData = new UserData()
.setUserId("user_12345")
.setUserIp("123.123.1.1")
.setEventTimestamp("Wed Oct 05 2024 16:48:00 GMT+0200")
.setDeviceInfo({
device_name: "My Device",
height: 2436,
width: 1125,
os: "iOS",
os_version: "14.4",
device_model: "iPhone15,4",
timezone: "America/New_York",
});
⚠️ Important: Detailed device_info is only required during the initial user registration. For later events, you only need to provide user_id and user_ip.
Prop | Type | Default |
---|---|---|
user_id | string | - |
ip_address | string | - |
timestamp? | string | - |
last_login? | string | - |
Device Info Object
Prop | Type | Default |
---|---|---|
device_name | string | - |
device_model | string | - |
timezone | string | - |
height | integer | - |
width | integer | - |
window_height | integer | - |
window_width | integer | - |
os | string | - |
os_version | string | - |
device_vendor? | string | - |
madid? | string | - |
advertiser_tracking_enabled? | boolean | - |
application_tracking_enabled? | boolean | - |
dpi? | integer | - |
screen_density? | double | - |
cores? | integer | - |
ext_stor_size? | integer | - |
free_stor? | integer | - |
low_battery_level? | boolean | - |
locale? | string | - |
carrier? | string | - |
Creative Token Info Object
Prop | Type | Default |
---|---|---|
creative_token? | string | - |
madid? | string | - |
os_system? | string | - |
device_name? | string | - |
device_model? | string | - |
utc_offset? | string | - |
install_date? | string | - |
last_login_date? | string | - |
If the event did not happen in real time, include an event_timestamp in ISO 8601 format.
You’re now ready to register the user or fetch the creative token.