File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed
Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11import { REPLAY_SESSION_KEY , WINDOW } from '../../src/constants' ;
22import type { ReplayContainer } from '../../src/types' ;
3+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
34
45/**
56 * Removes the session from Session Storage and unsets session in replay instance
@@ -13,9 +14,7 @@ export function clearSession(replay: ReplayContainer): void {
1314 * Deletes a session from storage
1415 */
1516function deleteSession ( ) : void {
16- const hasSessionStorage = 'sessionStorage' in WINDOW ;
17-
18- if ( ! hasSessionStorage ) {
17+ if ( ! hasSessionStorage ( ) ) {
1918 return ;
2019 }
2120
Original file line number Diff line number Diff line change 11import { REPLAY_SESSION_KEY , WINDOW } from '../constants' ;
22import type { Session } from '../types' ;
3+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
34import { makeSession } from './Session' ;
45
56/**
67 * Fetches a session from storage
78 */
89export function fetchSession ( ) : Session | null {
9- const hasSessionStorage = 'sessionStorage' in WINDOW ;
10-
11- if ( ! hasSessionStorage ) {
10+ if ( ! hasSessionStorage ( ) ) {
1211 return null ;
1312 }
1413
Original file line number Diff line number Diff line change 11import { REPLAY_SESSION_KEY , WINDOW } from '../constants' ;
22import type { Session } from '../types' ;
3+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
34
45/**
56 * Save a session to session storage.
67 */
78export function saveSession ( session : Session ) : void {
8- const hasSessionStorage = 'sessionStorage' in WINDOW ;
9- if ( ! hasSessionStorage ) {
9+ if ( ! hasSessionStorage ( ) ) {
1010 return ;
1111 }
1212
Original file line number Diff line number Diff line change 1+ import { WINDOW } from '../constants' ;
2+
3+ /** If sessionStorage is available. */
4+ export function hasSessionStorage ( ) : boolean {
5+ return 'sessionStorage' in WINDOW && ! ! WINDOW . sessionStorage ;
6+ }
You can’t perform that action at this time.
0 commit comments