react-event-tracking 2.0.0 → 2.0.2

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 (2) hide show
  1. package/README.md +10 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -111,6 +111,7 @@ type SystemEvents = {
111
111
 
112
112
  // analytics.ts
113
113
  export type AnalyticsEvents = SystemEvents & {
114
+ // supports deeply nested event maps
114
115
  login_screen: LoginScreenEvents
115
116
  }
116
117
 
@@ -120,12 +121,20 @@ export const useTracking = createReactEventTrackingHook<AnalyticsEvents>();
120
121
  2. Use it in your components:
121
122
  ```tsx
122
123
  const LoginButton = () => {
124
+ // You can use the full tracker
123
125
  const { track } = useTracking();
126
+
127
+ // Or narrow it down to a specific scope
128
+ const { track: track2 } = useTracking("login_screen");
124
129
 
125
130
  const handleLogin = () => {
126
- // This call transforms into "login_screen.logged_in" event with parameters
131
+ // Full path: eventName is derived from the call chain (result: "login_screen.logged_in")
127
132
  track.login_screen.logged_in({ timePassed: 3000 });
133
+
134
+ // Narrowed path: the same result: "login_screen.logged_in":
135
+ track2.logged_in({ timePassed: 3000 });
128
136
  };
137
+
129
138
  return (
130
139
  <button onClick={handleLogin}>
131
140
  Login with Google
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-event-tracking",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "files": [
5
5
  "dist"
6
6
  ],