fix(tracker): sessionHash & session reset

This commit is contained in:
Alex Kaminskii 2022-09-13 12:39:53 +02:00
parent 0956ff9a7d
commit 7cac0ceff7
3 changed files with 8 additions and 7 deletions

View file

@ -389,6 +389,7 @@ export default class App {
const sReset = this.sessionStorage.getItem(this.options.session_reset_key)
this.sessionStorage.removeItem(this.options.session_reset_key)
const shouldReset = startOpts.forceNew || sReset !== null
return window
.fetch(this.options.ingestPoint + '/v1/web/start', {
@ -400,10 +401,9 @@ export default class App {
...this.getTrackerInfo(),
timestamp,
userID: this.session.getInfo().userID,
token: this.session.getSessionToken(),
token: shouldReset ? undefined : this.session.getSessionToken(),
deviceMemory,
jsHeapSizeLimit,
reset: startOpts.forceNew || sReset !== null,
}),
})
.then((r) => {
@ -443,9 +443,12 @@ export default class App {
) {
return Promise.reject(`Incorrect server response: ${JSON.stringify(r)}`)
}
if (sessionID !== this.session.getInfo().sessionID) {
this.session.reset()
}
this.session.setSessionToken(token)
this.localStorage.setItem(this.options.local_uuid_key, userUUID)
this.session.update({ sessionID, timestamp: startTimestamp || timestamp, projectID }) // TODO: no no-explicit 'any'
this.localStorage.setItem(this.options.local_uuid_key, userUUID)
const startWorkerMsg: WorkerMessageData = {
type: 'auth',

View file

@ -97,7 +97,7 @@ export default class Session {
let token = hash
let pageNoStr = '100500' // back-compat for sessionToken
if (hashParts.length == 2) {
;[token, pageNoStr] = hashParts
;[pageNoStr, token] = hashParts
}
if (!pageNoStr || !token) {
return

View file

@ -187,9 +187,7 @@ export default class API {
return
}
this.app.stop()
const sessionHash = this.app.session.getSessionHash()
this.app.session.reset()
return sessionHash
return this.app.session.getSessionHash()
}
getSessionToken(): string | null | undefined {