@ninetailed/experience.js-react 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.
package/README.md CHANGED
@@ -1,7 +1,32 @@
1
- # experience-sdk-react
1
+ # @ninetailed/experience.js-react
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-react"><img src="https://img.shields.io/npm/v/@ninetailed/experience.js-react.svg" alt="NPM Version" /></a>
7
+ <a href="https://www.npmjs.com/package/@ninetailed/experience.js-react"><img src="https://img.shields.io/npm/l/@ninetailed/experience.js-react.svg" alt="Package License" /></a>
8
+ <a href="https://www.npmjs.com/package/@ninetailed/experience.js-react"><img src="https://img.shields.io/npm/dm/@ninetailed/experience.js-react.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 test sdks-react` to build the library.
4
29
 
5
30
  ## Running unit tests
6
31
 
7
- Run `nx test experience-sdk-react` to execute the unit tests via [Jest](https://jestjs.io).
32
+ Run `nx test sdks-react` to execute the unit tests via [Jest](https://jestjs.io).
package/index.cjs CHANGED
@@ -32,6 +32,7 @@ const NinetailedProvider = props => {
32
32
  onLog,
33
33
  onError,
34
34
  buildClientContext,
35
+ onInitProfileId,
35
36
  componentViewTrackingThreshold,
36
37
  storageImpl
37
38
  } = props;
@@ -47,6 +48,7 @@ const NinetailedProvider = props => {
47
48
  onLog,
48
49
  onError,
49
50
  buildClientContext,
51
+ onInitProfileId,
50
52
  componentViewTrackingThreshold,
51
53
  storageImpl
52
54
  });
@@ -118,15 +120,6 @@ const useProfile = () => {
118
120
  }
119
121
  });
120
122
  }, []);
121
- /**
122
- * Old implementation without profile state deep comparison
123
- */
124
- /*useEffect(() => {
125
- return ninetailed.onProfileChange((profileState) => {
126
- console.log('profileState', profileState);
127
- setProfileState(profileState);
128
- });
129
- }, []);*/
130
123
  const profileStateWithoutExperiences = __rest(profileState, ["experiences"]);
131
124
  return Object.assign(Object.assign({}, profileStateWithoutExperiences), {
132
125
  loading: profileState.status === 'loading'
@@ -392,8 +385,15 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
392
385
  } = useNinetailed();
393
386
  const markerRef = React.useRef(null);
394
387
  React.useEffect(() => {
395
- // TODO: Create a better message
396
- logger.debug('Using fallback mechanism to select component.');
388
+ var _a;
389
+ /*
390
+ Due to React's limitation on setting !important styles during rendering, we set the display property on the DOM element directly.
391
+ See: https://github.com/facebook/react/issues/1881
392
+ */
393
+ (_a = markerRef.current) === null || _a === void 0 ? void 0 : _a.style.setProperty('display', 'none', 'important');
394
+ }, []);
395
+ React.useEffect(() => {
396
+ logger.debug('Using fallback mechanism to detect when experiences are seen. This can lead to inaccurate results. Consider using a forwardRef instead. See: https://docs.ninetailed.io/for-developers/experience-sdk/rendering-experiences#tracking-impressions-of-experiences');
397
397
  }, [logger]);
398
398
  React.useEffect(() => {
399
399
  if (markerRef.current) {
@@ -410,7 +410,7 @@ const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
410
410
  return jsxRuntime.jsx("div", {
411
411
  className: "nt-cmp-marker",
412
412
  style: {
413
- display: 'none !important'
413
+ display: 'none'
414
414
  },
415
415
  ref: markerRef
416
416
  });
@@ -474,7 +474,6 @@ const Experience = _a => {
474
474
  unobserveElement,
475
475
  logger
476
476
  } = useNinetailed();
477
- // TODO we actually could hook into the experience hook here with the plugins
478
477
  const {
479
478
  status,
480
479
  hasVariants,
package/index.js CHANGED
@@ -24,6 +24,7 @@ const NinetailedProvider = props => {
24
24
  onLog,
25
25
  onError,
26
26
  buildClientContext,
27
+ onInitProfileId,
27
28
  componentViewTrackingThreshold,
28
29
  storageImpl
29
30
  } = props;
@@ -39,6 +40,7 @@ const NinetailedProvider = props => {
39
40
  onLog,
40
41
  onError,
41
42
  buildClientContext,
43
+ onInitProfileId,
42
44
  componentViewTrackingThreshold,
43
45
  storageImpl
44
46
  });
@@ -110,15 +112,6 @@ const useProfile = () => {
110
112
  }
111
113
  });
112
114
  }, []);
113
- /**
114
- * Old implementation without profile state deep comparison
115
- */
116
- /*useEffect(() => {
117
- return ninetailed.onProfileChange((profileState) => {
118
- console.log('profileState', profileState);
119
- setProfileState(profileState);
120
- });
121
- }, []);*/
122
115
  const profileStateWithoutExperiences = __rest(profileState, ["experiences"]);
123
116
  return Object.assign(Object.assign({}, profileStateWithoutExperiences), {
124
117
  loading: profileState.status === 'loading'
@@ -384,8 +377,15 @@ const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
384
377
  } = useNinetailed();
385
378
  const markerRef = useRef(null);
386
379
  useEffect(() => {
387
- // TODO: Create a better message
388
- logger.debug('Using fallback mechanism to select component.');
380
+ var _a;
381
+ /*
382
+ Due to React's limitation on setting !important styles during rendering, we set the display property on the DOM element directly.
383
+ See: https://github.com/facebook/react/issues/1881
384
+ */
385
+ (_a = markerRef.current) === null || _a === void 0 ? void 0 : _a.style.setProperty('display', 'none', 'important');
386
+ }, []);
387
+ useEffect(() => {
388
+ logger.debug('Using fallback mechanism to detect when experiences are seen. This can lead to inaccurate results. Consider using a forwardRef instead. See: https://docs.ninetailed.io/for-developers/experience-sdk/rendering-experiences#tracking-impressions-of-experiences');
389
389
  }, [logger]);
390
390
  useEffect(() => {
391
391
  if (markerRef.current) {
@@ -402,7 +402,7 @@ const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
402
402
  return jsx("div", {
403
403
  className: "nt-cmp-marker",
404
404
  style: {
405
- display: 'none !important'
405
+ display: 'none'
406
406
  },
407
407
  ref: markerRef
408
408
  });
@@ -466,7 +466,6 @@ const Experience = _a => {
466
466
  unobserveElement,
467
467
  logger
468
468
  } = useNinetailed();
469
- // TODO we actually could hook into the experience hook here with the plugins
470
469
  const {
471
470
  status,
472
471
  hasVariants,
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "7.4.2",
3
+ "version": "7.5.0-beta.0",
4
4
  "peerDependencies": {
5
5
  "react": ">=16.8.0"
6
6
  },
7
+ "license": "BSL-1.1",
7
8
  "module": "./index.js",
8
9
  "main": "./index.cjs",
9
10
  "type": "module",
10
- "types": "./index.d.ts",
11
+ "types": "./src/index.d.ts",
11
12
  "dependencies": {
12
- "@ninetailed/experience.js": "7.4.2",
13
- "react-is": "18.2.0",
14
- "@ninetailed/experience.js-shared": "7.4.2",
13
+ "@ninetailed/experience.js": "7.5.0-beta.0",
14
+ "@ninetailed/experience.js-shared": "7.5.0-beta.0",
15
15
  "radash": "10.9.0",
16
- "react-intersection-observer": "8.34.0"
16
+ "react-intersection-observer": "8.34.0",
17
+ "react-is": "18.2.0"
17
18
  }
18
19
  }
@@ -14,6 +14,7 @@ export type NinetailedProviderInstantiationProps = {
14
14
  onError?: OnErrorHandler;
15
15
  componentViewTrackingThreshold?: number;
16
16
  buildClientContext?: () => NinetailedRequestContext;
17
+ onInitProfileId?: (profileId?: string) => string | undefined;
17
18
  storageImpl?: Storage;
18
19
  };
19
20
  export type NinetailedProviderProps = NinetailedProviderInstantiationProps | {
@@ -0,0 +1 @@
1
+ export declare const useNinetailed: () => import("dist/packages/sdks/javascript/src").NinetailedInstance;
@@ -1 +0,0 @@
1
- export declare const useNinetailed: () => import("@ninetailed/experience.js").NinetailedInstance;
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
File without changes
File without changes