react-marketing-tools
Version:
React Marketing Tools are a set of tools to make it easier for you to implement analytics and track user journeys, interactions throughout your App. using dataLayer/Google Tag Manager, GA4 fetch directly or coming soon facebook pixel.
131 lines (130 loc) • 3.94 kB
TypeScript
export interface AnalyticsEventActionPrefix extends Record<string, string> {
}
export interface AnalyticsGlobalEventAction extends Record<string, string> {
}
export type Event = {
name: string;
params: Record<AllowedTypes, AllowedTypes>;
};
export type GooglePayload = {
non_personalized_ads: boolean;
client_id: string;
user_id: string;
user_properties: {
user_id: string;
user_type: string;
client_id: string;
};
events: Event[];
};
export type EventNameInfo = {
eventName?: string;
description?: string;
actionPrefix: string;
globalAppEvent: string;
previousGlobalAppEvent?: string;
};
export type AllowedTypes = string | number;
export type TrackAnalyticsEventOptions = {
data: Record<AllowedTypes, AllowedTypes>;
eventNameInfo: EventNameInfo;
analyticsType: string;
userDataKeysToHashArray?: Array<string> | null;
dataLayerCheck?: boolean;
consoleLogData?: object;
};
export type GlobalVars = {
app: string;
device_category?: string | undefined;
device_os?: string | undefined;
device_browser?: string | undefined;
};
export type DataLayer = {
event: string;
globalVars: GlobalVars;
journeyProps: Record<any, any>;
userProps: Record<any, any>;
};
export type ConsoleLogData = {
showGlobalVars?: boolean;
showJourneyPropsPayload?: boolean;
showUserProps?: boolean;
};
export interface AnalyticsTrackerDataOptions {
consoleLogData: ConsoleLogData | null;
data: Record<any, any>;
eventName: string;
globalAppEvent: string;
userDetails: Record<any, any>;
}
export interface HandleDataLayerPushOptions extends AnalyticsTrackerDataOptions {
dataLayerCheck: boolean;
}
export type ServerLocationData = {
SERVER_CITY: string;
SERVER_COUNTRY: string;
SERVER_HOSTNAME: string;
SERVER_IP: string;
SERVER_LOCATION: string;
SERVER_POSTAL: string;
SERVER_REGION: string;
SERVER_TIMEZONE: string;
};
export type IpInfo = {
city: string;
country: string;
SERVER_HOSTNAME: string;
hostname: string;
ip: string;
loc: string;
postal: string;
region: string;
timezone: string;
};
export type Ga4GoogleAnalyticsEventTracking = AnalyticsTrackerDataOptions;
export type Platform = 'GOOGLE' | 'FACEBOOK' | 'DATALAYER_PUSH';
export type AnalyticsPlatform = {
[key in Platform]: Platform;
};
export type Tokens = {
IP_INFO_TOKEN?: string;
GA4_PUBLIC_API_SECRET?: string;
GA4_PUBLIC_MEASUREMENT_ID?: string;
};
export type Config = {
TOKENS?: Tokens;
appName: string;
appSessionCookieName: string;
withDeviceInfo?: boolean;
includeUserKeys: Array<string>;
showMissingUserAttributesInConsole: boolean | undefined;
withServerLocationInfo: boolean | undefined;
eventActionPrefixList: AnalyticsEventActionPrefix;
analyticsGlobalEventActionList: AnalyticsGlobalEventAction;
};
export type BuildConfigOptions = {
appName: string;
appSessionCookieName: string;
eventActionPrefix?: AnalyticsEventActionPrefix;
globalEventActionList?: AnalyticsGlobalEventAction;
includeUserKeys?: Array<string> | undefined;
showMissingUserAttributesInConsole?: boolean;
showMeBuildInEventActionPrefixList?: boolean;
TOKENS?: Tokens;
withDeviceInfo?: boolean;
withServerLocationInfo?: boolean;
};
export declare let config: Config;
export type ProviderStateProps = {
appName: string;
appSessionCookieName: string;
analyticsPlatform: AnalyticsPlatform;
eventActionPrefixList: AnalyticsEventActionPrefix;
analyticsGlobalEventActionList: AnalyticsGlobalEventAction;
};
export type ProviderApiProps = {
trackAnalyticsEvent: (options: TrackAnalyticsEventOptions) => Promise<void>;
showMeBuildInAnalyticsPlatform: () => void;
showMeBuildInEventActionPrefixList: () => void;
showMeBuildInGlobalEventActionList: () => void;
};