Analytics
AlogameAnalytics wraps the native SDK's Adjust tracking (with optional
Firebase composite). Adjust tokens and the app token are managed by your
game operator on the backend — as a developer you only call these with
the event name agreed with your operator.
logEvent and logRevenue are the two methods real games actually use.
logPurchase, setTrackingEnabled, and isInitialized are supported for
parity with the native SDKs but see little real-world use in practice.
Auto-tracked events
The native SDK automatically tracks these lifecycle events once your operator has set them up on the backend — no game code required:
| Event Name | Trigger |
|---|---|
sdk_show_login | Login screen displayed |
sdk_register_success | Registration completed |
sdk_login_success | Manual login completed |
sdk_logout | User logs out or session expires |
sdk_recharge | In-app purchase verified (see Payment) |
Log an event
An event is just a name plus optional string parameters — there is no fixed list. Which events exist and how each name maps to an Adjust token is defined by your game operator; the SDK resolves the name to a token at runtime. An event with no configured token is silently skipped.
import { AlogameAnalytics } from 'alogame-sdk';
await AlogameAnalytics.logEvent('tutorial_complete');
await AlogameAnalytics.logEvent('level_up', {
level: '10',
score: '15000',
});
Log a revenue event
Events that carry money — web-store top-ups, first_recharge, or any custom
revenue event — must use logRevenue. Sending the amount only as a plain
parameter (e.g. charged_value) is not counted by Adjust — the dashboard
would show 0.
AlogamePayment.purchase() already fires sdk_recharge with revenue set —
no extra call needed. Use logRevenue only for events the game pushes
itself (web-store recharges, custom revenue events).
await AlogameAnalytics.logRevenue(
'Recharge', // event name set up as a revenue event by your operator
99000, // real amount paid (must be > 0)
'VND', // ISO 4217
'order_12345', // orderId — dedup id
{ payment_channel: 'web_store', product_id: 'vip_pack_1' }
);
A recharge is a revenue event — always send it via
logRevenue, not the plainlogEvent, otherwise Adjust records no revenue.
Log a purchase event (lower-level alternative to logRevenue)
await AlogameAnalytics.logPurchase(
'purchase_event_token',
4.99, // price
'USD',
'order_12345', // transactionId (optional)
'gem_pack_50' // productId (optional)
);
Enable / disable tracking
await AlogameAnalytics.setTrackingEnabled(false);
await AlogameAnalytics.setTrackingEnabled(true);
Check initialization
const ready = await AlogameAnalytics.isInitialized();