@uxbertlabs/reportly 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,6 +20,10 @@ class Config {
20
20
  };
21
21
  }
22
22
  loadFromStorage() {
23
+ // Check if we're in a browser environment
24
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
25
+ return;
26
+ }
23
27
  try {
24
28
  const saved = localStorage.getItem('uxbert-config');
25
29
  if (saved) {
@@ -32,6 +36,10 @@ class Config {
32
36
  }
33
37
  }
34
38
  save() {
39
+ // Check if we're in a browser environment
40
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
41
+ return;
42
+ }
35
43
  try {
36
44
  localStorage.setItem('uxbert-config', JSON.stringify(this.config));
37
45
  }
@@ -8823,6 +8831,22 @@ class DeviceInfo {
8823
8831
  this.info = this.collect();
8824
8832
  }
8825
8833
  collect() {
8834
+ // Check if we're in a browser environment
8835
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
8836
+ return {
8837
+ browser: 'SSR',
8838
+ os: 'SSR',
8839
+ screenResolution: '0x0',
8840
+ viewport: '0x0',
8841
+ url: '',
8842
+ timestamp: new Date().toISOString(),
8843
+ userAgent: 'SSR',
8844
+ language: 'en-US',
8845
+ platform: 'SSR',
8846
+ cookiesEnabled: false,
8847
+ onLine: false
8848
+ };
8849
+ }
8826
8850
  return {
8827
8851
  browser: this.getBrowserInfo(),
8828
8852
  os: this.getOSInfo(),
@@ -9006,6 +9030,11 @@ class Reportly {
9006
9030
  this.isInitialized = false;
9007
9031
  }
9008
9032
  init(userConfig = {}) {
9033
+ // Check if we're in a browser environment
9034
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
9035
+ console.warn("Uxbert Reportly can only be initialized in a browser environment");
9036
+ return;
9037
+ }
9009
9038
  if (this.isInitialized) {
9010
9039
  console.warn("Uxbert Reportly is already initialized");
9011
9040
  return;