forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analytics-node.d.ts
83 lines (73 loc) · 2.24 KB
/
analytics-node.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Type definitions for Segment's analytics.js for Node.js
// Project: https://segment.com/docs/libraries/node/
// Definitions by: Andrew Fong <https://github.com/fongandrew>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module AnalyticsNode {
interface Integrations {
[index: string]: boolean;
}
export class Analytics {
constructor(writeKey: string, opts?: {
flushAt?: number,
flushAfter?: number
});
/* The identify method lets you tie a user to their actions and record
traits about them. */
identify(message: {
userId: string | number;
traits?: Object;
timestamp?: Date;
context?: Object;
integrations?: Integrations;
}): Analytics;
/* The track method lets you record the actions your users perform. */
track(message: {
userId: string | number;
event: string;
properties?: Object;
timestamp?: Date;
context?: Object;
integrations?: Integrations;
}): Analytics;
/* The page method lets you record page views on your website, along with
optional extra information about the page being viewed. */
page(message: {
userId: string | number;
category?: string;
name?: string;
properties?: Object;
timestamp?: Date;
context?: Object;
integrations?: Integrations;
}): Analytics;
/* alias is how you associate one identity with another. */
alias(message: {
previousId: string | number;
userId: string | number;
integrations?: Integrations;
}): Analytics;
/* Group calls can be used to associate individual users with shared
accounts or companies. */
group(message: {
userId: string | number;
groupId: string | number;
traits?: Object;
context?: Object;
timestamp?: Date;
anonymous_id?: string | number;
integrations?: Integrations;
}): Analytics;
/* Flush batched calls to make sure nothing is left in the queue */
flush(fn?: (err: Error, batch: {
batch: Array<{
type: string;
}>;
messageId: string;
sentAt: Date;
timestamp: Date;
}) => void): Analytics;
}
}
declare module "analytics-node" {
export = AnalyticsNode.Analytics;
}