mixpanel-browser 2.78.0 → 2.79.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 (66) hide show
  1. package/.claude/settings.local.json +6 -11
  2. package/.eslintrc.json +12 -0
  3. package/.github/workflows/openfeature-provider-tests.yml +31 -0
  4. package/CHANGELOG.md +8 -1
  5. package/build.sh +2 -2
  6. package/dist/async-modules/{mixpanel-recorder-BjSlYaNJ.min.js → mixpanel-recorder-D5HJyV2E.min.js} +2 -2
  7. package/dist/async-modules/mixpanel-recorder-D5HJyV2E.min.js.map +1 -0
  8. package/dist/async-modules/{mixpanel-recorder-zMBXIyeG.js → mixpanel-recorder-P6SEnnPV.js} +57 -33
  9. package/dist/async-modules/mixpanel-targeting-1L9FyetZ.min.js +2 -0
  10. package/dist/async-modules/mixpanel-targeting-1L9FyetZ.min.js.map +1 -0
  11. package/dist/async-modules/{mixpanel-targeting-UHf4eBfC.js → mixpanel-targeting-BBMVbgJF.js} +24 -13
  12. package/dist/mixpanel-core.cjs.d.ts +45 -1
  13. package/dist/mixpanel-core.cjs.js +565 -197
  14. package/dist/mixpanel-recorder.js +57 -33
  15. package/dist/mixpanel-recorder.min.js +1 -1
  16. package/dist/mixpanel-recorder.min.js.map +1 -1
  17. package/dist/mixpanel-targeting.js +24 -13
  18. package/dist/mixpanel-targeting.min.js +1 -1
  19. package/dist/mixpanel-targeting.min.js.map +1 -1
  20. package/dist/mixpanel-with-async-modules.cjs.d.ts +45 -1
  21. package/dist/mixpanel-with-async-modules.cjs.js +567 -199
  22. package/dist/mixpanel-with-async-recorder.cjs.d.ts +45 -1
  23. package/dist/mixpanel-with-async-recorder.cjs.js +567 -199
  24. package/dist/mixpanel-with-recorder.d.ts +45 -1
  25. package/dist/mixpanel-with-recorder.js +490 -122
  26. package/dist/mixpanel-with-recorder.min.d.ts +45 -1
  27. package/dist/mixpanel-with-recorder.min.js +1 -1
  28. package/dist/mixpanel.amd.d.ts +45 -1
  29. package/dist/mixpanel.amd.js +490 -122
  30. package/dist/mixpanel.cjs.d.ts +45 -1
  31. package/dist/mixpanel.cjs.js +490 -122
  32. package/dist/mixpanel.globals.js +567 -199
  33. package/dist/mixpanel.min.js +199 -189
  34. package/dist/mixpanel.module.d.ts +45 -1
  35. package/dist/mixpanel.module.js +490 -122
  36. package/dist/mixpanel.umd.d.ts +45 -1
  37. package/dist/mixpanel.umd.js +490 -122
  38. package/package.json +1 -1
  39. package/packages/openfeature-web-provider/README.md +357 -0
  40. package/packages/openfeature-web-provider/package-lock.json +1636 -0
  41. package/packages/openfeature-web-provider/package.json +51 -0
  42. package/packages/openfeature-web-provider/rollup.config.browser.mjs +26 -0
  43. package/packages/openfeature-web-provider/src/MixpanelProvider.ts +302 -0
  44. package/packages/openfeature-web-provider/src/index.ts +1 -0
  45. package/packages/openfeature-web-provider/src/types.ts +72 -0
  46. package/packages/openfeature-web-provider/test/MixpanelProvider.spec.ts +484 -0
  47. package/packages/openfeature-web-provider/tsconfig.json +15 -0
  48. package/src/autocapture/index.js +7 -2
  49. package/src/config.js +1 -1
  50. package/src/flags/flags-persistence.js +176 -0
  51. package/src/flags/index.js +174 -23
  52. package/src/index.d.ts +45 -1
  53. package/src/mixpanel-core.js +24 -7
  54. package/src/recorder/idb-config.js +16 -0
  55. package/src/recorder/recording-registry.js +7 -2
  56. package/src/recorder/session-recording.js +9 -4
  57. package/src/recorder-manager.js +7 -2
  58. package/src/request-queue.js +1 -2
  59. package/src/shared-lock.js +2 -3
  60. package/src/storage/indexed-db.js +16 -15
  61. package/src/storage/local-storage.js +5 -3
  62. package/src/utils.js +25 -12
  63. package/tsconfig.base.json +9 -0
  64. package/dist/async-modules/mixpanel-recorder-BjSlYaNJ.min.js.map +0 -1
  65. package/dist/async-modules/mixpanel-targeting-BSHal4N9.min.js +0 -2
  66. package/dist/async-modules/mixpanel-targeting-BSHal4N9.min.js.map +0 -1
@@ -165,8 +165,47 @@ export interface AutocaptureConfig {
165
165
  block_element_callback?: (element: Element, event: Event) => boolean;
166
166
  }
167
167
 
168
+ /**
169
+ * Network-only variant lookup - no persistence. Default behavior.
170
+ */
171
+ export interface NetworkOnlyFlagsPolicy {
172
+ variantLookupPolicy: "networkOnly";
173
+ }
174
+
175
+ /**
176
+ * Network-first variant lookup - prioritizes freshness.
177
+ * Attempts network fetch first, falls back to persisted variants on failure.
178
+ */
179
+ export interface NetworkFirstFlagsPolicy {
180
+ variantLookupPolicy: "networkFirst";
181
+ /**
182
+ * Time-to-live in milliseconds. Persisted variants older than this are discarded.
183
+ * Defaults to 24 hours.
184
+ */
185
+ persistenceTtlMs?: number;
186
+ }
187
+
188
+ /**
189
+ * Serves persisted variants immediately while a network fetch runs in the background.
190
+ * Once the fetch succeeds, its result replaces the cached variants for the rest of the session.
191
+ */
192
+ export interface PersistenceUntilNetworkSuccessFlagsPolicy {
193
+ variantLookupPolicy: "persistenceUntilNetworkSuccess";
194
+ /**
195
+ * Time-to-live in milliseconds. Persisted variants older than this are discarded.
196
+ * Defaults to 24 hours.
197
+ */
198
+ persistenceTtlMs?: number;
199
+ }
200
+
201
+ export type FlagsPersistencePolicy =
202
+ | NetworkOnlyFlagsPolicy
203
+ | NetworkFirstFlagsPolicy
204
+ | PersistenceUntilNetworkSuccessFlagsPolicy;
205
+
168
206
  export interface FlagsConfig {
169
- context: Dict;
207
+ context?: Dict;
208
+ persistence?: FlagsPersistencePolicy;
170
209
  }
171
210
 
172
211
  export interface BeforeSendHookPayload {
@@ -349,6 +388,8 @@ export interface FlagsVariant {
349
388
  experiment_id?: string;
350
389
  is_experiment_active?: boolean;
351
390
  is_qa_tester?: boolean;
391
+ variant_source?: string;
392
+ persisted_at_in_ms?: number;
352
393
  }
353
394
 
354
395
  export interface FlagsUpdateContextOptions {
@@ -365,12 +406,15 @@ export interface FlagsManager {
365
406
  get_variant_sync(featureName: string, fallback: FlagsVariant): FlagsVariant;
366
407
  get_variant_value(featureName: string, fallbackValue: any): Promise<any>;
367
408
  get_variant_value_sync(featureName: string, fallbackValue: any): any;
409
+ get_all_variants(): Promise<Map<string, FlagsVariant>>;
410
+ get_all_variants_sync(): Map<string, FlagsVariant>;
368
411
  is_enabled(featureName: string, fallbackValue?: boolean): Promise<boolean>;
369
412
  is_enabled_sync(featureName: string, fallbackValue?: boolean): boolean;
370
413
  update_context(
371
414
  context: Dict,
372
415
  options?: FlagsUpdateContextOptions
373
416
  ): Promise<void>;
417
+ when_ready(): Promise<void>;
374
418
  }
375
419
 
376
420
  export interface Mixpanel {