@jitsu/jitsu-react 1.5.1 → 1.7.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/README.md +1 -39
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,42 +11,4 @@ npm install --save @jitsu/jitsu-react
|
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```tsx
|
|
17
|
-
import React from "react";
|
|
18
|
-
import { JitsuProvider } from "@jitsu/jitsu-react";
|
|
19
|
-
|
|
20
|
-
export default function App() {
|
|
21
|
-
return <JitsuProvider options={{ host: "https://<id>.d.jitsu.com" }}>
|
|
22
|
-
<Page />
|
|
23
|
-
</JitsuProvider>;
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Then use `useJitsu` hook in components where you want to track events.
|
|
28
|
-
|
|
29
|
-
```tsx
|
|
30
|
-
import * as React from "react";
|
|
31
|
-
import { useJitsu } from "@jitsu/jitsu-react";
|
|
32
|
-
import { useEffect } from "react";
|
|
33
|
-
|
|
34
|
-
export default function Page() {
|
|
35
|
-
const { analytics } = useJitsu();
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
// Track page view
|
|
38
|
-
analytics.track("event", { prop: "value" });
|
|
39
|
-
}, [location]);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div>
|
|
43
|
-
<button onClick={() => analytics.track("button-click")}>Click me!</button>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
As `location` you should use an value that changes on every navigation. Examples:
|
|
50
|
-
* React Router: `useLocationHook()`
|
|
51
|
-
* Next.js: `const rounter = useRouter()`; then `router.asPath`
|
|
52
|
-
* Others: `[window.location.pathname, window.location.search, window.location.hash]`
|
|
14
|
+
**Please read a documentation on [Jitsu Docs](https://docs.jitsu.com/sending-data/react)**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitsu/jitsu-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"node": ">=10"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jitsu/js": "1.
|
|
14
|
+
"@jitsu/js": "1.7.1"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "15.x || 16.x || 17.x || 18.x",
|