tracker: add options for emotionjs tracker
This commit is contained in:
parent
b4fd3def10
commit
db5fc57e43
2 changed files with 11 additions and 4 deletions
|
|
@ -40,6 +40,7 @@ import type { Options as TimingOptions } from './modules/timing.js'
|
|||
import type { Options as NetworkOptions } from './modules/network.js'
|
||||
import type { MouseHandlerOptions } from './modules/mouse.js'
|
||||
import type { SessionInfo } from './app/session.js'
|
||||
import type { CssRulesOptions } from './modules/cssrules.js'
|
||||
|
||||
import type { StartOptions } from './app/index.js'
|
||||
//TODO: unique options init
|
||||
|
|
@ -61,7 +62,7 @@ export type Options = Partial<
|
|||
}
|
||||
// dev only
|
||||
__DISABLE_SECURE_MODE?: boolean
|
||||
checkCssInterval?: number
|
||||
css: CssRulesOptions
|
||||
}
|
||||
|
||||
const DOCS_SETUP = '/en/sdk'
|
||||
|
|
@ -193,7 +194,7 @@ export default class API {
|
|||
Mouse(app, options.mouse)
|
||||
// inside iframe, we ignore viewport scroll
|
||||
Scroll(app, this.crossdomainMode)
|
||||
CSSRules(app, options)
|
||||
CSSRules(app, options.css)
|
||||
ConstructedStyleSheets(app)
|
||||
Console(app, options)
|
||||
Exception(app, options)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import {
|
|||
import { hasTag } from '../app/guards.js'
|
||||
import { nextID, styleSheetIDMap } from './constructedStyleSheets.js'
|
||||
|
||||
export default function (app: App, opts: { checkCssInterval?: number }) {
|
||||
export interface CssRulesOptions {
|
||||
checkCssInterval?: number
|
||||
scanInMemoryCSS?: boolean
|
||||
}
|
||||
|
||||
export default function (app: App, opts: CssRulesOptions) {
|
||||
if (app === null) return
|
||||
if (!window.CSSStyleSheet) {
|
||||
app.send(TechnicalInfo('no_stylesheet_prototype_in_window', ''))
|
||||
|
|
@ -22,6 +27,7 @@ export default function (app: App, opts: { checkCssInterval?: number }) {
|
|||
const checkIntervalMs = opts.checkCssInterval || 200
|
||||
|
||||
function checkRuleChanges() {
|
||||
if (!opts.scanInMemoryCSS) return
|
||||
for (let i = 0; i < document.styleSheets.length; i++) {
|
||||
try {
|
||||
const sheet = document.styleSheets[i]
|
||||
|
|
@ -171,7 +177,7 @@ export default function (app: App, opts: { checkCssInterval?: number }) {
|
|||
})
|
||||
|
||||
function startChecking() {
|
||||
if (checkInterval) return
|
||||
if (checkInterval || !opts.scanInMemoryCSS) return
|
||||
checkInterval = window.setInterval(checkRuleChanges, checkIntervalMs)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue