@@ -32,9 +32,8 @@ export interface CoreOptions {
3232 context ?: CoreExtraContext
3333 anonymousId ?: string
3434 userId ?: string
35- traits ?: CoreUserTraits
35+ traits ?: Traits
3636 // ugh, this is ugly, but we allow literally any property to be passed to options (which get spread onto the event)
37- // we may want to remove this...
3837 [ key : string ] : any
3938}
4039
@@ -142,7 +141,7 @@ export interface CoreExtraContext {
142141 * but also associate information from a previous identify call.
143142 * You should fill this object the same way you would fill traits in an identify call.
144143 */
145- traits ?: CoreUserTraits
144+ traits ?: Traits
146145
147146 /**
148147 * Dictionary of information about the campaign that resulted in the API call, containing name, source, medium, term, content, and any other custom UTM parameter.
@@ -187,7 +186,7 @@ export interface CoreSegmentEvent {
187186
188187 properties ?: EventProperties
189188
190- traits ?: CoreTraits // Traits is only defined in 'identify' and 'group', even if it can be passed in other calls.
189+ traits ?: Traits // Traits is only defined in 'identify' and 'group', even if it can be passed in other calls.
191190
192191 integrations ?: Integrations
193192 context ?: CoreExtraContext
@@ -257,30 +256,30 @@ type PhoneNumber = string | number // TODO: the docs say this can only be a stri
257256 * This interface represents reserved traits that Segment has standardized.
258257 * @link https://segment.com/docs/connections/spec/group/#traits
259258 */
260- type BaseCoreGroupTraits = DeepNullable < {
259+ type BaseGroupTraits = DeepNullable < {
261260 /**
262261 * Street address of a group.
263262 */
264- address ?: BaseCoreUserTraits [ 'address' ]
263+ address ?: BaseUserTraits [ 'address' ]
265264
266265 /**
267266 * URL to an avatar image for the group.
268267 */
269- avatar ?: BaseCoreUserTraits [ 'avatar' ]
268+ avatar ?: BaseUserTraits [ 'avatar' ]
270269
271270 /**
272271 * Date the group's account was first created. Segment recommends ISO-8601 date strings.
273272 */
274- createdAt ?: BaseCoreUserTraits [ 'createdAt' ]
273+ createdAt ?: BaseUserTraits [ 'createdAt' ]
275274
276275 /**
277276 * Description of a group
278277 */
279- description ?: BaseCoreUserTraits [ 'description' ]
278+ description ?: BaseUserTraits [ 'description' ]
280279 /**
281280 * Email address of group.
282281 */
283- email ?: BaseCoreUserTraits [ 'email' ]
282+ email ?: BaseUserTraits [ 'email' ]
284283 /**
285284 * Number of employees of a group, typically used for companies.
286285 */
@@ -289,40 +288,40 @@ type BaseCoreGroupTraits = DeepNullable<{
289288 /**
290289 * Unique ID in your database for a group.
291290 */
292- id ?: BaseCoreUserTraits [ 'id' ]
291+ id ?: BaseUserTraits [ 'id' ]
293292
294293 /**
295294 * Industry a group is part of.
296295 */
297- industry ?: BaseCoreUserTraits [ 'industry' ]
296+ industry ?: BaseUserTraits [ 'industry' ]
298297
299298 /**
300299 * Name of a group.
301300 */
302- name ?: BaseCoreUserTraits [ 'name' ]
301+ name ?: BaseUserTraits [ 'name' ]
303302
304303 /**
305304 * Phone number of a group
306305 */
307- phone ?: BaseCoreUserTraits [ 'phone' ]
306+ phone ?: BaseUserTraits [ 'phone' ]
308307
309308 /**
310309 * Website of a group.
311310 */
312- website ?: BaseCoreUserTraits [ 'website' ]
311+ website ?: BaseUserTraits [ 'website' ]
313312
314313 /**
315314 * Plan that a group is in.
316315 */
317- plan ?: BaseCoreUserTraits [ 'plan' ]
316+ plan ?: BaseUserTraits [ 'plan' ]
318317} >
319318
320319/**
321320 * Traits are pieces of information you know about a user.
322321 * This interface represents reserved traits that Segment has standardized.
323322 * @link https://segment.com/docs/connections/spec/identify/#traits
324323 */
325- type BaseCoreUserTraits = DeepNullable < {
324+ type BaseUserTraits = DeepNullable < {
326325 /**
327326 * Unique ID in your database for a user
328327 */
@@ -400,9 +399,9 @@ type BaseCoreUserTraits = DeepNullable<{
400399 company ?: {
401400 name ?: string
402401 id ?: DbId
403- industry ?: BaseCoreUserTraits [ 'industry' ]
402+ industry ?: BaseUserTraits [ 'industry' ]
404403 employee_count ?: number
405- plan ?: BaseCoreUserTraits [ 'plan' ]
404+ plan ?: BaseUserTraits [ 'plan' ]
406405 }
407406
408407 /**
@@ -438,7 +437,7 @@ type BaseCoreUserTraits = DeepNullable<{
438437 * This interface represents reserved traits that Segment has standardized.
439438 * @link https://segment.com/docs/connections/spec/group/#traits
440439 */
441- export type CoreGroupTraits = BaseCoreGroupTraits & {
440+ export type GroupTraits = BaseGroupTraits & {
442441 [ customTrait : string ] : any
443442}
444443
@@ -447,8 +446,11 @@ export type CoreGroupTraits = BaseCoreGroupTraits & {
447446 * This interface represents reserved traits that Segment has standardized.
448447 * @link https://segment.com/docs/connections/spec/identify/#traits
449448 */
450- export type CoreUserTraits = BaseCoreUserTraits & {
449+ export type UserTraits = BaseUserTraits & {
451450 [ customTrait : string ] : any
452451}
453452
454- export type CoreTraits = CoreUserTraits & CoreGroupTraits
453+ /**
454+ * Traits are pieces of information you know about a user or group.
455+ */
456+ export type Traits = UserTraits | GroupTraits
0 commit comments