@ninetailed/experience.js 4.3.0-beta.6 → 4.4.0-beta.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.
@@ -1,3 +1,2 @@
1
1
  export * from './get-analytics-plugin';
2
2
  export * from './constants';
3
- export * from './Events';
@@ -1,3 +1,2 @@
1
+ export declare const HAS_SEEN_EXPERIENCE = "has_seen_experience";
1
2
  export declare const HAS_SEEN_COMPONENT = "has_seen_component";
2
- export declare const HAS_SEEN_ELEMENT = "has_seen_element";
3
- export declare const PAGE_HIDDEN = "page_hidden";
@@ -11,10 +11,9 @@ 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, variantIndex, }: ExperienceSelectionMiddlewareReturnArg<Variant | VariantRef>) => {
14
+ middleware: ({ experience, variant, }: ExperienceSelectionMiddlewareReturnArg<Variant | VariantRef>) => {
15
15
  experience: ExperienceConfiguration<Variant | VariantRef> | null;
16
- variant: Variant | VariantRef;
17
- variantIndex: number;
16
+ variant: Variant | VariantRef | null;
18
17
  };
19
18
  };
20
19
  export {};
@@ -1,4 +1,83 @@
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
+ description?: string | undefined;
10
+ type: "nt_experiment" | "nt_personalization";
11
+ id: string;
12
+ name: string;
13
+ }, {
14
+ description?: string | undefined;
15
+ type: "nt_experiment" | "nt_personalization";
16
+ id: string;
17
+ name: string;
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
+ name?: string | undefined;
25
+ description?: string | undefined;
26
+ id: string;
27
+ }, {
28
+ name?: string | undefined;
29
+ description?: string | undefined;
30
+ id: string;
31
+ }>>>;
32
+ selectedVariant: z.ZodObject<{
33
+ id: z.ZodString;
34
+ }, "strip", z.ZodUnknown, {
35
+ [x: string]: unknown;
36
+ id: string;
37
+ }, {
38
+ [x: string]: unknown;
39
+ id: string;
40
+ }>;
41
+ selectedVariantIndex: z.ZodNumber;
42
+ }, "strip", z.ZodTypeAny, {
43
+ experience: {
44
+ description?: string | undefined;
45
+ type: "nt_experiment" | "nt_personalization";
46
+ id: string;
47
+ name: string;
48
+ };
49
+ audience: {
50
+ name?: string | undefined;
51
+ description?: string | undefined;
52
+ id: string;
53
+ };
54
+ selectedVariant: {
55
+ [x: string]: unknown;
56
+ id: string;
57
+ };
58
+ selectedVariantIndex: number;
59
+ }, {
60
+ audience?: {
61
+ name?: string | undefined;
62
+ description?: string | undefined;
63
+ id: string;
64
+ } | undefined;
65
+ experience: {
66
+ description?: string | undefined;
67
+ type: "nt_experiment" | "nt_personalization";
68
+ id: string;
69
+ name: string;
70
+ };
71
+ selectedVariant: {
72
+ [x: string]: unknown;
73
+ id: string;
74
+ };
75
+ selectedVariantIndex: number;
76
+ }>;
77
+ export type TrackExperienceProperties = z.input<typeof TrackExperienceProperties>;
78
+ export type SanitizedTrackExperienceProperties = z.infer<typeof TrackExperienceProperties> & {
79
+ selectedVariantSelector: string;
80
+ };
2
81
  export declare const TrackComponentProperties: z.ZodObject<{
3
82
  variant: z.ZodObject<{
4
83
  id: z.ZodString;
@@ -16,18 +95,18 @@ export declare const TrackComponentProperties: z.ZodObject<{
16
95
  }>;
17
96
  isPersonalized: z.ZodBoolean;
18
97
  }, "strip", z.ZodTypeAny, {
19
- variant: {
98
+ audience: {
20
99
  id: string;
21
100
  };
22
- audience: {
101
+ variant: {
23
102
  id: string;
24
103
  };
25
104
  isPersonalized: boolean;
26
105
  }, {
27
- variant: {
106
+ audience: {
28
107
  id: string;
29
108
  };
30
- audience: {
109
+ variant: {
31
110
  id: string;
32
111
  };
33
112
  isPersonalized: boolean;
@@ -1,9 +1,7 @@
1
1
  import { Logger, PageviewProperties, Profile, Properties, Traits } from '@ninetailed/experience.js-shared';
2
2
  import { DetachListeners } from 'analytics';
3
- import { TrackComponentProperties } from './TrackingProperties';
3
+ import { TrackExperienceProperties, TrackComponentProperties } from './TrackingProperties';
4
4
  import { NinetailedPlugin } from './NinetailedPlugin';
5
- import { type Ninetailed } from '../Ninetailed';
6
- import { ElementSeenPayload } from './ElementSeenPayload';
7
5
  type Loading = {
8
6
  status: 'loading';
9
7
  profile: null;
@@ -37,13 +35,11 @@ export type OnProfileChangeCallback = (profile: ProfileState) => void;
37
35
  export type Page = (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<FlushResult>;
38
36
  export type Track = (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<FlushResult>;
39
37
  export type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
40
- export type TrackHasSeenExperience = (properties: ElementSeenPayload) => Promise<void>;
38
+ export type TrackHasSeenExperience = (properties: TrackExperienceProperties) => Promise<void>;
41
39
  export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;
42
40
  export type Reset = () => void;
43
41
  export type Debug = (enable: boolean) => void;
44
42
  export type OnProfileChange = (cb: OnProfileChangeCallback) => DetachListeners;
45
- type ObserveElement = Ninetailed['observeElement'];
46
- type UnObserveElement = Ninetailed['unobserveElement'];
47
43
  export interface NinetailedInstance {
48
44
  page: Page;
49
45
  track: Track;
@@ -57,13 +53,8 @@ export interface NinetailedInstance {
57
53
  plugins: NinetailedPlugin[];
58
54
  logger: Logger;
59
55
  onIsInitialized: OnIsInitialized;
60
- observeElement: ObserveElement;
61
- unobserveElement: UnObserveElement;
62
56
  }
63
- export { NinetailedPlugin, TrackComponentProperties };
57
+ export { NinetailedPlugin, TrackExperienceProperties, TrackComponentProperties, };
64
58
  export type { EventHandler } from './EventHandler';
65
59
  export type { AnalyticsInstance } from './AnalyticsInstance';
66
- export { ElementSeenPayloadSchema } from './ElementSeenPayload';
67
- export type { ElementSeenPayload } from './ElementSeenPayload';
68
- export type { ProfileChangedPayload } from './ProfileChangedPayload';
69
- export type { Credentials } from './Credentials';
60
+ export type { SanitizedTrackExperienceProperties } from './TrackingProperties';
@@ -1,8 +1,7 @@
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;
5
- variantIndex: number;
4
+ variant: Variant | null;
6
5
  };
7
6
  type ExperienceSelectionMiddlewareReturn<Variant extends Reference> = (arg: ExperienceSelectionMiddlewareReturnArg<Variant>) => ExperienceSelectionMiddlewareReturnArg<Variant>;
8
7
  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.6",
3
+ "version": "4.4.0-beta.2",
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.6",
9
+ "@ninetailed/experience.js-shared": "4.4.0-beta.2",
10
10
  "analytics": "0.8.1",
11
11
  "zod": "3.21.4"
12
12
  },
@@ -1,16 +0,0 @@
1
- export type ElementSeenObserverOptions = {
2
- onElementSeen: (element: Element) => void;
3
- };
4
- export type ObserveOptions = {
5
- delay?: number;
6
- };
7
- export declare class ElementSeenObserver {
8
- private _options;
9
- private _intersectionObserver?;
10
- private _elementDelays;
11
- private _intersectionTimers;
12
- constructor(_options: ElementSeenObserverOptions);
13
- private onIntersection;
14
- observe(element: Element, options?: ObserveOptions): void;
15
- unobserve(element: Element): void;
16
- }
@@ -1,2 +0,0 @@
1
- import { AcceptsCredentials } from '../types/interfaces/AcceptsCredentials';
2
- export declare const acceptsCredentials: (plugin: unknown) => plugin is AcceptsCredentials;
@@ -1,2 +0,0 @@
1
- import { InterestedInHiddenPage } from '../types/interfaces/InterestedInHiddenPage';
2
- export declare const isInterestedInHiddenPage: (arg: unknown) => arg is InterestedInHiddenPage;
@@ -1,2 +0,0 @@
1
- import { InterestedInSeenElements } from '../types/interfaces/InterestedInSeenElements';
2
- export declare const isInterestedInSeenElements: (arg: unknown) => arg is InterestedInSeenElements;
@@ -1,4 +0,0 @@
1
- export type Credentials = {
2
- clientId: string;
3
- environment: string;
4
- };
@@ -1,82 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const ElementSeenPayloadSchema: 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 ElementSeenPayloadSchema>, 'element'> & {
81
- element: Element;
82
- };
@@ -1,4 +0,0 @@
1
- import { type Profile } from '@ninetailed/experience.js-shared';
2
- export type ProfileChangedPayload = {
3
- profile: Profile;
4
- };
@@ -1,4 +0,0 @@
1
- import { type Credentials } from '../Credentials';
2
- export interface AcceptsCredentials {
3
- setCredentials(credentials: Credentials): void;
4
- }
@@ -1,5 +0,0 @@
1
- import { PAGE_HIDDEN } from '../../constants';
2
- import { EventHandler } from '../EventHandler';
3
- export interface InterestedInHiddenPage {
4
- [PAGE_HIDDEN]: EventHandler<void>;
5
- }
@@ -1,6 +0,0 @@
1
- import { PROFILE_CHANGE } from '@ninetailed/experience.js-shared';
2
- import { EventHandler } from '../EventHandler';
3
- import { ProfileChangedPayload } from '../ProfileChangedPayload';
4
- export interface InterestedInProfileChange {
5
- [PROFILE_CHANGE]: EventHandler<ProfileChangedPayload>;
6
- }
@@ -1,6 +0,0 @@
1
- import { HAS_SEEN_ELEMENT } from '../../constants';
2
- import { ElementSeenPayload } from '../ElementSeenPayload';
3
- import { EventHandler } from '../EventHandler';
4
- export interface InterestedInSeenElements {
5
- [HAS_SEEN_ELEMENT]: EventHandler<ElementSeenPayload>;
6
- }