11import { CoreContext } from '../context'
22import { ID } from '../user'
3+ import { DeepNullable } from '../utils/ts-helpers'
34
45export type Callback < Ctx extends CoreContext = CoreContext > = (
56 ctx : Ctx
@@ -46,47 +47,47 @@ export interface CoreExtraContext {
4647 /**
4748 * This is usually used to flag an .identify() call to just update the trait, rather than "last seen".
4849 */
49- active ?: boolean
50+ active ?: boolean | null
5051
5152 /**
5253 * Current user's IP address.
5354 */
54- ip ?: string
55+ ip ?: string | null
5556
5657 /**
5758 * Locale string for the current user, for example en-US.
5859 * @example en-US
5960 */
60- locale ?: string
61+ locale ?: string | null
6162 /**
6263 * Dictionary of information about the user’s current location.
6364 */
6465 location ?: {
6566 /**
6667 * @example San Francisco
6768 */
68- city ?: string
69+ city ?: string | null
6970 /**
7071 * @example United States
7172 */
72- country ?: string
73+ country ?: string | null
7374 /**
7475 * @example 40.2964197
7576 */
76- latitude ?: string
77+ latitude ?: string | null
7778 /**
7879 * @example -76.9411617
7980 */
80- longitude ?: string
81+ longitude ?: string | null
8182 /**
8283 * @example CA
8384 */
84- region ?: string
85+ region ?: string | null
8586 /**
8687 * @example 100
8788 */
88- speed ?: number
89- }
89+ speed ?: number | null
90+ } | null
9091
9192 /**
9293 * Dictionary of information about the current web page.
@@ -95,29 +96,29 @@ export interface CoreExtraContext {
9596 /**
9697 * @example /academy/
9798 */
98- path ?: string
99+ path ?: string | null
99100 /**
100101 * @example https://www.foo.com/
101102 */
102- referrer ?: string
103+ referrer ?: string | null
103104 /**
104105 * @example projectId=123
105106 */
106- search ?: string
107+ search ?: string | null
107108 /**
108109 * @example Analytics Academy
109110 */
110- title ?: string
111+ title ?: string | null
111112 /**
112113 * @example https://segment.com/academy/
113114 */
114- url ?: string
115- }
115+ url ?: string | null
116+ } | null
116117
117118 /**
118119 * User agent of the device making the request.
119120 */
120- userAgent ?: string
121+ userAgent ?: string | null
121122
122123 /**
123124 * Information about the current library.
@@ -135,14 +136,14 @@ export interface CoreExtraContext {
135136 * @example "1.43.1"
136137 */
137138 version : string
138- }
139+ } | null
139140
140141 /**
141142 * This is useful in cases where you need to track an event,
142143 * but also associate information from a previous identify call.
143144 * You should fill this object the same way you would fill traits in an identify call.
144145 */
145- traits ?: CoreAnalyticsTraits
146+ traits ?: CoreAnalyticsTraits | null
146147
147148 /**
148149 * Dictionary of information about the campaign that resulted in the API call, containing name, source, medium, term, content, and any other custom UTM parameter.
@@ -153,26 +154,26 @@ export interface CoreExtraContext {
153154 source : string
154155 medium : string
155156 content : string
156- }
157+ } | null
157158
158159 /**
159160 * Dictionary of information about the way the user was referred to the website or app.
160161 */
161162 referrer ?: {
162- type ?: string
163- name ?: string
164- url ?: string
165- link ?: string
163+ type ?: string | null
164+ name ?: string | null
165+ url ?: string | null
166+ link ?: string | null
166167
167- id ?: string // undocumented
168- btid ?: string // undocumented?
169- urid ?: string // undocumented?
170- }
168+ id ?: string | null // undocumented
169+ btid ?: string | null // undocumented?
170+ urid ?: string | null // undocumented?
171+ } | null
171172
172173 amp ?: {
173174 // undocumented?
174175 id : string
175- }
176+ } | null
176177
177178 [ key : string ] : any
178179}
@@ -255,11 +256,11 @@ export interface PlanEvent {
255256 * @link https://segment.com/docs/connections/spec/identify/#traits
256257 * @link https://segment.com/docs/connections/spec/group/#traits
257258 */
258- export interface CoreAnalyticsTraits {
259+ export type CoreAnalyticsTraits = DeepNullable < {
259260 /**
260261 * Unique ID in your database for a user/group.
261262 */
262- id ?: string
263+ id ?: string | number
263264
264265 /**
265266 * Industry a user works in, or a group is part of.
@@ -372,4 +373,4 @@ export interface CoreAnalyticsTraits {
372373 gender ?: string
373374
374375 [ customTrait : string ] : any
375- }
376+ } >
0 commit comments