@goplayerzero/js-api
Version:
The official PlayerZero JavaScript SDK
113 lines • 3.68 kB
TypeScript
export declare class PzApi {
private readonly apiToken;
private static SPAN_COUNTER;
private static readonly CHECKS;
private readonly dataset;
private readonly prod;
private readonly batchEventsSize;
private readonly debounceInMs;
private readonly endpoint;
private readonly privacy?;
private readonly dequeuedEvents?;
private readonly queuedEvent?;
private readonly insight;
private currentIdentification?;
private currentIdentificationMetadata?;
constructor(apiToken: string, options?: PzInsightOptions);
identify(id: null | string | PzUserIdentity, metadata?: Record<string, any>): void;
track(name: string, options?: PzTrackOptions): void;
log(type: PzLogType, message: string | Error, options?: PzLogOptions): void;
span(traceId: string, type: string, name: string, duration: number, options?: PzSpanOptions): void;
flush(): void;
private publishInsights;
private flushQ;
private privatizeText;
private transformId;
}
export interface PzInsightOptions {
dataset?: string;
prod?: boolean;
batchEventsSize?: number;
debounceInMs?: number;
endpoint?: string;
privacy?: (text: string) => string;
dequeuedEvents?: (type: PzInsightType, events: PzInsight[]) => void;
queuedEvent?: (type: PzInsightType, event: PzInsight) => void;
restoreQueue?: (type: PzInsightType) => Promise<PzInsight[]>;
}
export type PzInsightType = 'Track' | 'Log' | 'Span';
export type PzLogType = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
export interface PzInsight {
readonly id?: string;
readonly properties?: Record<string, string>;
}
export interface PzTrackInsight extends PzInsight {
readonly identity: PzUserIdentity;
readonly value: string;
readonly type?: string;
readonly ts: Date;
readonly attributes?: Record<string, any>;
}
export interface PzTrackOptions {
readonly id?: string;
readonly type?: string;
readonly ts?: Date;
readonly properties?: Record<string, string>;
readonly attributes?: Record<string, any>;
}
export interface PzLogInsight extends PzInsight {
readonly traceId?: string;
readonly spanId?: string;
readonly type: PzLogType;
readonly value: string;
readonly ts: Date;
readonly qty?: number;
readonly attributes?: Record<string, any>;
}
export interface PzLogOptions {
readonly id?: string;
readonly traceId?: string;
readonly spanId?: string;
readonly ts?: Date;
readonly fp?: string;
readonly qty?: number;
readonly exception?: {
message?: string;
type?: string;
stacktrace?: string;
};
readonly properties?: Record<string, string>;
readonly attributes?: Record<string, any>;
}
export interface PzSpanInsight extends PzInsight {
readonly id: string;
readonly traceId: string;
readonly spanId?: string;
readonly type: string;
readonly value: string;
readonly start: Date;
readonly end: Date;
readonly error?: string;
readonly events?: PzSpanEvent[];
}
export interface PzSpanOptions {
readonly id?: string;
readonly parentId?: string;
readonly start?: Date;
readonly end?: Date;
readonly error?: string;
readonly events?: PzSpanEvent[];
readonly properties?: Record<string, string>;
readonly attributes?: Record<string, any>;
}
export interface PzUserIdentity {
readonly userId?: string;
readonly email?: string;
readonly anonId?: string;
}
export interface PzSpanEvent {
readonly name: string;
readonly ts: Date;
readonly properties?: Record<string, string>;
}
//# sourceMappingURL=index.d.ts.map