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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -8
- package/dist/index.mjs +11 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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);
|