saasco-sdk 0.1.18 → 0.1.20

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/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.18";
9
+ var version = "0.1.20";
10
10
 
11
11
  const timezones = {
12
12
  'Asia/Barnaul': 'RU',
@@ -579,6 +579,8 @@ class Saasco {
579
579
  window.saasco = this;
580
580
  }
581
581
  this.log('Saasco initialized', this.config);
582
+ if (this.config.debug) this.log('Debug mode active. This will log all events to the console.');
583
+ if (!this.config.enabled) this.log('Analytics is disabled. No requests will be sent to the server.');
582
584
  this.initiAutoPageTracking();
583
585
  this.isInitialized = true;
584
586
  }
@@ -712,9 +714,11 @@ class Saasco {
712
714
  return tslib.__awaiter(this, void 0, void 0, function* () {
713
715
  const base = this.config.proxy || 'https://www.saasco.com/api/';
714
716
  const url = `${base}${path}`;
715
- const logMessage = data.action === 'Page View' ? `Page View ${window.location.pathname}` // if its a page view, include pathname in console log
716
- : data.action || path;
717
- this.log(logMessage, data);
717
+ if (data.action === 'Page View') {
718
+ this.log('Page View', window.location.href, data);
719
+ } else {
720
+ this.log(data.action || path, data);
721
+ }
718
722
  // If analytics is disabled, don't send the request
719
723
  if (this.config.enabled === false) return {
720
724
  success: false,
@@ -751,18 +755,18 @@ class Saasco {
751
755
  log(...args) {
752
756
  if (!this.config.debug) return;
753
757
  const message = '◍ Saasco Debug';
754
- console.info(...[`\x1b[47m\x1b[30m ${message} \x1b[0m`,
758
+ console.info(
755
759
  // Message highlighted for easy finding
756
- ...args]);
760
+ `%c ${message}`, 'background: #eee; color: #000; padding: 2px 4px; border-radius: 2px;', ...args);
757
761
  }
758
762
  /**
759
763
  * @param args Arguments to be logged
760
764
  */
761
765
  error(...args) {
762
766
  const message = '◍ Saasco Error';
763
- console.error(...[`\x1b[41m\x1b[37m ${message} \x1b[0m`,
767
+ console.error(
764
768
  // Message highlighted for easy finding
765
- ...args]);
769
+ `%c ${message}`, 'background: red; color: white; padding: 2px 4px; border-radius: 2px;', ...args);
766
770
  return {
767
771
  success: false,
768
772
  message: args.join(' ')
@@ -1151,6 +1155,7 @@ const reservedPropertiesSchema = zod.z.object({
1151
1155
  // Default Properties
1152
1156
  $id: zod.z.string().nullish(),
1153
1157
  $lastSeen: zod.z.string().nullish(),
1158
+ $lastIdentifiedAt: zod.z.string().nullish(),
1154
1159
  $unsubscribed: zod.z.boolean().nullish(),
1155
1160
  $unsubscribeReason: zod.z.enum(['manual', 'complained', 'bounced']).nullish(),
1156
1161
  // Stripe Properties
package/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { __awaiter } from 'tslib';
2
2
  import { v4 } from '@lukeed/uuid';
3
3
  import { z } from 'zod';
4
4
 
5
- var version = "0.1.18";
5
+ var version = "0.1.20";
6
6
 
7
7
  const timezones = {
8
8
  'Asia/Barnaul': 'RU',
@@ -575,6 +575,8 @@ class Saasco {
575
575
  window.saasco = this;
576
576
  }
577
577
  this.log('Saasco initialized', this.config);
578
+ if (this.config.debug) this.log('Debug mode active. This will log all events to the console.');
579
+ if (!this.config.enabled) this.log('Analytics is disabled. No requests will be sent to the server.');
578
580
  this.initiAutoPageTracking();
579
581
  this.isInitialized = true;
580
582
  }
@@ -708,9 +710,11 @@ class Saasco {
708
710
  return __awaiter(this, void 0, void 0, function* () {
709
711
  const base = this.config.proxy || 'https://www.saasco.com/api/';
710
712
  const url = `${base}${path}`;
711
- const logMessage = data.action === 'Page View' ? `Page View ${window.location.pathname}` // if its a page view, include pathname in console log
712
- : data.action || path;
713
- this.log(logMessage, data);
713
+ if (data.action === 'Page View') {
714
+ this.log('Page View', window.location.href, data);
715
+ } else {
716
+ this.log(data.action || path, data);
717
+ }
714
718
  // If analytics is disabled, don't send the request
715
719
  if (this.config.enabled === false) return {
716
720
  success: false,
@@ -747,18 +751,18 @@ class Saasco {
747
751
  log(...args) {
748
752
  if (!this.config.debug) return;
749
753
  const message = '◍ Saasco Debug';
750
- console.info(...[`\x1b[47m\x1b[30m ${message} \x1b[0m`,
754
+ console.info(
751
755
  // Message highlighted for easy finding
752
- ...args]);
756
+ `%c ${message}`, 'background: #eee; color: #000; padding: 2px 4px; border-radius: 2px;', ...args);
753
757
  }
754
758
  /**
755
759
  * @param args Arguments to be logged
756
760
  */
757
761
  error(...args) {
758
762
  const message = '◍ Saasco Error';
759
- console.error(...[`\x1b[41m\x1b[37m ${message} \x1b[0m`,
763
+ console.error(
760
764
  // Message highlighted for easy finding
761
- ...args]);
765
+ `%c ${message}`, 'background: red; color: white; padding: 2px 4px; border-radius: 2px;', ...args);
762
766
  return {
763
767
  success: false,
764
768
  message: args.join(' ')
@@ -1147,6 +1151,7 @@ const reservedPropertiesSchema = z.object({
1147
1151
  // Default Properties
1148
1152
  $id: z.string().nullish(),
1149
1153
  $lastSeen: z.string().nullish(),
1154
+ $lastIdentifiedAt: z.string().nullish(),
1150
1155
  $unsubscribed: z.boolean().nullish(),
1151
1156
  $unsubscribeReason: z.enum(['manual', 'complained', 'bounced']).nullish(),
1152
1157
  // Stripe Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",
@@ -1232,6 +1232,7 @@ export declare const reservedPropertiesSchema: z.ZodObject<{
1232
1232
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1233
1233
  $id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1234
1234
  $lastSeen: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1235
+ $lastIdentifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1235
1236
  $unsubscribed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
1236
1237
  $unsubscribeReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<["manual", "complained", "bounced"]>>>;
1237
1238
  $stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1256,6 +1257,7 @@ export declare const reservedPropertiesSchema: z.ZodObject<{
1256
1257
  website?: string | null | undefined;
1257
1258
  $id?: string | null | undefined;
1258
1259
  $lastSeen?: string | null | undefined;
1260
+ $lastIdentifiedAt?: string | null | undefined;
1259
1261
  $unsubscribed?: boolean | null | undefined;
1260
1262
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1261
1263
  $stripeCustomerId?: string | null | undefined;
@@ -1280,6 +1282,7 @@ export declare const reservedPropertiesSchema: z.ZodObject<{
1280
1282
  website?: string | null | undefined;
1281
1283
  $id?: string | null | undefined;
1282
1284
  $lastSeen?: string | null | undefined;
1285
+ $lastIdentifiedAt?: string | null | undefined;
1283
1286
  $unsubscribed?: boolean | null | undefined;
1284
1287
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1285
1288
  $stripeCustomerId?: string | null | undefined;
@@ -1306,6 +1309,7 @@ export declare const contactPropertiesSchema: z.ZodIntersection<z.ZodOptional<z.
1306
1309
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1307
1310
  $id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1308
1311
  $lastSeen: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1312
+ $lastIdentifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1309
1313
  $unsubscribed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
1310
1314
  $unsubscribeReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<["manual", "complained", "bounced"]>>>;
1311
1315
  $stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1330,6 +1334,7 @@ export declare const contactPropertiesSchema: z.ZodIntersection<z.ZodOptional<z.
1330
1334
  website?: string | null | undefined;
1331
1335
  $id?: string | null | undefined;
1332
1336
  $lastSeen?: string | null | undefined;
1337
+ $lastIdentifiedAt?: string | null | undefined;
1333
1338
  $unsubscribed?: boolean | null | undefined;
1334
1339
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1335
1340
  $stripeCustomerId?: string | null | undefined;
@@ -1354,6 +1359,7 @@ export declare const contactPropertiesSchema: z.ZodIntersection<z.ZodOptional<z.
1354
1359
  website?: string | null | undefined;
1355
1360
  $id?: string | null | undefined;
1356
1361
  $lastSeen?: string | null | undefined;
1362
+ $lastIdentifiedAt?: string | null | undefined;
1357
1363
  $unsubscribed?: boolean | null | undefined;
1358
1364
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1359
1365
  $stripeCustomerId?: string | null | undefined;
@@ -1411,6 +1417,7 @@ export declare const analyticsUserSchema: z.ZodIntersection<z.ZodObject<Omit<{
1411
1417
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1412
1418
  $id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1413
1419
  $lastSeen: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1420
+ $lastIdentifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1414
1421
  $unsubscribed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
1415
1422
  $unsubscribeReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<["manual", "complained", "bounced"]>>>;
1416
1423
  $stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1435,6 +1442,7 @@ export declare const analyticsUserSchema: z.ZodIntersection<z.ZodObject<Omit<{
1435
1442
  website?: string | null | undefined;
1436
1443
  $id?: string | null | undefined;
1437
1444
  $lastSeen?: string | null | undefined;
1445
+ $lastIdentifiedAt?: string | null | undefined;
1438
1446
  $unsubscribed?: boolean | null | undefined;
1439
1447
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1440
1448
  $stripeCustomerId?: string | null | undefined;
@@ -1459,6 +1467,7 @@ export declare const analyticsUserSchema: z.ZodIntersection<z.ZodObject<Omit<{
1459
1467
  website?: string | null | undefined;
1460
1468
  $id?: string | null | undefined;
1461
1469
  $lastSeen?: string | null | undefined;
1470
+ $lastIdentifiedAt?: string | null | undefined;
1462
1471
  $unsubscribed?: boolean | null | undefined;
1463
1472
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1464
1473
  $stripeCustomerId?: string | null | undefined;
@@ -1485,6 +1494,7 @@ export declare const analyticsUserSchema: z.ZodIntersection<z.ZodObject<Omit<{
1485
1494
  website?: string | null | undefined;
1486
1495
  $id?: string | null | undefined;
1487
1496
  $lastSeen?: string | null | undefined;
1497
+ $lastIdentifiedAt?: string | null | undefined;
1488
1498
  $unsubscribed?: boolean | null | undefined;
1489
1499
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1490
1500
  $stripeCustomerId?: string | null | undefined;
@@ -1511,6 +1521,7 @@ export declare const analyticsUserSchema: z.ZodIntersection<z.ZodObject<Omit<{
1511
1521
  website?: string | null | undefined;
1512
1522
  $id?: string | null | undefined;
1513
1523
  $lastSeen?: string | null | undefined;
1524
+ $lastIdentifiedAt?: string | null | undefined;
1514
1525
  $unsubscribed?: boolean | null | undefined;
1515
1526
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1516
1527
  $stripeCustomerId?: string | null | undefined;
@@ -1567,6 +1578,7 @@ export declare const idenfitySchema: z.ZodObject<{
1567
1578
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1568
1579
  $id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1569
1580
  $lastSeen: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1581
+ $lastIdentifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1570
1582
  $unsubscribed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
1571
1583
  $unsubscribeReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<["manual", "complained", "bounced"]>>>;
1572
1584
  $stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1591,6 +1603,7 @@ export declare const idenfitySchema: z.ZodObject<{
1591
1603
  website?: string | null | undefined;
1592
1604
  $id?: string | null | undefined;
1593
1605
  $lastSeen?: string | null | undefined;
1606
+ $lastIdentifiedAt?: string | null | undefined;
1594
1607
  $unsubscribed?: boolean | null | undefined;
1595
1608
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1596
1609
  $stripeCustomerId?: string | null | undefined;
@@ -1615,6 +1628,7 @@ export declare const idenfitySchema: z.ZodObject<{
1615
1628
  website?: string | null | undefined;
1616
1629
  $id?: string | null | undefined;
1617
1630
  $lastSeen?: string | null | undefined;
1631
+ $lastIdentifiedAt?: string | null | undefined;
1618
1632
  $unsubscribed?: boolean | null | undefined;
1619
1633
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1620
1634
  $stripeCustomerId?: string | null | undefined;
@@ -1650,6 +1664,7 @@ export declare const idenfitySchema: z.ZodObject<{
1650
1664
  website?: string | null | undefined;
1651
1665
  $id?: string | null | undefined;
1652
1666
  $lastSeen?: string | null | undefined;
1667
+ $lastIdentifiedAt?: string | null | undefined;
1653
1668
  $unsubscribed?: boolean | null | undefined;
1654
1669
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1655
1670
  $stripeCustomerId?: string | null | undefined;
@@ -1685,6 +1700,7 @@ export declare const idenfitySchema: z.ZodObject<{
1685
1700
  website?: string | null | undefined;
1686
1701
  $id?: string | null | undefined;
1687
1702
  $lastSeen?: string | null | undefined;
1703
+ $lastIdentifiedAt?: string | null | undefined;
1688
1704
  $unsubscribed?: boolean | null | undefined;
1689
1705
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1690
1706
  $stripeCustomerId?: string | null | undefined;
@@ -1760,6 +1776,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1760
1776
  website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1761
1777
  $id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1762
1778
  $lastSeen: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1779
+ $lastIdentifiedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1763
1780
  $unsubscribed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
1764
1781
  $unsubscribeReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<["manual", "complained", "bounced"]>>>;
1765
1782
  $stripeCustomerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1784,6 +1801,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1784
1801
  website?: string | null | undefined;
1785
1802
  $id?: string | null | undefined;
1786
1803
  $lastSeen?: string | null | undefined;
1804
+ $lastIdentifiedAt?: string | null | undefined;
1787
1805
  $unsubscribed?: boolean | null | undefined;
1788
1806
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1789
1807
  $stripeCustomerId?: string | null | undefined;
@@ -1808,6 +1826,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1808
1826
  website?: string | null | undefined;
1809
1827
  $id?: string | null | undefined;
1810
1828
  $lastSeen?: string | null | undefined;
1829
+ $lastIdentifiedAt?: string | null | undefined;
1811
1830
  $unsubscribed?: boolean | null | undefined;
1812
1831
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1813
1832
  $stripeCustomerId?: string | null | undefined;
@@ -1834,6 +1853,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1834
1853
  website?: string | null | undefined;
1835
1854
  $id?: string | null | undefined;
1836
1855
  $lastSeen?: string | null | undefined;
1856
+ $lastIdentifiedAt?: string | null | undefined;
1837
1857
  $unsubscribed?: boolean | null | undefined;
1838
1858
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1839
1859
  $stripeCustomerId?: string | null | undefined;
@@ -1860,6 +1880,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1860
1880
  website?: string | null | undefined;
1861
1881
  $id?: string | null | undefined;
1862
1882
  $lastSeen?: string | null | undefined;
1883
+ $lastIdentifiedAt?: string | null | undefined;
1863
1884
  $unsubscribed?: boolean | null | undefined;
1864
1885
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1865
1886
  $stripeCustomerId?: string | null | undefined;
@@ -1898,6 +1919,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1898
1919
  website?: string | null | undefined;
1899
1920
  $id?: string | null | undefined;
1900
1921
  $lastSeen?: string | null | undefined;
1922
+ $lastIdentifiedAt?: string | null | undefined;
1901
1923
  $unsubscribed?: boolean | null | undefined;
1902
1924
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1903
1925
  $stripeCustomerId?: string | null | undefined;
@@ -1936,6 +1958,7 @@ export declare const latestIdentifiesResponseSchema: z.ZodObject<z.objectUtil.ex
1936
1958
  website?: string | null | undefined;
1937
1959
  $id?: string | null | undefined;
1938
1960
  $lastSeen?: string | null | undefined;
1961
+ $lastIdentifiedAt?: string | null | undefined;
1939
1962
  $unsubscribed?: boolean | null | undefined;
1940
1963
  $unsubscribeReason?: "manual" | "complained" | "bounced" | null | undefined;
1941
1964
  $stripeCustomerId?: string | null | undefined;