@@ -90,7 +90,7 @@ If you are using a self-hosted version of Rybbit Analytics, you can provide a cu
9090useScriptRybbitAnalytics ({
9191 scriptInput: {
9292 src: ' https://your-rybbit-instance.com/api/script.js'
93- }
93+ },
9494 siteId: ' YOUR_SITE_ID'
9595})
9696```
@@ -99,8 +99,38 @@ useScriptRybbitAnalytics({
9999
100100``` ts
101101export interface RybbitAnalyticsApi {
102+ /**
103+ * Tracks a page view
104+ */
102105 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
104134}
105135```
106136
@@ -110,7 +140,7 @@ You must provide the options when setting up the script for the first time.
110140
111141``` ts
112142export const RybbitAnalyticsOptions = object ({
113- siteId: string (), // required
143+ siteId: union ([ string (), number ()] ), // required
114144 trackSpa: optional (boolean ()),
115145 trackQuery: optional (boolean ()),
116146 skipPatterns: optional (array (string ())),
@@ -140,12 +170,12 @@ const { proxy } = useScriptRybbitAnalytics()
140170
141171// Track a pageview manually
142172function trackPage() {
143- proxy.rybbit. pageview()
173+ proxy.pageview()
144174}
145175
146176// Track a custom event
147177function trackEvent() {
148- proxy.rybbit. event('button_click', { buttonId: 'signup' })
178+ proxy.event('button_click', { buttonId: 'signup' })
149179}
150180</script>
151181
@@ -161,4 +191,4 @@ function trackEvent() {
161191</template>
162192```
163193
164- ::
194+ ::
0 commit comments