Skip to content

Commit d0ab9e3

Browse files
authored
feat: avoid requiring window for the observability plugins (#135)
## Summary Check for window availability in plugins. ## How did you test this change? CI <img width="828" height="451" alt="image" src="https://github.com/user-attachments/assets/17caef38-7a70-42cf-9dcd-16accdd6641c" /> <img width="1671" height="655" alt="Screenshot 2025-07-21 at 12 08 06" src="https://github.com/user-attachments/assets/fa69c606-1ff5-4651-8c47-f824803f5da8" /> ## Are there any deployment considerations? changeset
1 parent b89e986 commit d0ab9e3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.changeset/better-hotels-jog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'highlight.run': patch
3+
'@launchdarkly/observability': patch
4+
'@launchdarkly/session-replay': patch
5+
---
6+
7+
conditionally check for window api availability

sdk/highlight-run/src/client/utils/storage.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export const getPersistentStorage = () => {
6666
| typeof window.sessionStorage
6767
| null = null
6868

69+
if (typeof window === 'undefined') {
70+
return globalStorage
71+
}
72+
6973
try {
7074
switch (mode) {
7175
case 'localStorage':
@@ -167,6 +171,12 @@ export const monkeyPatchLocalStorage = (
167171
)
168172
return
169173
}
174+
if (typeof window === 'undefined') {
175+
console.warn(
176+
`highlight.io cannot use local storage (not a window); segment integration will not work`,
177+
)
178+
return
179+
}
170180

171181
const originalSetItem = window.localStorage.setItem
172182
window.localStorage.setItem = function () {

0 commit comments

Comments
 (0)