tracker: 16.0.2 fix str dictionary keys

This commit is contained in:
nick-delirium 2025-03-17 11:25:49 +01:00
parent cf9ecdc9a4
commit 9aca716e6b
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
5 changed files with 10 additions and 4 deletions

View file

@ -1,3 +1,7 @@
## 16.0.2
- fix attributeSender key generation to prevent calling native methods on objects
## 16.0.1
- drop computing ts digits

View file

@ -1,7 +1,7 @@
{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "16.0.1",
"version": "16.0.2",
"keywords": [
"logging",
"replay"

View file

@ -15,7 +15,9 @@ export class StringDictionary {
getKey = (str: string): [number, boolean] => {
let isNew = false
if (!this.backDict[str]) {
// avoiding potential native object properties
const safeKey = `__${str}`
if (!this.backDict[safeKey]) {
isNew = true
// shaving the first 2 digits of the timestamp (since they are irrelevant for next millennia)
const shavedTs = Date.now() % 10 ** (13 - 2)
@ -26,10 +28,10 @@ export class StringDictionary {
} else {
this.lastSuffix = 1
}
this.backDict[str] = id
this.backDict[safeKey] = id
this.lastTs = shavedTs
}
return [this.backDict[str], isNew]
return [this.backDict[safeKey], isNew]
}
}