saasco-sdk 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/index.cjs.js +1 -416
- package/index.esm.js +2 -382
- package/package.json +1 -1
- package/src/index.d.ts +1 -3
- package/src/lib/getBrowserContext.d.ts +1 -1
- package/src/lib/tracking/types.d.ts +0 -2762
- package/src/lib/coerceReservedProperties.d.ts +0 -2
- package/src/lib/types.d.ts +0 -1971
package/README.md
CHANGED
|
@@ -292,7 +292,7 @@ Reserved events are common events that happen during the lifecycle of a user, wi
|
|
|
292
292
|
- [Signed In](#signed-in)
|
|
293
293
|
- [Signed Out](#signed-out)
|
|
294
294
|
- [Trial Started](#trial-started)
|
|
295
|
-
- [Trial
|
|
295
|
+
- [Trial Ended](#trial-ended)
|
|
296
296
|
- [Payment Completed](#payment-completed)
|
|
297
297
|
- [Subscription Started](#subscription-started)
|
|
298
298
|
- [Subscription Cancelled](#subscription-cancelled)
|
|
@@ -355,9 +355,9 @@ Example:
|
|
|
355
355
|
saasco.track('Trial Started', { duration: 14, type: 'optOut' });
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
#### Trial
|
|
358
|
+
#### Trial Ended
|
|
359
359
|
|
|
360
|
-
Event triggered when a
|
|
360
|
+
Event triggered when a users trial ends.
|
|
361
361
|
| Property | Description |
|
|
362
362
|
|-------------------|---------------------------------------------------------------------|
|
|
363
363
|
| `daysLeftInTrial`| If a user manual upgrades before the end of the trial you can record this here|
|
|
@@ -365,10 +365,10 @@ Event triggered when a user successfully completes a trial.
|
|
|
365
365
|
Example:
|
|
366
366
|
|
|
367
367
|
```jsx
|
|
368
|
-
saasco.track('Trial
|
|
368
|
+
saasco.track('Trial Ended', { daysLeftInTrial: 4 });
|
|
369
369
|
```
|
|
370
370
|
|
|
371
|
-
#### Payment
|
|
371
|
+
#### Payment Ended
|
|
372
372
|
|
|
373
373
|
Event triggered when a payment is completed.
|
|
374
374
|
This is may be called on the server side after a confirmation webhook.
|
package/index.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var uuid = require('@lukeed/uuid');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
|
|
9
|
-
var version = "0.1.
|
|
9
|
+
var version = "0.1.21";
|
|
10
10
|
|
|
11
11
|
const timezones = {
|
|
12
12
|
'Asia/Barnaul': 'RU',
|
|
@@ -815,107 +815,6 @@ class Saasco {
|
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
function coerceReservedProperties(properties) {
|
|
819
|
-
const coerce = [{
|
|
820
|
-
key: 'age',
|
|
821
|
-
coerceFrom: ['age', 'age_value', 'ageValue', 'user_age', 'userAge', 'user_age_value', 'userAgeValue', 'age_of_user', 'ageOfUser', 'age_in_years', 'ageInYears', 'years_old', 'yearsOld', 'age_years', 'ageYears'],
|
|
822
|
-
schema: zod.z.coerce.number().optional()
|
|
823
|
-
}, {
|
|
824
|
-
key: 'avatar',
|
|
825
|
-
coerceFrom: ['avatar', 'user_avatar', 'userAvatar', 'avatar_url', 'avatarUrl', 'profile_picture', 'profilePicture', 'picture', 'user_picture', 'userPicture', 'profile_pic', 'profilePic', 'pic', 'user_pic', 'userPic', 'image', 'user_image', 'userImage', 'profile_image', 'profileImage', 'profile_image_url', 'profileImageUrl', 'profile_pic_url', 'profilePicUrl', 'pic_url', 'picUrl', 'image_url', 'imageUrl', 'user_image_url', 'userImageUrl', 'user_pic_url', 'userPicUrl', 'profile_pic_url', 'profilePicUrl', 'pic_url', 'picUrl', 'image_url', 'imageUrl', 'user_image_url', 'userImageUrl', 'user_pic_url', 'userPicUrl'],
|
|
826
|
-
schema: zod.z.coerce.string().url().optional()
|
|
827
|
-
}, {
|
|
828
|
-
key: 'birthday',
|
|
829
|
-
coerceFrom: ['birthday', 'birth_date', 'birthDate', 'date_of_birth', 'dateOfBirth', 'dob', 'Dob', 'birth_day', 'birthDay']
|
|
830
|
-
}, {
|
|
831
|
-
key: 'createdAt',
|
|
832
|
-
coerceFrom: ['createdAt', 'created_at', 'created', 'createdDate', 'created_date', 'dateCreated', 'date_created', 'date_created_at', 'dateCreatedAt', 'date_created_at', 'dateCreated', 'date_created'],
|
|
833
|
-
schema: zod.z.coerce.date().optional()
|
|
834
|
-
}, {
|
|
835
|
-
key: 'description',
|
|
836
|
-
coerceFrom: ['description', 'bio', 'about', 'about_me', 'aboutMe', 'user_description', 'userDescription', 'profile_description', 'profileDescription']
|
|
837
|
-
}, {
|
|
838
|
-
key: 'email',
|
|
839
|
-
coerceFrom: ['email', 'user_email', 'userEmail', 'email_address', 'emailAddress', 'e_mail', 'E_Mail', 'mail', 'Mail', 'contact_email', 'contactEmail', 'primary_email', 'primaryEmail'],
|
|
840
|
-
schema: zod.z.coerce.string().email().optional()
|
|
841
|
-
}, {
|
|
842
|
-
key: 'firstName',
|
|
843
|
-
coerceFrom: ['first_name', 'firstName', 'firstname', 'given_name', 'givenName', 'user_first_name', 'userFirstName', 'name_first', 'nameFirst', 'f_name', 'fName']
|
|
844
|
-
}, {
|
|
845
|
-
key: 'gender',
|
|
846
|
-
coerceFrom: ['gender', 'user_gender', 'userGender', 'sex', 'user_sex', 'userSex']
|
|
847
|
-
}, {
|
|
848
|
-
key: 'lastName',
|
|
849
|
-
coerceFrom: ['last_name', 'lastName', 'lastname', 'surname', 'user_last_name', 'userLastName', 'name_last', 'nameLast', 'l_name', 'lName']
|
|
850
|
-
}, {
|
|
851
|
-
key: 'name',
|
|
852
|
-
coerceFrom: ['name', 'full_name', 'fullName', 'user_name', 'userName', 'complete_name', 'completeName']
|
|
853
|
-
}, {
|
|
854
|
-
key: 'phone',
|
|
855
|
-
coerceFrom: ['phone', 'phone_number', 'phoneNumber', 'mobile', 'mobile_number', 'mobileNumber', 'contact_number', 'contactNumber', 'tel', 'telephone']
|
|
856
|
-
}, {
|
|
857
|
-
key: 'title',
|
|
858
|
-
coerceFrom: ['title', 'user_title', 'userTitle', 'position', 'job_title', 'jobTitle']
|
|
859
|
-
}, {
|
|
860
|
-
key: 'username',
|
|
861
|
-
coerceFrom: ['username', 'user_name', 'userName', 'user_login', 'userLogin', 'account_name', 'accountName', 'screen_name', 'screenName', 'handle']
|
|
862
|
-
}, {
|
|
863
|
-
key: 'website',
|
|
864
|
-
coerceFrom: ['website', 'web_site', 'site', 'web', 'personal_website', 'personalWebsite', 'company_website', 'companyWebsite'],
|
|
865
|
-
schema: zod.z.coerce.string().url().optional()
|
|
866
|
-
}, {
|
|
867
|
-
key: 'displayName',
|
|
868
|
-
coerceFrom: ['display_name', 'displayName', 'user_display_name', 'userDisplayName', 'full_name', 'fullName', 'user_full_name', 'userFullName', 'complete_name', 'completeName', 'user_complete_name', 'userCompleteName', 'name', 'username']
|
|
869
|
-
}, {
|
|
870
|
-
key: '$stripeCustomerId',
|
|
871
|
-
coerceFrom: ['stripe_customer_id', 'stripeCustomerId', 'stripe_customer_id', 'stripeCustomerId', 'stripe_customer_id', 'stripeCustomerId', 'stripe_customer_id', 'stripeCustomerId', 'stripe_customer_id', 'stripeCustomerId']
|
|
872
|
-
}];
|
|
873
|
-
return coerce.reduce((acc, {
|
|
874
|
-
key,
|
|
875
|
-
coerceFrom,
|
|
876
|
-
schema
|
|
877
|
-
}) => {
|
|
878
|
-
const coercedValue = coerceValue(properties, coerceFrom, schema);
|
|
879
|
-
if (coercedValue) acc[key] = coercedValue;
|
|
880
|
-
if (!coercedValue && key === 'displayName') {
|
|
881
|
-
let displayName = '';
|
|
882
|
-
if (acc['firstName']) {
|
|
883
|
-
displayName = `${acc['firstName'] || ''} ${acc['lastName'] || ''}`.trim();
|
|
884
|
-
} else if (acc['username'] && typeof acc['username'] === 'string') {
|
|
885
|
-
displayName = acc['username'];
|
|
886
|
-
} else if (acc['name'] && typeof acc['name'] === 'string') {
|
|
887
|
-
displayName = acc['name'];
|
|
888
|
-
}
|
|
889
|
-
if (displayName) acc[key] = displayName;
|
|
890
|
-
}
|
|
891
|
-
return acc;
|
|
892
|
-
}, properties);
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* Coerces the first non-null value from the properties object
|
|
896
|
-
* @param properties
|
|
897
|
-
* @param keys Provided in priority order, the first to match will return
|
|
898
|
-
* @returns
|
|
899
|
-
*/
|
|
900
|
-
function coerceValue(properties, keys, schema) {
|
|
901
|
-
let coercedValue = null;
|
|
902
|
-
for (const key of keys) {
|
|
903
|
-
if (properties[key] !== undefined) {
|
|
904
|
-
if (!schema) {
|
|
905
|
-
coercedValue = properties[key];
|
|
906
|
-
break;
|
|
907
|
-
} else {
|
|
908
|
-
const result = schema.safeParse(properties[key]);
|
|
909
|
-
if (result.success) {
|
|
910
|
-
coercedValue = properties[key];
|
|
911
|
-
break;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
return coercedValue;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
818
|
const browserContextSchema = zod.z.object({
|
|
920
819
|
$locale: zod.z.string(),
|
|
921
820
|
$location: zod.z.string(),
|
|
@@ -928,322 +827,8 @@ const browserContextSchema = zod.z.object({
|
|
|
928
827
|
$title: zod.z.string(),
|
|
929
828
|
$userAgent: zod.z.string()
|
|
930
829
|
});
|
|
931
|
-
const serverContextSchema = zod.z.object({
|
|
932
|
-
$city: zod.z.string().optional(),
|
|
933
|
-
$country: zod.z.string().optional(),
|
|
934
|
-
$continent: zod.z.string().optional(),
|
|
935
|
-
$latitude: zod.z.number().optional(),
|
|
936
|
-
$longitude: zod.z.number().optional(),
|
|
937
|
-
$timezone: zod.z.string().optional(),
|
|
938
|
-
$userAgent: zod.z.string().optional(),
|
|
939
|
-
$referrer: zod.z.string().optional(),
|
|
940
|
-
$ip: zod.z.string().optional(),
|
|
941
|
-
$processedAt: zod.z.string().datetime().optional(),
|
|
942
|
-
$identityHash: zod.z.string().optional()
|
|
943
|
-
});
|
|
944
|
-
const trackedEventTypesSchema = zod.z.enum(['SHORTLINK_REDIRECT']);
|
|
945
|
-
const trackedEventSchema = zod.z.object({
|
|
946
|
-
id: zod.z.string().uuid(),
|
|
947
|
-
timestamp: zod.z.string().datetime(),
|
|
948
|
-
projectId: zod.z.string(),
|
|
949
|
-
version: zod.z.string(),
|
|
950
|
-
type: trackedEventTypesSchema,
|
|
951
|
-
payload: zod.z.object({
|
|
952
|
-
browserContext: browserContextSchema.optional(),
|
|
953
|
-
serverContext: serverContextSchema.optional(),
|
|
954
|
-
properties: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
955
|
-
})
|
|
956
|
-
});
|
|
957
|
-
/**
|
|
958
|
-
* Creates a zod for tracking any type of event.
|
|
959
|
-
* Includes the base tracking schema and extends with any new schema
|
|
960
|
-
* @param type
|
|
961
|
-
* @param payloadSchema
|
|
962
|
-
* @returns
|
|
963
|
-
*/
|
|
964
|
-
function createTrackedEventTypeSchema(type, payloadSchema) {
|
|
965
|
-
const typeSchema = zod.z.literal(type);
|
|
966
|
-
return trackedEventSchema.extend({
|
|
967
|
-
type: typeSchema,
|
|
968
|
-
payload: zod.z.object(Object.assign(Object.assign({}, trackedEventSchema.shape.payload.shape), {
|
|
969
|
-
properties: payloadSchema
|
|
970
|
-
}))
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
const tbAny = zod.z.union([zod.z.string(), zod.z.number(), zod.z.array(zod.z.union([zod.z.string(), zod.z.number()]))]);
|
|
975
|
-
const tinyBirdBaseSchema = zod.z.object({
|
|
976
|
-
meta: zod.z.array(zod.z.object({
|
|
977
|
-
name: zod.z.string(),
|
|
978
|
-
type: zod.z.string()
|
|
979
|
-
})),
|
|
980
|
-
statistics: zod.z.object({
|
|
981
|
-
elapsed: zod.z.number(),
|
|
982
|
-
rows_read: zod.z.number(),
|
|
983
|
-
bytes_read: zod.z.number()
|
|
984
|
-
}),
|
|
985
|
-
rows: zod.z.number()
|
|
986
|
-
});
|
|
987
|
-
const TinybirdJobResponseSchema = zod.z.object({
|
|
988
|
-
id: zod.z.string(),
|
|
989
|
-
job_id: zod.z.string(),
|
|
990
|
-
job_url: zod.z.string().url(),
|
|
991
|
-
job: zod.z.object({
|
|
992
|
-
kind: zod.z.string(),
|
|
993
|
-
id: zod.z.string(),
|
|
994
|
-
job_id: zod.z.string(),
|
|
995
|
-
status: zod.z.string(),
|
|
996
|
-
created_at: zod.z.string(),
|
|
997
|
-
updated_at: zod.z.string(),
|
|
998
|
-
started_at: zod.z.string().nullable(),
|
|
999
|
-
is_cancellable: zod.z.boolean(),
|
|
1000
|
-
datasource: zod.z.object({
|
|
1001
|
-
id: zod.z.string(),
|
|
1002
|
-
name: zod.z.string()
|
|
1003
|
-
}),
|
|
1004
|
-
delete_condition: zod.z.string().optional()
|
|
1005
|
-
}),
|
|
1006
|
-
status: zod.z.string(),
|
|
1007
|
-
delete_id: zod.z.string().optional(),
|
|
1008
|
-
import_id: zod.z.string().optional()
|
|
1009
|
-
});
|
|
1010
|
-
const latestEventsRequestSchema = zod.z.object({
|
|
1011
|
-
projectId: zod.z.string(),
|
|
1012
|
-
limit: zod.z.number().optional(),
|
|
1013
|
-
payload: zod.z.boolean().optional(),
|
|
1014
|
-
distinctId: zod.z.string().optional(),
|
|
1015
|
-
action: zod.z.string().optional()
|
|
1016
|
-
});
|
|
1017
|
-
const latestEventItemSchema = zod.z.object({
|
|
1018
|
-
id: zod.z.string(),
|
|
1019
|
-
timestamp: zod.z.string(),
|
|
1020
|
-
action: zod.z.string(),
|
|
1021
|
-
location: zod.z.string(),
|
|
1022
|
-
referrer: zod.z.string(),
|
|
1023
|
-
href: zod.z.string(),
|
|
1024
|
-
device: zod.z.string(),
|
|
1025
|
-
browser: zod.z.string(),
|
|
1026
|
-
payload: zod.z.string().optional(),
|
|
1027
|
-
distinctId: zod.z.string().optional(),
|
|
1028
|
-
unique: zod.z.boolean().optional()
|
|
1029
|
-
});
|
|
1030
|
-
const latestEventsResponseSchema = tinyBirdBaseSchema.extend({
|
|
1031
|
-
data: zod.z.array(latestEventItemSchema)
|
|
1032
|
-
});
|
|
1033
|
-
const kpisRequestSchema = zod.z.object({
|
|
1034
|
-
projectId: zod.z.string(),
|
|
1035
|
-
dateTo: zod.z.string().optional(),
|
|
1036
|
-
dateFrom: zod.z.string().optional(),
|
|
1037
|
-
referrer: zod.z.string().optional(),
|
|
1038
|
-
location: zod.z.string().optional()
|
|
1039
|
-
});
|
|
1040
|
-
const kpiSchema = zod.z.object({
|
|
1041
|
-
date: zod.z.string(),
|
|
1042
|
-
users: zod.z.number(),
|
|
1043
|
-
sessions: zod.z.number(),
|
|
1044
|
-
pageViews: zod.z.number(),
|
|
1045
|
-
events: zod.z.number(),
|
|
1046
|
-
bounceRate: zod.z.nullable(zod.z.number()),
|
|
1047
|
-
avgSessionSec: zod.z.number()
|
|
1048
|
-
});
|
|
1049
|
-
const kpisResponseSchema = tinyBirdBaseSchema.extend({
|
|
1050
|
-
data: zod.z.array(kpiSchema)
|
|
1051
|
-
});
|
|
1052
|
-
const baseTopRequestSchema = zod.z.object({
|
|
1053
|
-
projectId: zod.z.string(),
|
|
1054
|
-
dateTo: zod.z.string().optional(),
|
|
1055
|
-
dateFrom: zod.z.string().optional(),
|
|
1056
|
-
limit: zod.z.number().optional(),
|
|
1057
|
-
skip: zod.z.number().optional(),
|
|
1058
|
-
referrer: zod.z.string().optional(),
|
|
1059
|
-
location: zod.z.string().optional()
|
|
1060
|
-
});
|
|
1061
|
-
const topPagesResponseSchema = tinyBirdBaseSchema.extend({
|
|
1062
|
-
data: zod.z.array(zod.z.object({
|
|
1063
|
-
pathname: zod.z.string(),
|
|
1064
|
-
users: zod.z.number(),
|
|
1065
|
-
events: zod.z.number()
|
|
1066
|
-
}))
|
|
1067
|
-
});
|
|
1068
|
-
const topLocationsResponseSchema = tinyBirdBaseSchema.extend({
|
|
1069
|
-
data: zod.z.array(zod.z.object({
|
|
1070
|
-
location: zod.z.string(),
|
|
1071
|
-
users: zod.z.number(),
|
|
1072
|
-
sessions: zod.z.number(),
|
|
1073
|
-
pageViews: zod.z.number(),
|
|
1074
|
-
bounceRate: zod.z.nullable(zod.z.number()),
|
|
1075
|
-
avgSessionSec: zod.z.number()
|
|
1076
|
-
}))
|
|
1077
|
-
});
|
|
1078
|
-
const topDevicesResponseSchema = tinyBirdBaseSchema.extend({
|
|
1079
|
-
data: zod.z.array(zod.z.object({
|
|
1080
|
-
device: zod.z.string(),
|
|
1081
|
-
visits: zod.z.number(),
|
|
1082
|
-
hits: zod.z.number(),
|
|
1083
|
-
bounceRate: zod.z.nullable(zod.z.number()),
|
|
1084
|
-
avgSessionSec: zod.z.number()
|
|
1085
|
-
}))
|
|
1086
|
-
});
|
|
1087
|
-
const topBrowsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
1088
|
-
data: zod.z.array(zod.z.object({
|
|
1089
|
-
browser: zod.z.string(),
|
|
1090
|
-
visits: zod.z.number(),
|
|
1091
|
-
hits: zod.z.number(),
|
|
1092
|
-
bounceRate: zod.z.nullable(zod.z.number()),
|
|
1093
|
-
avgSessionSec: zod.z.number()
|
|
1094
|
-
}))
|
|
1095
|
-
});
|
|
1096
|
-
const topSourcesSchema = zod.z.object({
|
|
1097
|
-
referrer: zod.z.string(),
|
|
1098
|
-
users: zod.z.number(),
|
|
1099
|
-
sessions: zod.z.number(),
|
|
1100
|
-
pageViews: zod.z.number(),
|
|
1101
|
-
bounceRate: zod.z.nullable(zod.z.number()),
|
|
1102
|
-
avgSessionSec: zod.z.number()
|
|
1103
|
-
});
|
|
1104
|
-
const topSourcesResponseSchema = tinyBirdBaseSchema.extend({
|
|
1105
|
-
data: zod.z.array(topSourcesSchema)
|
|
1106
|
-
});
|
|
1107
|
-
const topActionsResponseSchema = tinyBirdBaseSchema.extend({
|
|
1108
|
-
data: zod.z.array(zod.z.object({
|
|
1109
|
-
action: zod.z.string(),
|
|
1110
|
-
users: zod.z.number(),
|
|
1111
|
-
events: zod.z.number()
|
|
1112
|
-
}))
|
|
1113
|
-
});
|
|
1114
|
-
const analyticsEventSchema = zod.z.object({
|
|
1115
|
-
id: zod.z.string(),
|
|
1116
|
-
timestamp: zod.z.string(),
|
|
1117
|
-
projectId: zod.z.string(),
|
|
1118
|
-
anonymousId: zod.z.string(),
|
|
1119
|
-
sessionId: zod.z.string(),
|
|
1120
|
-
distinctId: zod.z.string().nullable(),
|
|
1121
|
-
version: zod.z.string(),
|
|
1122
|
-
action: zod.z.string(),
|
|
1123
|
-
payload: zod.z.string()
|
|
1124
|
-
});
|
|
1125
|
-
const userEventsResponseSchema = tinyBirdBaseSchema.extend({
|
|
1126
|
-
data: zod.z.array(analyticsEventSchema)
|
|
1127
|
-
});
|
|
1128
|
-
const currentUsersRequestSchema = zod.z.object({
|
|
1129
|
-
projectId: zod.z.string(),
|
|
1130
|
-
minutes: zod.z.number(),
|
|
1131
|
-
referrer: zod.z.string().optional(),
|
|
1132
|
-
location: zod.z.string().optional()
|
|
1133
|
-
});
|
|
1134
|
-
const currentUsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
1135
|
-
data: zod.z.array(zod.z.object({
|
|
1136
|
-
visits: zod.z.number()
|
|
1137
|
-
}))
|
|
1138
|
-
});
|
|
1139
|
-
const reservedPropertiesSchema = zod.z.object({
|
|
1140
|
-
age: zod.z.number().nullish(),
|
|
1141
|
-
avatar: zod.z.string().url().nullish(),
|
|
1142
|
-
birthday: zod.z.string().nullish(),
|
|
1143
|
-
createdAt: zod.z.string().nullish(),
|
|
1144
|
-
description: zod.z.string().nullish(),
|
|
1145
|
-
email: zod.z.string().email().or(zod.z.literal('')).nullish(),
|
|
1146
|
-
firstName: zod.z.string().nullish(),
|
|
1147
|
-
gender: zod.z.string().nullish(),
|
|
1148
|
-
id: zod.z.string().nullish(),
|
|
1149
|
-
lastName: zod.z.string().nullish(),
|
|
1150
|
-
name: zod.z.string().nullish(),
|
|
1151
|
-
phone: zod.z.string().nullish(),
|
|
1152
|
-
title: zod.z.string().nullish(),
|
|
1153
|
-
username: zod.z.string().nullish(),
|
|
1154
|
-
website: zod.z.string().nullish(),
|
|
1155
|
-
// Default Properties
|
|
1156
|
-
$id: zod.z.string().nullish(),
|
|
1157
|
-
$lastSeen: zod.z.string().nullish(),
|
|
1158
|
-
$lastIdentifiedAt: zod.z.string().nullish(),
|
|
1159
|
-
$unsubscribed: zod.z.boolean().nullish(),
|
|
1160
|
-
$unsubscribeReason: zod.z.enum(['manual', 'complained', 'bounced']).nullish(),
|
|
1161
|
-
// Stripe Properties
|
|
1162
|
-
$stripeCustomerId: zod.z.string().nullish(),
|
|
1163
|
-
$stripeTotalPayments: zod.z.number().or(zod.z.string()).nullish(),
|
|
1164
|
-
$stripeTotalSpent: zod.z.number().or(zod.z.string()).nullish(),
|
|
1165
|
-
// Internal properties
|
|
1166
|
-
$_toDelete: zod.z.boolean().nullish()
|
|
1167
|
-
});
|
|
1168
|
-
const contactPropertiesSchema = reservedPropertiesSchema.optional().and(zod.z.record(zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean(), zod.z.date(), zod.z.null(), zod.z.array(zod.z.union([zod.z.string(), zod.z.number(), zod.z.boolean(), zod.z.date(), zod.z.null()]))])));
|
|
1169
|
-
const analyticsUserRawSchema = zod.z.object({
|
|
1170
|
-
timestamp: zod.z.string(),
|
|
1171
|
-
distinctId: zod.z.string(),
|
|
1172
|
-
projectId: zod.z.string(),
|
|
1173
|
-
payload: zod.z.string()
|
|
1174
|
-
});
|
|
1175
|
-
const analyticsUserSchema = analyticsUserRawSchema.omit({
|
|
1176
|
-
payload: true
|
|
1177
|
-
}).and(zod.z.object({
|
|
1178
|
-
properties: contactPropertiesSchema
|
|
1179
|
-
}));
|
|
1180
|
-
const listUsersParamsSchema = zod.z.object({
|
|
1181
|
-
projectId: zod.z.string(),
|
|
1182
|
-
limit: zod.z.number().optional()
|
|
1183
|
-
});
|
|
1184
|
-
const getAnalyticsUserParamsSchema = zod.z.object({
|
|
1185
|
-
projectId: zod.z.string(),
|
|
1186
|
-
distinctId: zod.z.string()
|
|
1187
|
-
});
|
|
1188
|
-
const idenfitySchema = zod.z.object({
|
|
1189
|
-
id: zod.z.string(),
|
|
1190
|
-
timestamp: zod.z.string(),
|
|
1191
|
-
projectId: zod.z.string(),
|
|
1192
|
-
distinctId: zod.z.string(),
|
|
1193
|
-
anonymousId: zod.z.string(),
|
|
1194
|
-
version: zod.z.string(),
|
|
1195
|
-
payload: contactPropertiesSchema,
|
|
1196
|
-
context: zod.z.object({
|
|
1197
|
-
active: zod.z.boolean().optional()
|
|
1198
|
-
}).optional()
|
|
1199
|
-
});
|
|
1200
|
-
const latestIdentifiesRequestSchema = zod.z.object({
|
|
1201
|
-
projectId: zod.z.string(),
|
|
1202
|
-
limit: zod.z.number().optional(),
|
|
1203
|
-
fields: zod.z.array(zod.z.string()).optional()
|
|
1204
|
-
});
|
|
1205
|
-
const latestIdentifiesResponseSchema = tinyBirdBaseSchema.extend({
|
|
1206
|
-
data: zod.z.array(zod.z.object({
|
|
1207
|
-
properties: contactPropertiesSchema
|
|
1208
|
-
}))
|
|
1209
|
-
});
|
|
1210
830
|
|
|
1211
831
|
exports.Saasco = Saasco;
|
|
1212
|
-
exports.TinybirdJobResponseSchema = TinybirdJobResponseSchema;
|
|
1213
|
-
exports.analyticsEventSchema = analyticsEventSchema;
|
|
1214
|
-
exports.analyticsUserRawSchema = analyticsUserRawSchema;
|
|
1215
|
-
exports.analyticsUserSchema = analyticsUserSchema;
|
|
1216
|
-
exports.baseTopRequestSchema = baseTopRequestSchema;
|
|
1217
832
|
exports.browserContextSchema = browserContextSchema;
|
|
1218
|
-
exports.coerceReservedProperties = coerceReservedProperties;
|
|
1219
|
-
exports.contactPropertiesSchema = contactPropertiesSchema;
|
|
1220
|
-
exports.createTrackedEventTypeSchema = createTrackedEventTypeSchema;
|
|
1221
|
-
exports.currentUsersRequestSchema = currentUsersRequestSchema;
|
|
1222
|
-
exports.currentUsersResponseSchema = currentUsersResponseSchema;
|
|
1223
|
-
exports.getAnalyticsUserParamsSchema = getAnalyticsUserParamsSchema;
|
|
1224
833
|
exports.getBrowserContext = getBrowserContext;
|
|
1225
|
-
exports.idenfitySchema = idenfitySchema;
|
|
1226
|
-
exports.kpiSchema = kpiSchema;
|
|
1227
|
-
exports.kpisRequestSchema = kpisRequestSchema;
|
|
1228
|
-
exports.kpisResponseSchema = kpisResponseSchema;
|
|
1229
|
-
exports.latestEventItemSchema = latestEventItemSchema;
|
|
1230
|
-
exports.latestEventsRequestSchema = latestEventsRequestSchema;
|
|
1231
|
-
exports.latestEventsResponseSchema = latestEventsResponseSchema;
|
|
1232
|
-
exports.latestIdentifiesRequestSchema = latestIdentifiesRequestSchema;
|
|
1233
|
-
exports.latestIdentifiesResponseSchema = latestIdentifiesResponseSchema;
|
|
1234
|
-
exports.listUsersParamsSchema = listUsersParamsSchema;
|
|
1235
|
-
exports.reservedPropertiesSchema = reservedPropertiesSchema;
|
|
1236
|
-
exports.serverContextSchema = serverContextSchema;
|
|
1237
|
-
exports.tbAny = tbAny;
|
|
1238
834
|
exports.timezones = timezones;
|
|
1239
|
-
exports.tinyBirdBaseSchema = tinyBirdBaseSchema;
|
|
1240
|
-
exports.topActionsResponseSchema = topActionsResponseSchema;
|
|
1241
|
-
exports.topBrowsersResponseSchema = topBrowsersResponseSchema;
|
|
1242
|
-
exports.topDevicesResponseSchema = topDevicesResponseSchema;
|
|
1243
|
-
exports.topLocationsResponseSchema = topLocationsResponseSchema;
|
|
1244
|
-
exports.topPagesResponseSchema = topPagesResponseSchema;
|
|
1245
|
-
exports.topSourcesResponseSchema = topSourcesResponseSchema;
|
|
1246
|
-
exports.topSourcesSchema = topSourcesSchema;
|
|
1247
|
-
exports.trackedEventSchema = trackedEventSchema;
|
|
1248
|
-
exports.trackedEventTypesSchema = trackedEventTypesSchema;
|
|
1249
|
-
exports.userEventsResponseSchema = userEventsResponseSchema;
|