eventLog
Records analytics events that occur inside the mini-app. Supports multiple log types — from debug through to click and impression. In sandbox, logs are printed to the console; in the Apps in Toss environment they are forwarded to the logging system.
Signature
import { eventLog } from '@apps-in-toss/web-framework';
type Primitive = string | number | boolean | null | undefined | symbol;
interface EventLogParams {
log_name: string;
log_type: 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup';
params: Record<string, Primitive>;
}
declare function eventLog(params: EventLogParams): Promise<void>;
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
log_name | string | ✓ | Name of the log entry. |
log_type | 'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup' | ✓ | Type of the log entry. |
params | Record<string, Primitive> | ✓ | Additional key-value metadata to attach to the log. |
log_type guide
| Value | When to use |
|---|---|
'event' | General user action events (default choice) |
'click' | Click/tap interactions |
'screen' | Screen view |
'impression' | Component becomes visible |
'debug' | Development-only diagnostics |
'info' | Informational messages |
'warn' | Warnings |
'error' | Errors |
'popup' | Popup impressions |
Returns
Promise<void>— resolves when the log is recorded.
Permission
No permission required — eventLog is not bound to a PermissionName.
Examples
Minimal
import { eventLog } from '@apps-in-toss/web-framework';
await eventLog({
log_name: 'button_click',
log_type: 'click',
params: {},
});
Realistic — screen view logging
import { eventLog } from '@apps-in-toss/web-framework';
import { useEffect } from 'react';
function ProductPage({ productId }: { productId: string }) {
useEffect(() => {
eventLog({
log_name: 'product_screen_view',
log_type: 'screen',
params: {
product_id: productId,
},
});
}, [productId]);
return <main>{/* product content */}</main>;
}
Realistic — error logging
import { eventLog } from '@apps-in-toss/web-framework';
async function fetchData(url: string) {
try {
const response = await fetch(url);
return await response.json();
} catch (error) {
await eventLog({
log_name: 'fetch_error',
log_type: 'error',
params: {
url,
message: error instanceof Error ? error.message : String(error),
},
});
throw error;
}
}
Try it live
Run eventLog on the Analytics page in sdk-example.
Related APIs
Analytics.click— record a user click event.Analytics.impression— record when a UI component enters the viewport.Analytics.screen— record a screen view event.appsInTossEvent.addEventListener— subscribe to platform events.graniteEvent.addEventListener— subscribe to Granite events.
Related guides
External references
@apps-in-toss/web-framework— SDK package.eventLogis re-exported from@apps-in-toss/web-bridge.