@ninetailed/experience.js-react 7.9.4-beta.0 → 7.11.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/index.cjs.js +18 -7
- package/index.esm.js +19 -7
- package/package.json +5 -7
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,6 @@ var React = require('react');
|
|
|
7
7
|
var experience_js = require('@ninetailed/experience.js');
|
|
8
8
|
var experience_jsShared = require('@ninetailed/experience.js-shared');
|
|
9
9
|
var radash = require('radash');
|
|
10
|
-
var reactIntersectionObserver = require('react-intersection-observer');
|
|
11
10
|
var reactIs = require('react-is');
|
|
12
11
|
|
|
13
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -142,12 +141,24 @@ const TrackHasSeenComponent = ({
|
|
|
142
141
|
isPersonalized
|
|
143
142
|
}) => {
|
|
144
143
|
const ninetailed = useNinetailed();
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
const [inView, setInView] = React.useState(false);
|
|
145
|
+
const ref = React.useRef(null);
|
|
146
|
+
React.useEffect(() => {
|
|
147
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
148
|
+
if (entry.isIntersecting) {
|
|
149
|
+
setInView(true);
|
|
150
|
+
// Disconnect the observer since we only want to track
|
|
151
|
+
// the first time the component is seen
|
|
152
|
+
observer.disconnect();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
if (ref.current) {
|
|
156
|
+
observer.observe(ref.current);
|
|
157
|
+
}
|
|
158
|
+
return () => {
|
|
159
|
+
observer.disconnect();
|
|
160
|
+
};
|
|
161
|
+
}, []);
|
|
151
162
|
React.useEffect(() => {
|
|
152
163
|
if (experience_jsShared.isBrowser() && inView) {
|
|
153
164
|
ninetailed.trackHasSeenComponent({
|
package/index.esm.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Ninetailed, selectVariant, selectHasExperienceVariants } from '@ninetai
|
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { logger, isBrowser } from '@ninetailed/experience.js-shared';
|
|
5
5
|
import { isEqual, get } from 'radash';
|
|
6
|
-
import { useInView } from 'react-intersection-observer';
|
|
7
6
|
import { isForwardRef } from 'react-is';
|
|
8
7
|
|
|
9
8
|
const NinetailedContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -121,12 +120,25 @@ const TrackHasSeenComponent = ({
|
|
|
121
120
|
isPersonalized
|
|
122
121
|
}) => {
|
|
123
122
|
const ninetailed = useNinetailed();
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
const [inView, setInView] = useState(false);
|
|
124
|
+
const ref = useRef(null);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
127
|
+
if (entry.isIntersecting) {
|
|
128
|
+
setInView(true);
|
|
129
|
+
|
|
130
|
+
// Disconnect the observer since we only want to track
|
|
131
|
+
// the first time the component is seen
|
|
132
|
+
observer.disconnect();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (ref.current) {
|
|
136
|
+
observer.observe(ref.current);
|
|
137
|
+
}
|
|
138
|
+
return () => {
|
|
139
|
+
observer.disconnect();
|
|
140
|
+
};
|
|
141
|
+
}, []);
|
|
130
142
|
useEffect(() => {
|
|
131
143
|
if (isBrowser() && inView) {
|
|
132
144
|
ninetailed.trackHasSeenComponent({
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.0-beta.0",
|
|
4
4
|
"description": "Ninetailed SDK for React",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@ninetailed/experience.js": "7.
|
|
7
|
-
"@ninetailed/experience.js-shared": "7.
|
|
8
|
-
"@ninetailed/experience.js-plugin-analytics": "7.
|
|
6
|
+
"@ninetailed/experience.js": "7.11.0-beta.0",
|
|
7
|
+
"@ninetailed/experience.js-shared": "7.11.0-beta.0",
|
|
8
|
+
"@ninetailed/experience.js-plugin-analytics": "7.11.0-beta.0",
|
|
9
9
|
"radash": "10.9.0",
|
|
10
|
-
"react-intersection-observer": "8.34.0",
|
|
11
10
|
"react-is": "18.2.0",
|
|
12
|
-
"@testing-library/react
|
|
13
|
-
"@testing-library/react": "13.4.0"
|
|
11
|
+
"@testing-library/react": "16.2.0"
|
|
14
12
|
},
|
|
15
13
|
"peerDependencies": {
|
|
16
14
|
"react": ">=16.8.0"
|