@uxbertlabs/reportly 1.0.2 → 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.
package/dist/reportly.js CHANGED
@@ -23,6 +23,10 @@ var Reportly = (function () {
23
23
  };
24
24
  }
25
25
  loadFromStorage() {
26
+ // Check if we're in a browser environment
27
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
28
+ return;
29
+ }
26
30
  try {
27
31
  const saved = localStorage.getItem('uxbert-config');
28
32
  if (saved) {
@@ -35,6 +39,10 @@ var Reportly = (function () {
35
39
  }
36
40
  }
37
41
  save() {
42
+ // Check if we're in a browser environment
43
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
44
+ return;
45
+ }
38
46
  try {
39
47
  localStorage.setItem('uxbert-config', JSON.stringify(this.config));
40
48
  }
@@ -8826,6 +8834,22 @@ var Reportly = (function () {
8826
8834
  this.info = this.collect();
8827
8835
  }
8828
8836
  collect() {
8837
+ // Check if we're in a browser environment
8838
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
8839
+ return {
8840
+ browser: 'SSR',
8841
+ os: 'SSR',
8842
+ screenResolution: '0x0',
8843
+ viewport: '0x0',
8844
+ url: '',
8845
+ timestamp: new Date().toISOString(),
8846
+ userAgent: 'SSR',
8847
+ language: 'en-US',
8848
+ platform: 'SSR',
8849
+ cookiesEnabled: false,
8850
+ onLine: false
8851
+ };
8852
+ }
8829
8853
  return {
8830
8854
  browser: this.getBrowserInfo(),
8831
8855
  os: this.getOSInfo(),
@@ -9009,6 +9033,11 @@ var Reportly = (function () {
9009
9033
  this.isInitialized = false;
9010
9034
  }
9011
9035
  init(userConfig = {}) {
9036
+ // Check if we're in a browser environment
9037
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
9038
+ console.warn("Uxbert Reportly can only be initialized in a browser environment");
9039
+ return;
9040
+ }
9012
9041
  if (this.isInitialized) {
9013
9042
  console.warn("Uxbert Reportly is already initialized");
9014
9043
  return;