@leanbase-giangnd/js 0.3.0 → 0.3.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/dist/index.cjs +154 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +58 -81
- package/dist/index.mjs +154 -189
- package/dist/index.mjs.map +1 -1
- package/dist/leanbase.iife.js +154 -189
- package/dist/leanbase.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/extensions/replay/extension-shim.ts +1 -114
- package/src/extensions/replay/external/lazy-loaded-session-recorder.ts +130 -38
- package/src/extensions/replay/external/mutation-throttler.ts +1 -4
- package/src/extensions/replay/session-recording.ts +0 -59
- package/src/leanbase.ts +4 -1
- package/src/utils/request-router.ts +39 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Leanbase } from '../leanbase'
|
|
2
|
+
|
|
3
|
+
export type RequestRouterTarget = 'api' | 'ui' | 'assets'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Leanbase-local version of PostHog's RequestRouter.
|
|
7
|
+
*
|
|
8
|
+
* Browser SDK always has a requestRouter instance; Leanbase IIFE needs this too so
|
|
9
|
+
* features like Session Replay can construct ingestion URLs.
|
|
10
|
+
*/
|
|
11
|
+
export class RequestRouter {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
13
|
+
constructor(private readonly instance: Leanbase) {}
|
|
14
|
+
|
|
15
|
+
get apiHost(): string {
|
|
16
|
+
const configured = (this.instance.config.api_host || this.instance.config.host || '').trim()
|
|
17
|
+
return configured.replace(/\/$/, '')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get uiHost(): string | undefined {
|
|
21
|
+
const configured = this.instance.config.ui_host?.trim().replace(/\/$/, '')
|
|
22
|
+
return configured || undefined
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
endpointFor(target: RequestRouterTarget, path: string = ''): string {
|
|
26
|
+
if (path) {
|
|
27
|
+
path = path[0] === '/' ? path : `/${path}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (target === 'ui') {
|
|
31
|
+
const host = this.uiHost || this.apiHost
|
|
32
|
+
return host + path
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Leanbase doesn't currently do region-based routing; default to apiHost.
|
|
36
|
+
// Browser's router has special handling for assets; we keep parity in interface, not domains.
|
|
37
|
+
return this.apiHost + path
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.3.
|
|
1
|
+
export const version = '0.3.2'
|