* feat tracker: add document titles to tabs * feat: titles for tabs * feat tracker: send initial title, parse titles better * feat ui: tab name styles * feat tracker: update changelogs * fix tracker: fix tests * fix tracker: fix failing tests, add some coverage * fix tracker: fix failing tests, add some coverage * Heatmaps (#2264) * feat ui: start heatmaps ui and tracker update * fix ui: drop clickmap from session * fix ui: refactor heatmap painter * fix ui: store click coords as int percent * feat(backend): insert normalized x and y to PG * feat(backend): insert normalized x and y to CH * feat(connector): added missing import * feat(backend): fixed different uint type issue * fix tracker: use max scrollable size for doc * fix gen files * fix ui: fix random crash, remove demo data generator * fix ui: rm some dead code --------- Co-authored-by: Alexander <zavorotynskiy@pm.me> * fix tracker: add heatmap changelog to tracker CHANGELOG.md * fix tracker: fix peerjs version to 1.5.4 (was 1.5.1) * fix document height calculation * Crossdomain tracking (#2277) * feat tracker: crossdomain tracking (start commit) * catch crossdomain messages, add nodeid placeholder * click scroll * frame placeholder number -> dynamic * click rewriter, fix scroll prop * some docs * some docs * fix options merging * CHANGELOG.md update * checking that crossdomain will not fire automatically * simplify func declaration * update test data * change clickmap document height calculation to scrollheight (which should be true height) --------- Co-authored-by: Alexander <zavorotynskiy@pm.me>
83 lines
2.3 KiB
TypeScript
83 lines
2.3 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { createClickMapPlayer } from 'Player';
|
|
import { makeAutoObservable } from 'mobx';
|
|
import withLocationHandlers from 'HOCs/withLocationHandlers';
|
|
import PlayerContent from './ThinPlayerContent';
|
|
import { IPlayerContext, PlayerContext, defaultContextValue } from '../../playerContext';
|
|
import { observer } from 'mobx-react-lite';
|
|
import { toast } from 'react-toastify'
|
|
|
|
function WebPlayer(props: any) {
|
|
const {
|
|
session,
|
|
insights,
|
|
jumpTimestamp,
|
|
} = props;
|
|
// @ts-ignore
|
|
const [contextValue, setContextValue] = useState<IPlayerContext>(defaultContextValue);
|
|
const playerRef = React.useRef<any>(null);
|
|
|
|
useEffect(() => {
|
|
const init = () => {
|
|
const [WebPlayerInst, PlayerStore] = createClickMapPlayer(
|
|
session,
|
|
(state) => makeAutoObservable(state),
|
|
toast,
|
|
);
|
|
playerRef.current = WebPlayerInst;
|
|
setContextValue({ player: WebPlayerInst, store: PlayerStore });
|
|
}
|
|
|
|
if (!playerRef.current) {
|
|
init()
|
|
} else {
|
|
playerRef.current.clean()
|
|
playerRef.current = null;
|
|
setContextValue(defaultContextValue);
|
|
init();
|
|
}
|
|
}, [session.sessionId]);
|
|
|
|
React.useEffect(() => {
|
|
return () => {
|
|
playerRef.current && playerRef.current.clean();
|
|
playerRef.current = null;
|
|
// @ts-ignore
|
|
setContextValue(defaultContextValue);
|
|
}
|
|
}, [])
|
|
|
|
const isPlayerReady = contextValue.store?.get().ready
|
|
|
|
React.useEffect(() => {
|
|
contextValue.player && contextValue.player.play()
|
|
if (isPlayerReady && insights.size > 0) {
|
|
setTimeout(() => {
|
|
contextValue.player.pause()
|
|
contextValue.player.jump(jumpTimestamp)
|
|
contextValue.player.scale()
|
|
|
|
setTimeout(() => { contextValue.player.showClickmap(insights) }, 250)
|
|
}, 500)
|
|
}
|
|
return () => {
|
|
isPlayerReady && contextValue.player.showClickmap(null)
|
|
}
|
|
}, [insights, isPlayerReady, jumpTimestamp])
|
|
|
|
if (!contextValue.player || !session) return null;
|
|
|
|
return (
|
|
<PlayerContext.Provider value={contextValue}>
|
|
<PlayerContent />
|
|
</PlayerContext.Provider>
|
|
);
|
|
}
|
|
|
|
export default connect(
|
|
(state: any) => ({
|
|
insights: state.getIn(['sessions', 'insights']),
|
|
jwt: state.getIn(['user', 'jwt']),
|
|
})
|
|
)(withLocationHandlers()(observer(WebPlayer)));
|