3
3
// Definitions by: Andrew Fong <https://github.com/fongandrew>
4
4
// Thomas Thiebaud <https://github.com/thomasthiebaud>
5
5
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6
+ // TypeScript Version: 2.1
6
7
7
8
export = AnalyticsNode . Analytics ;
8
9
9
10
declare namespace AnalyticsNode {
10
- interface Message {
11
+ type Identity =
12
+ | { userId : string | number }
13
+ | { userId ?: string | number ; anonymousId : string | number } ;
14
+
15
+ type Message = Identity & {
11
16
type : string ;
12
17
context : {
13
18
library : {
@@ -22,9 +27,7 @@ declare namespace AnalyticsNode {
22
27
} ;
23
28
timestamp ?: Date ;
24
29
messageId ?: string ;
25
- anonymousId ?: string | number ;
26
- userId ?: string | number ;
27
- }
30
+ } ;
28
31
29
32
interface Data {
30
33
batch : Message [ ] ;
@@ -49,19 +52,15 @@ declare namespace AnalyticsNode {
49
52
50
53
/* The identify method lets you tie a user to their actions and record
51
54
traits about them. */
52
- identify ( message : {
53
- userId ?: string | number ;
54
- anonymousId ?: string | number ;
55
+ identify ( message : Identity & {
55
56
traits ?: any ;
56
57
timestamp ?: Date ;
57
58
context ?: any ;
58
59
integrations ?: Integrations ;
59
60
} , callback ?: ( err : Error , data : Data ) => void ) : Analytics ;
60
61
61
62
/* The track method lets you record the actions your users perform. */
62
- track ( message : {
63
- userId ?: string | number ;
64
- anonymousId ?: string | number ;
63
+ track ( message : Identity & {
65
64
event : string ;
66
65
properties ?: any ;
67
66
timestamp ?: Date ;
@@ -71,9 +70,7 @@ declare namespace AnalyticsNode {
71
70
72
71
/* The page method lets you record page views on your website, along with
73
72
optional extra information about the page being viewed. */
74
- page ( message : {
75
- userId ?: string | number ;
76
- anonymousId ?: string | number ;
73
+ page ( message : Identity & {
77
74
category ?: string ;
78
75
name ?: string ;
79
76
properties ?: any ;
@@ -83,18 +80,14 @@ declare namespace AnalyticsNode {
83
80
} , callback ?: ( err : Error , data : Data ) => void ) : Analytics ;
84
81
85
82
/* alias is how you associate one identity with another. */
86
- alias ( message : {
83
+ alias ( message : Identity & {
87
84
previousId : string | number ;
88
- userId ?: string | number ;
89
- anonymousId ?: string | number ;
90
85
integrations ?: Integrations ;
91
86
} , callback ?: ( err : Error , data : Data ) => void ) : Analytics ;
92
87
93
88
/* Group calls can be used to associate individual users with shared
94
89
accounts or companies. */
95
- group ( message : {
96
- userId ?: string | number ;
97
- anonymousId ?: string | number ;
90
+ group ( message : Identity & {
98
91
groupId : string | number ;
99
92
traits ?: any ;
100
93
context ?: any ;
0 commit comments