@ninetailed/experience.js 7.4.2 → 7.5.0-beta.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 (44) hide show
  1. package/README.md +28 -3
  2. package/index.cjs +17 -18
  3. package/index.js +17 -18
  4. package/package.json +4 -3
  5. package/{index.d.ts → src/index.d.ts} +1 -1
  6. package/{lib → src/lib}/Ninetailed.d.ts +3 -2
  7. package/{lib/analytics → src/lib/ninetailedCorePlugin}/index.d.ts +1 -1
  8. package/src/lib/ninetailedCorePlugin/ninetailedCorePlugin.d.ts +16 -0
  9. package/{lib → src/lib}/types/NinetailedPlugin.d.ts +0 -3
  10. package/src/lib/utils/asyncThrottle.d.ts +5 -0
  11. package/lib/analytics/get-analytics-plugin.d.ts +0 -17
  12. package/lib/utils/asyncThrottle.d.ts +0 -6
  13. /package/{lib → src/lib}/ElementSeenObserver.d.ts +0 -0
  14. /package/{lib → src/lib}/constants.d.ts +0 -0
  15. /package/{lib → src/lib}/experience/decodeExperienceVariantsMap.d.ts +0 -0
  16. /package/{lib → src/lib}/experience/index.d.ts +0 -0
  17. /package/{lib → src/lib}/experience/makeExperienceSelectMiddleware.d.ts +0 -0
  18. /package/{lib → src/lib}/experience/types/index.d.ts +0 -0
  19. /package/{lib → src/lib}/guards/acceptsCredentials.d.ts +0 -0
  20. /package/{lib → src/lib}/guards/hasExperienceSelectionMiddleware.d.ts +0 -0
  21. /package/{lib → src/lib}/guards/hasOnChangeEmitter.d.ts +0 -0
  22. /package/{lib → src/lib}/guards/isInterestedInHiddenPage.d.ts +0 -0
  23. /package/{lib → src/lib}/guards/isInterestedInSeenElements.d.ts +0 -0
  24. /package/{lib/analytics → src/lib/ninetailedCorePlugin}/Events/build-context.d.ts +0 -0
  25. /package/{lib/analytics → src/lib/ninetailedCorePlugin}/Events/build-locale.d.ts +0 -0
  26. /package/{lib/analytics → src/lib/ninetailedCorePlugin}/Events/index.d.ts +0 -0
  27. /package/{lib/analytics → src/lib/ninetailedCorePlugin}/constants.d.ts +0 -0
  28. /package/{lib → src/lib}/plugins/selectPluginsHavingExperienceSelectionMiddleware.d.ts +0 -0
  29. /package/{lib → src/lib}/plugins/selectPluginsHavingOnChangeEmitter.d.ts +0 -0
  30. /package/{lib → src/lib}/selectVariant.d.ts +0 -0
  31. /package/{lib → src/lib}/types/AnalyticsInstance.d.ts +0 -0
  32. /package/{lib → src/lib}/types/Credentials.d.ts +0 -0
  33. /package/{lib → src/lib}/types/ElementSeenPayload.d.ts +0 -0
  34. /package/{lib → src/lib}/types/EventHandler.d.ts +0 -0
  35. /package/{lib → src/lib}/types/ProfileChangedPayload.d.ts +0 -0
  36. /package/{lib → src/lib}/types/TrackingProperties.d.ts +0 -0
  37. /package/{lib → src/lib}/types/index.d.ts +0 -0
  38. /package/{lib → src/lib}/types/interfaces/AcceptsCredentials.d.ts +0 -0
  39. /package/{lib → src/lib}/types/interfaces/HasExperienceSelectionMiddleware.d.ts +0 -0
  40. /package/{lib → src/lib}/types/interfaces/HasOnChangeEmitter.d.ts +0 -0
  41. /package/{lib → src/lib}/types/interfaces/InterestedInHiddenPage.d.ts +0 -0
  42. /package/{lib → src/lib}/types/interfaces/InterestedInProfileChange.d.ts +0 -0
  43. /package/{lib → src/lib}/types/interfaces/InterestedInSeenElements.d.ts +0 -0
  44. /package/{lib → src/lib}/utils/OnChangeEmitter.d.ts +0 -0
package/README.md CHANGED
@@ -1,7 +1,32 @@
1
- # experience-sdk-javascript
1
+ # @ninetailed/experience.js
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ <!--Insert badges begin-->
4
+ <!--GENERATED TEXT - DO NOT EDIT HERE -->
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@ninetailed/experience.js"><img src="https://img.shields.io/npm/v/@ninetailed/experience.js.svg" alt="NPM Version" /></a>
7
+ <a href="https://www.npmjs.com/package/@ninetailed/experience.js"><img src="https://img.shields.io/npm/l/@ninetailed/experience.js.svg" alt="Package License" /></a>
8
+ <a href="https://www.npmjs.com/package/@ninetailed/experience.js"><img src="https://img.shields.io/npm/dm/@ninetailed/experience.js.svg" alt="NPM Downloads" /></a>
9
+ <a href="https://docs.ninetailed.io/" target="_blank"><img src="https://img.shields.io/badge/%F0%9F%93%96-Documentation-green.svg" alt="Documentation"/></a>
10
+ <a href="ninetailed-community.slack.com" target="_blank"><img src="https://img.shields.io/badge/Slack-Ninetailed%20Community-blue.svg" alt="Join the official Slack community"/>
11
+ </p>
12
+
13
+ <!--Insert badges end-->
14
+
15
+ <!--Insert template begin-->
16
+ <!--GENERATED TEXT - DO NOT EDIT HERE -->
17
+
18
+ ## About Ninetailed
19
+
20
+ Our extensible [Experience SDKs](https://docs.ninetailed.io/#getting-started-for-developers) help you integrate Ninetailed Experiences into your JavaScript / TypeScript applications. With support for ESR and SSR, out-of-the-box utilities, and plugins, you have all the tools you need to get started.
21
+
22
+ Using a framework we don't currently support? No problem! Our [Experience API](https://docs.ninetailed.io/for-developers/experience-api) enables you to use Ninetailed Experiences virtually anywhere.
23
+
24
+ <!--Insert template end-->
25
+
26
+ ## Building
27
+
28
+ Run `nx build sdks-javascript` to build the library.
4
29
 
5
30
  ## Running unit tests
6
31
 
7
- Run `nx test experience-sdk-javascript` to execute the unit tests via [Jest](https://jestjs.io).
32
+ Run `nx test sdks-javascript` to execute the unit tests via [Jest](https://jestjs.io).
package/index.cjs CHANGED
@@ -66,9 +66,8 @@ const buildClientNinetailedRequestContext = () => ({
66
66
  });
67
67
 
68
68
  /**
69
- * Similar to _.throttle but waits for the promise to resolve. There is no
70
- * wait time because you can simply await `Promise.timeout` inside `fn`
71
- * to wait some time before the next call.
69
+ * Similar to _.throttle but waits for the promise to resolve.
70
+ * There is no "wait time" because you can simply await `Promise.timeout` inside `fn` to wait some time before the next call.
72
71
  */
73
72
  function asyncThrottle(fn) {
74
73
  let runningPromise;
@@ -107,11 +106,11 @@ const EMPTY_MERGE_ID = 'nt:empty-merge-id';
107
106
 
108
107
  const PLUGIN_NAME = 'ninetailed';
109
108
  const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
110
- const ninetailedPlugin = ({
109
+ const ninetailedCorePlugin = ({
111
110
  apiClient,
112
- profile,
113
111
  locale,
114
112
  ninetailed,
113
+ onInitProfileId,
115
114
  buildClientContext
116
115
  }) => {
117
116
  let _instance;
@@ -168,7 +167,6 @@ const ninetailedPlugin = ({
168
167
  experience_jsShared.logger.debug('No fallback profile found - setting profile to null.');
169
168
  _instance.dispatch({
170
169
  type: PROFILE_CHANGE,
171
- // TODO is it a good idea to set the profile to null?
172
170
  profile: null,
173
171
  experiences: fallbackExperiences,
174
172
  error
@@ -209,8 +207,11 @@ const ninetailedPlugin = ({
209
207
  instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
210
208
  instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
211
209
  }
212
- if (profile) {
213
- instance.storage.setItem(ANONYMOUS_ID, profile.id);
210
+ if (typeof onInitProfileId === 'function') {
211
+ const profileId = onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
212
+ if (typeof profileId === 'string') {
213
+ instance.storage.setItem(ANONYMOUS_ID, profileId);
214
+ }
214
215
  }
215
216
  instance.on(SET_ENABLED_FEATURES, ({
216
217
  payload
@@ -282,7 +283,6 @@ const ninetailedPlugin = ({
282
283
  },
283
284
  methods: {
284
285
  reset: (...args) => __awaiter(void 0, void 0, void 0, function* () {
285
- // TODO it seems reset gets called during Next.js SSR builds. Need to verify that.
286
286
  experience_jsShared.logger.debug('Resetting profile.');
287
287
  const instance = args[args.length - 1];
288
288
  instance.dispatch({
@@ -371,6 +371,7 @@ class Ninetailed {
371
371
  onLog,
372
372
  onError,
373
373
  buildClientContext,
374
+ onInitProfileId,
374
375
  componentViewTrackingThreshold = 2000,
375
376
  storageImpl
376
377
  } = {}) {
@@ -383,7 +384,7 @@ class Ninetailed {
383
384
  }
384
385
  yield this.waitUntilInitialized();
385
386
  yield this.instance.page(data, this.buildOptions(options));
386
- return this.eventQueue.flush();
387
+ return this.ninetailedCorePlugin.flush();
387
388
  } catch (error) {
388
389
  experience_jsShared.logger.error(error);
389
390
  if (error instanceof RangeError) {
@@ -400,7 +401,7 @@ class Ninetailed {
400
401
  }
401
402
  yield this.waitUntilInitialized();
402
403
  yield this.instance.track(event.toString(), result.data, this.buildOptions(options));
403
- return this.eventQueue.flush();
404
+ return this.ninetailedCorePlugin.flush();
404
405
  } catch (error) {
405
406
  experience_jsShared.logger.error(error);
406
407
  if (error instanceof RangeError) {
@@ -460,7 +461,7 @@ class Ninetailed {
460
461
  }
461
462
  yield this.waitUntilInitialized();
462
463
  yield this.instance.identify(uid && uid.toString() !== '' ? uid.toString() : EMPTY_MERGE_ID, result.data, this.buildOptions(options));
463
- return this.eventQueue.flush();
464
+ return this.ninetailedCorePlugin.flush();
464
465
  } catch (error) {
465
466
  experience_jsShared.logger.error(error);
466
467
  if (error instanceof RangeError) {
@@ -573,16 +574,17 @@ class Ninetailed {
573
574
  experience_jsShared.logger.addSink(new experience_jsShared.OnErrorLogSink(onError));
574
575
  }
575
576
  this.logger = experience_jsShared.logger;
576
- this.eventQueue = ninetailedPlugin({
577
+ this.ninetailedCorePlugin = ninetailedCorePlugin({
577
578
  apiClient: this.apiClient,
578
579
  locale,
579
580
  requestTimeout,
580
581
  buildClientContext,
582
+ onInitProfileId,
581
583
  ninetailed: this
582
584
  });
583
585
  this.instance = Analytics__default["default"](Object.assign({
584
586
  app: 'ninetailed',
585
- plugins: [...this.plugins, this.eventQueue]
587
+ plugins: [...this.plugins, this.ninetailedCorePlugin]
586
588
  }, storageImpl ? {
587
589
  storage: storageImpl
588
590
  } : {}));
@@ -730,9 +732,6 @@ const TrackComponentProperties = zod.z.object({
730
732
  isPersonalized: zod.z.boolean()
731
733
  });
732
734
 
733
- /**
734
- * @deprecated Use `NinetailedPlugin` from the sdks/javascript package instead.
735
- */
736
735
  class NinetailedPlugin {}
737
736
 
738
737
  const ElementSeenPayloadSchema = zod.z.object({
@@ -932,7 +931,7 @@ exports.TrackComponentProperties = TrackComponentProperties;
932
931
  exports.buildClientNinetailedRequestContext = buildClientNinetailedRequestContext;
933
932
  exports.decodeExperienceVariantsMap = decodeExperienceVariantsMap;
934
933
  exports.makeExperienceSelectMiddleware = makeExperienceSelectMiddleware;
935
- exports.ninetailedPlugin = ninetailedPlugin;
934
+ exports.ninetailedCorePlugin = ninetailedCorePlugin;
936
935
  exports.selectPluginsHavingExperienceSelectionMiddleware = selectPluginsHavingExperienceSelectionMiddleware;
937
936
  exports.selectPluginsHavingOnChangeEmitter = selectPluginsHavingOnChangeEmitter;
938
937
  exports.selectVariant = selectVariant;
package/index.js CHANGED
@@ -59,9 +59,8 @@ const buildClientNinetailedRequestContext = () => ({
59
59
  });
60
60
 
61
61
  /**
62
- * Similar to _.throttle but waits for the promise to resolve. There is no
63
- * wait time because you can simply await `Promise.timeout` inside `fn`
64
- * to wait some time before the next call.
62
+ * Similar to _.throttle but waits for the promise to resolve.
63
+ * There is no "wait time" because you can simply await `Promise.timeout` inside `fn` to wait some time before the next call.
65
64
  */
66
65
  function asyncThrottle(fn) {
67
66
  let runningPromise;
@@ -100,11 +99,11 @@ const EMPTY_MERGE_ID = 'nt:empty-merge-id';
100
99
 
101
100
  const PLUGIN_NAME = 'ninetailed';
102
101
  const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
103
- const ninetailedPlugin = ({
102
+ const ninetailedCorePlugin = ({
104
103
  apiClient,
105
- profile,
106
104
  locale,
107
105
  ninetailed,
106
+ onInitProfileId,
108
107
  buildClientContext
109
108
  }) => {
110
109
  let _instance;
@@ -161,7 +160,6 @@ const ninetailedPlugin = ({
161
160
  logger.debug('No fallback profile found - setting profile to null.');
162
161
  _instance.dispatch({
163
162
  type: PROFILE_CHANGE,
164
- // TODO is it a good idea to set the profile to null?
165
163
  profile: null,
166
164
  experiences: fallbackExperiences,
167
165
  error
@@ -202,8 +200,11 @@ const ninetailedPlugin = ({
202
200
  instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
203
201
  instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
204
202
  }
205
- if (profile) {
206
- instance.storage.setItem(ANONYMOUS_ID, profile.id);
203
+ if (typeof onInitProfileId === 'function') {
204
+ const profileId = onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
205
+ if (typeof profileId === 'string') {
206
+ instance.storage.setItem(ANONYMOUS_ID, profileId);
207
+ }
207
208
  }
208
209
  instance.on(SET_ENABLED_FEATURES, ({
209
210
  payload
@@ -275,7 +276,6 @@ const ninetailedPlugin = ({
275
276
  },
276
277
  methods: {
277
278
  reset: (...args) => __awaiter(void 0, void 0, void 0, function* () {
278
- // TODO it seems reset gets called during Next.js SSR builds. Need to verify that.
279
279
  logger.debug('Resetting profile.');
280
280
  const instance = args[args.length - 1];
281
281
  instance.dispatch({
@@ -364,6 +364,7 @@ class Ninetailed {
364
364
  onLog,
365
365
  onError,
366
366
  buildClientContext,
367
+ onInitProfileId,
367
368
  componentViewTrackingThreshold = 2000,
368
369
  storageImpl
369
370
  } = {}) {
@@ -376,7 +377,7 @@ class Ninetailed {
376
377
  }
377
378
  yield this.waitUntilInitialized();
378
379
  yield this.instance.page(data, this.buildOptions(options));
379
- return this.eventQueue.flush();
380
+ return this.ninetailedCorePlugin.flush();
380
381
  } catch (error) {
381
382
  logger.error(error);
382
383
  if (error instanceof RangeError) {
@@ -393,7 +394,7 @@ class Ninetailed {
393
394
  }
394
395
  yield this.waitUntilInitialized();
395
396
  yield this.instance.track(event.toString(), result.data, this.buildOptions(options));
396
- return this.eventQueue.flush();
397
+ return this.ninetailedCorePlugin.flush();
397
398
  } catch (error) {
398
399
  logger.error(error);
399
400
  if (error instanceof RangeError) {
@@ -453,7 +454,7 @@ class Ninetailed {
453
454
  }
454
455
  yield this.waitUntilInitialized();
455
456
  yield this.instance.identify(uid && uid.toString() !== '' ? uid.toString() : EMPTY_MERGE_ID, result.data, this.buildOptions(options));
456
- return this.eventQueue.flush();
457
+ return this.ninetailedCorePlugin.flush();
457
458
  } catch (error) {
458
459
  logger.error(error);
459
460
  if (error instanceof RangeError) {
@@ -566,16 +567,17 @@ class Ninetailed {
566
567
  logger.addSink(new OnErrorLogSink(onError));
567
568
  }
568
569
  this.logger = logger;
569
- this.eventQueue = ninetailedPlugin({
570
+ this.ninetailedCorePlugin = ninetailedCorePlugin({
570
571
  apiClient: this.apiClient,
571
572
  locale,
572
573
  requestTimeout,
573
574
  buildClientContext,
575
+ onInitProfileId,
574
576
  ninetailed: this
575
577
  });
576
578
  this.instance = Analytics(Object.assign({
577
579
  app: 'ninetailed',
578
- plugins: [...this.plugins, this.eventQueue]
580
+ plugins: [...this.plugins, this.ninetailedCorePlugin]
579
581
  }, storageImpl ? {
580
582
  storage: storageImpl
581
583
  } : {}));
@@ -723,9 +725,6 @@ const TrackComponentProperties = z.object({
723
725
  isPersonalized: z.boolean()
724
726
  });
725
727
 
726
- /**
727
- * @deprecated Use `NinetailedPlugin` from the sdks/javascript package instead.
728
- */
729
728
  class NinetailedPlugin {}
730
729
 
731
730
  const ElementSeenPayloadSchema = z.object({
@@ -865,4 +864,4 @@ const makeExperienceSelectMiddleware = ({
865
864
  };
866
865
  };
867
866
 
868
- export { ANONYMOUS_ID, COMPONENT, COMPONENT_START, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCES_FALLBACK_CACHE, ElementSeenPayloadSchema, 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 };
867
+ export { ANONYMOUS_ID, COMPONENT, COMPONENT_START, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCES_FALLBACK_CACHE, ElementSeenPayloadSchema, 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, ninetailedCorePlugin, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "7.4.2",
3
+ "version": "7.5.0-beta.0",
4
+ "license": "BSL-1.1",
4
5
  "module": "./index.js",
5
6
  "main": "./index.cjs",
6
7
  "type": "module",
7
- "types": "./index.d.ts",
8
+ "types": "./src/index.d.ts",
8
9
  "dependencies": {
9
- "@ninetailed/experience.js-shared": "7.4.2",
10
+ "@ninetailed/experience.js-shared": "7.5.0-beta.0",
10
11
  "analytics": "0.8.1",
11
12
  "zod": "3.21.4"
12
13
  },
@@ -1,5 +1,5 @@
1
1
  export * from './lib/constants';
2
- export * from './lib/analytics';
2
+ export * from './lib/ninetailedCorePlugin';
3
3
  export * from './lib/Ninetailed';
4
4
  export * from './lib/selectVariant';
5
5
  export * from './lib/types';
@@ -28,6 +28,7 @@ type Options = {
28
28
  onLog?: OnLogHandler;
29
29
  onError?: OnErrorHandler;
30
30
  componentViewTrackingThreshold?: number;
31
+ onInitProfileId?: (profileId?: string) => string | undefined;
31
32
  buildClientContext?: () => NinetailedRequestContext;
32
33
  storageImpl?: Storage;
33
34
  };
@@ -37,7 +38,7 @@ export declare class Ninetailed implements NinetailedInstance {
37
38
  private _profileState;
38
39
  private isInitialized;
39
40
  private readonly apiClient;
40
- private readonly eventQueue;
41
+ private readonly ninetailedCorePlugin;
41
42
  private readonly elementSeenObserver;
42
43
  private readonly observedElements;
43
44
  private readonly clientId;
@@ -45,7 +46,7 @@ export declare class Ninetailed implements NinetailedInstance {
45
46
  readonly plugins: NinetailedPlugin[];
46
47
  readonly logger: Logger;
47
48
  private readonly componentViewTrackingThreshold;
48
- constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, locale, requestTimeout, onLog, onError, buildClientContext, componentViewTrackingThreshold, storageImpl, }?: Options);
49
+ constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, locale, requestTimeout, onLog, onError, buildClientContext, onInitProfileId, componentViewTrackingThreshold, storageImpl, }?: Options);
49
50
  page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
50
51
  track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
51
52
  /**
@@ -1,3 +1,3 @@
1
- export * from './get-analytics-plugin';
1
+ export * from './ninetailedCorePlugin';
2
2
  export * from './constants';
3
3
  export * from './Events';
@@ -0,0 +1,16 @@
1
+ import { Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
2
+ import { NinetailedInstance, FlushResult, NinetailedPlugin } from '../types';
3
+ type AnalyticsPluginNinetailedConfig = {
4
+ apiClient: NinetailedApiClient;
5
+ locale?: Locale;
6
+ requestTimeout?: number;
7
+ onInitProfileId?: (profileId?: string) => string | undefined;
8
+ buildClientContext?: () => NinetailedRequestContext;
9
+ ninetailed: NinetailedInstance;
10
+ };
11
+ export declare const PLUGIN_NAME = "ninetailed";
12
+ export interface NinetailedCorePlugin extends NinetailedPlugin {
13
+ flush: () => Promise<FlushResult>;
14
+ }
15
+ export declare const ninetailedCorePlugin: ({ apiClient, locale, ninetailed, onInitProfileId, buildClientContext, }: AnalyticsPluginNinetailedConfig) => NinetailedCorePlugin;
16
+ export {};
@@ -5,9 +5,6 @@ export type EventHandlerParams<T = unknown> = {
5
5
  instance: AnalyticsInstance;
6
6
  };
7
7
  export type EventHandler<T = unknown> = (params: EventHandlerParams<T>) => void;
8
- /**
9
- * @deprecated Use `NinetailedPlugin` from the sdks/javascript package instead.
10
- */
11
8
  export declare abstract class NinetailedPlugin implements AnalyticsPlugin {
12
9
  [x: string]: unknown;
13
10
  abstract readonly name: string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Similar to _.throttle but waits for the promise to resolve.
3
+ * There is no "wait time" because you can simply await `Promise.timeout` inside `fn` to wait some time before the next call.
4
+ */
5
+ export declare function asyncThrottle<I, O = void>(fn: (args: I) => Promise<O>): (args: I) => Promise<O>;
@@ -1,17 +0,0 @@
1
- import { AnalyticsPlugin } from 'analytics';
2
- import { Profile, Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
3
- import { NinetailedInstance, FlushResult } from '../types';
4
- type AnalyticsPluginNinetailedConfig = {
5
- apiClient: NinetailedApiClient;
6
- profile?: Profile;
7
- locale?: Locale;
8
- requestTimeout?: number;
9
- buildClientContext?: () => NinetailedRequestContext;
10
- ninetailed: NinetailedInstance;
11
- };
12
- export declare const PLUGIN_NAME = "ninetailed";
13
- export interface NinetailedEventQueue extends AnalyticsPlugin {
14
- flush: () => Promise<FlushResult>;
15
- }
16
- export declare const ninetailedPlugin: ({ apiClient, profile, locale, ninetailed, buildClientContext, }: AnalyticsPluginNinetailedConfig) => NinetailedEventQueue;
17
- export {};
@@ -1,6 +0,0 @@
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>;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes