Server SDKs
Retention Event
Send retention events with the Node.js SDK
Track daily user retention by sending retention events via the webhook endpoint.
Usage
import {
Client, UserData, RetentionData, AppEvent
} from "@geeklab.app/audiencelab_nodejs_sdk";
const client = new Client({
apiKey: "YOUR_API_KEY",
baseUrl: "https://analytics.geeklab.app",
});
const userData = new UserData()
.setUserId("user_12345")
.setUserIp("203.0.113.42")
.setUserCreativeTokenInfo({
creativeToken: "abc123-creative-token",
os_system: "iOS 17.4",
device_name: "iPhone 14 Pro",
device_model: "iPhone15,2",
utc_offset: "+03:00",
install_date: "2026-06-09T10:00:00+00:00",
last_login_date: "2026-06-09T10:00:00+00:00",
});
if (userData.shouldSendRetentionEvent()) {
const retention = new RetentionData()
.setRetentionData(userData);
const response = await new AppEvent(
client, retention, userData
).send();
}How It Works
RetentionData.setRetentionData(userData) calculates the retention day using calendar-day math from install_date, last_login_date, and the event timestamp stored in UserData. The retention event includes:
Prop
Type
Sending on Each Login
Call this on every user session start or app open.
shouldSendRetentionEvent() is an in-process guard. In multi-worker backends, persist userData.getRetentionGuardKey() or the last sent retention day in your own store and pass it back to shouldSendRetentionEvent(lastSentRetentionDay).