@ninetailed/experience.js 4.3.0-beta.2 → 4.3.0-beta.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/index.cjs CHANGED
@@ -10,7 +10,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var Analytics__default = /*#__PURE__*/_interopDefaultLegacy(Analytics);
12
12
 
13
- const HAS_SEEN_EXPERIENCE = 'has_seen_experience';
14
13
  const HAS_SEEN_COMPONENT = 'has_seen_component';
15
14
  const HAS_SEEN_ELEMENT = 'has_seen_element';
16
15
  const PAGE_HIDDEN = 'page_hidden';
@@ -3361,7 +3360,8 @@ class Ninetailed {
3361
3360
  locale,
3362
3361
  requestTimeout,
3363
3362
  onLog,
3364
- onError
3363
+ onError,
3364
+ componentViewTrackingThreshold = 2000
3365
3365
  } = {}) {
3366
3366
  this.isInitialized = false;
3367
3367
  this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
@@ -3398,14 +3398,22 @@ class Ninetailed {
3398
3398
  throw error;
3399
3399
  }
3400
3400
  });
3401
+ /**
3402
+ * @deprecated The legacy datamodel is not recommended anymore
3403
+ * Will be removed in version 5 of the SDK
3404
+ */
3401
3405
  this.trackHasSeenComponent = properties => __awaiter(this, void 0, void 0, function* () {
3402
3406
  return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3403
3407
  type: HAS_SEEN_COMPONENT
3404
3408
  }));
3405
3409
  });
3410
+ /**
3411
+ * @deprecated Use the Ninetailed provided observers instead
3412
+ * Will be removed in version 5 of the SDK
3413
+ */
3406
3414
  this.trackHasSeenExperience = properties => {
3407
3415
  return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3408
- type: HAS_SEEN_EXPERIENCE
3416
+ type: HAS_SEEN_ELEMENT
3409
3417
  }));
3410
3418
  };
3411
3419
  this.observeElement = (payload, options) => {
@@ -3414,7 +3422,9 @@ class Ninetailed {
3414
3422
  } = payload,
3415
3423
  remaingPayload = __rest(payload, ["element"]);
3416
3424
  this.observedElements.set(element, remaingPayload);
3417
- this.elementSeenObserver.observe(element, options);
3425
+ this.elementSeenObserver.observe(element, Object.assign({
3426
+ delay: this.componentViewTrackingThreshold
3427
+ }, options));
3418
3428
  };
3419
3429
  this.unobserveElement = element => {
3420
3430
  this.observedElements.delete(element);
@@ -3586,6 +3596,7 @@ class Ninetailed {
3586
3596
  this.elementSeenObserver = new ElementSeenObserver({
3587
3597
  onElementSeen: this.onElementSeen.bind(this)
3588
3598
  });
3599
+ this.componentViewTrackingThreshold = componentViewTrackingThreshold;
3589
3600
  const hasPluginsInterestedInHiddenPage = this.plugins.some(isInterestedInHiddenPage);
3590
3601
  if (hasPluginsInterestedInHiddenPage) {
3591
3602
  this.onVisibilityChange();
@@ -3702,39 +3713,41 @@ const selectVariant = (baseline, variants, {
3702
3713
  };
3703
3714
  };
3704
3715
 
3705
- const TrackExperienceProperties = zod.z.object({
3716
+ const TrackComponentProperties = zod.z.object({
3717
+ variant: zod.z.object({
3718
+ id: zod.z.string()
3719
+ }),
3720
+ audience: zod.z.object({
3721
+ id: zod.z.string()
3722
+ }),
3723
+ isPersonalized: zod.z.boolean()
3724
+ });
3725
+
3726
+ class NinetailedPlugin {}
3727
+
3728
+ const ElementSeenPayload = zod.z.object({
3729
+ element: zod.z.any(),
3706
3730
  experience: zod.z.object({
3707
3731
  id: zod.z.string(),
3708
3732
  type: zod.z.union([zod.z.literal('nt_experiment'), zod.z.literal('nt_personalization')]),
3709
- name: zod.z.string(),
3733
+ name: zod.z.string().optional(),
3710
3734
  description: zod.z.string().optional()
3711
- }),
3735
+ }).optional().nullable(),
3712
3736
  audience: zod.z.object({
3713
3737
  id: zod.z.string(),
3714
3738
  name: zod.z.string().optional(),
3715
3739
  description: zod.z.string().optional()
3716
- }).optional().default({
3740
+ }).optional().nullable().default({
3717
3741
  id: 'ALL_VISITORS',
3718
3742
  name: 'All Visitors',
3719
3743
  description: 'This is the default all visitors audience as no audience was set.'
3720
3744
  }),
3721
- selectedVariant: zod.z.object({
3722
- id: zod.z.string()
3723
- }).catchall(zod.z.unknown()),
3724
- selectedVariantIndex: zod.z.number()
3725
- });
3726
- const TrackComponentProperties = zod.z.object({
3727
3745
  variant: zod.z.object({
3728
3746
  id: zod.z.string()
3729
- }),
3730
- audience: zod.z.object({
3731
- id: zod.z.string()
3732
- }),
3733
- isPersonalized: zod.z.boolean()
3747
+ }).catchall(zod.z.unknown()),
3748
+ variantIndex: zod.z.number()
3734
3749
  });
3735
3750
 
3736
- class NinetailedPlugin {}
3737
-
3738
3751
  var aCallable = aCallable$8;
3739
3752
  var toObject = toObject$5;
3740
3753
  var IndexedObject = indexedObject;
@@ -3941,11 +3954,13 @@ const selectPluginsHavingExperienceSelectionMiddleware = plugins => {
3941
3954
  const createPassThroughMiddleware = () => {
3942
3955
  return ({
3943
3956
  experience,
3944
- variant
3957
+ variant,
3958
+ variantIndex
3945
3959
  }) => {
3946
3960
  return {
3947
3961
  experience,
3948
- variant
3962
+ variant,
3963
+ variantIndex
3949
3964
  };
3950
3965
  };
3951
3966
  };
@@ -4032,9 +4047,9 @@ exports.ANONYMOUS_ID = ANONYMOUS_ID;
4032
4047
  exports.CONSENT = CONSENT;
4033
4048
  exports.DEBUG_FLAG = DEBUG_FLAG;
4034
4049
  exports.EMPTY_MERGE_ID = EMPTY_MERGE_ID;
4050
+ exports.ElementSeenPayload = ElementSeenPayload;
4035
4051
  exports.HAS_SEEN_COMPONENT = HAS_SEEN_COMPONENT;
4036
4052
  exports.HAS_SEEN_ELEMENT = HAS_SEEN_ELEMENT;
4037
- exports.HAS_SEEN_EXPERIENCE = HAS_SEEN_EXPERIENCE;
4038
4053
  exports.LEGACY_ANONYMOUS_ID = LEGACY_ANONYMOUS_ID;
4039
4054
  exports.Ninetailed = Ninetailed;
4040
4055
  exports.NinetailedPlugin = NinetailedPlugin;
@@ -4046,7 +4061,6 @@ exports.PROFILE_FALLBACK_CACHE = PROFILE_FALLBACK_CACHE;
4046
4061
  exports.PROFILE_RESET = PROFILE_RESET;
4047
4062
  exports.SET_ENABLED_FEATURES = SET_ENABLED_FEATURES;
4048
4063
  exports.TrackComponentProperties = TrackComponentProperties;
4049
- exports.TrackExperienceProperties = TrackExperienceProperties;
4050
4064
  exports.buildClientNinetailedRequestContext = buildClientNinetailedRequestContext;
4051
4065
  exports.decodeExperienceVariantsMap = decodeExperienceVariantsMap;
4052
4066
  exports.makeExperienceSelectMiddleware = makeExperienceSelectMiddleware;
package/index.js CHANGED
@@ -3,7 +3,6 @@ export { EXPERIENCE_TRAIT_PREFIX, isExperienceMatch, selectActiveExperiments, se
3
3
  import Analytics from 'analytics';
4
4
  import { z } from 'zod';
5
5
 
6
- const HAS_SEEN_EXPERIENCE = 'has_seen_experience';
7
6
  const HAS_SEEN_COMPONENT = 'has_seen_component';
8
7
  const HAS_SEEN_ELEMENT = 'has_seen_element';
9
8
  const PAGE_HIDDEN = 'page_hidden';
@@ -3354,7 +3353,8 @@ class Ninetailed {
3354
3353
  locale,
3355
3354
  requestTimeout,
3356
3355
  onLog,
3357
- onError
3356
+ onError,
3357
+ componentViewTrackingThreshold = 2000
3358
3358
  } = {}) {
3359
3359
  this.isInitialized = false;
3360
3360
  this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
@@ -3391,14 +3391,22 @@ class Ninetailed {
3391
3391
  throw error;
3392
3392
  }
3393
3393
  });
3394
+ /**
3395
+ * @deprecated The legacy datamodel is not recommended anymore
3396
+ * Will be removed in version 5 of the SDK
3397
+ */
3394
3398
  this.trackHasSeenComponent = properties => __awaiter(this, void 0, void 0, function* () {
3395
3399
  return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3396
3400
  type: HAS_SEEN_COMPONENT
3397
3401
  }));
3398
3402
  });
3403
+ /**
3404
+ * @deprecated Use the Ninetailed provided observers instead
3405
+ * Will be removed in version 5 of the SDK
3406
+ */
3399
3407
  this.trackHasSeenExperience = properties => {
3400
3408
  return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
3401
- type: HAS_SEEN_EXPERIENCE
3409
+ type: HAS_SEEN_ELEMENT
3402
3410
  }));
3403
3411
  };
3404
3412
  this.observeElement = (payload, options) => {
@@ -3407,7 +3415,9 @@ class Ninetailed {
3407
3415
  } = payload,
3408
3416
  remaingPayload = __rest(payload, ["element"]);
3409
3417
  this.observedElements.set(element, remaingPayload);
3410
- this.elementSeenObserver.observe(element, options);
3418
+ this.elementSeenObserver.observe(element, Object.assign({
3419
+ delay: this.componentViewTrackingThreshold
3420
+ }, options));
3411
3421
  };
3412
3422
  this.unobserveElement = element => {
3413
3423
  this.observedElements.delete(element);
@@ -3579,6 +3589,7 @@ class Ninetailed {
3579
3589
  this.elementSeenObserver = new ElementSeenObserver({
3580
3590
  onElementSeen: this.onElementSeen.bind(this)
3581
3591
  });
3592
+ this.componentViewTrackingThreshold = componentViewTrackingThreshold;
3582
3593
  const hasPluginsInterestedInHiddenPage = this.plugins.some(isInterestedInHiddenPage);
3583
3594
  if (hasPluginsInterestedInHiddenPage) {
3584
3595
  this.onVisibilityChange();
@@ -3695,39 +3706,41 @@ const selectVariant = (baseline, variants, {
3695
3706
  };
3696
3707
  };
3697
3708
 
3698
- const TrackExperienceProperties = z.object({
3709
+ const TrackComponentProperties = z.object({
3710
+ variant: z.object({
3711
+ id: z.string()
3712
+ }),
3713
+ audience: z.object({
3714
+ id: z.string()
3715
+ }),
3716
+ isPersonalized: z.boolean()
3717
+ });
3718
+
3719
+ class NinetailedPlugin {}
3720
+
3721
+ const ElementSeenPayload = z.object({
3722
+ element: z.any(),
3699
3723
  experience: z.object({
3700
3724
  id: z.string(),
3701
3725
  type: z.union([z.literal('nt_experiment'), z.literal('nt_personalization')]),
3702
- name: z.string(),
3726
+ name: z.string().optional(),
3703
3727
  description: z.string().optional()
3704
- }),
3728
+ }).optional().nullable(),
3705
3729
  audience: z.object({
3706
3730
  id: z.string(),
3707
3731
  name: z.string().optional(),
3708
3732
  description: z.string().optional()
3709
- }).optional().default({
3733
+ }).optional().nullable().default({
3710
3734
  id: 'ALL_VISITORS',
3711
3735
  name: 'All Visitors',
3712
3736
  description: 'This is the default all visitors audience as no audience was set.'
3713
3737
  }),
3714
- selectedVariant: z.object({
3715
- id: z.string()
3716
- }).catchall(z.unknown()),
3717
- selectedVariantIndex: z.number()
3718
- });
3719
- const TrackComponentProperties = z.object({
3720
3738
  variant: z.object({
3721
3739
  id: z.string()
3722
- }),
3723
- audience: z.object({
3724
- id: z.string()
3725
- }),
3726
- isPersonalized: z.boolean()
3740
+ }).catchall(z.unknown()),
3741
+ variantIndex: z.number()
3727
3742
  });
3728
3743
 
3729
- class NinetailedPlugin {}
3730
-
3731
3744
  var aCallable = aCallable$8;
3732
3745
  var toObject = toObject$5;
3733
3746
  var IndexedObject = indexedObject;
@@ -3934,11 +3947,13 @@ const selectPluginsHavingExperienceSelectionMiddleware = plugins => {
3934
3947
  const createPassThroughMiddleware = () => {
3935
3948
  return ({
3936
3949
  experience,
3937
- variant
3950
+ variant,
3951
+ variantIndex
3938
3952
  }) => {
3939
3953
  return {
3940
3954
  experience,
3941
- variant
3955
+ variant,
3956
+ variantIndex
3942
3957
  };
3943
3958
  };
3944
3959
  };
@@ -3981,4 +3996,4 @@ const makeExperienceSelectMiddleware = ({
3981
3996
  };
3982
3997
  };
3983
3998
 
3984
- export { ANONYMOUS_ID, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT, HAS_SEEN_EXPERIENCE, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedPlugin, OnChangeEmitter, PAGE_HIDDEN, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, TrackComponentProperties, TrackExperienceProperties, buildClientNinetailedRequestContext, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, ninetailedPlugin, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
3999
+ export { ANONYMOUS_ID, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, ElementSeenPayload, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedPlugin, OnChangeEmitter, PAGE_HIDDEN, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, TrackComponentProperties, buildClientNinetailedRequestContext, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, ninetailedPlugin, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
@@ -20,6 +20,7 @@ type Options = {
20
20
  requestTimeout?: number;
21
21
  onLog?: OnLogHandler;
22
22
  onError?: OnErrorHandler;
23
+ componentViewTrackingThreshold?: number;
23
24
  };
24
25
  type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
25
26
  export declare class Ninetailed implements NinetailedInstance {
@@ -34,10 +35,19 @@ export declare class Ninetailed implements NinetailedInstance {
34
35
  private readonly environment;
35
36
  readonly plugins: NinetailedPlugin[];
36
37
  readonly logger: Logger;
37
- constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, }?: Options);
38
+ private readonly componentViewTrackingThreshold;
39
+ constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, componentViewTrackingThreshold, }?: Options);
38
40
  page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
39
41
  track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
42
+ /**
43
+ * @deprecated The legacy datamodel is not recommended anymore
44
+ * Will be removed in version 5 of the SDK
45
+ */
40
46
  trackHasSeenComponent: TrackHasSeenComponent;
47
+ /**
48
+ * @deprecated Use the Ninetailed provided observers instead
49
+ * Will be removed in version 5 of the SDK
50
+ */
41
51
  trackHasSeenExperience: TrackHasSeenExperience;
42
52
  observeElement: (payload: ElementSeenPayload, options?: ObserveOptions) => void;
43
53
  unobserveElement: (element: Element) => void;
@@ -1,4 +1,3 @@
1
- export declare const HAS_SEEN_EXPERIENCE = "has_seen_experience";
2
1
  export declare const HAS_SEEN_COMPONENT = "has_seen_component";
3
2
  export declare const HAS_SEEN_ELEMENT = "has_seen_element";
4
3
  export declare const PAGE_HIDDEN = "page_hidden";
@@ -11,9 +11,10 @@ type MakeExperienceSelectMiddlewareArg<Variant extends Reference> = {
11
11
  export declare const makeExperienceSelectMiddleware: <Variant extends Reference>({ plugins, onChange, experiences, baseline, profile, }: MakeExperienceSelectMiddlewareArg<Variant>) => {
12
12
  addListeners: () => void;
13
13
  removeListeners: () => void;
14
- middleware: ({ experience, variant, }: ExperienceSelectionMiddlewareReturnArg<Variant | VariantRef>) => {
14
+ middleware: ({ experience, variant, variantIndex, }: ExperienceSelectionMiddlewareReturnArg<Variant | VariantRef>) => {
15
15
  experience: ExperienceConfiguration<Variant | VariantRef> | null;
16
- variant: Variant | VariantRef | null;
16
+ variant: Variant | VariantRef;
17
+ variantIndex: number;
17
18
  };
18
19
  };
19
20
  export {};
@@ -1,7 +1,82 @@
1
- export type ElementSeenPayload = {
1
+ import { z } from 'zod';
2
+ export declare const ElementSeenPayload: z.ZodObject<{
3
+ element: z.ZodAny;
4
+ experience: z.ZodNullable<z.ZodOptional<z.ZodObject<{
5
+ id: z.ZodString;
6
+ type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
7
+ name: z.ZodOptional<z.ZodString>;
8
+ description: z.ZodOptional<z.ZodString>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ id: string;
11
+ type: "nt_experiment" | "nt_personalization";
12
+ name?: string | undefined;
13
+ description?: string | undefined;
14
+ }, {
15
+ id: string;
16
+ type: "nt_experiment" | "nt_personalization";
17
+ name?: string | undefined;
18
+ description?: string | undefined;
19
+ }>>>;
20
+ audience: z.ZodDefault<z.ZodNullable<z.ZodOptional<z.ZodObject<{
21
+ id: z.ZodString;
22
+ name: z.ZodOptional<z.ZodString>;
23
+ description: z.ZodOptional<z.ZodString>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ id: string;
26
+ name?: string | undefined;
27
+ description?: string | undefined;
28
+ }, {
29
+ id: string;
30
+ name?: string | undefined;
31
+ description?: string | undefined;
32
+ }>>>>;
33
+ variant: z.ZodObject<{
34
+ id: z.ZodString;
35
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
36
+ id: z.ZodString;
37
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
38
+ id: z.ZodString;
39
+ }, z.ZodUnknown, "strip">>;
40
+ variantIndex: z.ZodNumber;
41
+ }, "strip", z.ZodTypeAny, {
42
+ audience: {
43
+ id: string;
44
+ name?: string | undefined;
45
+ description?: string | undefined;
46
+ } | null;
47
+ variant: {
48
+ id: string;
49
+ } & {
50
+ [k: string]: unknown;
51
+ };
52
+ variantIndex: number;
53
+ element?: any;
54
+ experience?: {
55
+ id: string;
56
+ type: "nt_experiment" | "nt_personalization";
57
+ name?: string | undefined;
58
+ description?: string | undefined;
59
+ } | null | undefined;
60
+ }, {
61
+ variant: {
62
+ id: string;
63
+ } & {
64
+ [k: string]: unknown;
65
+ };
66
+ variantIndex: number;
67
+ element?: any;
68
+ experience?: {
69
+ id: string;
70
+ type: "nt_experiment" | "nt_personalization";
71
+ name?: string | undefined;
72
+ description?: string | undefined;
73
+ } | null | undefined;
74
+ audience?: {
75
+ id: string;
76
+ name?: string | undefined;
77
+ description?: string | undefined;
78
+ } | null | undefined;
79
+ }>;
80
+ export type ElementSeenPayload = Omit<z.input<typeof ElementSeenPayload>, 'element'> & {
2
81
  element: Element;
3
- experienceId?: string;
4
- baselineId?: string;
5
- variantId?: string;
6
- audienceId?: string;
7
82
  };
@@ -1,83 +1,4 @@
1
1
  import { z } from 'zod';
2
- export declare const TrackExperienceProperties: z.ZodObject<{
3
- experience: z.ZodObject<{
4
- id: z.ZodString;
5
- type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
6
- name: z.ZodString;
7
- description: z.ZodOptional<z.ZodString>;
8
- }, "strip", z.ZodTypeAny, {
9
- type: "nt_experiment" | "nt_personalization";
10
- id: string;
11
- name: string;
12
- description?: string | undefined;
13
- }, {
14
- type: "nt_experiment" | "nt_personalization";
15
- id: string;
16
- name: string;
17
- description?: string | undefined;
18
- }>;
19
- audience: z.ZodDefault<z.ZodOptional<z.ZodObject<{
20
- id: z.ZodString;
21
- name: z.ZodOptional<z.ZodString>;
22
- description: z.ZodOptional<z.ZodString>;
23
- }, "strip", z.ZodTypeAny, {
24
- id: string;
25
- name?: string | undefined;
26
- description?: string | undefined;
27
- }, {
28
- id: string;
29
- name?: string | undefined;
30
- description?: string | undefined;
31
- }>>>;
32
- selectedVariant: z.ZodObject<{
33
- id: z.ZodString;
34
- }, "strip", z.ZodUnknown, z.objectOutputType<{
35
- id: z.ZodString;
36
- }, z.ZodUnknown, "strip">, z.objectInputType<{
37
- id: z.ZodString;
38
- }, z.ZodUnknown, "strip">>;
39
- selectedVariantIndex: z.ZodNumber;
40
- }, "strip", z.ZodTypeAny, {
41
- experience: {
42
- type: "nt_experiment" | "nt_personalization";
43
- id: string;
44
- name: string;
45
- description?: string | undefined;
46
- };
47
- audience: {
48
- id: string;
49
- name?: string | undefined;
50
- description?: string | undefined;
51
- };
52
- selectedVariant: {
53
- id: string;
54
- } & {
55
- [k: string]: unknown;
56
- };
57
- selectedVariantIndex: number;
58
- }, {
59
- experience: {
60
- type: "nt_experiment" | "nt_personalization";
61
- id: string;
62
- name: string;
63
- description?: string | undefined;
64
- };
65
- selectedVariant: {
66
- id: string;
67
- } & {
68
- [k: string]: unknown;
69
- };
70
- selectedVariantIndex: number;
71
- audience?: {
72
- id: string;
73
- name?: string | undefined;
74
- description?: string | undefined;
75
- } | undefined;
76
- }>;
77
- export type TrackExperienceProperties = z.input<typeof TrackExperienceProperties>;
78
- export type SanitizedTrackExperienceProperties = z.infer<typeof TrackExperienceProperties> & {
79
- selectedVariantSelector: string;
80
- };
81
2
  export declare const TrackComponentProperties: z.ZodObject<{
82
3
  variant: z.ZodObject<{
83
4
  id: z.ZodString;
@@ -95,18 +16,18 @@ export declare const TrackComponentProperties: z.ZodObject<{
95
16
  }>;
96
17
  isPersonalized: z.ZodBoolean;
97
18
  }, "strip", z.ZodTypeAny, {
98
- audience: {
19
+ variant: {
99
20
  id: string;
100
21
  };
101
- variant: {
22
+ audience: {
102
23
  id: string;
103
24
  };
104
25
  isPersonalized: boolean;
105
26
  }, {
106
- audience: {
27
+ variant: {
107
28
  id: string;
108
29
  };
109
- variant: {
30
+ audience: {
110
31
  id: string;
111
32
  };
112
33
  isPersonalized: boolean;
@@ -1,8 +1,9 @@
1
1
  import { Logger, PageviewProperties, Profile, Properties, Traits } from '@ninetailed/experience.js-shared';
2
2
  import { DetachListeners } from 'analytics';
3
- import { TrackExperienceProperties, TrackComponentProperties } from './TrackingProperties';
3
+ import { TrackComponentProperties } from './TrackingProperties';
4
4
  import { NinetailedPlugin } from './NinetailedPlugin';
5
5
  import { type Ninetailed } from '../Ninetailed';
6
+ import { ElementSeenPayload } from './ElementSeenPayload';
6
7
  type Loading = {
7
8
  status: 'loading';
8
9
  profile: null;
@@ -36,7 +37,7 @@ export type OnProfileChangeCallback = (profile: ProfileState) => void;
36
37
  export type Page = (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<FlushResult>;
37
38
  export type Track = (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<FlushResult>;
38
39
  export type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
39
- export type TrackHasSeenExperience = (properties: TrackExperienceProperties) => Promise<void>;
40
+ export type TrackHasSeenExperience = (properties: ElementSeenPayload) => Promise<void>;
40
41
  export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;
41
42
  export type Reset = () => void;
42
43
  export type Debug = (enable: boolean) => void;
@@ -59,10 +60,9 @@ export interface NinetailedInstance {
59
60
  observeElement: ObserveElement;
60
61
  unobserveElement: UnObserveElement;
61
62
  }
62
- export { NinetailedPlugin, TrackExperienceProperties, TrackComponentProperties, };
63
+ export { NinetailedPlugin, TrackComponentProperties };
63
64
  export type { EventHandler } from './EventHandler';
64
65
  export type { AnalyticsInstance } from './AnalyticsInstance';
65
- export type { SanitizedTrackExperienceProperties } from './TrackingProperties';
66
- export type { ElementSeenPayload } from './ElementSeenPayload';
66
+ export { ElementSeenPayload } from './ElementSeenPayload';
67
67
  export type { ProfileChangedPayload } from './ProfileChangedPayload';
68
68
  export type { Credentials } from './Credentials';
@@ -1,7 +1,8 @@
1
1
  import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js-shared';
2
2
  export type ExperienceSelectionMiddlewareReturnArg<Variant extends Reference> = {
3
3
  experience: ExperienceConfiguration<Variant> | null;
4
- variant: Variant | null;
4
+ variant: Variant;
5
+ variantIndex: number;
5
6
  };
6
7
  type ExperienceSelectionMiddlewareReturn<Variant extends Reference> = (arg: ExperienceSelectionMiddlewareReturnArg<Variant>) => ExperienceSelectionMiddlewareReturnArg<Variant>;
7
8
  type ExperienceSelectionMiddlewareArg<Variant extends Reference> = {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "4.3.0-beta.2",
3
+ "version": "4.3.0-beta.4",
4
4
  "module": "./index.js",
5
5
  "main": "./index.cjs",
6
6
  "type": "module",
7
7
  "types": "./index.d.ts",
8
8
  "dependencies": {
9
- "@ninetailed/experience.js-shared": "4.3.0-beta.2",
9
+ "@ninetailed/experience.js-shared": "4.3.0-beta.4",
10
10
  "analytics": "0.8.1",
11
11
  "zod": "3.21.4"
12
12
  },