tracker: changelogs

This commit is contained in:
nick-delirium 2025-05-09 11:38:04 +02:00 committed by Delirium
parent 83b6b6a3dd
commit d58031caf6
3 changed files with 43 additions and 7 deletions

View file

@ -1,3 +1,30 @@
## 16.3.0
- optional dynamic css scanning for better emotionjs support
```
new Tracker({
...css: cssScanOptions
})
interface cssScanOptions {
/** turn this on if you have issues with emotionjs created styles */
scanInMemoryCSS?: boolean
/** how often to scan tracked stylesheets (with "empty" rules) */
checkCssInterval?: number
/**
Useful for cases where you expect limited amount of mutations
i.e when sheets are hydrated on client after initial render.
if you want to observe for x seconds, do (x*1000)/checkCssInterval = checkLimit
applied to each stylesheet individually.
*/
checkLimit?: number
}
```
## 16.2.1 ## 16.2.1
- easier inliner options: - easier inliner options:

View file

@ -1,7 +1,7 @@
{ {
"name": "@openreplay/tracker", "name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package", "description": "The OpenReplay tracker main package",
"version": "16.3.0", "version": "16.3.0-beta.0",
"keywords": [ "keywords": [
"logging", "logging",
"replay" "replay"

View file

@ -9,8 +9,10 @@ import { hasTag } from '../app/guards.js'
import { nextID, styleSheetIDMap } from './constructedStyleSheets.js' import { nextID, styleSheetIDMap } from './constructedStyleSheets.js'
export interface CssRulesOptions { export interface CssRulesOptions {
checkCssInterval?: number /** turn this on if you have issues with emotionjs created styles */
scanInMemoryCSS?: boolean scanInMemoryCSS?: boolean
/** how often to scan tracked stylesheets (with "empty" rules) */
checkCssInterval?: number
/** /**
Useful for cases where you expect limited amount of mutations Useful for cases where you expect limited amount of mutations
@ -23,34 +25,41 @@ export interface CssRulesOptions {
checkLimit?: number checkLimit?: number
} }
const defaults: CssRulesOptions = {
checkCssInterval: 200,
scanInMemoryCSS: false,
checkLimit: undefined,
}
export default function (app: App, opts: CssRulesOptions) { export default function (app: App, opts: CssRulesOptions) {
if (app === null) return if (app === null) return
if (!window.CSSStyleSheet) { if (!window.CSSStyleSheet) {
app.send(TechnicalInfo('no_stylesheet_prototype_in_window', '')) app.send(TechnicalInfo('no_stylesheet_prototype_in_window', ''))
return return
} }
const options = { ...defaults, ...opts }
// sheetID:index -> ruleText // sheetID:index -> ruleText
const ruleSnapshots = new Map<string, string>() const ruleSnapshots = new Map<string, string>()
let checkInterval: number | null = null let checkInterval: number | null = null
const trackedSheets: Set<CSSStyleSheet> = new Set(); const trackedSheets: Set<CSSStyleSheet> = new Set();
const checkIntervalMs = opts.checkCssInterval || 200 const checkIntervalMs = options.checkCssInterval || 200
let checkIterations: Record<number, number> = {} let checkIterations: Record<number, number> = {}
function checkRuleChanges() { function checkRuleChanges() {
if (!opts.scanInMemoryCSS) return if (!options.scanInMemoryCSS) return
const allSheets = trackedSheets.values() const allSheets = trackedSheets.values()
for (const sheet of allSheets) { for (const sheet of allSheets) {
try { try {
const sheetID = styleSheetIDMap.get(sheet) const sheetID = styleSheetIDMap.get(sheet)
if (!sheetID) continue if (!sheetID) continue
if (opts.checkLimit) { if (options.checkLimit) {
if (!checkIterations[sheetID]) { if (!checkIterations[sheetID]) {
checkIterations[sheetID] = 0 checkIterations[sheetID] = 0
} else { } else {
checkIterations[sheetID]++ checkIterations[sheetID]++
} }
if (checkIterations[sheetID] > opts.checkLimit) { if (checkIterations[sheetID] > options.checkLimit) {
trackedSheets.delete(sheet) trackedSheets.delete(sheet)
return return
} }
@ -199,7 +208,7 @@ export default function (app: App, opts: CssRulesOptions) {
}) })
function startChecking() { function startChecking() {
if (checkInterval || !opts.scanInMemoryCSS) return if (checkInterval || !options.scanInMemoryCSS) return
checkInterval = window.setInterval(checkRuleChanges, checkIntervalMs) checkInterval = window.setInterval(checkRuleChanges, checkIntervalMs)
} }