@miso.ai/client-sdk-core 1.10.2-beta.7 → 1.10.2-beta.8
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 +6 -4
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/plugin/user.js +7 -4
- 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,9 +94,10 @@ class UserPlugin extends _commons.Component {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
exports.default = UserPlugin;
|
|
97
|
+
let _pageBasedAutoAnonymousId;
|
|
97
98
|
function getAutoAnonymousId() {
|
|
98
99
|
try {
|
|
99
|
-
return
|
|
100
|
+
return (0, _commons.getOrComputeFromStorage)('miso_anonymous_id', _commons.uuidv4);
|
|
100
101
|
} catch (e) {
|
|
101
102
|
// if the SDK is loaded as a 3rd party script, accessing cookie/localStorage may throw a SecurityError
|
|
102
103
|
// in this case, abort getting the auto anonymous id
|
|
@@ -104,14 +105,15 @@ function getAutoAnonymousId() {
|
|
|
104
105
|
throw e;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
// fallback to page-based auto anonymous id
|
|
109
|
+
return _pageBasedAutoAnonymousId || (_pageBasedAutoAnonymousId = (0, _commons.uuidv4)());
|
|
108
110
|
}
|
|
109
111
|
class UserContext {
|
|
110
112
|
constructor(plugin) {
|
|
111
113
|
this._plugin = plugin;
|
|
112
114
|
}
|
|
113
115
|
get anonymous_id() {
|
|
114
|
-
return this._anonymousId ||
|
|
116
|
+
return this._anonymousId || this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId());
|
|
115
117
|
}
|
|
116
118
|
set anonymous_id(value) {
|
|
117
119
|
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,9 +61,11 @@ export default class UserPlugin extends Component {
|
|
|
61
61
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
let _pageBasedAutoAnonymousId;
|
|
65
|
+
|
|
64
66
|
function getAutoAnonymousId() {
|
|
65
67
|
try {
|
|
66
|
-
return
|
|
68
|
+
return getOrComputeFromStorage('miso_anonymous_id', uuidv4);
|
|
67
69
|
} catch (e) {
|
|
68
70
|
// if the SDK is loaded as a 3rd party script, accessing cookie/localStorage may throw a SecurityError
|
|
69
71
|
// in this case, abort getting the auto anonymous id
|
|
@@ -71,7 +73,8 @@ function getAutoAnonymousId() {
|
|
|
71
73
|
throw e;
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
|
-
|
|
76
|
+
// fallback to page-based auto anonymous id
|
|
77
|
+
return _pageBasedAutoAnonymousId || (_pageBasedAutoAnonymousId = uuidv4());
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
class UserContext {
|
|
@@ -81,7 +84,7 @@ class UserContext {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
get anonymous_id() {
|
|
84
|
-
return this._anonymousId ||
|
|
87
|
+
return this._anonymousId || this._autoAnonymousId || (this._autoAnonymousId = getAutoAnonymousId());
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
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.8';
|