UNPKG

@trimble-oss/trimble-id

Version:

Trimble Identity SDK for JavaScript/TypeScript

90 lines (89 loc) 3.91 kB
/** * Copyright (c) Trimble Inc. */ /** * Event types for analytics tracking * @enum {string} */ declare enum EventType { /** Initialization event type */ INIT = "INIT", /** Method usage event type */ METHOD_USAGE = "METHOD", /** Exception event type */ EXCEPTION = "EXCEPTION" } /** * A HTTP client for sending event hits to Google Analytics */ export default class AnalyticsHttpClient { private static readonly BASE_ADDRESS; private static readonly MEASUREMENT_ID; private static readonly ENCODED_API_KEY; private static readonly SDK_NAME; private static readonly SDK_VERSION; private static readonly HEX_BASE; private static readonly UUID_VARIANT_MASK; private static readonly UUID_VARIANT_BITS; private static _cid; /** * Gets the decoded API key using jsrsasign b64utoutf8 */ private static get API_KEY(); /** * Gets the client ID, generating it if not already created */ private static get CID(); /** * Sends a generic event to Google Analytics * * @param name - Name of the event to send * @param params - Additional parameters for the event * @returns Promise that resolves when the event is sent * @throws Will silently catch and ignore any errors during event sending * */ static sendEvent(name: string, params: any): Promise<void>; /** * Sends a custom event with specified event type and parameters * * @param name - Base name of the event (will be suffixed with event type) * @param eventType - Type of the event (INIT, METHOD_USAGE, or EXCEPTION) * @param applicationId - Optional client id for the calling application * @param clientName - Name of the client SDK (defaults to SDK name if not provided) * @param clientVersion - Version of the client SDK (defaults to SDK version if not provided) * @param exceptionMessage - Optional exception message (only used for EXCEPTION events) * */ static sendCustomEvent(name: string, eventType: EventType, applicationId?: string, clientName?: string | null, clientVersion?: string | null, exceptionMessage?: string | null): void; /** * Sends a method usage event to track method invocations * * @param name - Name of the method or action being tracked * @param applicationId - Optional client id for the calling application * @param clientName - Optional name of the client SDK (defaults to SDK name) * @param clientVersion - Optional version of the client SDK (defaults to SDK version) */ static sendMethodEvent(name: string, applicationId?: string, clientName?: string | null, clientVersion?: string | null): void; /** * Sends an initialization event to track SDK or application startup * * @param name - Name of the initialization event * @param applicationId - Optional client id for the calling application * @param clientName - Optional name of the client SDK (defaults to SDK name) * @param clientVersion - Optional version of the client SDK (defaults to SDK version) */ static sendInitEvent(name: string, applicationId?: string, clientName?: string | null, clientVersion?: string | null): void; /** * Sends an exception event to track errors and exceptions * * @param name - Name of the exception event * @param exceptionMessage - The exception or error message to track * @param applicationId - Optional client id for the calling application * @param clientName - Optional name of the client SDK (defaults to SDK name) * @param clientVersion - Optional version of the client SDK (defaults to SDK version) */ static sendExceptionEvent(name: string, exceptionMessage: string, applicationId?: string, clientName?: string | null, clientVersion?: string | null): void; private static uuidv4; } export {};