(id, now = new Date())
| 68 | } |
| 69 | }, |
| 70 | logEventEnd(id, now = new Date()) { |
| 71 | const event = durationEventsQueue.current.get(id); |
| 72 | if (event) { |
| 73 | if (!event.event_timestamp) { |
| 74 | throw new Error('Missing event timestamp for duration event'); |
| 75 | } |
| 76 | |
| 77 | durationEventsQueue.current.delete(id); |
| 78 | event.event_duration = |
| 79 | now.getTime() - event.event_timestamp.getTime(); |
| 80 | if (window.scrollY > 0 && event.event_name !== 'page inactive') { |
| 81 | event.page_state = 'active'; |
| 82 | } |
| 83 | pushToQueue([event]); |
| 84 | } |
| 85 | }, |
| 86 | sendBeacon, |
| 87 | }), |
| 88 | [sharedPropsRef, getPage, pushToQueue, durationEventsQueue, sendBeacon], |
no outgoing calls