luzzi-analytics 0.1.2 → 0.1.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/index.d.mts CHANGED
@@ -10,6 +10,8 @@ interface LuzziConfig {
10
10
  flushInterval?: number;
11
11
  /** Enable debug logging */
12
12
  debug?: boolean;
13
+ /** Device info (useful for React Native where auto-detection doesn't work) */
14
+ deviceInfo?: DeviceInfo;
13
15
  }
14
16
  interface DeviceInfo {
15
17
  os?: string;
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ interface LuzziConfig {
10
10
  flushInterval?: number;
11
11
  /** Enable debug logging */
12
12
  debug?: boolean;
13
+ /** Device info (useful for React Native where auto-detection doesn't work) */
14
+ deviceInfo?: DeviceInfo;
13
15
  }
14
16
  interface DeviceInfo {
15
17
  os?: string;
package/dist/index.js CHANGED
@@ -171,9 +171,10 @@ var LuzziCore = class {
171
171
  this.debug = config.debug || false;
172
172
  this.sessionId = this.generateSessionId();
173
173
  try {
174
- this.deviceInfo = this.collectDeviceInfo();
174
+ const autoDetected = this.collectDeviceInfo();
175
+ this.deviceInfo = { ...autoDetected, ...config.deviceInfo };
175
176
  } catch {
176
- this.deviceInfo = {};
177
+ this.deviceInfo = config.deviceInfo || {};
177
178
  }
178
179
  this.queue.init(
179
180
  this.apiKey,
@@ -184,15 +185,17 @@ var LuzziCore = class {
184
185
  );
185
186
  this.initialized = true;
186
187
  this.log("Initialized", { apiKey: apiKey.slice(0, 10) + "...", sessionId: this.sessionId });
187
- if (typeof window !== "undefined") {
188
+ if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
188
189
  window.addEventListener("beforeunload", () => {
189
190
  this.flush();
190
191
  });
191
- window.addEventListener("visibilitychange", () => {
192
- if (document.visibilityState === "hidden") {
193
- this.flush();
194
- }
195
- });
192
+ if (typeof document !== "undefined") {
193
+ window.addEventListener("visibilitychange", () => {
194
+ if (document.visibilityState === "hidden") {
195
+ this.flush();
196
+ }
197
+ });
198
+ }
196
199
  }
197
200
  } catch (error) {
198
201
  console.warn("[Luzzi] Failed to initialize:", error);
package/dist/index.mjs CHANGED
@@ -138,9 +138,10 @@ var LuzziCore = class {
138
138
  this.debug = config.debug || false;
139
139
  this.sessionId = this.generateSessionId();
140
140
  try {
141
- this.deviceInfo = this.collectDeviceInfo();
141
+ const autoDetected = this.collectDeviceInfo();
142
+ this.deviceInfo = { ...autoDetected, ...config.deviceInfo };
142
143
  } catch {
143
- this.deviceInfo = {};
144
+ this.deviceInfo = config.deviceInfo || {};
144
145
  }
145
146
  this.queue.init(
146
147
  this.apiKey,
@@ -151,15 +152,17 @@ var LuzziCore = class {
151
152
  );
152
153
  this.initialized = true;
153
154
  this.log("Initialized", { apiKey: apiKey.slice(0, 10) + "...", sessionId: this.sessionId });
154
- if (typeof window !== "undefined") {
155
+ if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
155
156
  window.addEventListener("beforeunload", () => {
156
157
  this.flush();
157
158
  });
158
- window.addEventListener("visibilitychange", () => {
159
- if (document.visibilityState === "hidden") {
160
- this.flush();
161
- }
162
- });
159
+ if (typeof document !== "undefined") {
160
+ window.addEventListener("visibilitychange", () => {
161
+ if (document.visibilityState === "hidden") {
162
+ this.flush();
163
+ }
164
+ });
165
+ }
163
166
  }
164
167
  } catch (error) {
165
168
  console.warn("[Luzzi] Failed to initialize:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "luzzi-analytics",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Simple, plug-and-play analytics SDK for solo builders",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",