luzzi-analytics 0.1.1 → 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 +37 -25
- package/dist/index.mjs +37 -25
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -161,33 +161,45 @@ var LuzziCore = class {
|
|
|
161
161
|
* Must be called before any other method
|
|
162
162
|
*/
|
|
163
163
|
init(apiKey, config = {}) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
164
|
+
try {
|
|
165
|
+
if (!apiKey) {
|
|
166
|
+
console.error("[Luzzi] API key is required");
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.apiKey = apiKey;
|
|
170
|
+
this.apiUrl = config.apiUrl || DEFAULT_API_URL;
|
|
171
|
+
this.debug = config.debug || false;
|
|
172
|
+
this.sessionId = this.generateSessionId();
|
|
173
|
+
try {
|
|
174
|
+
const autoDetected = this.collectDeviceInfo();
|
|
175
|
+
this.deviceInfo = { ...autoDetected, ...config.deviceInfo };
|
|
176
|
+
} catch {
|
|
177
|
+
this.deviceInfo = config.deviceInfo || {};
|
|
178
|
+
}
|
|
179
|
+
this.queue.init(
|
|
180
|
+
this.apiKey,
|
|
181
|
+
this.apiUrl,
|
|
182
|
+
config.batchSize || DEFAULT_BATCH_SIZE,
|
|
183
|
+
config.flushInterval || DEFAULT_FLUSH_INTERVAL,
|
|
184
|
+
this.debug
|
|
185
|
+
);
|
|
186
|
+
this.initialized = true;
|
|
187
|
+
this.log("Initialized", { apiKey: apiKey.slice(0, 10) + "...", sessionId: this.sessionId });
|
|
188
|
+
if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
189
|
+
window.addEventListener("beforeunload", () => {
|
|
188
190
|
this.flush();
|
|
191
|
+
});
|
|
192
|
+
if (typeof document !== "undefined") {
|
|
193
|
+
window.addEventListener("visibilitychange", () => {
|
|
194
|
+
if (document.visibilityState === "hidden") {
|
|
195
|
+
this.flush();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
189
198
|
}
|
|
190
|
-
}
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.warn("[Luzzi] Failed to initialize:", error);
|
|
202
|
+
this.initialized = true;
|
|
191
203
|
}
|
|
192
204
|
}
|
|
193
205
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -128,33 +128,45 @@ var LuzziCore = class {
|
|
|
128
128
|
* Must be called before any other method
|
|
129
129
|
*/
|
|
130
130
|
init(apiKey, config = {}) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
131
|
+
try {
|
|
132
|
+
if (!apiKey) {
|
|
133
|
+
console.error("[Luzzi] API key is required");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.apiKey = apiKey;
|
|
137
|
+
this.apiUrl = config.apiUrl || DEFAULT_API_URL;
|
|
138
|
+
this.debug = config.debug || false;
|
|
139
|
+
this.sessionId = this.generateSessionId();
|
|
140
|
+
try {
|
|
141
|
+
const autoDetected = this.collectDeviceInfo();
|
|
142
|
+
this.deviceInfo = { ...autoDetected, ...config.deviceInfo };
|
|
143
|
+
} catch {
|
|
144
|
+
this.deviceInfo = config.deviceInfo || {};
|
|
145
|
+
}
|
|
146
|
+
this.queue.init(
|
|
147
|
+
this.apiKey,
|
|
148
|
+
this.apiUrl,
|
|
149
|
+
config.batchSize || DEFAULT_BATCH_SIZE,
|
|
150
|
+
config.flushInterval || DEFAULT_FLUSH_INTERVAL,
|
|
151
|
+
this.debug
|
|
152
|
+
);
|
|
153
|
+
this.initialized = true;
|
|
154
|
+
this.log("Initialized", { apiKey: apiKey.slice(0, 10) + "...", sessionId: this.sessionId });
|
|
155
|
+
if (typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
156
|
+
window.addEventListener("beforeunload", () => {
|
|
155
157
|
this.flush();
|
|
158
|
+
});
|
|
159
|
+
if (typeof document !== "undefined") {
|
|
160
|
+
window.addEventListener("visibilitychange", () => {
|
|
161
|
+
if (document.visibilityState === "hidden") {
|
|
162
|
+
this.flush();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
156
165
|
}
|
|
157
|
-
}
|
|
166
|
+
}
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.warn("[Luzzi] Failed to initialize:", error);
|
|
169
|
+
this.initialized = true;
|
|
158
170
|
}
|
|
159
171
|
}
|
|
160
172
|
/**
|