• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yext / analytics / 6356907193

29 Sep 2023 08:39PM UTC coverage: 86.29% (+0.6%) from 85.714%
6356907193

Pull #99

github

web-flow
Merge 6a839a603 into 857222b75
Pull Request #99: EventsSDK: Release Candidate v1.0.0-beta.1

52 of 58 branches covered (0.0%)

Branch coverage included in aggregate %.

30 of 30 new or added lines in 5 files covered. (100.0%)

55 of 66 relevant lines covered (83.33%)

10.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.67
/src/setupSessionId.ts
1
import { ulid } from 'ulidx';
2

3
const SESSION_ID_KEY = 'yext_analytics_session_id';
1✔
4

5
/**
6
 * Retrieves session id from session storage, or generates a new ULID to use as session id.
7
 * The new id is then stored in session storage. Returns null if the sessionStorage API is
8
 * unavailable (e.g. The function is running on the server for SSR).
9
 */
10
export function getOrSetupSessionId(): string | null {
11
  if (typeof window === 'undefined') {
×
12
    return null;
×
13
  }
14
  try {
×
15
    let sessionId = window.sessionStorage.getItem(SESSION_ID_KEY);
×
16
    if (!sessionId) {
×
17
      sessionId = ulid();
×
18
      window.sessionStorage.setItem(SESSION_ID_KEY, sessionId);
×
19
    }
20
    return sessionId;
×
21
  } catch (err) {
22
    console.warn('Unable to use browser sessionStorage for sessionId.\n', err);
×
23
    return null;
×
24
  }
25
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc