amberflo-metering-typescript
Version:
Amberflo metering client for TypeScript
54 lines (53 loc) • 2.27 kB
TypeScript
import { MeterMessage } from "./model/meterMessage";
import { IngestClient } from "./ingestClient/ingestClient";
import { IngestOptions } from "./model/ingestOptions";
import { CustomerDetailsApiClient } from "./ingestClient/customerDetailsApiClient";
/**
* Metering is the main class to ingest meters into Amberflo
*/
export declare class Metering {
readonly customerDetailsApiClient: CustomerDetailsApiClient;
readonly apiKey: string;
readonly debug: boolean;
readonly ingestClient: IngestClient;
private signature;
private isStarted;
/**
* Initialize a new metering client without any side effects. Call start() to start up the ingestion client.
* @param apiKey
* @param debug
* @param ingestOptions
*/
constructor(apiKey: string, debug: boolean, ingestOptions?: IngestOptions);
/**
* Start and initialize the ingestion client. If this is not called, all ingestion calls will fail.
*/
start(): void;
/**
* Queue a meter for ingestion.
* In auto flush mode, queue will be flushed automatically when ingestOptions.batchSize is exceeded or periodically ingestOptions.frequencyMillis
* In manual flush mode, call flush() To ingest messages in the queue
* @param {string} meterApiName
* @param {number} meterValue
* @param {number} meterTimeInMillis
* @param {string} customerId
* @param {Map<string,string>} dimensions
*/
meter(meterApiName: string, meterValue: number, meterTimeInMillis: number, customerId: string, dimensions?: Map<string, string>): void;
static validateMeterMessage(meterMessage: MeterMessage): string[];
/**
* Add or update customer details.
* @param customerId
* @param customerName
* @param traits
*/
addOrUpdateCustomerDetails(customerId: string, customerName: string, traits?: Map<string, string>): Promise<import("./model/customerApiPayload").CustomerDetails>;
/**
* Process all pending ingestion meter messages and wait for all requests to API to complete.
*/
flush(): Promise<void | import("axios").AxiosResponse<string, any>>;
/**
* Shutdown the ingestion client.
*/
shutdown(): Promise<void | import("axios").AxiosResponse<string, any>>;
}