Skip to main content

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

NameTypeRequiredDescription
log_namestringName of the log entry.
log_type'debug' | 'info' | 'warn' | 'error' | 'event' | 'screen' | 'impression' | 'click' | 'popup'Type of the log entry.
paramsRecord<string, Primitive>Additional key-value metadata to attach to the log.

log_type guide

ValueWhen 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.

Open in sdk-example

External references