mixpanel-browser 2.73.0 → 2.75.0

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.
Files changed (55) hide show
  1. package/.eslintrc.json +7 -4
  2. package/.github/workflows/integration-tests.yml +52 -0
  3. package/.github/workflows/unit-tests.yml +40 -0
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +3 -3
  6. package/build.sh +1 -5
  7. package/dist/mixpanel-core.cjs.d.ts +12 -1
  8. package/dist/mixpanel-core.cjs.js +432 -34
  9. package/dist/mixpanel-recorder.js +5364 -684
  10. package/dist/mixpanel-recorder.min.js +1 -1
  11. package/dist/mixpanel-recorder.min.js.map +1 -1
  12. package/dist/mixpanel-targeting.js +2576 -0
  13. package/dist/mixpanel-targeting.min.js +2 -0
  14. package/dist/mixpanel-targeting.min.js.map +1 -0
  15. package/dist/mixpanel-with-async-modules.cjs.d.ts +522 -0
  16. package/dist/mixpanel-with-async-modules.cjs.js +9700 -0
  17. package/dist/mixpanel-with-async-recorder.cjs.d.ts +12 -1
  18. package/dist/mixpanel-with-async-recorder.cjs.js +432 -34
  19. package/dist/mixpanel-with-recorder.d.ts +12 -1
  20. package/dist/mixpanel-with-recorder.js +7889 -2839
  21. package/dist/mixpanel-with-recorder.min.d.ts +12 -1
  22. package/dist/mixpanel-with-recorder.min.js +1 -1
  23. package/dist/mixpanel.amd.d.ts +12 -1
  24. package/dist/mixpanel.amd.js +8446 -2813
  25. package/dist/mixpanel.cjs.d.ts +12 -1
  26. package/dist/mixpanel.cjs.js +8446 -2813
  27. package/dist/mixpanel.globals.js +432 -34
  28. package/dist/mixpanel.min.js +182 -173
  29. package/dist/mixpanel.module.d.ts +12 -1
  30. package/dist/mixpanel.module.js +8446 -2813
  31. package/dist/mixpanel.umd.d.ts +12 -1
  32. package/dist/mixpanel.umd.js +8446 -2813
  33. package/dist/rrweb-bundled.js +4434 -596
  34. package/dist/rrweb-compiled.js +5078 -646
  35. package/package.json +33 -7
  36. package/rollup.config.mjs +286 -224
  37. package/src/autocapture/utils.js +15 -7
  38. package/src/config.js +1 -1
  39. package/src/flags/index.js +269 -8
  40. package/src/globals.js +14 -0
  41. package/src/index.d.ts +12 -1
  42. package/src/loaders/loader-module.js +1 -0
  43. package/src/mixpanel-core.js +101 -8
  44. package/src/recorder/index.js +2 -1
  45. package/src/recorder/masking.js +197 -0
  46. package/src/recorder/rrweb-entrypoint.js +2 -1
  47. package/src/recorder/session-recording.js +43 -4
  48. package/src/recorder/utils.js +5 -1
  49. package/src/targeting/event-matcher.js +97 -0
  50. package/src/targeting/index.js +11 -0
  51. package/src/targeting/loader.js +36 -0
  52. package/src/utils.js +12 -10
  53. package/testServer.js +51 -7
  54. package/.github/workflows/tests.yml +0 -25
  55. /package/src/loaders/{loader-module-with-async-recorder.js → loader-module-with-async-modules.js} +0 -0
package/.eslintrc.json CHANGED
@@ -8,7 +8,9 @@
8
8
  "sourceType": "module"
9
9
  },
10
10
  "rules": {
11
- "camelcase": "error",
11
+ "camelcase": ["error", {
12
+ "properties": "never"
13
+ }],
12
14
  "eol-last": "error",
13
15
  "eqeqeq": "error",
14
16
  "indent":
@@ -29,13 +31,14 @@
29
31
  ]
30
32
  },
31
33
  "overrides": [{
32
- "files": ["tests/unit/**/*.js"],
34
+ "files": ["tests/unit/**/*.js", "tests/browser/**/*.js", "*.mjs"],
33
35
  "parserOptions": {
34
- "ecmaVersion": 8,
36
+ "ecmaVersion": 9,
35
37
  "sourceType": "module"
36
38
  },
37
39
  "env": {
38
- "mocha": true
40
+ "mocha": true,
41
+ "node": true
39
42
  },
40
43
  "rules": {
41
44
  "camelcase": "error",
@@ -0,0 +1,52 @@
1
+ name: Integration Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ contents: read
15
+ checks: write # for dorny/test-reporter to post results
16
+
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ browser: [chrome-latest, edge-latest, safari-latest, firefox-latest, ios-safari-sim, android-chrome-sim]
21
+
22
+ env:
23
+ SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
24
+ SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
25
+ SAUCE_TUNNEL_NAME: ci-js-sdk-test-${{ matrix.browser }}-${{ github.run_id }}
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - name: Use Node.js 22.x
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: 22.x
33
+
34
+ - name: Install Dependencies
35
+ run: npm ci
36
+
37
+ - name: Build
38
+ run: npm run build-full
39
+
40
+ - name: Sauce test
41
+ # for some reason, android emulator tests don't work with localhost so we need an IP to give to the runner...
42
+ run: BROWSER=${{ matrix.browser }} ROOT_DIR=$(pwd) SAUCE_HOST=$(hostname -I | awk '{print $1; exit}') npm run integration-test:sauce
43
+
44
+ - name: Test Report
45
+ uses: dorny/test-reporter@7b7927aa7da8b82e81e755810cb51f39941a2cc7 # v2
46
+ if: success() || failure() # run this step even if previous step failed
47
+ with:
48
+ name: Browser Tests # Name of the check run which will be created
49
+ reporter: mocha-json # Format of test results
50
+ path: 'tests/browser/results/*.json' # Path to test results
51
+ list-tests: 'failed'
52
+ fail-on-error: 'false'
@@ -0,0 +1,40 @@
1
+ name: Unit Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ contents: read
15
+ checks: write # for dorny/test-reporter to post results
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [20.x, 22.x, 24.x]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - name: Use Node.js ${{ matrix.node-version }}
24
+ uses: actions/setup-node@v4
25
+ with:
26
+ node-version: ${{ matrix.node-version }}
27
+ - run: npm ci
28
+ - run: npm run test:ci
29
+ - run: npm run build-dist
30
+
31
+ - name: Test Report
32
+ uses: dorny/test-reporter@7b7927aa7da8b82e81e755810cb51f39941a2cc7 # v2
33
+ if: success() || failure()
34
+ with:
35
+ name: Unit Tests
36
+ reporter: mocha-json
37
+ path: 'tests/unit/results/*.json'
38
+ list-tests: 'failed'
39
+ fail-on-error: 'false'
40
+
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ **2.75.0** (24 Feb 2026)
2
+ - Adds support for Feature Flags targeting based on events tracked during the current session (Runtime Targeting)
3
+ - Fixes memory leaks in Session Recording on sites which create/destroy iframes
4
+ - Fixes usage of arrow functions in `hooks` config
5
+
6
+ **2.74.0** (27 Jan 2026)
7
+ - New session recording masking configuration options, including the ability to unmask inputs and allowlist-based selector masking.
8
+ - Adds initial support for the remote settings API, allowing remote configuration of SDK config options.
9
+ - Adds new automated browser test suite that runs in CI and locally in chrome headless. See tests/browser/README.html for more information.
10
+ - Fixes type definitions for api_routes
11
+ - Removes outdated examples in the examples/ dir
12
+
1
13
  **2.73.0** (23 Dec 2025)
2
14
  - Adds several new hooks: `before_identify`, `before_register`, `before_register_once`, `before_track`, `before_unregister`
3
15
  - Adds instance-initialization notification to allow Data Inspector browser extension to hook into SDK actions
package/README.md CHANGED
@@ -30,9 +30,9 @@ To load the core SDK with no option of session recording:
30
30
  import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';
31
31
  ```
32
32
 
33
- To load the core SDK and optionally load session recording bundle asynchronously (via script tag):
33
+ To load the core SDK and optionally load session recording and targeting bundles asynchronously (via script tag):
34
34
  ```javascript
35
- import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-recorder';
35
+ import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-modules';
36
36
  ```
37
37
 
38
38
  ## Use as a browser JavaScript module
@@ -67,7 +67,7 @@ mixpanel.init('YOUR_TOKEN', {autocapture: true, debug: true, persistence: 'local
67
67
  - Install development dependencies: `npm install`
68
68
  - Run unit tests: `npm test`
69
69
  - Start test server for browser tests: `npm run integration_test`
70
- - Browse to [http://localhost:3000/tests/](http://localhost:3000/tests/) and choose a scenario to run
70
+ - Browse to [http://localhost:3001/tests/](http://localhost:3001/tests/) and choose a scenario to run
71
71
 
72
72
  In the future we plan to automate the last step with a headless browser to streamline development (although
73
73
  Mixpanel production releases are tested against a large matrix of browsers and operating systems).
package/build.sh CHANGED
@@ -19,15 +19,11 @@ if [ ! -z "$FULL" ]; then
19
19
  npx webpack tests/module-cjs.js tests/module-cjs.bundle.js
20
20
  npx browserify tests/module-es2015.js -t [ babelify --compact false ] --outfile tests/module-es2015.bundle.js
21
21
 
22
- echo 'Bundling module-loader examples'
23
- pushd examples/commonjs-browserify; npm install && npm run build; popd
24
- pushd examples/es2015-babelify; npm install && npm run build; popd
25
- pushd examples/umd-webpack; npm install && npm run build; popd
26
22
  pushd examples/typescript; npm install && npm run build; popd
27
23
  fi
28
24
 
29
25
  if [ ! -z "$DIST" ]; then
30
26
  echo 'Copying to dist/'
31
27
  rm -r dist
32
- cp -r build dist
28
+ rsync -av --exclude='test' build/ dist/
33
29
  fi
@@ -6,6 +6,8 @@ export type PushItem = Array<string | Dict | ((this: Mixpanel) => void)>;
6
6
 
7
7
  export type Query = string | Element | Element[];
8
8
 
9
+ export type RemoteSettingType = "disabled" | "fallback" | "strict";
10
+
9
11
  export interface Dict {
10
12
  [key: string]: any;
11
13
  }
@@ -166,6 +168,8 @@ export interface Config {
166
168
  track?: string;
167
169
  engage?: string;
168
170
  groups?: string;
171
+ record?: string;
172
+ flags?: string;
169
173
  };
170
174
  api_method: string;
171
175
  api_transport: string;
@@ -225,12 +229,18 @@ export interface Config {
225
229
  record_idle_timeout_ms: number;
226
230
  record_inline_images: boolean;
227
231
  record_mask_text_class: string | RegExp;
228
- record_mask_text_selector: string;
232
+ record_mask_text_selector: string | string[];
233
+ record_unmask_text_selector: string | string[];
234
+ record_mask_all_text: boolean;
235
+ record_mask_input_selector: string | string[];
236
+ record_unmask_input_selector: string | string[];
237
+ record_mask_all_inputs: boolean;
229
238
  record_min_ms: number;
230
239
  record_max_ms: number;
231
240
  record_sessions_percent: number;
232
241
  record_canvas: boolean;
233
242
  record_heatmap_data: boolean;
243
+ remote_settings_mode: RemoteSettingType;
234
244
  hooks: {
235
245
  before_identify?: (new_distinct_id: string) => string | null;
236
246
  before_register?: (
@@ -256,6 +266,7 @@ export interface Config {
256
266
  };
257
267
  }
258
268
 
269
+
259
270
  export type VerboseResponse =
260
271
  | {
261
272
  status: 1;