Skip to main content

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

MethodReturn typePurpose
Analytics.clickPromise<void> | undefinedRecord a user tap or click on a UI element.
Analytics.impressionPromise<void> | undefinedRecord when a UI component enters the viewport.
Analytics.screenPromise<void> | undefinedRecord a screen (page) view event.
eventLogPromise<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.screen on page mount. The standard pattern is useEffect(() => { Analytics.screen({ page: 'home' }); }, []).
  • Call Analytics.impression on viewport entry, not on mount. Use an IntersectionObserver so only components the user actually sees are counted.
  • Call Analytics.click inside the event handler. Place it in onClick / onPress for a 1:1 match with actual taps.
  • Keep log_name stable. Changing an event name mid-stream breaks historical continuity — coordinate with your data pipeline before renaming.
  • The return value can be undefined. Always await and never depend on the resolved value.

Try it live

Both methods are available on the Analytics page in sdk-example.

Open in sdk-example

External references