saasco-sdk 0.1.17 → 0.1.18

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.17";
9
+ var version = "0.1.18";
10
10
 
11
11
  const timezones = {
12
12
  'Asia/Barnaul': 'RU',
@@ -665,7 +665,7 @@ class Saasco {
665
665
  // This should only be called when distinctId is null and there is an existing userId.
666
666
  // This means the user has logged out and we should reset the session and anonymous IDs
667
667
  const userIdChangedToNull = distinctId === null && !!getUserId();
668
- if (userIdChangedToNull) this.log('User ID change to null. Session reset');
668
+ if (userIdChangedToNull) this.log('User logged out');
669
669
  const reset = userIdChangedToNull;
670
670
  setSessionId({
671
671
  reset
@@ -677,7 +677,7 @@ class Saasco {
677
677
  setUserId(distinctId);
678
678
  // No distinctId provided so we don't track the user
679
679
  if (!distinctId) return Promise.resolve({
680
- success: false,
680
+ success: true,
681
681
  message: 'No distinctId provided'
682
682
  });
683
683
  const data = {
@@ -692,6 +692,16 @@ class Saasco {
692
692
  };
693
693
  return this.doRequest('identify', data);
694
694
  }
695
+ /**
696
+ * This should only be called when the user logs out
697
+ * It will reset the session, anonymous id, and user id
698
+ *
699
+ * All events after calling reset will be tracked as a new user
700
+ *
701
+ */
702
+ logout() {
703
+ this.identify(null);
704
+ }
695
705
  /**
696
706
  * Handles sending data to the Saasco API
697
707
  * If you have a proxy set up, it will send the data to the proxy and you can handle forawrding the data to the Saasco events API
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.17";
5
+ var version = "0.1.18";
6
6
 
7
7
  const timezones = {
8
8
  'Asia/Barnaul': 'RU',
@@ -661,7 +661,7 @@ class Saasco {
661
661
  // This should only be called when distinctId is null and there is an existing userId.
662
662
  // This means the user has logged out and we should reset the session and anonymous IDs
663
663
  const userIdChangedToNull = distinctId === null && !!getUserId();
664
- if (userIdChangedToNull) this.log('User ID change to null. Session reset');
664
+ if (userIdChangedToNull) this.log('User logged out');
665
665
  const reset = userIdChangedToNull;
666
666
  setSessionId({
667
667
  reset
@@ -673,7 +673,7 @@ class Saasco {
673
673
  setUserId(distinctId);
674
674
  // No distinctId provided so we don't track the user
675
675
  if (!distinctId) return Promise.resolve({
676
- success: false,
676
+ success: true,
677
677
  message: 'No distinctId provided'
678
678
  });
679
679
  const data = {
@@ -688,6 +688,16 @@ class Saasco {
688
688
  };
689
689
  return this.doRequest('identify', data);
690
690
  }
691
+ /**
692
+ * This should only be called when the user logs out
693
+ * It will reset the session, anonymous id, and user id
694
+ *
695
+ * All events after calling reset will be tracked as a new user
696
+ *
697
+ */
698
+ logout() {
699
+ this.identify(null);
700
+ }
691
701
  /**
692
702
  * Handles sending data to the Saasco API
693
703
  * If you have a proxy set up, it will send the data to the proxy and you can handle forawrding the data to the Saasco events API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",
@@ -71,6 +71,14 @@ export declare class Saasco {
71
71
  identify(distinctId: string | number | null, properties?: Record<string, any>, context?: {
72
72
  active?: boolean;
73
73
  }): Promise<DoRequestResponse>;
74
+ /**
75
+ * This should only be called when the user logs out
76
+ * It will reset the session, anonymous id, and user id
77
+ *
78
+ * All events after calling reset will be tracked as a new user
79
+ *
80
+ */
81
+ logout(): void;
74
82
  /**
75
83
  * Handles sending data to the Saasco API
76
84
  * If you have a proxy set up, it will send the data to the proxy and you can handle forawrding the data to the Saasco events API