From d095f35e67739931dc4c7cea7a54076c2621e9fe Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 6 Oct 2014 16:58:54 +0900 Subject: [PATCH] add insight.d.ts --- CONTRIBUTORS.md | 1 + insight/insight-tests.ts | 21 +++++++++++++++++ insight/insight.d.ts | 49 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 insight/insight-tests.ts create mode 100644 insight/insight.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f0968971ab..539cbb10f5 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -144,6 +144,7 @@ All definitions files include a header with the author and editors, so at some p * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) * [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) +* [insight](https://github.com/yeoman/insight) (by [vvakame](https://github.com/vvakame)) * [interact.js](http://github.com/taye/interact.js) (by [Douglas Eichelberger](https://github.com/dduugg)) * [Ion.RangeSlider](https://github.com/IonDen/ion.rangeSlider) (by [Douglas Eichelberger](https://github.com/dduugg)) * [Ionic-Cordova](https://github.com/driftyco/) (by [Hendrik Maus](https://github.com/hendrikmaus)) diff --git a/insight/insight-tests.ts b/insight/insight-tests.ts new file mode 100644 index 0000000000..9d081fff18 --- /dev/null +++ b/insight/insight-tests.ts @@ -0,0 +1,21 @@ +/// + +declare var require:any; + +import Insight = require('insight'); +var pkg:any = require('./package.json'); + +var insight = new Insight({ + // Google Analytics tracking code + trackingCode: 'UA-XXXXXXXX-X', + packageName: pkg.name, + packageVersion: pkg.version +}); + +// ask for permission the first time +if (insight.optOut === undefined) { + return insight.askPermission(); +} + +insight.track('foo', 'bar'); +// recorded in Analytics as `/foo/bar` diff --git a/insight/insight.d.ts b/insight/insight.d.ts new file mode 100644 index 0000000000..8b78dba989 --- /dev/null +++ b/insight/insight.d.ts @@ -0,0 +1,49 @@ +// Type definitions for insight 0.4.3 +// Project: https://github.com/yeoman/insight +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module insight { + interface IOptions { + trackingCode:string; + trackingProvider?:string; + packageName:string; + packageVersion?:string; + config?:IConfigstore; + } + + interface IConfigstore { + path:string; + all:any; + get(key:string):any; + set(key:string, val:any):void; + del(key:string):void; + } +} + +declare module "insight" { + import IOptions = insight.IOptions; + import IConfigstore = insight.IConfigstore; + + class Insight { + trackingCode:string; + trackingProvider:string; + packageName:string; + packageVersion:string; + os:string; + nodeVersion:string; + appVersion:string; + config:IConfigstore; + + optOut:boolean; + clientId:string; + + constructor(options:IOptions); + + track(...args:string[]):void; + + askPermission(msg?:string, cb?:Function):void; + } + + export = Insight; +}