@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
package/dist/index.esm.js
CHANGED
|
@@ -225,6 +225,7 @@ const createDefaultMetrics = (fieldName, ltm) => ({
|
|
|
225
225
|
started_at: 0,
|
|
226
226
|
ended_at: 0,
|
|
227
227
|
interaction_count: 0,
|
|
228
|
+
modifier_key_count: 0,
|
|
228
229
|
characters_count: 0,
|
|
229
230
|
paste_count: 0,
|
|
230
231
|
autofill_count: 0,
|
|
@@ -268,7 +269,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
268
269
|
const registeredFieldsIdRef = useRef(track_fields.map((field) => field.id));
|
|
269
270
|
const trackedFieldMetricsRef = useRef({});
|
|
270
271
|
const fieldFocusMetricsRef = useRef({});
|
|
271
|
-
const
|
|
272
|
+
const modifierKeysMapRef = useRef({});
|
|
272
273
|
// For key hold Time (How long each key is pressed)
|
|
273
274
|
const activeKeysRef = useRef(new Map());
|
|
274
275
|
const holdTimesRef = useRef({});
|
|
@@ -300,7 +301,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
300
301
|
};
|
|
301
302
|
const computeModifierKeysCount = (id, e) => {
|
|
302
303
|
const key = e.key;
|
|
303
|
-
const modifierKeys =
|
|
304
|
+
const modifierKeys = modifierKeysMapRef.current;
|
|
304
305
|
if (MODIFIER_KEYS.includes(key)) {
|
|
305
306
|
modifierKeys[id] = (modifierKeys[id] || 0) + 1;
|
|
306
307
|
}
|
|
@@ -398,7 +399,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
398
399
|
delete field[id];
|
|
399
400
|
};
|
|
400
401
|
const removeModifierMetric = (id) => {
|
|
401
|
-
const field =
|
|
402
|
+
const field = modifierKeysMapRef.current;
|
|
402
403
|
if (!field)
|
|
403
404
|
return;
|
|
404
405
|
delete field[id];
|
|
@@ -412,7 +413,7 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
412
413
|
const resetFields = () => {
|
|
413
414
|
trackedFieldMetricsRef.current = {};
|
|
414
415
|
fieldFocusMetricsRef.current = {};
|
|
415
|
-
|
|
416
|
+
modifierKeysMapRef.current = {};
|
|
416
417
|
holdTimesRef.current = {};
|
|
417
418
|
};
|
|
418
419
|
// Calculate distraction count
|
|
@@ -439,7 +440,8 @@ const useEvent = ({ event_type, track_fields, request_id, }) => {
|
|
|
439
440
|
const id = field.field_name;
|
|
440
441
|
const key_hold_times = holdTimesRef.current[id] || [];
|
|
441
442
|
const flight_time = getFlightTime(id);
|
|
442
|
-
|
|
443
|
+
const modifier_key_count = modifierKeysMapRef.current[id];
|
|
444
|
+
return { ...field, key_hold_times, flight_time, modifier_key_count };
|
|
443
445
|
});
|
|
444
446
|
}, []);
|
|
445
447
|
const getFlightTime = (id) => {
|