@miso.ai/client-sdk-core 1.8.1-beta.2 → 1.8.1-beta.4

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.
@@ -114,7 +114,7 @@ class ApiHelpers {
114
114
  if (method && method !== 'POST') {
115
115
  throw new Error(`Non-POST API is not supported in useBeacon mode: ${url}`);
116
116
  }
117
- if (!window.navigator.sendBeacon(url, JSON.stringify(payload))) {
117
+ if (!(this._root._customSendBeacon || window.navigator.sendBeacon)(url, JSON.stringify(payload))) {
118
118
  throw new Error(`Send beacon unsuccessful: ${url}`);
119
119
  }
120
120
  }
@@ -104,6 +104,12 @@ class PluginRoot extends _commons.Registry {
104
104
  }
105
105
  this._root._customFetch = fetch;
106
106
  }
107
+ setCustomSendBeacon(sendBeacon) {
108
+ if (typeof sendBeacon !== 'function') {
109
+ throw new Error(`Expect parameter to be a function: ${sendBeacon}`);
110
+ }
111
+ this._root._customSendBeacon = sendBeacon;
112
+ }
107
113
  _tryConfig(instance, options) {
108
114
  if (options === undefined) {
109
115
  return;
@@ -215,7 +221,7 @@ class PluginRoot extends _commons.Registry {
215
221
  exports.default = PluginRoot;
216
222
  class PluginContext {
217
223
  constructor(root, classes) {
218
- (0, _commons.delegateGetters)(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'whenInstalled', 'whenRegistered']);
224
+ (0, _commons.delegateGetters)(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'setCustomSendBeacon', 'whenInstalled', 'whenRegistered']);
219
225
  (0, _commons.defineValues)(this, {
220
226
  classes
221
227
  });
package/dist/cjs/root.js CHANGED
@@ -22,6 +22,7 @@ class Root extends _commons.Component {
22
22
  this._payloadPasses = [];
23
23
  this._urlPasses = [];
24
24
  this._customFetch = undefined;
25
+ this._customSendBeacon = undefined;
25
26
  this.version = _version.default || 'dev';
26
27
  }
27
28
  get instances() {
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '1.8.1-beta.2';
7
+ var _default = '1.8.1-beta.4';
8
8
  exports.default = _default;
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.8.1-beta.2"
32
+ "@miso.ai/commons": "1.8.1-beta.4"
33
33
  },
34
- "version": "1.8.1-beta.2"
34
+ "version": "1.8.1-beta.4"
35
35
  }
@@ -83,7 +83,7 @@ export default class ApiHelpers {
83
83
  if (method && method !== 'POST') {
84
84
  throw new Error(`Non-POST API is not supported in useBeacon mode: ${url}`);
85
85
  }
86
- if (!window.navigator.sendBeacon(url, JSON.stringify(payload))) {
86
+ if (!(this._root._customSendBeacon || window.navigator.sendBeacon)(url, JSON.stringify(payload))) {
87
87
  throw new Error(`Send beacon unsuccessful: ${url}`);
88
88
  }
89
89
  }
@@ -108,6 +108,13 @@ export default class PluginRoot extends Registry {
108
108
  this._root._customFetch = fetch;
109
109
  }
110
110
 
111
+ setCustomSendBeacon(sendBeacon) {
112
+ if (typeof sendBeacon !== 'function') {
113
+ throw new Error(`Expect parameter to be a function: ${sendBeacon}`);
114
+ }
115
+ this._root._customSendBeacon = sendBeacon;
116
+ }
117
+
111
118
  _tryConfig(instance, options) {
112
119
  if (options === undefined) {
113
120
  return;
@@ -222,7 +229,7 @@ export default class PluginRoot extends Registry {
222
229
  class PluginContext {
223
230
 
224
231
  constructor(root, classes) {
225
- delegateGetters(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'whenInstalled', 'whenRegistered']);
232
+ delegateGetters(this, root, ['getPluginClass', 'addSubtree', 'addPayloadPass', 'addUrlPass', 'setCustomFetch', 'setCustomSendBeacon', 'whenInstalled', 'whenRegistered']);
226
233
  defineValues(this, { classes });
227
234
  }
228
235
 
package/src/root.js CHANGED
@@ -15,6 +15,7 @@ class Root extends Component {
15
15
  this._payloadPasses = [];
16
16
  this._urlPasses = [];
17
17
  this._customFetch = undefined;
18
+ this._customSendBeacon = undefined;
18
19
  this.version = version || 'dev';
19
20
  }
20
21
 
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.8.1-beta.2';
1
+ export default '1.8.1-beta.4';