promoted-snowplow-logger
Version:
Logging utility for browser-side Typescript that logs Promoted events to our Metrics Snowplow-compatible API
40 lines (39 loc) • 1.66 kB
TypeScript
import type { Action, Click, CohortMembership, HasUserInfo, Impression, View } from './types/event';
import type { EventLogger, EventLoggerArguments } from './types/logger';
export declare const getViewContexts: (view: View) => {
schema: string;
data: View;
}[];
export declare const createEventLogger: (args: EventLoggerArguments) => EventLogger;
/**
* A utility class for logging events.
*
* Warning: This class modifies the inputs. We avoid creating duplicate objects
* to reduce memory pressure.
*/
export declare class EventLoggerImpl implements EventLogger {
private handleError;
private getUserInfo?;
private snowplow;
private snowplowTrackers?;
/**
* @params {EventLoggerArguments} args The arguments for the logger.
*/
constructor(args: EventLoggerArguments);
private validateArgs;
logCohortMembership: (cohortMembership: CohortMembership) => void;
logView: (view: View) => void;
logImpression: (impression: Impression) => void;
logAction: (action: Action) => void;
private prepareAction;
logClick: (click: Click) => void;
mergeBaseUserInfo: <T extends HasUserInfo>(record: T) => T;
/**
* Wraps a value in an array if it is not already an array. If the value is undefined, it returns undefined.
*
* @param value - The value to be wrapped in an array. It can be of any type T or an array of type T.
* @returns If the value is an array, it returns the array as is. If the value is not an array but is defined,
* it returns the value wrapped in an array. If the value is undefined, it returns undefined.
*/
private arrayWrap;
}