From 32d8918a4e0d93753f4dc6ee469c1a7191cde4b7 Mon Sep 17 00:00:00 2001 From: Eirik Hoem Date: Wed, 8 Apr 2015 08:52:19 +0200 Subject: [PATCH] Added support for Calq --- calq/calq-test.ts | 28 ++++++++++++++++++++++++++++ calq/calq.d.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 calq/calq-test.ts create mode 100644 calq/calq.d.ts diff --git a/calq/calq-test.ts b/calq/calq-test.ts new file mode 100644 index 000000000..6f8019261 --- /dev/null +++ b/calq/calq-test.ts @@ -0,0 +1,28 @@ +/// +function calq_base() +{ + calq.init("bfff14a4e0225789be3d9d22c4bb42a1"); + + calq.init("bfff14a4e0225789be3d9d22c4bb42a1", { your: "config" }); + + calq.action.track("Product Review", {"Rating": 9.0}); + + calq.action.trackSale("Product Sale", { "Product Id": 149, "Product Name": "Dinosaur T-Shirt XL" }, "USD",10); + + calq.action.trackHTMLLink('Link', { 'Target': 'Calq'}); + + calq.action.trackPageView(); + + calq.action.trackPageView("Custom Action"); + + calq.action.setGlobalProperty("Referral Source", "Google Campaign"); +} + +function calq_people() +{ + calq.user.identify("1001"); + + calq.user.clear(); + + calq.user.profile( { "Company": "MegaCorp", "$email": "super_customer1@notarealemail.com" }); +} diff --git a/calq/calq.d.ts b/calq/calq.d.ts new file mode 100644 index 000000000..c574df58f --- /dev/null +++ b/calq/calq.d.ts @@ -0,0 +1,34 @@ +// Type definitions for calq +// Project: https://calq.io/docs/client/javascript/reference +// Definitions by: Eirik Hoem +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Calq +{ + action:Calq.Action; + user:Calq.User; + + init(writeKey:string, options?:{[index:string]:any}):void; +} + +declare module Calq +{ + interface Action + { + track(action:string, params?:{[index:string]:any}):void; + trackSale(action:string, params:{[index:string]:any}, currency:string, amount:number):void; + trackHTMLLink(action:string, params?:{[index:string]:any}):void; + trackPageView(action?:string):void; + setGlobalProperty(name:string,value:any):void; + } + + interface User + { + identify(userId:string):void; + clear():void; + profile(params:{[index:string]:any}):void; + + } +} + +declare var calq:Calq; \ No newline at end of file