tracker: add restart on token expiration for canvas tracker
This commit is contained in:
parent
62d3636136
commit
bd7ecf18f4
5 changed files with 19 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
|||
# 14.0.7
|
||||
|
||||
- check for stopping status during restarts
|
||||
- restart if token expired during canvas fetch
|
||||
|
||||
# 14.0.6
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "14.0.7-beta.0",
|
||||
"version": "14.0.7",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class CanvasRecorder {
|
|||
return
|
||||
}
|
||||
if (!canvas || !hasTag(canvas, 'canvas') || canvas !== node) {
|
||||
this.app.debug.log('Canvas element not in sync')
|
||||
this.app.debug.log('Canvas element not in sync', canvas, node)
|
||||
clearInterval(int)
|
||||
return
|
||||
} else {
|
||||
|
|
@ -160,6 +160,14 @@ class CanvasRecorder {
|
|||
}
|
||||
})
|
||||
|
||||
const initRestart = () => {
|
||||
this.app.debug.log('Restarting tracker; token expired')
|
||||
this.app.stop(false)
|
||||
setTimeout(() => {
|
||||
void this.app.start({}, true)
|
||||
}, 250)
|
||||
}
|
||||
|
||||
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
|
@ -167,7 +175,10 @@ class CanvasRecorder {
|
|||
},
|
||||
body: formData,
|
||||
})
|
||||
.then(() => {
|
||||
.then((r) => {
|
||||
if (r.status === 401) {
|
||||
return initRestart()
|
||||
}
|
||||
return true
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ export default class Session {
|
|||
private projectID: string | undefined
|
||||
private tabId: string
|
||||
public userInfo: UserInfo
|
||||
private token: string | undefined
|
||||
|
||||
constructor(
|
||||
private readonly app: App,
|
||||
|
|
@ -109,10 +110,12 @@ export default class Session {
|
|||
}
|
||||
|
||||
getSessionToken(): string | undefined {
|
||||
return this.app.sessionStorage.getItem(this.options.session_token_key) || undefined
|
||||
const token = this.token || this.app.sessionStorage.getItem(this.options.session_token_key)
|
||||
return token || undefined
|
||||
}
|
||||
|
||||
setSessionToken(token: string): void {
|
||||
this.token = token
|
||||
this.app.sessionStorage.setItem(this.options.session_token_key, token)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue