@ninetailed/experience.js 2.2.8 → 3.0.1-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,9 +1,7 @@
1
1
  import { PageData, AnalyticsPlugin, DetachListeners } from 'analytics';
2
- import { Locale, Traits, Profile, Variant } from '@ninetailed/experience.js-shared';
2
+ import { Locale, Traits, Profile, Variant, Logger, OnLogHandler, OnErrorHandler } from '@ninetailed/experience.js-shared';
3
3
  import { ProfileState } from './types';
4
4
  import { ExperienceConfiguration } from './experience';
5
- import { Logger, OnLogHandler, OnErrorHandler } from './logger';
6
- export type { OnErrorHandler, OnLogHandler } from './logger';
7
5
  declare global {
8
6
  interface Window {
9
7
  ninetailed?: {
@@ -69,7 +67,6 @@ export interface NinetailedInstance {
69
67
  export declare class Ninetailed implements NinetailedInstance {
70
68
  private readonly instance;
71
69
  private _profileState;
72
- private isInitialized;
73
70
  readonly plugins: AnalyticsPlugin[];
74
71
  readonly logger: Logger;
75
72
  constructor({ clientId, environment, preview, }: {
@@ -77,11 +74,11 @@ export declare class Ninetailed implements NinetailedInstance {
77
74
  environment?: string;
78
75
  preview?: boolean;
79
76
  }, { plugins, url, profile, locale, requestTimeout, onLog, onError, }?: Options);
80
- page: (data?: PageData, options?: EventFunctionOptions) => Promise<any>;
81
- track: (event: string, payload?: unknown, options?: EventFunctionOptions) => Promise<any>;
77
+ page: (data?: PageData<string> | undefined, options?: EventFunctionOptions | undefined) => Promise<any>;
78
+ track: (event: string, payload?: unknown, options?: EventFunctionOptions | undefined) => Promise<any>;
82
79
  trackHasSeenComponent: TrackHasSeenComponent;
83
80
  trackExperience: TrackExperience;
84
- identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<any>;
81
+ identify: (uid: string, traits?: Traits | undefined, options?: EventFunctionOptions | undefined) => Promise<any>;
85
82
  reset: () => void;
86
83
  debug: (enabled: boolean) => void;
87
84
  onProfileChange: (cb: OnProfileChangeCallback) => DetachListeners;
@@ -91,3 +88,4 @@ export declare class Ninetailed implements NinetailedInstance {
91
88
  private buildOptions;
92
89
  private registerWindowHandlers;
93
90
  }
91
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const LEGACY_ANONYMOUS_ID = "__anon_id";
2
+ export declare const ANONYMOUS_ID = "__nt_anonymous_id__";
3
+ export declare const DEBUG_FLAG = "__nt_debug__";
4
+ export declare const PROFILE_FALLBACK_CACHE = "__nt_profile__";
@@ -16,11 +16,5 @@ export declare const NINETAILED_TRACKER_EVENTS: {
16
16
  profile: string;
17
17
  };
18
18
  export declare const PLUGIN_NAME = "ninetailed";
19
- /**
20
- * Similar to _.throttle but waits for the promise to resolve. There is no
21
- * wait time because you can simply await `Promise.timeout` inside `fn`
22
- * to wait some time before the next call.
23
- */
24
- export default function asyncThrottle<I, O = void>(fn: (args: I) => Promise<O>): (args: I) => Promise<O>;
25
19
  export declare const ninetailedPlugin: ({ clientId, environment, preview, url, profile, locale, }: AnalyticsPluginNinetailedConfig) => AnalyticsPlugin;
26
20
  export {};
@@ -1,2 +1 @@
1
1
  export * from './get-analytics-plugin';
2
- export * as Cache from './Cache';
@@ -5,5 +5,5 @@ declare type SelectVariantArgs = {
5
5
  experience: ExperienceConfiguration;
6
6
  profile: Profile;
7
7
  };
8
- export declare const selectVariant: ({ baseline, experience, profile, }: SelectVariantArgs) => Variant;
8
+ export declare const selectVariant: ({ baseline, experience, profile, }: SelectVariantArgs) => Variant | null;
9
9
  export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Similar to _.throttle but waits for the promise to resolve. There is no
3
+ * wait time because you can simply await `Promise.timeout` inside `fn`
4
+ * to wait some time before the next call.
5
+ */
6
+ export declare function asyncThrottle<I, O = void>(fn: (args: I) => Promise<O>): (args: I) => Promise<O>;
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "2.2.8",
3
+ "version": "3.0.1-beta.3",
4
4
  "main": "./index.umd.js",
5
5
  "module": "./index.esm.js",
6
6
  "typings": "./index.d.ts",
7
7
  "dependencies": {
8
- "analytics": "^0.8.0",
9
- "@ninetailed/experience.js-shared": "2.2.8",
10
- "uuid": "^8.3.2",
8
+ "@ninetailed/experience.js-shared": "3.0.1-beta.3",
11
9
  "ts-toolbelt": "^9.6.0",
10
+ "diary": "^0.3.1",
11
+ "zod": "^3.18.0",
12
12
  "locale-enum": "^1.1.1",
13
13
  "i18n-iso-countries": "^7.3.0",
14
+ "analytics": "^0.8.0",
14
15
  "lodash": "^4.17.21",
15
- "murmurhash-js": "^1.0.0",
16
- "diary": "^0.3.1"
16
+ "murmurhash-js": "^1.0.0"
17
17
  },
18
18
  "peerDependencies": {}
19
19
  }
@@ -1,11 +0,0 @@
1
- import { AnalyticsInstance } from 'analytics';
2
- import { Cache } from '@ninetailed/experience.js-shared';
3
- declare type CacheOptions = {
4
- instance: AnalyticsInstance;
5
- };
6
- export declare const initialize: ({ instance }: CacheOptions, data?: Partial<Cache>) => Cache;
7
- export declare const get: ({ instance }: CacheOptions) => Cache | null;
8
- export declare const set: (cache: Cache, { instance }: CacheOptions) => Cache;
9
- export declare const remove: ({ instance }: CacheOptions) => void;
10
- export declare const reset: ({ instance }: CacheOptions) => Cache;
11
- export {};
@@ -1 +0,0 @@
1
- export * from './cache';
@@ -1,23 +0,0 @@
1
- import { AudienceSignals, IngestProfileEventsRequestBody, Profile, Session } from '@ninetailed/experience.js-shared';
2
- declare type NinetailedApiClientOptions = {
3
- clientId: string;
4
- environment: string;
5
- url?: string;
6
- };
7
- declare type ProfileOptions = IngestProfileEventsRequestBody & {
8
- timeout?: number;
9
- };
10
- declare type ProfileResponse = {
11
- profile: Profile;
12
- signals: AudienceSignals;
13
- traitsUpdatedAt: string;
14
- sessions: Session[];
15
- };
16
- export declare class NinetailedApiClient {
17
- private readonly clientId;
18
- private readonly environment;
19
- private readonly url;
20
- constructor({ clientId, environment, url, }: NinetailedApiClientOptions);
21
- profile(options: ProfileOptions): Promise<ProfileResponse>;
22
- }
23
- export {};
@@ -1 +0,0 @@
1
- export * from './apiClient';
@@ -1,10 +0,0 @@
1
- import { LogSink } from './LogSink';
2
- export declare class ConsoleLogSink implements LogSink {
3
- name: string;
4
- debug(message: string, ...args: unknown[]): void;
5
- info(message: string, ...args: unknown[]): void;
6
- log(message: string, ...args: unknown[]): void;
7
- warn(message: string, ...args: unknown[]): void;
8
- error(message: string | Error, ...args: unknown[]): void;
9
- fatal(message: string | Error, ...args: unknown[]): void;
10
- }
@@ -1,10 +0,0 @@
1
- import { LogFn, LogFnAsError } from 'diary';
2
- export interface LogSink {
3
- name: string;
4
- debug?: LogFn;
5
- info?: LogFn;
6
- log?: LogFn;
7
- warn?: LogFn;
8
- error?: LogFnAsError;
9
- fatal?: LogFnAsError;
10
- }
@@ -1,17 +0,0 @@
1
- import { LogSink } from './LogSink';
2
- export declare class Logger {
3
- readonly name = "@ninetailed/experience.js";
4
- private readonly diary;
5
- private sinks;
6
- constructor();
7
- addSink(sink: LogSink): void;
8
- removeSink(name: string): void;
9
- debug(message: string, ...args: unknown[]): void;
10
- info(message: string, ...args: unknown[]): void;
11
- log(message: string, ...args: unknown[]): void;
12
- warn(message: string, ...args: unknown[]): void;
13
- error(message: string | Error, ...args: unknown[]): void;
14
- fatal(message: string | Error, ...args: unknown[]): void;
15
- private onLogEvent;
16
- }
17
- export declare const logger: Logger;
@@ -1,10 +0,0 @@
1
- import { LogFnAsError } from 'diary';
2
- import { LogSink } from './LogSink';
3
- export declare type OnErrorHandler = LogFnAsError;
4
- export declare class OnErrorLogSink implements LogSink {
5
- private readonly onError;
6
- name: string;
7
- constructor(onError: OnErrorHandler);
8
- error(message: string | Error, ...args: unknown[]): void;
9
- fatal(message: string | Error, ...args: unknown[]): void;
10
- }
@@ -1,12 +0,0 @@
1
- import { LogFnAsError } from 'diary';
2
- import { LogSink } from './LogSink';
3
- export declare type OnLogHandler = LogFnAsError;
4
- export declare class OnLogLogSink implements LogSink {
5
- private readonly onLog;
6
- name: string;
7
- constructor(onLog: OnLogHandler);
8
- debug(message: string, ...args: unknown[]): void;
9
- info(message: string, ...args: unknown[]): void;
10
- log(message: string, ...args: unknown[]): void;
11
- warn(message: string, ...args: unknown[]): void;
12
- }
@@ -1,7 +0,0 @@
1
- export { Logger, logger } from './Logger';
2
- export { ConsoleLogSink } from './ConsoleLogSink';
3
- export { OnLogLogSink } from './OnLogLogSink';
4
- export { OnErrorLogSink } from './OnErrorLogSink';
5
- export type { LogSink } from './LogSink';
6
- export type { OnLogHandler } from './OnLogLogSink';
7
- export type { OnErrorHandler } from './OnErrorLogSink';