@leanbase-giangnd/js 0.0.3 → 0.0.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.
package/package.json CHANGED
@@ -1,47 +1,48 @@
1
1
  {
2
- "name": "@leanbase-giangnd/js",
3
- "version": "0.0.3",
4
- "description": "Leanbase browser SDK - event tracking, autocapture, and session replay",
5
- "repository": {
6
- "type": "git",
7
- "directory": "packages/leanbase"
8
- },
9
- "author": "leanbase",
10
- "license": "Copyrighted by Leanflag Limited",
11
- "main": "dist/index.cjs",
12
- "module": "dist/index.mjs",
13
- "types": "dist/index.d.ts",
14
- "unpkg": "dist/leanbase.iife.js",
15
- "jsdelivr": "dist/leanbase.iife.js",
16
- "files": [
17
- "dist",
18
- "src",
19
- "README.md"
20
- ],
21
- "publishConfig": {
22
- "access": "public"
23
- },
24
- "dependencies": {
25
- "@rrweb/record": "2.0.0-alpha.17",
26
- "fflate": "^0.4.8",
27
- "@posthog/core": "1.3.1"
28
- },
29
- "devDependencies": {
30
- "jest": "^29.7.0",
31
- "jest-environment-jsdom": "^29.7.0",
32
- "rollup": "^4.44.1",
33
- "rimraf": "^6.0.1",
34
- "@posthog-tooling/rollup-utils": "1.0.0",
35
- "@posthog-tooling/tsconfig-base": "1.0.0"
36
- },
37
- "scripts": {
38
- "clean": "rimraf dist coverage",
39
- "test:unit": "jest -c jest.config.js",
40
- "lint": "eslint src test",
41
- "lint:fix": "eslint src test --fix",
42
- "prebuild": "node -p \"'export const version = \\'' + require('./package.json').version + '\\''\" > src/version.ts",
43
- "build": "rollup -c",
44
- "dev": "rollup -c -w",
45
- "package": "mkdir -p ../../target && pnpm pack --pack-destination ../../target"
46
- }
47
- }
2
+ "name": "@leanbase-giangnd/js",
3
+ "version": "0.0.4",
4
+ "description": "Leanbase browser SDK - event tracking, autocapture, and session replay",
5
+ "repository": {
6
+ "type": "git",
7
+ "directory": "packages/leanbase"
8
+ },
9
+ "author": "leanbase",
10
+ "license": "Copyrighted by Leanflag Limited",
11
+ "main": "dist/index.cjs",
12
+ "module": "dist/index.mjs",
13
+ "types": "dist/index.d.ts",
14
+ "unpkg": "dist/leanbase.iife.js",
15
+ "jsdelivr": "dist/leanbase.iife.js",
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage",
18
+ "test:unit": "jest -c jest.config.js",
19
+ "lint": "eslint src test",
20
+ "lint:fix": "eslint src test --fix",
21
+ "prebuild": "node -p \"'export const version = \\'' + require('./package.json').version + '\\''\" > src/version.ts",
22
+ "build": "rollup -c",
23
+ "dev": "rollup -c -w",
24
+ "prepublishOnly": "pnpm lint && pnpm test:unit && pnpm build",
25
+ "package": "mkdir -p ../../target && pnpm pack --pack-destination ../../target"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "src",
30
+ "README.md"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@posthog/core": "workspace:*",
37
+ "@rrweb/record": "2.0.0-alpha.17",
38
+ "fflate": "^0.4.8"
39
+ },
40
+ "devDependencies": {
41
+ "@posthog-tooling/tsconfig-base": "workspace:*",
42
+ "@posthog-tooling/rollup-utils": "workspace:*",
43
+ "jest": "catalog:",
44
+ "jest-environment-jsdom": "catalog:",
45
+ "rollup": "catalog:",
46
+ "rimraf": "^6.0.1"
47
+ }
48
+ }
package/src/leanbase.ts CHANGED
@@ -36,7 +36,7 @@ import { decompressSync, strFromU8 } from 'fflate'
36
36
  import Config from './config'
37
37
  import { Autocapture } from './autocapture'
38
38
  import { logger } from './leanbase-logger'
39
- import { COOKIELESS_MODE_FLAG_PROPERTY, USER_STATE } from './constants'
39
+ import { COOKIELESS_MODE_FLAG_PROPERTY, USER_STATE, SESSION_RECORDING_REMOTE_CONFIG } from './constants'
40
40
  import { getEventProperties } from './utils/event-utils'
41
41
  import { SessionIdManager } from './sessionid'
42
42
  import { SessionPropsManager } from './session-props'
@@ -293,6 +293,36 @@ export class Leanbase extends PostHogCore {
293
293
  )
294
294
  } catch {}
295
295
 
296
+ // If remote config has explicitly disabled session recording, drop snapshot events
297
+ try {
298
+ // Read persisted remote config that SessionRecording stores
299
+ const persisted: any = this.get_property(SESSION_RECORDING_REMOTE_CONFIG)
300
+ const serverAllowsRecording = !(
301
+ (persisted && persisted.enabled === false) ||
302
+ this.config.disable_session_recording === true
303
+ )
304
+
305
+ if (!serverAllowsRecording && hasSnapshot) {
306
+ // remove snapshot events from the batch before sending to /batch/
307
+ parsed.batch = parsed.batch.filter((item: any) => !(item && item.event === '$snapshot'))
308
+ // If no events remain, short-circuit and avoid sending an empty batch
309
+ if (!parsed.batch.length) {
310
+ try {
311
+ // eslint-disable-next-line no-console
312
+ console.debug(
313
+ '[Leanbase.fetch] sessionRecording disabled, dropping snapshot-only batch'
314
+ )
315
+ } catch {}
316
+ return { status: 200, json: async () => ({}) } as any
317
+ }
318
+ // re-encode the body so the underlying fetch receives the modified batch
319
+ try {
320
+ const newBody = JSON.stringify(parsed)
321
+ options = { ...options, body: newBody }
322
+ } catch {}
323
+ }
324
+ } catch {}
325
+
296
326
  if (hasSnapshot) {
297
327
  const host = (this.config && this.config.host) || ''
298
328
  const newUrl = host ? `${host.replace(/\/$/, '')}/s/` : url
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.0.3'
1
+ export const version = '0.0.4'
package/LICENSE DELETED
@@ -1,37 +0,0 @@
1
- Copyright 2025 Leanflag Limited
2
- This project is a fork of PostHog/posthog-js.
3
-
4
- All rights reserved. This software is proprietary to Leanflag Limited and may only be used for Leanflag Limited products and internal purposes. Redistribution, modification, or commercial use outside of Leanflag Limited is strictly prohibited without explicit written permission from Leanflag Limited.
5
-
6
-
7
- ---
8
-
9
- Copyright 2020 Posthog / Hiberly, Inc.
10
-
11
- Copyright 2015 Mixpanel, Inc.
12
-
13
-
14
- Some files in this codebase contain code from getsentry/sentry-javascript by Software, Inc. dba Sentry.
15
- In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
16
-
17
- MIT License
18
-
19
- Copyright (c) 2012 Functional Software, Inc. dba Sentry
20
-
21
- Permission is hereby granted, free of charge, to any person obtaining a copy of
22
- this software and associated documentation files (the "Software"), to deal in
23
- the Software without restriction, including without limitation the rights to
24
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
25
- of the Software, and to permit persons to whom the Software is furnished to do
26
- so, subject to the following conditions:
27
-
28
- The above copyright notice and this permission notice shall be included in all
29
- copies or substantial portions of the Software.
30
-
31
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
- SOFTWARE.