@@ -24,87 +24,162 @@ import { showToolbarToggle } from "./toolbar";
24
24
const isMobile = typeof window !== "undefined" && window . innerWidth < 768 ;
25
25
const isNode = typeof document === "undefined" ; // deno supports "window" but not "document" according to https://remix.run/docs/en/main/guides/gotchas
26
26
27
+ /**
28
+ * (Internal) User context.
29
+ *
30
+ * @internal
31
+ */
27
32
export type User = {
28
33
/**
29
- * Identifier of the user
34
+ * Identifier of the user.
30
35
*/
31
36
userId : string ;
32
37
33
38
/**
34
- * User attributes
39
+ * User attributes.
35
40
*/
36
41
attributes ?: {
42
+ /**
43
+ * Name of the user.
44
+ */
37
45
name ?: string ;
46
+
47
+ /**
48
+ * Email of the user.
49
+ */
50
+ email ?: string ;
51
+
52
+ /**
53
+ * Avatar URL of the user.
54
+ */
55
+ avatar ?: string ;
56
+
57
+ /**
58
+ * Custom attributes of the user.
59
+ */
38
60
[ key : string ] : any ;
39
61
} ;
40
62
63
+ /**
64
+ * Custom context of the user.
65
+ */
41
66
context ?: PayloadContext ;
42
67
} ;
43
68
69
+ /**
70
+ * (Internal) Company context.
71
+ *
72
+ * @internal
73
+ */
44
74
export type Company = {
45
75
/**
46
- * User identifier
76
+ * User identifier.
47
77
*/
48
78
userId : string ;
49
79
50
80
/**
51
- * Company identifier
81
+ * Company identifier.
52
82
*/
53
83
companyId : string ;
54
84
55
85
/**
56
- * Company attributes
86
+ * Company attributes.
57
87
*/
58
88
attributes ?: {
89
+ /**
90
+ * Name of the company.
91
+ */
59
92
name ?: string ;
93
+
94
+ /**
95
+ * Custom attributes of the company.
96
+ */
60
97
[ key : string ] : any ;
61
98
} ;
62
99
63
100
context ?: PayloadContext ;
64
101
} ;
65
102
103
+ /**
104
+ * Tracked event.
105
+ */
66
106
export type TrackedEvent = {
67
107
/**
68
- * Event name
108
+ * Event name.
69
109
*/
70
110
event : string ;
71
111
72
112
/**
73
- * User identifier
113
+ * User identifier.
74
114
*/
75
115
userId : string ;
76
116
77
117
/**
78
- * Company identifier
118
+ * Company identifier.
79
119
*/
80
120
companyId ?: string ;
81
121
82
122
/**
83
- * Event attributes
123
+ * Event attributes.
84
124
*/
85
125
attributes ?: Record < string , any > ;
86
126
127
+ /**
128
+ * Custom context of the event.
129
+ */
87
130
context ?: PayloadContext ;
88
131
} ;
89
132
133
+ /**
134
+ * (Internal) Custom context of the event.
135
+ *
136
+ * @internal
137
+ */
90
138
export type PayloadContext = {
139
+ /**
140
+ * Whether the company and user associated with the event are active.
141
+ */
91
142
active ?: boolean ;
92
143
} ;
93
144
145
+ /**
146
+ * BucketClient configuration.
147
+ */
94
148
interface Config {
149
+ /**
150
+ * Base URL of Bucket servers.
151
+ */
95
152
apiBaseUrl : string ;
153
+
154
+ /**
155
+ * Base URL of the Bucket web app.
156
+ */
96
157
appBaseUrl : string ;
158
+
159
+ /**
160
+ * Base URL of Bucket servers for SSE connections used by AutoFeedback.
161
+ */
97
162
sseBaseUrl : string ;
163
+
164
+ /**
165
+ * Whether to enable tracking.
166
+ */
98
167
enableTracking : boolean ;
99
168
}
100
169
170
+ /**
171
+ * Toolbar options.
172
+ */
101
173
export type ToolbarOptions =
102
174
| boolean
103
175
| {
104
176
show ?: boolean ;
105
177
position ?: ToolbarPosition ;
106
178
} ;
107
179
180
+ /**
181
+ * Feature definitions.
182
+ */
108
183
export type FeatureDefinitions = Readonly < Array < string > > ;
109
184
110
185
/**
@@ -117,12 +192,14 @@ export interface InitOptions {
117
192
publishableKey : string ;
118
193
119
194
/**
120
- * User related context. If you provide `id` Bucket will enrich the evaluation context with user attributes on Bucket servers.
195
+ * User related context. If you provide `id` Bucket will enrich the evaluation context with
196
+ * user attributes on Bucket servers.
121
197
*/
122
198
user ?: UserContext ;
123
199
124
200
/**
125
- * Company related context. If you provide `id` Bucket will enrich the evaluation context with company attributes on Bucket servers.
201
+ * Company related context. If you provide `id` Bucket will enrich the evaluation context with
202
+ * company attributes on Bucket servers.
126
203
*/
127
204
company ?: CompanyContext ;
128
205
@@ -182,13 +259,18 @@ export interface InitOptions {
182
259
* Version of the SDK
183
260
*/
184
261
sdkVersion ?: string ;
262
+
263
+ /**
264
+ * Whether to enable tracking. Defaults to `true`.
265
+ */
185
266
enableTracking ?: boolean ;
186
267
187
268
/**
188
269
* Toolbar configuration (alpha)
189
270
* @ignore
190
271
*/
191
272
toolbar ?: ToolbarOptions ;
273
+
192
274
/**
193
275
* Local-first definition of features (alpha)
194
276
* @ignore
@@ -259,7 +341,6 @@ function shouldShowToolbar(opts: InitOptions) {
259
341
260
342
/**
261
343
* BucketClient lets you interact with the Bucket API.
262
- *
263
344
*/
264
345
export class BucketClient {
265
346
private readonly publishableKey : string ;
0 commit comments