@miso.ai/client-sdk-core 1.10.2-beta.5 → 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.
- package/dist/cjs/api/helpers.js +2 -2
- package/dist/cjs/plugin/user.js +13 -4
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/api/helpers.js +2 -2
- package/src/plugin/user.js +13 -4
- package/src/version.js +1 -1
package/dist/cjs/api/helpers.js
CHANGED
|
@@ -153,7 +153,7 @@ class ApiHelpers {
|
|
|
153
153
|
url
|
|
154
154
|
}) || url;
|
|
155
155
|
} catch (e) {
|
|
156
|
-
component.error(e);
|
|
156
|
+
(component._error || console.error)(e);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
return url;
|
|
@@ -174,7 +174,7 @@ class ApiHelpers {
|
|
|
174
174
|
payload
|
|
175
175
|
}) || payload;
|
|
176
176
|
} catch (e) {
|
|
177
|
-
component.error(e);
|
|
177
|
+
(component._error || console.error)(e);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return payload;
|
package/dist/cjs/plugin/user.js
CHANGED
|
@@ -83,11 +83,11 @@ class UserPlugin extends _commons.Component {
|
|
|
83
83
|
anonymous_id,
|
|
84
84
|
user_id
|
|
85
85
|
} = client.context;
|
|
86
|
-
const
|
|
86
|
+
const userInfo = (0, _commons.trimObj)({
|
|
87
87
|
anonymous_id,
|
|
88
88
|
user_id
|
|
89
89
|
});
|
|
90
|
-
data = data.map(obj => Object.assign({},
|
|
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
|
-
|
|
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);
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
package/src/api/helpers.js
CHANGED
|
@@ -113,7 +113,7 @@ export default class ApiHelpers {
|
|
|
113
113
|
try {
|
|
114
114
|
url = pass({ client, apiGroup, apiName, url }) || url;
|
|
115
115
|
} catch(e) {
|
|
116
|
-
component.error(e);
|
|
116
|
+
(component._error || console.error)(e);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
return url;
|
|
@@ -125,7 +125,7 @@ export default class ApiHelpers {
|
|
|
125
125
|
try {
|
|
126
126
|
payload = pass({ client, apiGroup, apiName, payload }) || payload;
|
|
127
127
|
} catch(e) {
|
|
128
|
-
component.error(e);
|
|
128
|
+
(component._error || console.error)(e);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
return payload;
|
package/src/plugin/user.js
CHANGED
|
@@ -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
|
|
58
|
-
data = data.map(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
|
-
|
|
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.
|
|
1
|
+
export default '1.10.2-beta.7';
|