@miso.ai/client-sdk-core 1.10.2-beta.6 → 1.10.2-beta.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.
@@ -83,11 +83,11 @@ class UserPlugin extends _commons.Component {
83
83
  anonymous_id,
84
84
  user_id
85
85
  } = client.context;
86
- const baseObj = (0, _commons.trimObj)({
86
+ const userInfo = (0, _commons.trimObj)({
87
87
  anonymous_id,
88
88
  user_id
89
89
  });
90
- data = data.map(obj => Object.assign({}, baseObj, obj));
90
+ data = data.map(obj => Object.assign({}, userInfo, obj));
91
91
  return {
92
92
  data
93
93
  };
@@ -95,14 +95,23 @@ class UserPlugin extends _commons.Component {
95
95
  }
96
96
  exports.default = UserPlugin;
97
97
  function getAutoAnonymousId() {
98
- return (0, _commons.getOrComputeFromStorage)('miso_anonymous_id', _commons.uuidv4);
98
+ try {
99
+ return [(0, _commons.getOrComputeFromStorage)('miso_anonymous_id', _commons.uuidv4)];
100
+ } catch (e) {
101
+ // if the SDK is loaded as a 3rd party script, accessing cookie/localStorage may throw a SecurityError
102
+ // in this case, abort getting the auto anonymous id
103
+ if (e.name !== 'SecurityError') {
104
+ throw e;
105
+ }
106
+ }
107
+ return [];
99
108
  }
100
109
  class UserContext {
101
110
  constructor(plugin) {
102
111
  this._plugin = plugin;
103
112
  }
104
113
  get anonymous_id() {
105
- return this._anonymousId || this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId());
114
+ return this._anonymousId || (this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId()))[0];
106
115
  }
107
116
  set anonymous_id(value) {
108
117
  value = (0, _commons.asString)(value);
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.10.2-beta.6';
7
+ var _default = exports.default = '1.10.2-beta.7';
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@miso.ai/commons": "1.10.2-beta.6"
32
+ "@miso.ai/commons": "1.10.2-beta.7"
33
33
  },
34
- "version": "1.10.2-beta.6"
34
+ "version": "1.10.2-beta.7"
35
35
  }
@@ -54,15 +54,24 @@ export default class UserPlugin extends Component {
54
54
 
55
55
  _modifyPayloadForInteractions(client, { data }) {
56
56
  const { anonymous_id, user_id } = client.context;
57
- const baseObj = trimObj({ anonymous_id, user_id });
58
- data = data.map(obj => ({ ...baseObj, ...obj }));
57
+ const userInfo = trimObj({ anonymous_id, user_id });
58
+ data = data.map(obj => ({ ...userInfo, ...obj }));
59
59
  return { data };
60
60
  }
61
61
 
62
62
  }
63
63
 
64
64
  function getAutoAnonymousId() {
65
- return getOrComputeFromStorage('miso_anonymous_id', uuidv4);
65
+ try {
66
+ return [getOrComputeFromStorage('miso_anonymous_id', uuidv4)];
67
+ } catch (e) {
68
+ // if the SDK is loaded as a 3rd party script, accessing cookie/localStorage may throw a SecurityError
69
+ // in this case, abort getting the auto anonymous id
70
+ if (e.name !== 'SecurityError') {
71
+ throw e;
72
+ }
73
+ }
74
+ return [];
66
75
  }
67
76
 
68
77
  class UserContext {
@@ -72,7 +81,7 @@ class UserContext {
72
81
  }
73
82
 
74
83
  get anonymous_id() {
75
- return this._anonymousId || this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId());
84
+ return this._anonymousId || (this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId()))[0];
76
85
  }
77
86
 
78
87
  set anonymous_id(value) {
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.10.2-beta.6';
1
+ export default '1.10.2-beta.7';