File tree Expand file tree Collapse file tree 2 files changed +123
-0
lines changed Expand file tree Collapse file tree 2 files changed +123
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// <reference path="../node/node.d.ts" />
2
+ /// <reference path="piwik-tracker.d.ts" />
3
+
4
+ // Example code taken from https://www.npmjs.com/package/piwik-tracker
5
+
6
+ var PiwikTracker = require ( 'piwik-tracker' ) ;
7
+
8
+ // Initialize with your site ID and Piwik URL
9
+ var piwik = new PiwikTracker ( 1 , 'http://mywebsite.com/piwik.php' ) ;
10
+
11
+ // Optional: Respond to tracking errors
12
+ piwik . on ( 'error' , function ( err : Error ) {
13
+ console . log ( 'error tracking request: ' , err )
14
+ } )
15
+
16
+ // Track a request URL:
17
+ // Either as a simple string …
18
+ piwik . track ( 'http://example.com/track/this/url' ) ;
19
+
20
+ // … or provide further options:
21
+ piwik . track ( {
22
+ url : 'http://example.com/track/this/url' ,
23
+ action_name : 'This will be shown in your dashboard' ,
24
+ ua : 'Node.js v0.10.24' ,
25
+ cvar : JSON . stringify ( {
26
+ '1' : [ 'custom variable name' , 'custom variable value' ]
27
+ } )
28
+ } ) ;
Original file line number Diff line number Diff line change
1
+ // Type definitions for PiwikTracker v0.1.1
2
+ // Project: https://www.npmjs.com/package/piwik-tracker
3
+ // Definitions by: Guilherme Bernal <https://github.com/lbguilherme>
4
+ // Definitions: https://github.com/borisyankov/DefinitelyTyped
5
+
6
+ /// <reference path="../node/node.d.ts" />
7
+
8
+ declare module "piwik-tracker" {
9
+
10
+ import events = require( 'events' ) ;
11
+
12
+ export = PiwikTracker ;
13
+
14
+ // refer to http://developer.piwik.org/api-reference/tracking-api
15
+ interface PiwikTrackOptions {
16
+ // Required parameters
17
+ url : string ;
18
+
19
+ // Recommended parameters
20
+ action_name ? : string ;
21
+ _id ? : string ;
22
+ rand ? : string ;
23
+ apiv ? : number ;
24
+
25
+ // Optional User info
26
+ urlref ? : string ;
27
+ _cvar ? : string ;
28
+ _idvc ? : string ;
29
+ _viewts ? : string ;
30
+ _idts ? : string ;
31
+ _rcn ? : string ;
32
+ _rck ? : string ;
33
+ res ? : string ;
34
+ h ? : number ;
35
+ m ? : number ;
36
+ s ? : number ;
37
+ ua ? : string ;
38
+ lang ? : string ;
39
+ uid ? : string ;
40
+ cid ? : string ;
41
+ new_visit ? : number ;
42
+
43
+ // Optional Action info
44
+ cvar ? : string ;
45
+ link ? : string ;
46
+ download ? : string ;
47
+ search ? : string ;
48
+ search_cat ? : string ;
49
+ search_count ? : number ;
50
+ idgoal ? : number ;
51
+ revenue ? : number ;
52
+ gt_ms ? : number ;
53
+ cs ? : string ;
54
+
55
+ // Optional Event Tracking info
56
+ e_c ? : string ;
57
+ e_a ? : string ;
58
+ e_n ? : string ;
59
+ e_v ? : string ;
60
+
61
+ // Optional Content Tracking info
62
+ c_n ? : string ;
63
+ c_p ? : string ;
64
+ c_t ? : string ;
65
+ c_i ? : string ;
66
+
67
+ // Optional Ecommerce info
68
+ ec_id ? : string ;
69
+ ec_items ? : string ;
70
+ ec_st ? : number ;
71
+ ec_tx ? : number ;
72
+ ec_sh ? : number ;
73
+ ec_dt ? : number ;
74
+ _ects ? : number ;
75
+
76
+ // Other parameters (require authentication via token_auth)
77
+ token_auth ? : string ;
78
+ cip ? : string ;
79
+ cdt ? : string ;
80
+ country ? : string ;
81
+ region ? : string ;
82
+ city ? : string ;
83
+ lat ? : string ;
84
+ long ? : string ;
85
+
86
+ // Other parameters
87
+ send_image ? : number ;
88
+ }
89
+
90
+ class PiwikTracker extends events . EventEmitter {
91
+ constructor ( siteId : number , trackerUrl : string ) ;
92
+ track ( options : PiwikTrackOptions ) : void ;
93
+ }
94
+
95
+ }
You can’t perform that action at this time.
0 commit comments