UNPKG

@segment/analytics-next

Version:

Analytics Next (aka Analytics 2.0) is the latest version of Segment’s JavaScript SDK - enabling you to send your data to any tool without having to learn, test, or use a new API every time.

50 lines 1.77 kB
import { Analytics } from '../core/analytics'; import { AnalyticsBuffered } from '../core/buffer'; import { CDNSettings, AnalyticsBrowserSettings, InitOptions } from './settings'; export type { CDNSettings, AnalyticsBrowserSettings }; export declare function loadCDNSettings(writeKey: string, baseUrl: string): Promise<CDNSettings>; /** * The public browser interface for Segment Analytics * * @example * ```ts * export const analytics = new AnalyticsBrowser() * analytics.load({ writeKey: 'foo' }) * ``` * @link https://github.com/segmentio/analytics-next/#readme */ export declare class AnalyticsBrowser extends AnalyticsBuffered { private _resolveLoadStart; constructor(); /** * Fully initialize an analytics instance, including: * * * Fetching settings from the segment CDN (by default). * * Fetching all remote destinations configured by the user (if applicable). * * Flushing buffered analytics events. * * Loading all middleware. * * Note:️ This method should only be called *once* in your application. * * @example * ```ts * export const analytics = new AnalyticsBrowser() * analytics.load({ writeKey: 'foo' }) * ``` */ load(settings: AnalyticsBrowserSettings, options?: InitOptions): AnalyticsBrowser; /** * Instantiates an object exposing Analytics methods. * * @example * ```ts * const ajs = AnalyticsBrowser.load({ writeKey: '<YOUR_WRITE_KEY>' }) * * ajs.track("foo") * ... * ``` */ static load(settings: AnalyticsBrowserSettings, options?: InitOptions): AnalyticsBrowser; static standalone(writeKey: string, options?: InitOptions): Promise<Analytics>; } //# sourceMappingURL=index.d.ts.map