@levo-so/core 0.1.33 → 0.1.34
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LevoAudience.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoAudience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,YAAa,SAAQ,UAAU;;IAC1C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAC1C,aAAa,EAAE,GAAG,CAAQ;IAoB1B,OAAO,CAAC,YAAY,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW;IA8Bb,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"LevoAudience.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoAudience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,YAAa,SAAQ,UAAU;;IAC1C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAC1C,aAAa,EAAE,GAAG,CAAQ;IAoB1B,OAAO,CAAC,YAAY,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW;IA8Bb,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IA8J7C,QAAQ;IAed,WAAW;;;;;;;;;;;IAmEX,qBAAqB;IAqBrB,iBAAiB,IAAI;QACnB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAcF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IAc3C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU;IAoC/D,eAAe;IAaf,WAAW;CAYZ"}
|
|
@@ -229,34 +229,30 @@ var getUserProperties = async () => {
|
|
|
229
229
|
properties.orientation = screen?.orientation?.type;
|
|
230
230
|
}
|
|
231
231
|
if (navigator && "getBattery" in navigator) {
|
|
232
|
-
const battery = await navigator
|
|
232
|
+
const battery = await navigator?.getBattery();
|
|
233
233
|
if (battery) {
|
|
234
|
-
properties.battery_level = Number((battery
|
|
235
|
-
properties.battery_charging = battery
|
|
236
|
-
properties.battery_discharging_time = battery
|
|
237
|
-
properties.battery_full_charge_capacity = battery
|
|
238
|
-
properties.battery_charging_time = battery
|
|
234
|
+
properties.battery_level = Number((battery?.level * 100).toFixed(0));
|
|
235
|
+
properties.battery_charging = battery?.charging;
|
|
236
|
+
properties.battery_discharging_time = battery?.dischargingTime;
|
|
237
|
+
properties.battery_full_charge_capacity = battery?.fullChargeCapacity;
|
|
238
|
+
properties.battery_charging_time = battery?.chargingTime;
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
if (navigator && "deviceMemory" in navigator) {
|
|
242
|
-
properties.device_memory = navigator
|
|
242
|
+
properties.device_memory = navigator?.deviceMemory;
|
|
243
243
|
}
|
|
244
244
|
const supportsTouch = "ontouchstart" in window || typeof navigator?.maxTouchPoints !== "undefined" && navigator?.maxTouchPoints > 0;
|
|
245
|
-
|
|
246
|
-
properties.touch_support = true;
|
|
247
|
-
} else {
|
|
248
|
-
properties.touch_support = false;
|
|
249
|
-
}
|
|
245
|
+
properties.touch_supported = supportsTouch;
|
|
250
246
|
if ("hardwareConcurrency" in navigator) {
|
|
251
|
-
properties.hardware_concurrency = navigator
|
|
247
|
+
properties.hardware_concurrency = navigator?.hardwareConcurrency;
|
|
252
248
|
}
|
|
253
249
|
if (navigator && "mediaDevices" in navigator) {
|
|
254
|
-
const mediaDevices = navigator
|
|
255
|
-
const devices = await mediaDevices
|
|
256
|
-
const hasCamera = devices.some((device) => device
|
|
250
|
+
const mediaDevices = navigator?.mediaDevices;
|
|
251
|
+
const devices = await mediaDevices?.enumerateDevices();
|
|
252
|
+
const hasCamera = devices.some((device) => device?.kind === "videoinput");
|
|
257
253
|
properties.camera_supported = hasCamera;
|
|
258
254
|
const hasMicrophone = devices.some(
|
|
259
|
-
(device) => device
|
|
255
|
+
(device) => device?.kind === "audioinput"
|
|
260
256
|
);
|
|
261
257
|
properties.microphone_supported = hasMicrophone;
|
|
262
258
|
}
|
|
@@ -347,10 +343,12 @@ var LevoAudience = class extends LevoPlugin {
|
|
|
347
343
|
session_id: this.#session,
|
|
348
344
|
device_id: this.#device,
|
|
349
345
|
event: payload.event,
|
|
346
|
+
version: payload.version || 1,
|
|
350
347
|
workspace_id: this.client.workspace,
|
|
351
348
|
properties: {
|
|
352
349
|
...properties,
|
|
353
350
|
...payloadProperties,
|
|
351
|
+
version: void 0,
|
|
354
352
|
resource: void 0,
|
|
355
353
|
identifier: void 0,
|
|
356
354
|
hostname: void 0,
|
|
@@ -369,10 +367,17 @@ var LevoAudience = class extends LevoPlugin {
|
|
|
369
367
|
tab_id: this.getCurrentTabId(),
|
|
370
368
|
tab_count: this.getTabCount()
|
|
371
369
|
};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
370
|
+
let isQueued = false;
|
|
371
|
+
try {
|
|
372
|
+
isQueued = navigator.sendBeacon(
|
|
373
|
+
`${this?.client?.insightsUrl}/v1/insights/event/collect`,
|
|
374
|
+
JSON.stringify(collectInput)
|
|
375
|
+
);
|
|
376
|
+
} catch (e) {
|
|
377
|
+
}
|
|
378
|
+
if (!isQueued) {
|
|
379
|
+
this.request("/v1/insights/event/collect", collectInput);
|
|
380
|
+
}
|
|
376
381
|
this.#events.push({
|
|
377
382
|
input: payload,
|
|
378
383
|
payload: collectInput,
|
|
@@ -421,10 +426,18 @@ var LevoAudience = class extends LevoPlugin {
|
|
|
421
426
|
this.#is_identified = true;
|
|
422
427
|
this.#session = data.content.data.session;
|
|
423
428
|
this.#device = data.content.data.device;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
429
|
+
let isQueued = false;
|
|
430
|
+
try {
|
|
431
|
+
isQueued = navigator.sendBeacon(
|
|
432
|
+
`${this?.client?.insightsUrl}/v1/insights/event/bulk?workspace=${this?.client?.workspace}`,
|
|
433
|
+
JSON.stringify(this.#batch)
|
|
434
|
+
);
|
|
435
|
+
} catch (e) {
|
|
436
|
+
}
|
|
437
|
+
if (!isQueued) {
|
|
438
|
+
this.request("/v1/insights/event/bulk", this.#batch);
|
|
439
|
+
}
|
|
440
|
+
this.#batch = [];
|
|
428
441
|
identifyLock.releaseLock();
|
|
429
442
|
}).catch((e) => {
|
|
430
443
|
identifyLock.releaseLock();
|
|
@@ -450,7 +463,6 @@ var LevoAudience = class extends LevoPlugin {
|
|
|
450
463
|
}
|
|
451
464
|
const referrer = this.getReferrer();
|
|
452
465
|
const traits = await getUserProperties();
|
|
453
|
-
console.log(traits);
|
|
454
466
|
await this.instance.identify("", {
|
|
455
467
|
...traits,
|
|
456
468
|
referrer
|
|
@@ -526,8 +538,10 @@ var LevoAudience = class extends LevoPlugin {
|
|
|
526
538
|
}
|
|
527
539
|
return this.#batch.push({
|
|
528
540
|
event,
|
|
541
|
+
version: properties?.version || 1,
|
|
529
542
|
properties: {
|
|
530
543
|
...properties,
|
|
544
|
+
version: void 0,
|
|
531
545
|
resource: void 0,
|
|
532
546
|
identifier: void 0,
|
|
533
547
|
hostname: void 0,
|
|
@@ -102,8 +102,8 @@ var LevoLogger = class extends LevoPlugin {
|
|
|
102
102
|
super(client);
|
|
103
103
|
this.batch = new LogBatch(batchOptions);
|
|
104
104
|
this.context = context;
|
|
105
|
-
this.logLevel = batchOptions?.level ?? (this.client.NODE_ENV
|
|
106
|
-
this.enableRemote = batchOptions?.enableRemote ?? this.client.NODE_ENV
|
|
105
|
+
this.logLevel = batchOptions?.level ?? (this.client.NODE_ENV !== "development" ? 1 /* info */ : 0 /* debug */);
|
|
106
|
+
this.enableRemote = batchOptions?.enableRemote ?? this.client.NODE_ENV !== "development";
|
|
107
107
|
}
|
|
108
108
|
debug = (...args) => {
|
|
109
109
|
this.log(0 /* debug */, args);
|
package/dist/types/audience.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/types/audience.ts"],"names":[],"mappings":"AACA,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,MAAM;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9B,CAAC;QACF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC;IAED,KAAY,cAAc,GAAG,MAAM,GAAG;QACpC,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,UAAiB,eAAe;QAC9B,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,UAAiB,kBAAkB;QACjC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IAED,UAAiB,gBAAgB;QAC/B,OAAO,EAAE,MAAM,CAAC;KACjB;IAED,KAAY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UAAU,CAAC;QACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;IAEF,KAAY,SAAS,GAAG;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAY,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IAE9C,KAAY,eAAe,GAAG;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,KAAY,YAAY,GAAG,SAAS,GAAG;QACrC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,CAAC;IAEF,KAAY,cAAc,GAAG;QAC3B,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserProperties.d.ts","sourceRoot":"","sources":["../../src/utils/getUserProperties.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,iBAAiB;;;;;;
|
|
1
|
+
{"version":3,"file":"getUserProperties.d.ts","sourceRoot":"","sources":["../../src/utils/getUserProperties.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,iBAAiB;;;;;;EAgH7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"author": "Levo Engineering <devs@theinternetfolks.com>",
|
|
5
5
|
"description": "Levo common utilities",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsup": "8.2.4",
|
|
25
25
|
"typescript": "5.5.4",
|
|
26
|
-
"@levo/
|
|
27
|
-
"@levo/
|
|
26
|
+
"@levo/eslint-config": "0.0.0",
|
|
27
|
+
"@levo/ts-config": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"main": "./dist/index.js",
|
|
30
30
|
"module": "./dist/index.js",
|