SDK di Analytics del tracker
SDK di Analytics
Section titled SDK di AnalyticsScopri come configurare lo SDK di analytics del tracker di OpenReplay.
Abilitare lo SDK
Section titled Abilitare lo SDKLo SDK di analytics è opt-in. Viene istanziato solo quando passi analytics.active al costruttore del tracker: fino ad allora tracker.analytics è null e tracker.track() non fa nulla.
import Tracker from '@openreplay/tracker'
const tracker = new Tracker({
projectKey: "YOUR_PROJECT_KEY",
analytics: { active: true },
})
tracker.start()
Opzioni
Section titled Opzioniactive: booleanAttiva lo SDK di analytics. Predefinito:false.ingestPoint?: stringEndpoint a cui vengono inviati i batch di analytics. Solo per i deployment self-hosted: su OpenReplay Cloud viene ignorato e si usahttps://api.openreplay.com/ingest. Per impostazione predefinita usa l’ingestPointdel tracker.
Moduli
Section titled ModuliPer saperne di più sulla gestione dei dati di analytics nell’interfaccia di OpenReplay, visita Gestione dei dati.
Firme di primo livello
Section titled Firme di primo livello// Identify a user with an id (e.g. email, username, etc.)
tracker.analytics.identify(userId: string): void
// same as
tracker.analytics.people.identify(userId)
// Add event to batch with option to send it immediately
tracker.analytics.track(eventName: string, tempProperties?: Record<string, any>, options?: { send_immediately: boolean })
// same as
tracker.analytics.events.track(eventName, tempProperties, options)
// Clear user id, people properties and super properties, and stop the batcher
tracker.analytics.reset(): void
Scorciatoie a livello di tracker
Section titled Scorciatoie a livello di trackerSi trovano sul tracker stesso, quindi puoi chiamarle senza passare da tracker.analytics (non fanno nulla finché analytics è disattivato):
// Same as tracker.analytics.track(...)
tracker.track(eventName: string, properties?: Record<string, any>, options?: { send_immediately: boolean })
// Sets the replay's user ID *and* calls analytics.people.identify() with it
tracker.setUserID(id: string): void
tracker.identify(id: string): void // alias of setUserID
// Send analytics events under your own token, without session recording
tracker.setAnalyticsToken(token: string): void
reset
Section titled resetCancella l’utente identificato (incluso l’ID persistente del dispositivo), tutte le proprietà people, tutte le super properties e arresta il batcher. Chiamalo al logout.
tracker.analytics.reset()
Hai domande?
Section titled Hai domande?Se riscontri problemi, collegati al nostro Slack e chiedi aiuto alla nostra community.