@@ -22,6 +22,26 @@ export const specialProperties = [
22
22
"unsubscribed" ,
23
23
] ;
24
24
25
+ const invalidDistinctIds = new Set ( [
26
+ "00000000-0000-0000-0000-000000000000" ,
27
+ "anon" ,
28
+ "anonymous" ,
29
+ "nil" ,
30
+ "none" ,
31
+ "null" ,
32
+ "n/a" ,
33
+ "na" ,
34
+ "undefined" ,
35
+ "unknown" ,
36
+ "<nil>" ,
37
+ "0" ,
38
+ "-1" ,
39
+ "true" ,
40
+ "false" ,
41
+ "[]" ,
42
+ "{}" ,
43
+ ] ) ;
44
+
25
45
const CLICK_IDS = [ "dclid" , "fbclid" , "gclid" , "ko_click_id" , "li_fat_id" , "msclkid" , "ttclid" , "twclid" , "wbraid" ] ;
26
46
27
47
export type MixpanelRequest = {
@@ -204,6 +224,14 @@ function trackEvent(
204
224
} ,
205
225
} ;
206
226
if ( ctx [ "connectionOptions" ] ?. mode === "batch" && bulkerBase ) {
227
+ let tableName = "import" ;
228
+ if ( ctx [ "connectionOptions" ] ?. multithreading ) {
229
+ const threadsCount = ctx [ "connectionOptions" ] ?. threadsCount || 2 ;
230
+ const thread = Math . floor ( Math . random ( ) * threadsCount ) ;
231
+ if ( thread > 0 ) {
232
+ tableName = `import_${ thread + 1 } ` ;
233
+ }
234
+ }
207
235
const metricsMeta : Omit < MetricsMeta , "messageId" > = {
208
236
workspaceId : ctx . workspace . id ,
209
237
streamId : ctx . source . id ,
@@ -212,7 +240,7 @@ function trackEvent(
212
240
functionId : "builtin.destination.bulker" ,
213
241
} ;
214
242
return {
215
- url : `${ bulkerBase } /post/${ ctx . connection . id } ?tableName=import &modeOverride=batch` ,
243
+ url : `${ bulkerBase } /post/${ ctx . connection . id } ?tableName=${ tableName } &modeOverride=batch` ,
216
244
eventType,
217
245
insertId,
218
246
headers : {
@@ -506,6 +534,9 @@ const MixpanelDestination: JitsuFunction<AnalyticsServerEvent, MixpanelCredentia
506
534
return ;
507
535
}
508
536
const distinctId = getDistinctId ( ctx , event , deviceId ) ;
537
+ if ( invalidDistinctIds . has ( distinctId ) ) {
538
+ throw new Error ( `Invalid distinctId '${ distinctId } '. Skipping event: ${ JSON . stringify ( event ) } ` ) ;
539
+ }
509
540
// no userId or email
510
541
const isAnonymous = event . anonymousId && distinctId . endsWith ( event . anonymousId ) ;
511
542
if ( isAnonymous && ! ctx . props . enableAnonymousUserProfiles ) {
0 commit comments