@@ -90,7 +90,7 @@ If you are using a self-hosted version of Rybbit Analytics, you can provide a cu
90
90
useScriptRybbitAnalytics ({
91
91
scriptInput: {
92
92
src: ' https://your-rybbit-instance.com/api/script.js'
93
- }
93
+ },
94
94
siteId: ' YOUR_SITE_ID'
95
95
})
96
96
```
@@ -99,8 +99,38 @@ useScriptRybbitAnalytics({
99
99
100
100
``` ts
101
101
export interface RybbitAnalyticsApi {
102
+ /**
103
+ * Tracks a page view
104
+ */
102
105
pageview: () => void
103
- event: (eventName : string , properties ? : Record <string , any >) => void
106
+
107
+ /**
108
+ * Tracks a custom event
109
+ * @param name Name of the event
110
+ * @param properties Optional properties for the event
111
+ */
112
+ event: (name : string , properties ? : Record <string , any >) => void
113
+
114
+ /**
115
+ * Sets a custom user ID for tracking logged-in users
116
+ * @param userId The user ID to set (will be stored in localStorage)
117
+ */
118
+ identify: (userId : string ) => void
119
+
120
+ /**
121
+ * Clears the stored user ID
122
+ */
123
+ clearUserId: () => void
124
+
125
+ /**
126
+ * Gets the currently set user ID
127
+ * @returns The current user ID or null if not set
128
+ */
129
+ getUserId: () => string | null
130
+ /**
131
+ * @deprecated use top level functions instead
132
+ */
133
+ rybbit: RybbitAnalyticsApi
104
134
}
105
135
```
106
136
@@ -110,7 +140,7 @@ You must provide the options when setting up the script for the first time.
110
140
111
141
``` ts
112
142
export const RybbitAnalyticsOptions = object ({
113
- siteId: string (), // required
143
+ siteId: union ([ string (), number ()] ), // required
114
144
trackSpa: optional (boolean ()),
115
145
trackQuery: optional (boolean ()),
116
146
skipPatterns: optional (array (string ())),
@@ -140,12 +170,12 @@ const { proxy } = useScriptRybbitAnalytics()
140
170
141
171
// Track a pageview manually
142
172
function trackPage() {
143
- proxy.rybbit. pageview()
173
+ proxy.pageview()
144
174
}
145
175
146
176
// Track a custom event
147
177
function trackEvent() {
148
- proxy.rybbit. event('button_click', { buttonId: 'signup' })
178
+ proxy.event('button_click', { buttonId: 'signup' })
149
179
}
150
180
</script>
151
181
@@ -161,4 +191,4 @@ function trackEvent() {
161
191
</template>
162
192
```
163
193
164
- ::
194
+ ::
0 commit comments