@ginger-ai/ginger-react 0.0.3 → 0.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/hooks/useEvent/helper.d.ts.map +1 -1
- package/dist/hooks/useEvent/index.d.ts.map +1 -1
- package/dist/index.cjs.js +7 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +7 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEvent/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,mBAAmB,QAAO,MAEtC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,KAAK,OAAO,KACX,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEvent/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,mBAAmB,QAAO,MAEtC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,KAAK,OAAO,KACX,KAAK,CAAC,YAeP,CAAC;AAEH,eAAO,MAAM,aAAa,UAwBzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEvent/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,CACR,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,GAAG,KAEhB;QACE,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;QAC9C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;KAC9C,GACD,EAAE,CAAC;IACP,oBAAoB,EAAE,KAAK,CAAC,YAAY,CAAC;IACzC,WAAW,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACjC,CAAC;AAWF,eAAO,MAAM,QAAQ,GAAI,2CAItB,KAAK,CAAC,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useEvent/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMpC,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,CACR,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,GAAG,KAEhB;QACE,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;QAC9C,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;KAC9C,GACD,EAAE,CAAC;IACP,oBAAoB,EAAE,KAAK,CAAC,YAAY,CAAC;IACzC,WAAW,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACjC,CAAC;AAWF,eAAO,MAAM,QAAQ,GAAI,2CAItB,KAAK,CAAC,MAAM,KAAG,cA4SjB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -227,6 +227,7 @@ const createDefaultMetrics = (fieldName, ltm) => ({
|
|
|
227
227
|
started_at: 0,
|
|
228
228
|
ended_at: 0,
|
|
229
229
|
interaction_count: 0,
|
|
230
|
+
modifier_key_count: 0,
|
|
230
231
|
characters_count: 0,
|
|
231
232
|
paste_count: 0,
|
|
232
233
|
autofill_count: 0,
|
|
@@ -270,7 +271,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
270
271
|
const registeredFieldsIdRef = react.useRef(track_fields.map((field) => field.id));
|
|
271
272
|
const trackedFieldMetricsRef = react.useRef({});
|
|
272
273
|
const fieldFocusMetricsRef = react.useRef({});
|
|
273
|
-
const
|
|
274
|
+
const modifierKeysMapRef = react.useRef({});
|
|
274
275
|
// For key hold Time (How long each key is pressed)
|
|
275
276
|
const activeKeysRef = react.useRef(new Map());
|
|
276
277
|
const holdTimesRef = react.useRef({});
|
|
@@ -302,7 +303,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
302
303
|
};
|
|
303
304
|
const computeModifierKeysCount = (id, e) => {
|
|
304
305
|
const key = e.key;
|
|
305
|
-
const modifierKeys =
|
|
306
|
+
const modifierKeys = modifierKeysMapRef.current;
|
|
306
307
|
if (MODIFIER_KEYS.includes(key)) {
|
|
307
308
|
modifierKeys[id] = (modifierKeys[id] || 0) + 1;
|
|
308
309
|
}
|
|
@@ -400,7 +401,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
400
401
|
delete field[id];
|
|
401
402
|
};
|
|
402
403
|
const removeModifierMetric = (id) => {
|
|
403
|
-
const field =
|
|
404
|
+
const field = modifierKeysMapRef.current;
|
|
404
405
|
if (!field)
|
|
405
406
|
return;
|
|
406
407
|
delete field[id];
|
|
@@ -414,7 +415,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
414
415
|
const resetFields = () => {
|
|
415
416
|
trackedFieldMetricsRef.current = {};
|
|
416
417
|
fieldFocusMetricsRef.current = {};
|
|
417
|
-
|
|
418
|
+
modifierKeysMapRef.current = {};
|
|
418
419
|
holdTimesRef.current = {};
|
|
419
420
|
};
|
|
420
421
|
// Calculate distraction count
|
|
@@ -441,7 +442,8 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
441
442
|
const id = field.field_name;
|
|
442
443
|
const key_hold_times = holdTimesRef.current[id] || [];
|
|
443
444
|
const flight_time = getFlightTime(id);
|
|
444
|
-
|
|
445
|
+
const modifier_key_count = modifierKeysMapRef.current[id];
|
|
446
|
+
return { ...field, key_hold_times, flight_time, modifier_key_count };
|
|
445
447
|
});
|
|
446
448
|
}, []);
|
|
447
449
|
const getFlightTime = (id) => {
|