saasco-sdk 0.1.6 → 0.1.7

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
@@ -611,8 +611,12 @@ class Saasco {
611
611
  // When the user gets identified as null this will reset the users session and anonymous id
612
612
  // This should only be called when distinctId is null and there is an existing userId.
613
613
  // This means the user has logged out and we should reset the session and anonymous IDs
614
- const reset = !distinctId && !!userId;
615
- if (reset) this.log('User logged out and session reset');
614
+ const userIdChangedToNull = !distinctId && !!userId;
615
+ if (userIdChangedToNull) this.log('User ID change to null. Session reset');
616
+ // If we have a userId, but a new user ID is provided, we should reset the session and anonymous IDs
617
+ const userIdChanged = !!userId && distinctId !== userId;
618
+ if (userIdChanged) this.log('User ID changed. Session reset');
619
+ const reset = userIdChangedToNull || userIdChanged;
616
620
  setSessionId({
617
621
  reset
618
622
  });
@@ -768,8 +772,7 @@ function coerceReservedProperties(properties) {
768
772
  schema: zod.z.coerce.string().url().optional()
769
773
  }, {
770
774
  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()
775
+ 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
776
  }];
774
777
  return coerce.reduce((acc, {
775
778
  key,
package/index.esm.js CHANGED
@@ -607,8 +607,12 @@ class Saasco {
607
607
  // When the user gets identified as null this will reset the users session and anonymous id
608
608
  // This should only be called when distinctId is null and there is an existing userId.
609
609
  // This means the user has logged out and we should reset the session and anonymous IDs
610
- const reset = !distinctId && !!userId;
611
- if (reset) this.log('User logged out and session reset');
610
+ const userIdChangedToNull = !distinctId && !!userId;
611
+ if (userIdChangedToNull) this.log('User ID change to null. Session reset');
612
+ // If we have a userId, but a new user ID is provided, we should reset the session and anonymous IDs
613
+ const userIdChanged = !!userId && distinctId !== userId;
614
+ if (userIdChanged) this.log('User ID changed. Session reset');
615
+ const reset = userIdChangedToNull || userIdChanged;
612
616
  setSessionId({
613
617
  reset
614
618
  });
@@ -764,8 +768,7 @@ function coerceReservedProperties(properties) {
764
768
  schema: z.coerce.string().url().optional()
765
769
  }, {
766
770
  key: 'displayName',
767
- coerceFrom: ['display_name', 'displayName', 'user_display_name', 'userDisplayName', 'full_name', 'fullName', 'user_full_name', 'userFullName', 'complete_name', 'completeName', 'user_complete_name', 'userCompleteName', 'name', 'username'],
768
- schema: z.coerce.string().url().optional()
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']
769
772
  }];
770
773
  return coerce.reduce((acc, {
771
774
  key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",