saasco-sdk 0.1.7 → 0.1.9
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 +155 -86
- package/index.esm.js +148 -85
- 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 +737 -278
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(),
|
|
@@ -577,22 +593,14 @@ class Saasco {
|
|
|
577
593
|
version: '2',
|
|
578
594
|
sessionId: getSessionId(),
|
|
579
595
|
anonymousId: getAnonymousId(),
|
|
596
|
+
distinctId: userId,
|
|
580
597
|
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,
|
|
598
|
+
payload: JSON.stringify(Object.assign(Object.assign({}, browserContext), {
|
|
592
599
|
properties: properties || {}
|
|
593
|
-
})
|
|
600
|
+
})),
|
|
601
|
+
context: JSON.stringify(context || {})
|
|
594
602
|
};
|
|
595
|
-
this.doRequest('events', data);
|
|
603
|
+
return this.doRequest('events', data);
|
|
596
604
|
}
|
|
597
605
|
/**
|
|
598
606
|
* The page method lets you record page views on your website
|
|
@@ -601,13 +609,13 @@ class Saasco {
|
|
|
601
609
|
* Before implementing this make sure you have disabled the autoPageTracking in the config or you will get duplicate page views
|
|
602
610
|
*/
|
|
603
611
|
page() {
|
|
604
|
-
this.track('Page View');
|
|
612
|
+
return this.track('Page View');
|
|
605
613
|
}
|
|
606
|
-
identify(distinctIdOrProperties,
|
|
614
|
+
identify(distinctIdOrProperties, propertiesOrContext, contextOrNothing) {
|
|
607
615
|
const hasId = typeof distinctIdOrProperties === 'string' || typeof distinctIdOrProperties === 'number' || distinctIdOrProperties === null;
|
|
608
616
|
const distinctId = hasId ? distinctIdOrProperties === null || distinctIdOrProperties === void 0 ? void 0 : distinctIdOrProperties.toString() : `soft_${uuid.v4()}`;
|
|
609
|
-
const properties = hasId ?
|
|
610
|
-
const
|
|
617
|
+
const properties = hasId ? propertiesOrContext : distinctIdOrProperties;
|
|
618
|
+
const context = hasId ? contextOrNothing : propertiesOrContext;
|
|
611
619
|
// When the user gets identified as null this will reset the users session and anonymous id
|
|
612
620
|
// This should only be called when distinctId is null and there is an existing userId.
|
|
613
621
|
// This means the user has logged out and we should reset the session and anonymous IDs
|
|
@@ -635,9 +643,9 @@ class Saasco {
|
|
|
635
643
|
anonymousId,
|
|
636
644
|
version: '2',
|
|
637
645
|
payload: properties || {},
|
|
638
|
-
|
|
646
|
+
context: context || {}
|
|
639
647
|
};
|
|
640
|
-
this.doRequest('identify', data);
|
|
648
|
+
return this.doRequest('identify', data);
|
|
641
649
|
}
|
|
642
650
|
/**
|
|
643
651
|
* Handles sending data to the Saasco API
|
|
@@ -646,25 +654,31 @@ class Saasco {
|
|
|
646
654
|
* @param data
|
|
647
655
|
*/
|
|
648
656
|
doRequest(path, data) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
657
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
658
|
+
const base = this.config.proxy || 'https://www.saasco.com/api/';
|
|
659
|
+
const url = `${base}${path}`;
|
|
660
|
+
const logMessage = data.action === 'Page View' ? `Page View ${window.location.pathname}` // if its a page view, include pathname in console log
|
|
661
|
+
: data.action || path;
|
|
662
|
+
this.log(logMessage, data);
|
|
663
|
+
// If analytics is disabled, don't send the request
|
|
664
|
+
if (this.config.enabled === false) return;
|
|
665
|
+
try {
|
|
666
|
+
const response = yield fetch(url, {
|
|
667
|
+
method: 'POST',
|
|
668
|
+
headers: {
|
|
669
|
+
'Content-Type': 'application/json'
|
|
670
|
+
},
|
|
671
|
+
body: JSON.stringify(data)
|
|
672
|
+
});
|
|
673
|
+
if (!response.ok) {
|
|
674
|
+
throw new Error(response.status.toString());
|
|
675
|
+
}
|
|
676
|
+
return response;
|
|
677
|
+
} catch (error) {
|
|
678
|
+
const errorMessage = 'Error with Saasco request: ' + error.message;
|
|
679
|
+
console.error(errorMessage, path, data);
|
|
680
|
+
return errorMessage;
|
|
665
681
|
}
|
|
666
|
-
}).catch(e => {
|
|
667
|
-
console.error('Error with Saasco request: ' + e.message, path, data);
|
|
668
682
|
});
|
|
669
683
|
}
|
|
670
684
|
/**
|
|
@@ -673,14 +687,10 @@ class Saasco {
|
|
|
673
687
|
log(...args) {
|
|
674
688
|
if (!this.config.debug) return;
|
|
675
689
|
const message = '◍ Saasco Debug';
|
|
676
|
-
console.
|
|
690
|
+
console.info(...[`\x1b[47m\x1b[30m ${message} \x1b[0m`,
|
|
677
691
|
// Message highlighted for easy finding
|
|
678
692
|
...args]);
|
|
679
693
|
}
|
|
680
|
-
getSearchParam(param) {
|
|
681
|
-
if (typeof window === 'undefined') return undefined;
|
|
682
|
-
return new URLSearchParams(window.location.search).get(param);
|
|
683
|
-
}
|
|
684
694
|
/**
|
|
685
695
|
* If autoPageTracking is enabled, this will automatically track page views
|
|
686
696
|
* It listens to url changes to track new pages every time the url changes
|
|
@@ -826,49 +836,88 @@ const tinyBirdBaseSchema = zod.z.object({
|
|
|
826
836
|
}),
|
|
827
837
|
rows: zod.z.number()
|
|
828
838
|
});
|
|
839
|
+
const TinybirdJobResponseSchema = zod.z.object({
|
|
840
|
+
id: zod.z.string(),
|
|
841
|
+
job_id: zod.z.string(),
|
|
842
|
+
job_url: zod.z.string().url(),
|
|
843
|
+
job: zod.z.object({
|
|
844
|
+
kind: zod.z.string(),
|
|
845
|
+
id: zod.z.string(),
|
|
846
|
+
job_id: zod.z.string(),
|
|
847
|
+
status: zod.z.string(),
|
|
848
|
+
created_at: zod.z.string(),
|
|
849
|
+
updated_at: zod.z.string(),
|
|
850
|
+
started_at: zod.z.string().nullable(),
|
|
851
|
+
is_cancellable: zod.z.boolean(),
|
|
852
|
+
datasource: zod.z.object({
|
|
853
|
+
id: zod.z.string(),
|
|
854
|
+
name: zod.z.string()
|
|
855
|
+
}),
|
|
856
|
+
delete_condition: zod.z.string().optional()
|
|
857
|
+
}),
|
|
858
|
+
status: zod.z.string(),
|
|
859
|
+
delete_id: zod.z.string().optional(),
|
|
860
|
+
import_id: zod.z.string().optional()
|
|
861
|
+
});
|
|
862
|
+
const latestEventsRequestSchema = zod.z.object({
|
|
863
|
+
projectId: zod.z.string(),
|
|
864
|
+
limit: zod.z.number().optional(),
|
|
865
|
+
payload: zod.z.boolean().optional()
|
|
866
|
+
});
|
|
867
|
+
const latestEventItemSchema = zod.z.object({
|
|
868
|
+
id: zod.z.string(),
|
|
869
|
+
timestamp: zod.z.string(),
|
|
870
|
+
action: zod.z.string(),
|
|
871
|
+
location: zod.z.string(),
|
|
872
|
+
referrer: zod.z.string(),
|
|
873
|
+
href: zod.z.string(),
|
|
874
|
+
device: zod.z.string(),
|
|
875
|
+
browser: zod.z.string(),
|
|
876
|
+
payload: zod.z.string().optional()
|
|
877
|
+
});
|
|
878
|
+
const latestEventsResponseSchema = tinyBirdBaseSchema.extend({
|
|
879
|
+
data: zod.z.array(latestEventItemSchema)
|
|
880
|
+
});
|
|
829
881
|
const kpisRequestSchema = zod.z.object({
|
|
830
882
|
projectId: zod.z.string(),
|
|
831
883
|
dateTo: zod.z.string().optional(),
|
|
832
884
|
dateFrom: zod.z.string().optional(),
|
|
833
|
-
|
|
885
|
+
referrer: zod.z.string().optional(),
|
|
834
886
|
location: zod.z.string().optional()
|
|
835
887
|
});
|
|
836
888
|
const kpisResponseSchema = tinyBirdBaseSchema.extend({
|
|
837
889
|
data: zod.z.array(zod.z.object({
|
|
838
890
|
date: zod.z.string(),
|
|
839
|
-
|
|
840
|
-
|
|
891
|
+
users: zod.z.number(),
|
|
892
|
+
sessions: zod.z.number(),
|
|
893
|
+
pageViews: zod.z.number(),
|
|
894
|
+
events: zod.z.number(),
|
|
841
895
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
842
896
|
avgSessionSec: zod.z.number()
|
|
843
897
|
}))
|
|
844
898
|
});
|
|
845
|
-
const eventsKpisResponseSchema = tinyBirdBaseSchema.extend({
|
|
846
|
-
data: zod.z.array(zod.z.object({
|
|
847
|
-
unique: zod.z.number(),
|
|
848
|
-
total: zod.z.number()
|
|
849
|
-
}))
|
|
850
|
-
});
|
|
851
899
|
const baseTopRequestSchema = zod.z.object({
|
|
852
900
|
projectId: zod.z.string(),
|
|
853
901
|
dateTo: zod.z.string().optional(),
|
|
854
902
|
dateFrom: zod.z.string().optional(),
|
|
855
903
|
limit: zod.z.number().optional(),
|
|
856
904
|
skip: zod.z.number().optional(),
|
|
857
|
-
|
|
905
|
+
referrer: zod.z.string().optional(),
|
|
858
906
|
location: zod.z.string().optional()
|
|
859
907
|
});
|
|
860
908
|
const topPagesResponseSchema = tinyBirdBaseSchema.extend({
|
|
861
909
|
data: zod.z.array(zod.z.object({
|
|
862
910
|
pathname: zod.z.string(),
|
|
863
|
-
|
|
864
|
-
|
|
911
|
+
users: zod.z.number(),
|
|
912
|
+
events: zod.z.number()
|
|
865
913
|
}))
|
|
866
914
|
});
|
|
867
915
|
const topLocationsResponseSchema = tinyBirdBaseSchema.extend({
|
|
868
916
|
data: zod.z.array(zod.z.object({
|
|
869
917
|
location: zod.z.string(),
|
|
870
|
-
|
|
871
|
-
|
|
918
|
+
users: zod.z.number(),
|
|
919
|
+
sessions: zod.z.number(),
|
|
920
|
+
pageViews: zod.z.number(),
|
|
872
921
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
873
922
|
avgSessionSec: zod.z.number()
|
|
874
923
|
}))
|
|
@@ -893,8 +942,9 @@ const topBrowsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
893
942
|
});
|
|
894
943
|
const topSourcesSchema = zod.z.object({
|
|
895
944
|
referrer: zod.z.string(),
|
|
896
|
-
|
|
897
|
-
|
|
945
|
+
users: zod.z.number(),
|
|
946
|
+
sessions: zod.z.number(),
|
|
947
|
+
pageViews: zod.z.number(),
|
|
898
948
|
bounceRate: zod.z.nullable(zod.z.number()),
|
|
899
949
|
avgSessionSec: zod.z.number()
|
|
900
950
|
});
|
|
@@ -904,8 +954,8 @@ const topSourcesResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
904
954
|
const topActionsResponseSchema = tinyBirdBaseSchema.extend({
|
|
905
955
|
data: zod.z.array(zod.z.object({
|
|
906
956
|
action: zod.z.string(),
|
|
907
|
-
|
|
908
|
-
|
|
957
|
+
users: zod.z.number(),
|
|
958
|
+
events: zod.z.number()
|
|
909
959
|
}))
|
|
910
960
|
});
|
|
911
961
|
const analyticsEventSchema = zod.z.object({
|
|
@@ -914,6 +964,7 @@ const analyticsEventSchema = zod.z.object({
|
|
|
914
964
|
projectId: zod.z.string(),
|
|
915
965
|
anonymousId: zod.z.string(),
|
|
916
966
|
sessionId: zod.z.string(),
|
|
967
|
+
distinctId: zod.z.string().optional(),
|
|
917
968
|
version: zod.z.string(),
|
|
918
969
|
action: zod.z.string(),
|
|
919
970
|
payload: zod.z.string()
|
|
@@ -924,7 +975,7 @@ const userEventsResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
924
975
|
const currentUsersRequestSchema = zod.z.object({
|
|
925
976
|
projectId: zod.z.string(),
|
|
926
977
|
minutes: zod.z.number().optional(),
|
|
927
|
-
|
|
978
|
+
referrer: zod.z.string().optional(),
|
|
928
979
|
location: zod.z.string().optional()
|
|
929
980
|
});
|
|
930
981
|
const currentUsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
@@ -933,7 +984,7 @@ const currentUsersResponseSchema = tinyBirdBaseSchema.extend({
|
|
|
933
984
|
}))
|
|
934
985
|
});
|
|
935
986
|
const reservedPropertiesSchema = zod.z.object({
|
|
936
|
-
age: zod.z.number().nullish(),
|
|
987
|
+
age: zod.z.number().or(zod.z.string()).nullish(),
|
|
937
988
|
avatar: zod.z.string().url().nullish(),
|
|
938
989
|
birthday: zod.z.string().nullish(),
|
|
939
990
|
createdAt: zod.z.string().nullish(),
|
|
@@ -947,9 +998,11 @@ const reservedPropertiesSchema = zod.z.object({
|
|
|
947
998
|
phone: zod.z.string().nullish(),
|
|
948
999
|
title: zod.z.string().nullish(),
|
|
949
1000
|
username: zod.z.string().nullish(),
|
|
950
|
-
website: zod.z.string().nullish()
|
|
1001
|
+
website: zod.z.string().nullish(),
|
|
1002
|
+
$id: zod.z.string().nullish(),
|
|
1003
|
+
$lastSeen: zod.z.string().nullish()
|
|
951
1004
|
});
|
|
952
|
-
const
|
|
1005
|
+
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()]))])));
|
|
953
1006
|
const analyticsUserRawSchema = zod.z.object({
|
|
954
1007
|
timestamp: zod.z.string(),
|
|
955
1008
|
distinctId: zod.z.string(),
|
|
@@ -959,7 +1012,7 @@ const analyticsUserRawSchema = zod.z.object({
|
|
|
959
1012
|
const analyticsUserSchema = analyticsUserRawSchema.omit({
|
|
960
1013
|
payload: true
|
|
961
1014
|
}).and(zod.z.object({
|
|
962
|
-
properties:
|
|
1015
|
+
properties: contactPropertiesSchema
|
|
963
1016
|
}));
|
|
964
1017
|
const listUsersParamsSchema = zod.z.object({
|
|
965
1018
|
projectId: zod.z.string(),
|
|
@@ -976,28 +1029,45 @@ const idenfitySchema = zod.z.object({
|
|
|
976
1029
|
distinctId: zod.z.string(),
|
|
977
1030
|
anonymousId: zod.z.string(),
|
|
978
1031
|
version: zod.z.string(),
|
|
979
|
-
payload:
|
|
980
|
-
|
|
1032
|
+
payload: contactPropertiesSchema,
|
|
1033
|
+
context: zod.z.object({
|
|
981
1034
|
active: zod.z.boolean().optional()
|
|
982
1035
|
}).optional()
|
|
983
1036
|
});
|
|
1037
|
+
const latestIdentifiesRequestSchema = zod.z.object({
|
|
1038
|
+
projectId: zod.z.string(),
|
|
1039
|
+
limit: zod.z.number().optional(),
|
|
1040
|
+
fields: zod.z.array(zod.z.string()).optional()
|
|
1041
|
+
});
|
|
1042
|
+
const latestIdentifiesResponseSchema = tinyBirdBaseSchema.extend({
|
|
1043
|
+
data: zod.z.array(zod.z.object({
|
|
1044
|
+
properties: contactPropertiesSchema
|
|
1045
|
+
}))
|
|
1046
|
+
});
|
|
984
1047
|
|
|
985
1048
|
exports.Saasco = Saasco;
|
|
1049
|
+
exports.TinybirdJobResponseSchema = TinybirdJobResponseSchema;
|
|
986
1050
|
exports.analyticsEventSchema = analyticsEventSchema;
|
|
987
1051
|
exports.analyticsUserRawSchema = analyticsUserRawSchema;
|
|
988
1052
|
exports.analyticsUserSchema = analyticsUserSchema;
|
|
989
1053
|
exports.baseTopRequestSchema = baseTopRequestSchema;
|
|
990
1054
|
exports.coerceReservedProperties = coerceReservedProperties;
|
|
1055
|
+
exports.contactPropertiesSchema = contactPropertiesSchema;
|
|
991
1056
|
exports.currentUsersRequestSchema = currentUsersRequestSchema;
|
|
992
1057
|
exports.currentUsersResponseSchema = currentUsersResponseSchema;
|
|
993
|
-
exports.eventsKpisResponseSchema = eventsKpisResponseSchema;
|
|
994
1058
|
exports.getAnalyticsUserParamsSchema = getAnalyticsUserParamsSchema;
|
|
995
1059
|
exports.idenfitySchema = idenfitySchema;
|
|
996
1060
|
exports.kpisRequestSchema = kpisRequestSchema;
|
|
997
1061
|
exports.kpisResponseSchema = kpisResponseSchema;
|
|
1062
|
+
exports.latestEventItemSchema = latestEventItemSchema;
|
|
1063
|
+
exports.latestEventsRequestSchema = latestEventsRequestSchema;
|
|
1064
|
+
exports.latestEventsResponseSchema = latestEventsResponseSchema;
|
|
1065
|
+
exports.latestIdentifiesRequestSchema = latestIdentifiesRequestSchema;
|
|
1066
|
+
exports.latestIdentifiesResponseSchema = latestIdentifiesResponseSchema;
|
|
998
1067
|
exports.listUsersParamsSchema = listUsersParamsSchema;
|
|
999
1068
|
exports.reservedPropertiesSchema = reservedPropertiesSchema;
|
|
1000
1069
|
exports.tbAny = tbAny;
|
|
1070
|
+
exports.timezones = timezones;
|
|
1001
1071
|
exports.tinyBirdBaseSchema = tinyBirdBaseSchema;
|
|
1002
1072
|
exports.topActionsResponseSchema = topActionsResponseSchema;
|
|
1003
1073
|
exports.topBrowsersResponseSchema = topBrowsersResponseSchema;
|
|
@@ -1007,4 +1077,3 @@ exports.topPagesResponseSchema = topPagesResponseSchema;
|
|
|
1007
1077
|
exports.topSourcesResponseSchema = topSourcesResponseSchema;
|
|
1008
1078
|
exports.topSourcesSchema = topSourcesSchema;
|
|
1009
1079
|
exports.userEventsResponseSchema = userEventsResponseSchema;
|
|
1010
|
-
exports.userPropertiesSchema = userPropertiesSchema;
|