UNPKG

matomo-react-native

Version:

Enhanced Matomo tracking library for React Native and Expo projects with TypeScript support and automatic platform detection.

147 lines (146 loc) 5.12 kB
export interface MatomoUserInfo { uid?: string; cip?: string; cdt?: string; cvar?: Record<string, [string, string]>; [key: string]: any; } export interface PlatformInfo { os: 'ios' | 'android' | 'web' | 'windows' | 'macos' | 'unknown'; version?: string; } export interface MatomoEnhancedUserInfo extends MatomoUserInfo { resolution?: string; language?: string; timezone?: string; userAgent?: string; } export type UserInfo = MatomoUserInfo; export type Action = MatomoTrackActionOptions; export type Event = MatomoTrackEventOptions; export type AppStart = MatomoTrackAppStartOptions; export type PageView = MatomoTrackPageViewOptions; export interface MatomoInitOptions { urlBase: string; siteId: number; trackerUrl?: string; userId?: string; disabled?: boolean; log?: boolean; } export interface MatomoTrackAppStartOptions { url?: string; referrer?: string; platform?: string; userAgent?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackPageViewOptions { name: string; url: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackScreenViewOptions { name: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackActionOptions { name: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackEventOptions { category: string; action: string; name?: string; value?: number; campaign?: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackContentOptions { contentName: string; contentPiece?: string; contentTarget?: string; contentInteraction?: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackSiteSearchOptions { keyword: string; category?: string; count?: number; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackLinkOptions { link: string; linkType?: 'link' | 'download'; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackDownloadOptions { download: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackReferralUrlOptions { referralUrl: string; campaign?: string; source?: string; medium?: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackAdClickOptions { adId: string; adName: string; adSource?: string; adCampaign?: string; targetUrl?: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackAdImpressionOptions { adId: string; adName: string; adSource?: string; adCampaign?: string; url?: string; userInfo?: MatomoUserInfo; } export interface MatomoTrackerInstance { trackAppStart: (options?: MatomoTrackAppStartOptions) => Promise<void>; trackPageView: (options: MatomoTrackPageViewOptions) => Promise<void>; trackScreenView: (options: MatomoTrackScreenViewOptions) => Promise<void>; trackAction: (options: MatomoTrackActionOptions) => Promise<void>; trackEvent: (options: MatomoTrackEventOptions) => Promise<void>; trackContent: (options: MatomoTrackContentOptions) => Promise<void>; trackSiteSearch: (options: MatomoTrackSiteSearchOptions) => Promise<void>; trackLink: (options: MatomoTrackLinkOptions) => Promise<void>; trackDownload: (options: MatomoTrackDownloadOptions) => Promise<void>; trackReferralUrl: (options: MatomoTrackReferralUrlOptions) => Promise<void>; trackAdClick: (options: MatomoTrackAdClickOptions) => Promise<void>; trackAdImpression: (options: MatomoTrackAdImpressionOptions) => Promise<void>; updateUserInfo: (userInfo: MatomoUserInfo) => void; removeUserInfo: () => void; } export interface MatomoHook { trackAppStart: (params?: MatomoTrackAppStartOptions) => Promise<void> | undefined; trackPageView: (params: MatomoTrackPageViewOptions) => Promise<void> | undefined; trackScreenView: (params: MatomoTrackScreenViewOptions) => Promise<void> | undefined; trackAction: (params: MatomoTrackActionOptions) => Promise<void> | undefined; trackEvent: (params: MatomoTrackEventOptions) => Promise<void> | undefined; trackContent: (params: MatomoTrackContentOptions) => Promise<void> | undefined; trackSiteSearch: (params: MatomoTrackSiteSearchOptions) => Promise<void> | undefined; trackLink: (params: MatomoTrackLinkOptions) => Promise<void> | undefined; trackDownload: (params: MatomoTrackDownloadOptions) => Promise<void> | undefined; updateUserInfo: (params: MatomoUserInfo) => void | undefined; removeUserInfo: () => void | undefined; trackReferralUrl: (params: MatomoTrackReferralUrlOptions) => Promise<void> | undefined; trackAdClick: (params: MatomoTrackAdClickOptions) => Promise<void> | undefined; trackAdImpression: (params: MatomoTrackAdImpressionOptions) => Promise<void> | undefined; } export declare const getPlatformInfo: () => PlatformInfo; export declare const generateUserAgent: (platformInfo?: PlatformInfo) => string;