saasco-sdk 0.1.6 → 0.1.8
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 +3 -4
- package/index.cjs.js +126 -90
- package/index.esm.js +124 -89
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/analytics.d.ts +7 -6
- package/src/lib/types.d.ts +274 -184
package/README.md
CHANGED
|
@@ -166,6 +166,7 @@ saasco.debug(true);
|
|
|
166
166
|
|
|
167
167
|
Saasco has reserved some properties that have semantic meanings for contacts and, and will handle them in special ways.
|
|
168
168
|
For example, Saasco always expects email to be a string of the user’s email address, this is important for when sending emails using the marketing app.
|
|
169
|
+
The SDK will do its best to match these properties, eg (created_at will be mapped to createdAt), but if possible you should use the reserved properties.
|
|
169
170
|
|
|
170
171
|
### Reserved Contact Properties
|
|
171
172
|
|
|
@@ -180,7 +181,6 @@ For example, Saasco always expects email to be a string of the user’s email ad
|
|
|
180
181
|
| firstName | String | First name of a user |
|
|
181
182
|
| displayName | String | The prefered users display name, will default to "firstName lastName" |
|
|
182
183
|
| gender | String | Gender of a user |
|
|
183
|
-
| id | String | The ID of the user from your database, coerced to a string. eg 1 becomes "1" |
|
|
184
184
|
| lastName | String | Last name of a user |
|
|
185
185
|
| name | String | Full name of a user. If you only pass a first and last name Segment automatically fills in the full name for you. |
|
|
186
186
|
| phone | String | Phone number of a user |
|
|
@@ -195,8 +195,8 @@ Any property that starts with `$` is a property that has been generated by the S
|
|
|
195
195
|
|
|
196
196
|
| Property | Display Name | Description |
|
|
197
197
|
| ----------------------- | --------------------------- | -------------------------------------------------------------------------------------- |
|
|
198
|
+
| $id | ID | The ID of the user from your database, coerced to a string. eg 1 becomes "1" |
|
|
198
199
|
| $city | City | The city of the user parsed from the IP. |
|
|
199
|
-
| $region | Region | The region of the user parsed from the IP |
|
|
200
200
|
| $countryCode | Country Code | The country of the user parsed from the IP property. |
|
|
201
201
|
| $latitude | Latitude | Latitude of the user's IP location. |
|
|
202
202
|
| $longitude | Longitude | Longitude of the user's IP location. |
|
|
@@ -205,7 +205,7 @@ Any property that starts with `$` is a property that has been generated by the S
|
|
|
205
205
|
| $screenHeight | Screen Height | The most recent height of the device screen in pixels |
|
|
206
206
|
| $screenWidth | Screen Width | The most recent width of the device screen in pixels |
|
|
207
207
|
| $screenDpi | Screen DPI | The most recent Pixel density of the device screen. |
|
|
208
|
-
| $lastSeen |
|
|
208
|
+
| $lastSeen | Last Seen | The last time a user was identified while active was not false in the context |
|
|
209
209
|
| $os | Operating System | The most recent OS of the user. |
|
|
210
210
|
| $browser | Browser | The most recent browser of the user. |
|
|
211
211
|
| $browserVersion | Browser Version | The most recent bowser version of the user. |
|
|
@@ -242,7 +242,6 @@ Our SDKs automatically collect certain properties on every event or user profile
|
|
|
242
242
|
| Property | Display Name | Description |
|
|
243
243
|
| ---------------- | --------------------------- | -------------------------------------------------------------------------------- |
|
|
244
244
|
| $city | City | The city of the user parsed from the IP. |
|
|
245
|
-
| $region | Region | The region of the user parsed from the IP |
|
|
246
245
|
| $countryCode | Country Code | The country of the user parsed from the IP property. |
|
|
247
246
|
| $latitude | Latitude | Latitude of the user's IP location. |
|
|
248
247
|
| $longitude | Longitude | Longitude of the user's IP location. |
|
package/index.cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
5
6
|
var uuid = require('@lukeed/uuid');
|
|
6
7
|
var zod = require('zod');
|
|
7
8
|
|
|
@@ -433,7 +434,6 @@ const timezones = {
|
|
|
433
434
|
'Asia/Calcutta': 'IN'
|
|
434
435
|
};
|
|
435
436
|
|
|
436
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
437
437
|
const isBrowser = typeof window !== 'undefined';
|
|
438
438
|
let userId = null;
|
|
439
439
|
const PREF = 'saasco-sdk';
|
|
@@ -501,6 +501,36 @@ function setAnonmousId({
|
|
|
501
501
|
storeData(`anonymous-id`, anonymousId, 1000 * 60 * 60 * 24 * 365);
|
|
502
502
|
return anonymousId;
|
|
503
503
|
}
|
|
504
|
+
function getBrowserContext() {
|
|
505
|
+
var _a;
|
|
506
|
+
if (!isBrowser) return {};
|
|
507
|
+
const customNavigator = navigator;
|
|
508
|
+
const $locale = (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages) && (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages.length) ? customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages[0] : (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.userLanguage) || (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.language) || (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.browserLanguage) || 'en';
|
|
509
|
+
// https://caniuse.com/?search=Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
510
|
+
// Only has 96.63% global support, so we need to check for undefined
|
|
511
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
512
|
+
const $location = timezones[timezone] || ((_a = $locale === null || $locale === void 0 ? void 0 : $locale.split('-')) === null || _a === void 0 ? void 0 : _a[1]) || 'undefined';
|
|
513
|
+
const $href = window.location.href;
|
|
514
|
+
const $pathname = window.location.pathname;
|
|
515
|
+
const $referrer = document.referrer;
|
|
516
|
+
const $screenDPI = window.devicePixelRatio;
|
|
517
|
+
const $screenHeight = screen.height;
|
|
518
|
+
const $screenWidth = screen.width;
|
|
519
|
+
const $title = document.title;
|
|
520
|
+
const $userAgent = window.navigator.userAgent;
|
|
521
|
+
return {
|
|
522
|
+
$locale,
|
|
523
|
+
$location,
|
|
524
|
+
$href,
|
|
525
|
+
$pathname,
|
|
526
|
+
$referrer,
|
|
527
|
+
$screenDPI,
|
|
528
|
+
$screenHeight,
|
|
529
|
+
$screenWidth,
|
|
530
|
+
$title,
|
|
531
|
+
$userAgent
|
|
532
|
+
};
|
|
533
|
+
}
|
|
504
534
|
class Saasco {
|
|
505
535
|
/**
|
|
506
536
|
* Creates an instance of Saasco SDK.
|
|
@@ -542,8 +572,7 @@ class Saasco {
|
|
|
542
572
|
*/
|
|
543
573
|
track(name,
|
|
544
574
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
545
|
-
properties) {
|
|
546
|
-
var _a;
|
|
575
|
+
properties, context) {
|
|
547
576
|
// Prevent duplicate Page View tracking
|
|
548
577
|
if (name === 'Page View') {
|
|
549
578
|
if (!isBrowser) {
|
|
@@ -556,20 +585,7 @@ class Saasco {
|
|
|
556
585
|
}
|
|
557
586
|
setSessionId();
|
|
558
587
|
setAnonmousId();
|
|
559
|
-
const
|
|
560
|
-
const $locale = isBrowser ? (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages) && (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages.length) ? customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.languages[0] : (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.userLanguage) || (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.language) || (customNavigator === null || customNavigator === void 0 ? void 0 : customNavigator.browserLanguage) || 'en' : undefined;
|
|
561
|
-
// https://caniuse.com/?search=Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
562
|
-
// Only has 96.63% global support, so we need to check for undefined
|
|
563
|
-
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
564
|
-
const $location = isBrowser ? timezones[timezone] || ((_a = $locale === null || $locale === void 0 ? void 0 : $locale.split('-')) === null || _a === void 0 ? void 0 : _a[1]) || 'undefined' : undefined;
|
|
565
|
-
const $href = isBrowser ? window.location.href : undefined;
|
|
566
|
-
const $pathname = isBrowser ? window.location.pathname : undefined;
|
|
567
|
-
const $referrer = isBrowser ? document.referrer : undefined;
|
|
568
|
-
const $screenDPI = isBrowser ? window.devicePixelRatio : undefined;
|
|
569
|
-
const $screenHeight = isBrowser ? screen.height : undefined;
|
|
570
|
-
const $screenWidth = isBrowser ? screen.width : undefined;
|
|
571
|
-
const $title = isBrowser ? document.title : undefined;
|
|
572
|
-
const $userAgent = isBrowser ? window.navigator.userAgent : undefined;
|
|
588
|
+
const browserContext = getBrowserContext();
|
|
573
589
|
const data = {
|
|
574
590
|
id: uuid.v4(),
|
|
575
591
|
timestamp: new Date().toISOString(),
|
|
@@ -578,21 +594,12 @@ class Saasco {
|
|
|
578
594
|
sessionId: getSessionId(),
|
|
579
595
|
anonymousId: getAnonymousId(),
|
|
580
596
|
projectId: this.config.projectId,
|
|
581
|
-
payload: JSON.stringify({
|
|
582
|
-
$href,
|
|
583
|
-
$locale,
|
|
584
|
-
$location,
|
|
585
|
-
$pathname,
|
|
586
|
-
$referrer,
|
|
587
|
-
$screenDPI,
|
|
588
|
-
$screenHeight,
|
|
589
|
-
$screenWidth,
|
|
590
|
-
$title,
|
|
591
|
-
$userAgent,
|
|
597
|
+
payload: JSON.stringify(Object.assign(Object.assign({}, browserContext), {
|
|
592
598
|
properties: properties || {}
|
|
593
|
-
})
|
|
599
|
+
})),
|
|
600
|
+
context: JSON.stringify(context || {})
|
|
594
601
|
};
|
|
595
|
-
this.doRequest('events', data);
|
|
602
|
+
return this.doRequest('events', data);
|
|
596
603
|
}
|
|
597
604
|
/**
|
|
598
605
|
* The page method lets you record page views on your website
|
|
@@ -601,18 +608,22 @@ class Saasco {
|
|
|
601
608
|
* Before implementing this make sure you have disabled the autoPageTracking in the config or you will get duplicate page views
|
|
602
609
|
*/
|
|
603
610
|
page() {
|
|
604
|
-
this.track('Page View');
|
|
611
|
+
return this.track('Page View');
|
|
605
612
|
}
|
|
606
|
-
identify(distinctIdOrProperties,
|
|
613
|
+
identify(distinctIdOrProperties, propertiesOrContext, contextOrNothing) {
|
|
607
614
|
const hasId = typeof distinctIdOrProperties === 'string' || typeof distinctIdOrProperties === 'number' || distinctIdOrProperties === null;
|
|
608
615
|
const distinctId = hasId ? distinctIdOrProperties === null || distinctIdOrProperties === void 0 ? void 0 : distinctIdOrProperties.toString() : `soft_${uuid.v4()}`;
|
|
609
|
-
const properties = hasId ?
|
|
610
|
-
const
|
|
616
|
+
const properties = hasId ? propertiesOrContext : distinctIdOrProperties;
|
|
617
|
+
const context = hasId ? contextOrNothing : propertiesOrContext;
|
|
611
618
|
// When the user gets identified as null this will reset the users session and anonymous id
|
|
612
619
|
// This should only be called when distinctId is null and there is an existing userId.
|
|
613
620
|
// This means the user has logged out and we should reset the session and anonymous IDs
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
621
|
+
const userIdChangedToNull = !distinctId && !!userId;
|
|
622
|
+
if (userIdChangedToNull) this.log('User ID change to null. Session reset');
|
|
623
|
+
// If we have a userId, but a new user ID is provided, we should reset the session and anonymous IDs
|
|
624
|
+
const userIdChanged = !!userId && distinctId !== userId;
|
|
625
|
+
if (userIdChanged) this.log('User ID changed. Session reset');
|
|
626
|
+
const reset = userIdChangedToNull || userIdChanged;
|
|
616
627
|
setSessionId({
|
|
617
628
|
reset
|
|
618
629
|
});
|
|
@@ -631,9 +642,9 @@ class Saasco {
|
|
|
631
642
|
anonymousId,
|
|
632
643
|
version: '2',
|
|
633
644
|
payload: properties || {},
|
|
634
|
-
|
|
645
|
+
context: context || {}
|
|
635
646
|
};
|
|
636
|
-
this.doRequest('identify', data);
|
|
647
|
+
return this.doRequest('identify', data);
|
|
637
648
|
}
|
|
638
649
|
/**
|
|
639
650
|
* Handles sending data to the Saasco API
|
|
@@ -642,25 +653,31 @@ class Saasco {
|
|
|
642
653
|
* @param data
|
|
643
654
|
*/
|
|
644
655
|
doRequest(path, data) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
656
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
657
|
+
const base = this.config.proxy || 'https://www.saasco.com/api/';
|
|
658
|
+
const url = `${base}${path}`;
|
|
659
|
+
const logMessage = data.action === 'Page View' ? `Page View ${window.location.pathname}` // if its a page view, include pathname in console log
|
|
660
|
+
: data.action || path;
|
|
661
|
+
this.log(logMessage, data);
|
|
662
|
+
// If analytics is disabled, don't send the request
|
|
663
|
+
if (this.config.enabled === false) return;
|
|
664
|
+
try {
|
|
665
|
+
const response = yield fetch(url, {
|
|
666
|
+
method: 'POST',
|
|
667
|
+
headers: {
|
|
668
|
+
'Content-Type': 'application/json'
|
|
669
|
+
},
|
|
670
|
+
body: JSON.stringify(data)
|
|
671
|
+
});
|
|
672
|
+
if (!response.ok) {
|
|
673
|
+
throw new Error(response.status.toString());
|
|
674
|
+
}
|
|
675
|
+
return response;
|
|
676
|
+
} catch (error) {
|
|
677
|
+
const errorMessage = 'Error with Saasco request: ' + error.message;
|
|
678
|
+
console.error(errorMessage, path, data);
|
|
679
|
+
return errorMessage;
|
|
661
680
|
}
|
|
662
|
-
}).catch(e => {
|
|
663
|
-
console.error('Error with Saasco request: ' + e.message, path, data);
|
|
664
681
|
});
|
|
665
682
|
}
|
|
666
683
|
/**
|
|
@@ -669,14 +686,10 @@ class Saasco {
|
|
|
669
686
|
log(...args) {
|
|
670
687
|
if (!this.config.debug) return;
|
|
671
688
|
const message = '◍ Saasco Debug';
|
|
672
|
-
console.
|
|
689
|
+
console.info(...[`\x1b[47m\x1b[30m ${message} \x1b[0m`,
|
|
673
690
|
// Message highlighted for easy finding
|
|
674
691
|
...args]);
|
|
675
692
|
}
|
|
676
|
-
getSearchParam(param) {
|
|
677
|
-
if (typeof window === 'undefined') return undefined;
|
|
678
|
-
return new URLSearchParams(window.location.search).get(param);
|
|
679
|
-
}
|
|
680
693
|
/**
|
|
681
694
|
* If autoPageTracking is enabled, this will automatically track page views
|
|
682
695
|
* It listens to url changes to track new pages every time the url changes
|
|
@@ -768,8 +781,7 @@ function coerceReservedProperties(properties) {
|
|
|
768
781
|
schema: zod.z.coerce.string().url().optional()
|
|
769
782
|
}, {
|
|
770
783
|
key: 'displayName',
|
|
771
|
-
coerceFrom: ['display_name', 'displayName', 'user_display_name', 'userDisplayName', 'full_name', 'fullName', 'user_full_name', 'userFullName', 'complete_name', 'completeName', 'user_complete_name', 'userCompleteName', 'name', 'username']
|
|
772
|
-
schema: zod.z.coerce.string().url().optional()
|
|
784
|
+
coerceFrom: ['display_name', 'displayName', 'user_display_name', 'userDisplayName', 'full_name', 'fullName', 'user_full_name', 'userFullName', 'complete_name', 'completeName', 'user_complete_name', 'userCompleteName', 'name', 'username']
|
|
773
785
|
}];
|
|
774
786
|
return coerce.reduce((acc, {
|
|
775
787
|
key,
|
|
@@ -823,49 +835,69 @@ const tinyBirdBaseSchema = zod.z.object({
|
|
|
823
835
|
}),
|
|
824
836
|
rows: zod.z.number()
|
|
825
837
|
});
|
|
838
|
+
const TinybirdJobResponseSchema = zod.z.object({
|
|
839
|
+
id: zod.z.string(),
|
|
840
|
+
job_id: zod.z.string(),
|
|
841
|
+
job_url: zod.z.string().url(),
|
|
842
|
+
job: zod.z.object({
|
|
843
|
+
kind: zod.z.string(),
|
|
844
|
+
id: zod.z.string(),
|
|
845
|
+
job_id: zod.z.string(),
|
|
846
|
+
status: zod.z.string(),
|
|
847
|
+
created_at: zod.z.string(),
|
|
848
|
+
updated_at: zod.z.string(),
|
|
849
|
+
started_at: zod.z.string().nullable(),
|
|
850
|
+
is_cancellable: zod.z.boolean(),
|
|
851
|
+
datasource: zod.z.object({
|
|
852
|
+
id: zod.z.string(),
|
|
853
|
+
name: zod.z.string()
|
|
854
|
+
}),
|
|
855
|
+
delete_condition: zod.z.string().optional()
|
|
856
|
+
}),
|
|
857
|
+
status: zod.z.string(),
|
|
858
|
+
delete_id: zod.z.string().optional(),
|
|
859
|
+
import_id: zod.z.string().optional()
|
|
860
|
+
});
|
|
826
861
|
const kpisRequestSchema = zod.z.object({
|
|
827
862
|
projectId: zod.z.string(),
|
|
828
863
|
dateTo: zod.z.string().optional(),
|
|
829
864
|
dateFrom: zod.z.string().optional(),
|
|
830
|
-
|
|
865
|
+
referrer: zod.z.string().optional(),
|
|
831
866
|
location: zod.z.string().optional()
|
|
832
867
|
});
|
|
833
868
|
const kpisResponseSchema = tinyBirdBaseSchema.extend({
|
|
834
869
|
data: zod.z.array(zod.z.object({
|
|
835
870
|
date: zod.z.string(),
|
|
836
|
-
|
|
837
|
-
|
|
871
|
+
users: zod.z.number(),
|
|
872
|
+
sessions: zod.z.number(),
|
|
873
|
+
pageViews: zod.z.number(),
|
|
874
|
+
events: zod.z.number(),
|
|
838
875
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
839
876
|
avgSessionSec: zod.z.number()
|
|
840
877
|
}))
|
|
841
878
|
});
|
|
842
|
-
const eventsKpisResponseSchema = tinyBirdBaseSchema.extend({
|
|
843
|
-
data: zod.z.array(zod.z.object({
|
|
844
|
-
unique: zod.z.number(),
|
|
845
|
-
total: zod.z.number()
|
|
846
|
-
}))
|
|
847
|
-
});
|
|
848
879
|
const baseTopRequestSchema = zod.z.object({
|
|
849
880
|
projectId: zod.z.string(),
|
|
850
881
|
dateTo: zod.z.string().optional(),
|
|
851
882
|
dateFrom: zod.z.string().optional(),
|
|
852
883
|
limit: zod.z.number().optional(),
|
|
853
884
|
skip: zod.z.number().optional(),
|
|
854
|
-
|
|
885
|
+
referrer: zod.z.string().optional(),
|
|
855
886
|
location: zod.z.string().optional()
|
|
856
887
|
});
|
|
857
888
|
const topPagesResponseSchema = tinyBirdBaseSchema.extend({
|
|
858
889
|
data: zod.z.array(zod.z.object({
|
|
859
890
|
pathname: zod.z.string(),
|
|
860
|
-
|
|
861
|
-
|
|
891
|
+
users: zod.z.number(),
|
|
892
|
+
events: zod.z.number()
|
|
862
893
|
}))
|
|
863
894
|
});
|
|
864
895
|
const topLocationsResponseSchema = tinyBirdBaseSchema.extend({
|
|
865
896
|
data: zod.z.array(zod.z.object({
|
|
866
897
|
location: zod.z.string(),
|
|
867
|
-
|
|
868
|
-
|
|
898
|
+
users: zod.z.number(),
|
|
899
|
+
sessions: zod.z.number(),
|
|
900
|
+
pageViews: zod.z.number(),
|
|
869
901
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
870
902
|
avgSessionSec: zod.z.number()
|
|
871
903
|
}))
|
|
@@ -890,8 +922,9 @@ const topBrowsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
890
922
|
});
|
|
891
923
|
const topSourcesSchema = zod.z.object({
|
|
892
924
|
referrer: zod.z.string(),
|
|
893
|
-
|
|
894
|
-
|
|
925
|
+
users: zod.z.number(),
|
|
926
|
+
sessions: zod.z.number(),
|
|
927
|
+
pageViews: zod.z.number(),
|
|
895
928
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
896
929
|
avgSessionSec: zod.z.number()
|
|
897
930
|
});
|
|
@@ -901,8 +934,8 @@ const topSourcesResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
901
934
|
const topActionsResponseSchema = tinyBirdBaseSchema.extend({
|
|
902
935
|
data: zod.z.array(zod.z.object({
|
|
903
936
|
action: zod.z.string(),
|
|
904
|
-
|
|
905
|
-
|
|
937
|
+
users: zod.z.number(),
|
|
938
|
+
events: zod.z.number()
|
|
906
939
|
}))
|
|
907
940
|
});
|
|
908
941
|
const analyticsEventSchema = zod.z.object({
|
|
@@ -921,7 +954,7 @@ const userEventsResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
921
954
|
const currentUsersRequestSchema = zod.z.object({
|
|
922
955
|
projectId: zod.z.string(),
|
|
923
956
|
minutes: zod.z.number().optional(),
|
|
924
|
-
|
|
957
|
+
referrer: zod.z.string().optional(),
|
|
925
958
|
location: zod.z.string().optional()
|
|
926
959
|
});
|
|
927
960
|
const currentUsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
@@ -930,7 +963,7 @@ const currentUsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
930
963
|
}))
|
|
931
964
|
});
|
|
932
965
|
const reservedPropertiesSchema = zod.z.object({
|
|
933
|
-
age: zod.z.number().nullish(),
|
|
966
|
+
age: zod.z.number().or(zod.z.string()).nullish(),
|
|
934
967
|
avatar: zod.z.string().url().nullish(),
|
|
935
968
|
birthday: zod.z.string().nullish(),
|
|
936
969
|
createdAt: zod.z.string().nullish(),
|
|
@@ -944,9 +977,11 @@ const reservedPropertiesSchema = zod.z.object({
|
|
|
944
977
|
phone: zod.z.string().nullish(),
|
|
945
978
|
title: zod.z.string().nullish(),
|
|
946
979
|
username: zod.z.string().nullish(),
|
|
947
|
-
website: zod.z.string().nullish()
|
|
980
|
+
website: zod.z.string().nullish(),
|
|
981
|
+
$id: zod.z.string().nullish(),
|
|
982
|
+
$lastSeen: zod.z.string().nullish()
|
|
948
983
|
});
|
|
949
|
-
const
|
|
984
|
+
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()]))])));
|
|
950
985
|
const analyticsUserRawSchema = zod.z.object({
|
|
951
986
|
timestamp: zod.z.string(),
|
|
952
987
|
distinctId: zod.z.string(),
|
|
@@ -956,7 +991,7 @@ const analyticsUserRawSchema = zod.z.object({
|
|
|
956
991
|
const analyticsUserSchema = analyticsUserRawSchema.omit({
|
|
957
992
|
payload: true
|
|
958
993
|
}).and(zod.z.object({
|
|
959
|
-
properties:
|
|
994
|
+
properties: contactPropertiesSchema
|
|
960
995
|
}));
|
|
961
996
|
const listUsersParamsSchema = zod.z.object({
|
|
962
997
|
projectId: zod.z.string(),
|
|
@@ -973,21 +1008,22 @@ const idenfitySchema = zod.z.object({
|
|
|
973
1008
|
distinctId: zod.z.string(),
|
|
974
1009
|
anonymousId: zod.z.string(),
|
|
975
1010
|
version: zod.z.string(),
|
|
976
|
-
payload:
|
|
977
|
-
|
|
1011
|
+
payload: contactPropertiesSchema,
|
|
1012
|
+
context: zod.z.object({
|
|
978
1013
|
active: zod.z.boolean().optional()
|
|
979
1014
|
}).optional()
|
|
980
1015
|
});
|
|
981
1016
|
|
|
982
1017
|
exports.Saasco = Saasco;
|
|
1018
|
+
exports.TinybirdJobResponseSchema = TinybirdJobResponseSchema;
|
|
983
1019
|
exports.analyticsEventSchema = analyticsEventSchema;
|
|
984
1020
|
exports.analyticsUserRawSchema = analyticsUserRawSchema;
|
|
985
1021
|
exports.analyticsUserSchema = analyticsUserSchema;
|
|
986
1022
|
exports.baseTopRequestSchema = baseTopRequestSchema;
|
|
987
1023
|
exports.coerceReservedProperties = coerceReservedProperties;
|
|
1024
|
+
exports.contactPropertiesSchema = contactPropertiesSchema;
|
|
988
1025
|
exports.currentUsersRequestSchema = currentUsersRequestSchema;
|
|
989
1026
|
exports.currentUsersResponseSchema = currentUsersResponseSchema;
|
|
990
|
-
exports.eventsKpisResponseSchema = eventsKpisResponseSchema;
|
|
991
1027
|
exports.getAnalyticsUserParamsSchema = getAnalyticsUserParamsSchema;
|
|
992
1028
|
exports.idenfitySchema = idenfitySchema;
|
|
993
1029
|
exports.kpisRequestSchema = kpisRequestSchema;
|
|
@@ -995,6 +1031,7 @@ exports.kpisResponseSchema = kpisResponseSchema;
|
|
|
995
1031
|
exports.listUsersParamsSchema = listUsersParamsSchema;
|
|
996
1032
|
exports.reservedPropertiesSchema = reservedPropertiesSchema;
|
|
997
1033
|
exports.tbAny = tbAny;
|
|
1034
|
+
exports.timezones = timezones;
|
|
998
1035
|
exports.tinyBirdBaseSchema = tinyBirdBaseSchema;
|
|
999
1036
|
exports.topActionsResponseSchema = topActionsResponseSchema;
|
|
1000
1037
|
exports.topBrowsersResponseSchema = topBrowsersResponseSchema;
|
|
@@ -1004,4 +1041,3 @@ exports.topPagesResponseSchema = topPagesResponseSchema;
|
|
|
1004
1041
|
exports.topSourcesResponseSchema = topSourcesResponseSchema;
|
|
1005
1042
|
exports.topSourcesSchema = topSourcesSchema;
|
|
1006
1043
|
exports.userEventsResponseSchema = userEventsResponseSchema;
|
|
1007
|
-
exports.userPropertiesSchema = userPropertiesSchema;
|