Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#1624 from Bartvds/def/universal-an…
Browse files Browse the repository at this point in the history
…alytics

Created definitions for 'universal-analytics'
  • Loading branch information
vvakame committed Jan 28, 2014
2 parents 4b5e679 + c4bc4c0 commit 8c614a5
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ List of Definitions
* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
* [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/))
* [Underscore-ko.js](https://github.com/kamranayub/UnderscoreKO) (by [Maurits Elbers](https://github.com/MagicMau))
* [universal-analytics](https://github.com/peaksandpies/universal-analytics) (by [Bart van der Schoor](https://github.com/Bartvds))
* [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade))
* [Valerie](https://github.com/davewatts/valerie) (by [Howard Richards](https://github.com/conficient))
* [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov))
Expand Down
87 changes: 87 additions & 0 deletions universal-analytics/universal-analytics-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/// <reference path="universal-analytics.d.ts" />

var ui:UniversalAnalytics;

var str:string;
var num:number;
var value:any;
var bool:boolean;
var params:Object;
var x:any;

var client:UniversalAnalytics.Client = ui('UA-123-00');
client = ui.debug();
client.send();

client = client.pageview(str);
client.pageview(str, (err:any) => {});
client = client.pageview(params);
client.pageview(params, (err:any) => {});
client = client.pageview(str, str);
client.pageview(str, str, (err:any) => {});
client = client.pageview(str, str, str);
client.pageview(str, str, str, (err:any) => {});


client = client.event(str, str);
client.event(str, str, (err:any) => {});
client = client.event(str, str, str);
client.event(str, str, str, (err:any) => {});
client = client.event(str, str, str, value);
client.event(str, str, str, value, (err:any) => {});
client.event(str, str, str, value, params, (err:any) => {});
client = client.event(params);
client.event(params, (err:any) => {});


client = client.transaction(str);
client.transaction(str, (err:any) => {});
client = client.transaction(str, num);
client.transaction(str, num, (err:any) => {});
client = client.transaction(str, num, num);
client.transaction(str, num, num, (err:any) => {});
client = client.transaction(str, num, num, num);
client.transaction(str, num, num, num, (err:any) => {});
client = client.transaction(str, num, num, num, str);
client.transaction(str, num, num, num, str, (err:any) => {});
client = client.transaction(params);
client.transaction(params, (err:any) => {});


client = client.item(num);
client.item(num, (err:any) => {});
client = client.item(num, num);
client.item(num, num, (err:any) => {});
client = client.item(num, num, num);
client.item(num, num, num, (err:any) => {});
client = client.item(num, num, num, str);
client.item(num, num, num, str, (err:any) => {});
client = client.item(num, num, num, str, str);
client.item(num, num, num, str, str, (err:any) => {});
client = client.item(num, num, num, str, str, params);
client.item(num, num, num, str, str, params, (err:any) => {});
client = client.item(params);
client.item(params, (err:any) => {});


client = client.exception(str);
client.exception(str, (err:any) => {});
client = client.exception(str, bool);
client.exception(str, bool, (err:any) => {});
client = client.exception(params);
client.exception(params, (err:any) => {});


client = client.timing(str);
client.timing(str, (err:any) => {});
client = client.timing(str, str);
client.timing(str, str, (err:any) => {});
client = client.timing(str, str, num);
client.timing(str, str, num, (err:any) => {});
client = client.timing(str, str, num, str);
client.timing(str, str, num, str, (err:any) => {});
client = client.timing(params);
client.timing(params, (err:any) => {});


x = client.middleware(str, {});
94 changes: 94 additions & 0 deletions universal-analytics/universal-analytics.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Type definitions for universal-analytics v0.3.2
// Project: https://github.com/peaksandpies/universal-analytics
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

interface UniversalAnalytics {
(accountID:string, uuid?:string, opts?:Object):UniversalAnalytics.Client;
debug():UniversalAnalytics.Client;
}

declare module UniversalAnalytics {

interface Client {

send():void;

pageview(path:string):Client;
pageview(path:string, callback?:(err:any) => void):void;
pageview(params:Object):Client;
pageview(params:Object, callback?:(err:any) => void):void;
pageview(path:string, hostname:string):Client;
pageview(path:string, hostname:string, callback?:(err:any) => void):void;
pageview(path:string, title:string, hostname:string):Client;
pageview(path:string, title:string, hostname:string, callback?:(err:any) => void):void;


event(category:string, action:string):Client;
event(category:string, action:string, callback?:(err:any) => void):void;
event(category:string, action:string, label:string):Client;
event(category:string, action:string, label:string, callback?:(err:any) => void):void;
event(category:string, action:string, label:string, value:any):Client;
event(category:string, action:string, label:string, value:any, callback?:(err:any) => void):void;
event(category:string, action:string, label:string, value:any, params:Object, callback?:(err:any) => void):void;
event(params:Object):Client;
event(params:Object, callback:(err:any) => void):void;


transaction(id:string):Client;
transaction(id:string, callback:(err:any) => void):void;
transaction(id:string, revenue:number):Client;
transaction(id:string, revenue:number, callback:(err:any) => void):void;
transaction(id:string, revenue:number, shipping:number):Client;
transaction(id:string, revenue:number, shipping:number, callback:(err:any) => void):void;
transaction(id:string, revenue:number, shipping:number, taxping:number):Client;
transaction(id:string, revenue:number, shipping:number, taxping:number, callback:(err:any) => void):void;
transaction(id:string, revenue:number, shipping:number, taxping:number, affiliation:string):Client;
transaction(id:string, revenue:number, shipping:number, taxping:number, affiliation:string, callback:(err:any) => void):void;
transaction(params:Object):Client;
transaction(params:Object, callback:(err:any) => void):void;


item(price:number):Client;
item(price:number, callback:(err:any) => void):void;
item(price:number, quantity:number):Client;
item(price:number, quantity:number, callback:(err:any) => void):void;
item(price:number, quantity:number, sku:number):Client;
item(price:number, quantity:number, sku:number, callback:(err:any) => void):void;
item(price:number, quantity:number, sku:number, name:string):Client;
item(price:number, quantity:number, sku:number, name:string, callback:(err:any) => void):void;
item(price:number, quantity:number, sku:number, name:string, variation:string):Client;
item(price:number, quantity:number, sku:number, name:string, variation:string, callback:(err:any) => void):void;
item(price:number, quantity:number, sku:number, name:string, variation:string, params:Object):Client;
item(price:number, quantity:number, sku:number, name:string, variation:string, params:Object, callback:(err:any) => void):void;
item(params:Object):Client;
item(params:Object, callback:(err:any) => void):void;


exception(description:string):Client;
exception(description:string, callback:(err:any) => void):void;
exception(description:string, fatal:boolean):Client;
exception(description:string, fatal:boolean, callback:(err:any) => void):void;
exception(params:Object):Client;
exception(params:Object, callback:(err:any) => void):void;


timing(category:string):Client;
timing(category:string, callback:(err:any) => void):void;
timing(category:string, variable:string):Client;
timing(category:string, variable:string, callback:(err:any) => void):void;
timing(category:string, variable:string, time:number):Client;
timing(category:string, variable:string, time:number, callback:(err:any) => void):void;
timing(category:string, variable:string, time:number, label:string):Client;
timing(category:string, variable:string, time:number, label:string, callback:(err:any) => void):void;
timing(params:Object):Client;
timing(params:Object, callback:(err:any) => void):void;


middleware(accountID:string, options?:any):any;
}
}

declare module 'universal-analytics' {
export = UniversalAnalytics;
}

0 comments on commit 8c614a5

Please sign in to comment.