@leanbase-giangnd/js 0.1.1 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leanbase-giangnd/js",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Leanbase browser SDK - event tracking, autocapture, and session replay",
5
5
  "repository": {
6
6
  "type": "git",
package/src/iife.ts CHANGED
@@ -2,6 +2,12 @@ import { Leanbase } from './leanbase'
2
2
  import type { LeanbaseConfig } from './types'
3
3
  import { isArray } from '@posthog/core'
4
4
 
5
+ declare global {
6
+ interface Window {
7
+ __LEANBASE__?: Leanbase | null
8
+ }
9
+ }
10
+
5
11
  type QueuedCall = { fn: keyof typeof api; args: any[] }
6
12
 
7
13
  const api = {
@@ -10,6 +16,10 @@ const api = {
10
16
 
11
17
  init(apiKey: string, options?: LeanbaseConfig) {
12
18
  this._instance = new Leanbase(apiKey, options)
19
+ // Expose the instantiated SDK for legacy/global access when running in a browser
20
+ if (typeof window !== 'undefined') {
21
+ window.__LEANBASE__ = this._instance
22
+ }
13
23
  const q = this._queue
14
24
  this._queue = []
15
25
  for (const { fn, args } of q) {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.1.1'
1
+ export const version = '0.1.2'