Skip to content

Instantly share code, notes, and snippets.

@tommedema
Created Aug 13, 2019
Embed
What would you like to do?
index.d.ts for analytics.js
/// <reference lib="dom"/>
declare function Analytics(opts: Analytics.IOptions): Analytics.IAnalytics
declare namespace Analytics {
interface IOptions {
app: string,
plugins: object[]
}
interface IPageData {
title?: string
url?: string
path?: string
referrer?: string
}
interface ITraits {
[key: string]: string | number | boolean | undefined
}
interface IAnalytics {
page: (data?: IPageData) => void,
track: (event: string, traits?: ITraits) => void,
identify: (userId: string, traits?: ITraits) => void,
ready: (cb: () => void) => void
}
}
export = Analytics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment