Check if client for session id hook
This commit is contained in:
@@ -3,8 +3,13 @@ import { v4 as uuidv4 } from "uuid"
|
|||||||
|
|
||||||
const storageKey = "sessionId"
|
const storageKey = "sessionId"
|
||||||
|
|
||||||
export function useSessionId(): string {
|
export function useSessionId(): string | null {
|
||||||
const sessionId = useMemo(() => {
|
const sessionId = useMemo(() => {
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
// Return null if running on the server
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
let currentSessionId = sessionStorage.getItem(storageKey)
|
let currentSessionId = sessionStorage.getItem(storageKey)
|
||||||
if (!currentSessionId) {
|
if (!currentSessionId) {
|
||||||
currentSessionId = uuidv4()
|
currentSessionId = uuidv4()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export type TrackingSDKPageData = {
|
|||||||
domain?: string
|
domain?: string
|
||||||
siteSections: string
|
siteSections: string
|
||||||
pageLoadTime?: number // Page load time in seconds
|
pageLoadTime?: number // Page load time in seconds
|
||||||
sessionId?: string
|
sessionId?: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LoginTypeEnum {
|
export enum LoginTypeEnum {
|
||||||
|
|||||||
Reference in New Issue
Block a user