Analytics
Namespace for recording screen views, component impressions, and user click events. The three Analytics methods (screen/impression/click) accept a shared LoggerParams object; the standalone eventLog function supports nine log types via the log_type field.
Methods
| Method | Return type | Purpose |
|---|---|---|
Analytics.click | Promise<void> | undefined | Record a user tap or click on a UI element. |
Analytics.impression | Promise<void> | undefined | Record when a UI component enters the viewport. |
Analytics.screen | Promise<void> | undefined | Record a screen (page) view event. |
eventLog | Promise<void> | Log a generic event with an arbitrary key-value payload and one of nine log_type values. |
Shared parameter type
Analytics.screen/impression/click all accept the same LoggerParams type. eventLog uses a separate EventLogParams — see its page for the shape.
import { Analytics } from '@apps-in-toss/web-framework';
type Primitive = string | number | boolean | null;
type LoggerParams = {
log_name?: string;
} & {
[key: string]: Primitive;
};
log_name identifies the event in your analytics dashboard. Any additional keys are passed through as event properties and must be Primitive values.
Permission
No permission required. None of the Analytics methods are bound to a PermissionName. For how permissions work in other namespaces see Guides — Permissions pattern.
UX guidance
- Call
Analytics.screenon page mount. The standard pattern isuseEffect(() => { Analytics.screen({ page: 'home' }); }, []). - Call
Analytics.impressionon viewport entry, not on mount. Use anIntersectionObserverso only components the user actually sees are counted. - Call
Analytics.clickinside the event handler. Place it inonClick/onPressfor a 1:1 match with actual taps. - Keep
log_namestable. Changing an event name mid-stream breaks historical continuity — coordinate with your data pipeline before renaming. - The return value can be
undefined. Alwaysawaitand never depend on the resolved value.
Try it live
Both methods are available on the Analytics page in sdk-example.
Open in sdk-exampleExternal references
@apps-in-toss/web-framework— SDK package.Analyticsis re-exported from@apps-in-toss/web-analytics.