@miso.ai/client-sdk-core 1.10.2-beta.7 → 1.10.2-beta.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/dist/cjs/plugin/user.js +7 -12
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/plugin/user.js +8 -12
- package/src/version.js +1 -1
package/dist/cjs/plugin/user.js
CHANGED
|
@@ -26,7 +26,7 @@ class UserPlugin extends _commons.Component {
|
|
|
26
26
|
_injectClient(client) {
|
|
27
27
|
const context = new UserContext(this);
|
|
28
28
|
this._contexts.set(client, context);
|
|
29
|
-
(0, _commons.delegateProperties)(client.context, context, ['anonymous_id', 'user_id', 'user_hash']);
|
|
29
|
+
(0, _commons.delegateProperties)(client.context, context, ['anonymous_id', 'user_id', 'user_hash', 'user_type']);
|
|
30
30
|
}
|
|
31
31
|
_modifyPayload(_ref) {
|
|
32
32
|
let {
|
|
@@ -94,24 +94,19 @@ class UserPlugin extends _commons.Component {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
exports.default = UserPlugin;
|
|
97
|
+
let _pageBasedAutoAnonymousId;
|
|
97
98
|
function getAutoAnonymousId() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// in this case, abort getting the auto anonymous id
|
|
103
|
-
if (e.name !== 'SecurityError') {
|
|
104
|
-
throw e;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return [];
|
|
99
|
+
// 1. Cache the value for the page
|
|
100
|
+
// 2. Get and set the value from cookies/localStorage is possible
|
|
101
|
+
// 3. In case cookies/localStorage are disabled, generate a new value for each page
|
|
102
|
+
return _pageBasedAutoAnonymousId || (_pageBasedAutoAnonymousId = (0, _commons.getOrComputeFromStorage)('miso_anonymous_id', _commons.uuidv4));
|
|
108
103
|
}
|
|
109
104
|
class UserContext {
|
|
110
105
|
constructor(plugin) {
|
|
111
106
|
this._plugin = plugin;
|
|
112
107
|
}
|
|
113
108
|
get anonymous_id() {
|
|
114
|
-
return this._anonymousId ||
|
|
109
|
+
return this._anonymousId || getAutoAnonymousId();
|
|
115
110
|
}
|
|
116
111
|
set anonymous_id(value) {
|
|
117
112
|
value = (0, _commons.asString)(value);
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
package/src/plugin/user.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class UserPlugin extends Component {
|
|
|
24
24
|
_injectClient(client) {
|
|
25
25
|
const context = new UserContext(this);
|
|
26
26
|
this._contexts.set(client, context);
|
|
27
|
-
delegateProperties(client.context, context, ['anonymous_id', 'user_id', 'user_hash']);
|
|
27
|
+
delegateProperties(client.context, context, ['anonymous_id', 'user_id', 'user_hash', 'user_type']);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
_modifyPayload({ client, apiGroup, apiName, payload }) {
|
|
@@ -61,17 +61,13 @@ export default class UserPlugin extends Component {
|
|
|
61
61
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
let _pageBasedAutoAnonymousId;
|
|
65
|
+
|
|
64
66
|
function getAutoAnonymousId() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// in this case, abort getting the auto anonymous id
|
|
70
|
-
if (e.name !== 'SecurityError') {
|
|
71
|
-
throw e;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return [];
|
|
67
|
+
// 1. Cache the value for the page
|
|
68
|
+
// 2. Get and set the value from cookies/localStorage is possible
|
|
69
|
+
// 3. In case cookies/localStorage are disabled, generate a new value for each page
|
|
70
|
+
return _pageBasedAutoAnonymousId || (_pageBasedAutoAnonymousId = getOrComputeFromStorage('miso_anonymous_id', uuidv4));
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
class UserContext {
|
|
@@ -81,7 +77,7 @@ class UserContext {
|
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
get anonymous_id() {
|
|
84
|
-
return this._anonymousId ||
|
|
80
|
+
return this._anonymousId || getAutoAnonymousId();
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
set anonymous_id(value) {
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.2-beta.
|
|
1
|
+
export default '1.10.2-beta.9';
|