@ninetailed/experience.js 4.3.0-beta.3 → 5.0.0-beta.3

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,7 +1,6 @@
1
1
  /// <reference types="analytics" />
2
- import { Locale, Traits, Profile, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions } from '@ninetailed/experience.js-shared';
3
- import { EventFunctionOptions, NinetailedInstance, NinetailedPlugin, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, TrackHasSeenExperience, ElementSeenPayload } from './types';
4
- import { ObserveOptions } from './ElementSeenObserver';
2
+ import { Locale, Traits, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions } from '@ninetailed/experience.js-shared';
3
+ import { EventFunctionOptions, NinetailedInstance, NinetailedPlugin, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, TrackHasSeenExperience } from './types';
5
4
  declare global {
6
5
  interface Window {
7
6
  ninetailed?: {
@@ -16,7 +15,6 @@ type Options = {
16
15
  url?: string;
17
16
  locale?: Locale;
18
17
  plugins?: (NinetailedPlugin | NinetailedPlugin[])[];
19
- profile?: Profile;
20
18
  requestTimeout?: number;
21
19
  onLog?: OnLogHandler;
22
20
  onError?: OnErrorHandler;
@@ -28,20 +26,15 @@ export declare class Ninetailed implements NinetailedInstance {
28
26
  private isInitialized;
29
27
  private readonly apiClient;
30
28
  private readonly eventQueue;
31
- private readonly elementSeenObserver;
32
- private readonly observedElements;
33
29
  private readonly clientId;
34
30
  private readonly environment;
35
31
  readonly plugins: NinetailedPlugin[];
36
32
  readonly logger: Logger;
37
- constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, }?: Options);
33
+ constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, locale, requestTimeout, onLog, onError }?: Options);
38
34
  page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
39
35
  track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
40
36
  trackHasSeenComponent: TrackHasSeenComponent;
41
37
  trackHasSeenExperience: TrackHasSeenExperience;
42
- observeElement: (payload: ElementSeenPayload, options?: ObserveOptions) => void;
43
- unobserveElement: (element: Element) => void;
44
- private onElementSeen;
45
38
  identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
46
39
  reset: () => Promise<void>;
47
40
  debug: (enabled: boolean) => Promise<void>;
@@ -51,6 +44,5 @@ export declare class Ninetailed implements NinetailedInstance {
51
44
  get profileState(): ProfileState;
52
45
  private buildOptions;
53
46
  private registerWindowHandlers;
54
- private onVisibilityChange;
55
47
  }
56
48
  export {};
@@ -2,6 +2,7 @@ export declare const LEGACY_ANONYMOUS_ID = "__anon_id";
2
2
  export declare const ANONYMOUS_ID = "__nt_anonymous_id__";
3
3
  export declare const DEBUG_FLAG = "__nt_debug__";
4
4
  export declare const PROFILE_FALLBACK_CACHE = "__nt_profile__";
5
+ export declare const EXPERIENCES_FALLBACK_CACHE = "__nt_experiences__";
5
6
  export declare const PROFILE_CHANGE = "profile-change";
6
7
  export declare const PROFILE_RESET = "profile-reset";
7
8
  export declare const CONSENT = "__nt-consent__";
@@ -1,3 +1,2 @@
1
1
  export * from './get-analytics-plugin';
2
2
  export * from './constants';
3
- export * from './Events';
@@ -1,4 +1,2 @@
1
1
  export declare const HAS_SEEN_EXPERIENCE = "has_seen_experience";
2
2
  export declare const HAS_SEEN_COMPONENT = "has_seen_component";
3
- export declare const HAS_SEEN_ELEMENT = "has_seen_element";
4
- export declare const PAGE_HIDDEN = "page_hidden";
@@ -1,4 +1,4 @@
1
1
  export * from './types';
2
- export { EXPERIENCE_TRAIT_PREFIX, selectDistribution, isExperienceMatch, selectVariant as selectExperienceVariant, selectHasVariants as selectHasExperienceVariants, selectVariants as selectExperienceVariants, selectBaselineWithVariants as selectExperienceBaselineWithVariants, selectExperience, selectEligibleExperiences, selectActiveExperiments, } from '@ninetailed/experience.js-shared';
2
+ export { EXPERIENCE_TRAIT_PREFIX, selectDistribution, isExperienceMatch, selectVariantClientSide as selectExperienceVariantClientSide, selectHasVariants as selectHasExperienceVariants, selectVariants as selectExperienceVariants, selectBaselineWithVariants as selectExperienceBaselineWithVariants, selectExperience, selectEligibleExperiences, selectActiveExperiments, } from '@ninetailed/experience.js-shared';
3
3
  export { decodeExperienceVariantsMap } from './decodeExperienceVariantsMap';
4
4
  export { makeExperienceSelectMiddleware } from './makeExperienceSelectMiddleware';
@@ -6,73 +6,73 @@ export declare const TrackExperienceProperties: z.ZodObject<{
6
6
  name: z.ZodString;
7
7
  description: z.ZodOptional<z.ZodString>;
8
8
  }, "strip", z.ZodTypeAny, {
9
+ description?: string | undefined;
9
10
  type: "nt_experiment" | "nt_personalization";
10
11
  id: string;
11
12
  name: string;
12
- description?: string | undefined;
13
13
  }, {
14
+ description?: string | undefined;
14
15
  type: "nt_experiment" | "nt_personalization";
15
16
  id: string;
16
17
  name: string;
17
- description?: string | undefined;
18
18
  }>;
19
19
  audience: z.ZodDefault<z.ZodOptional<z.ZodObject<{
20
20
  id: z.ZodString;
21
21
  name: z.ZodOptional<z.ZodString>;
22
22
  description: z.ZodOptional<z.ZodString>;
23
23
  }, "strip", z.ZodTypeAny, {
24
- id: string;
25
24
  name?: string | undefined;
26
25
  description?: string | undefined;
27
- }, {
28
26
  id: string;
27
+ }, {
29
28
  name?: string | undefined;
30
29
  description?: string | undefined;
30
+ id: string;
31
31
  }>>>;
32
32
  selectedVariant: z.ZodObject<{
33
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">>;
34
+ }, "strip", z.ZodUnknown, {
35
+ [x: string]: unknown;
36
+ id: string;
37
+ }, {
38
+ [x: string]: unknown;
39
+ id: string;
40
+ }>;
39
41
  selectedVariantIndex: z.ZodNumber;
40
42
  }, "strip", z.ZodTypeAny, {
41
43
  experience: {
44
+ description?: string | undefined;
42
45
  type: "nt_experiment" | "nt_personalization";
43
46
  id: string;
44
47
  name: string;
45
- description?: string | undefined;
46
48
  };
47
49
  audience: {
48
- id: string;
49
50
  name?: string | undefined;
50
51
  description?: string | undefined;
52
+ id: string;
51
53
  };
52
54
  selectedVariant: {
55
+ [x: string]: unknown;
53
56
  id: string;
54
- } & {
55
- [k: string]: unknown;
56
57
  };
57
58
  selectedVariantIndex: number;
58
59
  }, {
60
+ audience?: {
61
+ name?: string | undefined;
62
+ description?: string | undefined;
63
+ id: string;
64
+ } | undefined;
59
65
  experience: {
66
+ description?: string | undefined;
60
67
  type: "nt_experiment" | "nt_personalization";
61
68
  id: string;
62
69
  name: string;
63
- description?: string | undefined;
64
70
  };
65
71
  selectedVariant: {
72
+ [x: string]: unknown;
66
73
  id: string;
67
- } & {
68
- [k: string]: unknown;
69
74
  };
70
75
  selectedVariantIndex: number;
71
- audience?: {
72
- id: string;
73
- name?: string | undefined;
74
- description?: string | undefined;
75
- } | undefined;
76
76
  }>;
77
77
  export type TrackExperienceProperties = z.input<typeof TrackExperienceProperties>;
78
78
  export type SanitizedTrackExperienceProperties = z.infer<typeof TrackExperienceProperties> & {
@@ -1,21 +1,23 @@
1
- import { Logger, PageviewProperties, Profile, Properties, Traits } from '@ninetailed/experience.js-shared';
1
+ import { Logger, PageviewProperties, Profile, Properties, Traits, SelectedVariantInfo } from '@ninetailed/experience.js-shared';
2
2
  import { DetachListeners } from 'analytics';
3
3
  import { TrackExperienceProperties, TrackComponentProperties } from './TrackingProperties';
4
4
  import { NinetailedPlugin } from './NinetailedPlugin';
5
- import { type Ninetailed } from '../Ninetailed';
6
5
  type Loading = {
7
6
  status: 'loading';
8
7
  profile: null;
8
+ experiences: null;
9
9
  error: null;
10
10
  };
11
11
  type Success = {
12
12
  status: 'success';
13
13
  profile: Profile;
14
+ experiences: SelectedVariantInfo[];
14
15
  error: null;
15
16
  };
16
17
  type Fail = {
17
18
  status: 'error';
18
19
  profile: null;
20
+ experiences: null;
19
21
  error: Error;
20
22
  };
21
23
  export type ProfileState = {
@@ -41,8 +43,6 @@ export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOpt
41
43
  export type Reset = () => void;
42
44
  export type Debug = (enable: boolean) => void;
43
45
  export type OnProfileChange = (cb: OnProfileChangeCallback) => DetachListeners;
44
- type ObserveElement = Ninetailed['observeElement'];
45
- type UnObserveElement = Ninetailed['unobserveElement'];
46
46
  export interface NinetailedInstance {
47
47
  page: Page;
48
48
  track: Track;
@@ -56,13 +56,8 @@ export interface NinetailedInstance {
56
56
  plugins: NinetailedPlugin[];
57
57
  logger: Logger;
58
58
  onIsInitialized: OnIsInitialized;
59
- observeElement: ObserveElement;
60
- unobserveElement: UnObserveElement;
61
59
  }
62
60
  export { NinetailedPlugin, TrackExperienceProperties, TrackComponentProperties, };
63
61
  export type { EventHandler } from './EventHandler';
64
62
  export type { AnalyticsInstance } from './AnalyticsInstance';
65
63
  export type { SanitizedTrackExperienceProperties } from './TrackingProperties';
66
- export type { ElementSeenPayload } from './ElementSeenPayload';
67
- export type { ProfileChangedPayload } from './ProfileChangedPayload';
68
- export type { Credentials } from './Credentials';
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "4.3.0-beta.3",
3
+ "version": "5.0.0-beta.3",
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.3",
9
+ "@ninetailed/experience.js-shared": "5.0.0-beta.3",
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,7 +0,0 @@
1
- export type ElementSeenPayload = {
2
- element: Element;
3
- experienceId?: string;
4
- baselineId?: string;
5
- variantId?: string;
6
- audienceId?: string;
7
- };
@@ -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
- }