@leanbase-giangnd/js 0.0.1 → 0.0.2
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/LICENSE +37 -0
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/dist/leanbase.iife.js +31 -7
- package/dist/leanbase.iife.js.map +1 -1
- package/package.json +46 -47
- package/src/extensions/replay/external/lazy-loaded-session-recorder.ts +2 -4
- package/src/leanbase.ts +26 -0
- package/src/version.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1183,7 +1183,7 @@ const detectDeviceType = function (user_agent) {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
};
|
|
1185
1185
|
|
|
1186
|
-
var version = "0.0.
|
|
1186
|
+
var version = "0.0.2";
|
|
1187
1187
|
var packageInfo = {
|
|
1188
1188
|
version: version};
|
|
1189
1189
|
|
|
@@ -5171,14 +5171,12 @@ class LazyLoadedSessionRecording {
|
|
|
5171
5171
|
}
|
|
5172
5172
|
_snapshotUrl() {
|
|
5173
5173
|
const host = this._instance.config.host || '';
|
|
5174
|
-
// Ensure endpoint is set; default to /s/ if not provided or malformed
|
|
5175
|
-
const endpoint = this._endpoint || '/s/';
|
|
5176
5174
|
try {
|
|
5177
5175
|
// eslint-disable-next-line compat/compat
|
|
5178
|
-
return new URL(
|
|
5176
|
+
return new URL(this._endpoint, host).href;
|
|
5179
5177
|
} catch {
|
|
5180
5178
|
const normalizedHost = host.endsWith('/') ? host.slice(0, -1) : host;
|
|
5181
|
-
const normalizedEndpoint =
|
|
5179
|
+
const normalizedEndpoint = this._endpoint.startsWith('/') ? this._endpoint.slice(1) : this._endpoint;
|
|
5182
5180
|
return `${normalizedHost}/${normalizedEndpoint}`;
|
|
5183
5181
|
}
|
|
5184
5182
|
}
|
|
@@ -5822,6 +5820,29 @@ class Leanbase extends PostHogCore {
|
|
|
5822
5820
|
if (!fetchFn) {
|
|
5823
5821
|
return Promise.reject(new Error('Fetch API is not available in this environment.'));
|
|
5824
5822
|
}
|
|
5823
|
+
try {
|
|
5824
|
+
const isPost = !options.method || options.method.toUpperCase() === 'POST';
|
|
5825
|
+
const isBatchEndpoint = typeof url === 'string' && url.endsWith('/batch/');
|
|
5826
|
+
if (isPost && isBatchEndpoint && options && options.body) {
|
|
5827
|
+
let parsed = null;
|
|
5828
|
+
try {
|
|
5829
|
+
const bodyString = typeof options.body === 'string' ? options.body : String(options.body);
|
|
5830
|
+
parsed = JSON.parse(bodyString);
|
|
5831
|
+
} catch {
|
|
5832
|
+
parsed = null;
|
|
5833
|
+
}
|
|
5834
|
+
if (parsed && isArray(parsed.batch)) {
|
|
5835
|
+
const hasSnapshot = parsed.batch.some(item => item && item.event === '$snapshot');
|
|
5836
|
+
if (hasSnapshot) {
|
|
5837
|
+
const host = this.config && this.config.host || '';
|
|
5838
|
+
const newUrl = host ? `${host.replace(/\/$/, '')}/s/` : url;
|
|
5839
|
+
return fetchFn(newUrl, options);
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
}
|
|
5843
|
+
} catch {
|
|
5844
|
+
return fetchFn(url, options);
|
|
5845
|
+
}
|
|
5825
5846
|
return fetchFn(url, options);
|
|
5826
5847
|
}
|
|
5827
5848
|
setConfig(config) {
|