feat(tracker-assist):3.5.5: SESSION_UPDATE for title, hiddenstate, userID and metadata
This commit is contained in:
parent
135a8d0e7b
commit
ce2cd38db1
2 changed files with 38 additions and 13 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker-assist",
|
||||
"description": "Tracker plugin for screen assistance through the WebRTC",
|
||||
"version": "3.5.4",
|
||||
"version": "3.5.5",
|
||||
"keywords": [
|
||||
"WebRTC",
|
||||
"assistance",
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
"replace-paths": "replace-in-files cjs/* --string='@openreplay/tracker' --replacement='@openreplay/tracker/cjs' && replace-in-files cjs/* --string='/lib/' --replacement='/'",
|
||||
"replace-versions": "npm run replace-pkg-version && npm run replace-req-version",
|
||||
"replace-pkg-version": "replace-in-files lib/* cjs/* --string='PACKAGE_VERSION' --replacement=$npm_package_version",
|
||||
"replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='3.5.0'",
|
||||
"replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='3.5.3'",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -72,21 +72,43 @@ export default class Assist {
|
|||
},
|
||||
options,
|
||||
);
|
||||
app.attachStartCallback(() => {
|
||||
if (this.assistDemandedRestart) { return; }
|
||||
this.onStart()
|
||||
|
||||
if (document.hidden !== undefined) {
|
||||
const sendActivityState = () => this.emit("UPDATE_SESSION", { active: !document.hidden })
|
||||
app.attachEventListener(
|
||||
document,
|
||||
'visibilitychange',
|
||||
sendActivityState,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
}
|
||||
const titleNode = document.querySelector('title')
|
||||
const observer = titleNode && new MutationObserver(() => {
|
||||
this.emit("UPDATE_SESSION", { pageTitle: document.title })
|
||||
})
|
||||
app.attachCommitCallback((messages) => {
|
||||
if (this.socket && this.agentsConnected) {
|
||||
// @ts-ignore No need in statistics messages. TODO proper filter
|
||||
if (messages.length === 2 && messages[0]._id === 0 && messages[1]._id === 49) { return }
|
||||
this.socket.emit("messages", messages)
|
||||
}
|
||||
app.attachStartCallback(() => {
|
||||
if (this.assistDemandedRestart) { return; }
|
||||
this.onStart()
|
||||
observer && observer.observe(titleNode, { subtree: true, characterData: true, childList: true })
|
||||
})
|
||||
app.attachStopCallback(() => {
|
||||
if (this.assistDemandedRestart) { return; }
|
||||
this.clean()
|
||||
observer && observer.disconnect()
|
||||
})
|
||||
app.attachCommitCallback((messages) => {
|
||||
if (this.agentsConnected) {
|
||||
// @ts-ignore No need in statistics messages. TODO proper filter
|
||||
if (messages.length === 2 && messages[0]._id === 0 && messages[1]._id === 49) { return }
|
||||
this.emit("messages", messages)
|
||||
}
|
||||
})
|
||||
app.session.attachUpdateCallback(sessInfo => this.emit("UPDATE_SESSION", sessInfo))
|
||||
}
|
||||
|
||||
private emit(ev: string, ...args) {
|
||||
this.socket && this.socket.emit(ev, ...args)
|
||||
}
|
||||
|
||||
private get agentsConnected(): boolean {
|
||||
|
|
@ -94,7 +116,7 @@ export default class Assist {
|
|||
}
|
||||
|
||||
private notifyCallEnd() {
|
||||
this.socket && this.socket.emit("call_end");
|
||||
this.emit("call_end");
|
||||
}
|
||||
private onRemoteCallEnd = () => {}
|
||||
|
||||
|
|
@ -108,7 +130,10 @@ export default class Assist {
|
|||
query: {
|
||||
"peerId": peerID,
|
||||
"identity": "session",
|
||||
"sessionInfo": JSON.stringify(this.app.getSessionInfo()),
|
||||
"sessionInfo": JSON.stringify({
|
||||
pageTitle: document.title,
|
||||
...this.app.getSessionInfo()
|
||||
}),
|
||||
},
|
||||
transports: ["websocket"],
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue