Skip to content

Commit

Permalink
[mixpanel] Add time_event, people.union, and typedef for init config …
Browse files Browse the repository at this point in the history
…param (DefinitelyTyped#20342)

* @types/mixpanel: Add 'time_event' and 'people.union' functions

* @types/mixpanel: Add typedef for mixpanel.init() library configuration
  • Loading branch information
pnw authored and weswigham committed Oct 11, 2017
1 parent b7d6b8d commit 6b3463e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
63 changes: 61 additions & 2 deletions types/mixpanel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for Mixpanel 2.11
// Type definitions for Mixpanel 2.13.0
// Project: https://mixpanel.com/
// https://github.com/mixpanel/mixpanel-js
// Definitions by: Knut Eirik Leira Hjelle <https://github.com/hjellek>
Expand All @@ -8,12 +8,14 @@ interface Mixpanel
{
people:Mixpanel.People;

init(token:string, config?:{[index:string]:any}, libraryName?:string):Mixpanel;
init(token:string, config?:Mixpanel.Config, libraryName?:string):Mixpanel;

push(item:any[]):void;

disable(events?:string[]):void;

time_event(eventName:string):void;

track(eventName:string, params?:{[index:string]:any}, callback?:() => void):void;

track_links(querySelector:string, eventName:string, params?:{[index:string]:any}):void;
Expand Down Expand Up @@ -53,6 +55,10 @@ declare namespace Mixpanel

set_once(key:string, value:any, callback?:() => void):void;

union(prop: string, values:any, callback?:() => void):void;

union(keys:{[index:string]:any}, callback?:() => void):void;

increment(key:string):void;

increment(keys:{[index:string]:number}):void;
Expand All @@ -69,6 +75,59 @@ declare namespace Mixpanel

delete_user():void;
}

interface Config
{
api_host?: string;

app_host?: string;

cdn?: string;

persistence?: string;

persistence_name?: string;

cookie_name?: string;

autotrack?: boolean;

cross_subdomain_cookie?: boolean;

store_google?: boolean;

save_referrer?: boolean;

test?: boolean;

verbose?: boolean;

img?: boolean;

track_pageview?: boolean;

debug?: boolean;

upgrade?: boolean;

disable_persistence?: boolean;

disable_cookie?: boolean;

secure_cookie?: boolean;

ip?: boolean;

loaded?: (lib:Mixpanel) => void;

track_links_timeout?: number;

cookie_expiration?: number;

property_blacklist?: string[];

[other:string]:any
}
}

declare var mixpanel:Mixpanel;
8 changes: 8 additions & 0 deletions types/mixpanel/mixpanel-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function mixpanel_base()

mixpanel.disable(['my_event']);

mixpanel.time_event('Registered');

mixpanel.track("Registered", {"Gender": "Male", "Age": 21});

mixpanel.track_links("#nav", "Clicked Nav Link");
Expand Down Expand Up @@ -59,6 +61,12 @@ function mixpanel_people()
counter2: 1
});

mixpanel.people.union('pages_visited', 'homepage');
mixpanel.people.union({
list1: 'bob',
list2: 123
});

mixpanel.people.append('pages_visited', 'homepage');
mixpanel.people.append({
list1: 'bob',
Expand Down

0 comments on commit 6b3463e

Please sign in to comment.