@ninetailed/experience.js-react 2.0.2 → 2.1.1-beta.1

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.esm.js CHANGED
@@ -30,7 +30,9 @@ const NinetailedProvider = ({
30
30
  profile,
31
31
  locale,
32
32
  requestTimeout,
33
- plugins: _plugins = []
33
+ plugins: _plugins = [],
34
+ onLog,
35
+ onError
34
36
  }) => {
35
37
  const ninetailed = useMemo(() => new Ninetailed({
36
38
  clientId,
@@ -41,7 +43,9 @@ const NinetailedProvider = ({
41
43
  plugins: _plugins,
42
44
  profile,
43
45
  locale,
44
- requestTimeout
46
+ requestTimeout,
47
+ onLog,
48
+ onError
45
49
  }), []);
46
50
  return /*#__PURE__*/React.createElement(NinetailedContext.Provider, {
47
51
  value: ninetailed
@@ -2571,10 +2575,14 @@ const DefaultExperienceLoadingComponent = _a => {
2571
2575
  } = _a,
2572
2576
  baseline = __rest(_a, ["component", "experiences", "unhideAfterMs"]);
2573
2577
 
2578
+ const {
2579
+ logger
2580
+ } = useNinetailed();
2574
2581
  const [hidden, setHidden] = useState(true);
2575
2582
  useEffect(() => {
2576
2583
  const timer = setTimeout(() => {
2577
2584
  setHidden(false);
2585
+ logger.error(new Error(`The experience was still in loading state after ${unhideAfterMs}ms. That happens when no events are sent to the Ninetailed API. The baseline is now shown instead.`));
2578
2586
  }, unhideAfterMs);
2579
2587
  return () => {
2580
2588
  clearTimeout(timer);
package/index.umd.js CHANGED
@@ -36,7 +36,9 @@
36
36
  locale = _a.locale,
37
37
  requestTimeout = _a.requestTimeout,
38
38
  _c = _a.plugins,
39
- plugins = _c === void 0 ? [] : _c;
39
+ plugins = _c === void 0 ? [] : _c,
40
+ onLog = _a.onLog,
41
+ onError = _a.onError;
40
42
  var ninetailed = React.useMemo(function () {
41
43
  return new experience_js.Ninetailed({
42
44
  clientId: clientId,
@@ -47,7 +49,9 @@
47
49
  plugins: plugins,
48
50
  profile: profile,
49
51
  locale: locale,
50
- requestTimeout: requestTimeout
52
+ requestTimeout: requestTimeout,
53
+ onLog: onLog,
54
+ onError: onError
51
55
  });
52
56
  }, []);
53
57
  return /*#__PURE__*/React__default["default"].createElement(NinetailedContext.Provider, {
@@ -2117,6 +2121,8 @@
2117
2121
  unhideAfterMs = _b === void 0 ? 5000 : _b,
2118
2122
  baseline = __rest(_a, ["component", "experiences", "unhideAfterMs"]);
2119
2123
 
2124
+ var logger = useNinetailed().logger;
2125
+
2120
2126
  var _c = React.useState(true),
2121
2127
  hidden = _c[0],
2122
2128
  setHidden = _c[1];
@@ -2124,6 +2130,7 @@
2124
2130
  React.useEffect(function () {
2125
2131
  var timer = setTimeout(function () {
2126
2132
  setHidden(false);
2133
+ logger.error(new Error("The experience was still in loading state after ".concat(unhideAfterMs, "ms. That happens when no events are sent to the Ninetailed API. The baseline is now shown instead.")));
2127
2134
  }, unhideAfterMs);
2128
2135
  return function () {
2129
2136
  clearTimeout(timer);
@@ -1,4 +1,4 @@
1
- import { ExperienceConfiguration } from './types';
1
+ import { ExperienceConfiguration } from '@ninetailed/experience.js';
2
2
  declare type ExperimentsContextValue = {
3
3
  experiments: ExperienceConfiguration[];
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ExperienceConfiguration } from './types';
2
+ import { ExperienceConfiguration } from '@ninetailed/experience.js';
3
3
  declare type ExperimentsProviderProps = {
4
4
  experiments: ExperienceConfiguration[];
5
5
  };
@@ -1,4 +1,3 @@
1
1
  export type { Baseline } from './Baseline';
2
2
  export type { Variant } from './Variant';
3
3
  export type { BaselineWithVariants } from './BaselineWithVariants';
4
- export type { ExperienceConfiguration } from './ExperienceConfiguration';
@@ -1,5 +1,4 @@
1
- import { Profile } from '@ninetailed/experience.js';
2
- import { ExperienceConfiguration } from './types';
1
+ import { Profile, ExperienceConfiguration } from '@ninetailed/experience.js';
3
2
  declare type UseJoinExperimentArgs = {
4
3
  experiences: ExperienceConfiguration[];
5
4
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AnalyticsPlugin } from 'analytics';
3
+ import { OnErrorHandler, OnLogHandler, ExperienceConfiguration } from '@ninetailed/experience.js';
3
4
  import { Profile, Locale } from '@ninetailed/experience.js-shared';
4
- import { ExperienceConfiguration } from './Experience/types';
5
5
  export declare type NinetailedProviderProps = {
6
6
  clientId: string;
7
7
  environment?: string;
@@ -12,5 +12,7 @@ export declare type NinetailedProviderProps = {
12
12
  profile?: Profile;
13
13
  locale?: Locale;
14
14
  requestTimeout?: number;
15
+ onLog?: OnLogHandler;
16
+ onError?: OnErrorHandler;
15
17
  };
16
18
  export declare const NinetailedProvider: React.FC<React.PropsWithChildren<NinetailedProviderProps>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "2.0.2",
3
+ "version": "2.1.1-beta.1",
4
4
  "peerDependencies": {
5
5
  "react": ">=16.8.0"
6
6
  },
@@ -8,15 +8,15 @@
8
8
  "@analytics/google-analytics": "0.5.3",
9
9
  "react-visibility-sensor": "5.1.1",
10
10
  "lodash": "^4.17.21",
11
- "@ninetailed/experience.js": "2.0.2",
11
+ "@ninetailed/experience.js": "2.1.1-beta.1",
12
12
  "analytics": "^0.8.0",
13
- "@ninetailed/experience.js-shared": "2.0.2",
13
+ "@ninetailed/experience.js-shared": "2.1.1-beta.1",
14
14
  "uuid": "^8.3.2",
15
15
  "ts-toolbelt": "^9.6.0",
16
16
  "locale-enum": "^1.1.1",
17
17
  "i18n-iso-countries": "^7.3.0",
18
- "loglevel": "^1.8.0",
19
18
  "murmurhash-js": "^1.0.0",
19
+ "diary": "^0.3.1",
20
20
  "react-intersection-observer": "^8.33.1"
21
21
  },
22
22
  "main": "./index.umd.js",