Skip to content

Commit

Permalink
breaking out the style states into 2 fields and ensuring we dont rese…
Browse files Browse the repository at this point in the history
…t in the middle of capturing subsequent pages
  • Loading branch information
Sam Martin committed May 14, 2024
1 parent bfb8a5d commit dd016d8
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.7.34",
"version": "0.7.35",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion packages/clarity-decode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-decode",
"version": "0.7.34",
"version": "0.7.35",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-devtools",
"version": "0.7.34",
"version": "0.7.35",
"private": true,
"description": "Adds Clarity debugging support to browser devtools",
"author": "Microsoft Corp.",
Expand Down
4 changes: 2 additions & 2 deletions packages/clarity-devtools/static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"manifest_version": 2,
"name": "Microsoft Clarity Developer Tools",
"description": "Clarity helps you understand how users are interacting with your website.",
"version": "0.7.34",
"version_name": "0.7.34",
"version": "0.7.35",
"version_name": "0.7.35",
"minimum_chrome_version": "50",
"devtools_page": "devtools.html",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-js",
"version": "0.7.34",
"version": "0.7.35",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-js/src/core/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
let version = "0.7.34";
let version = "0.7.35";
export default version;
2 changes: 2 additions & 0 deletions packages/clarity-js/src/insight/blank.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export let state = [];
export let sheetAdoptionState = [];
export let sheetUpdateState = [];
export let data = null;

/* Intentionally blank module with empty code */
Expand Down
8 changes: 4 additions & 4 deletions packages/clarity-js/src/insight/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { StyleSheetState } from "@clarity-types/layout";
import * as core from "@src/core";
import * as metric from "@src/data/metric";

export let state: StyleSheetState[] = [];
export let sheetAdoptionState: StyleSheetState[] = [];
export let sheetUpdateState: StyleSheetState[] = [];
let replace: (text?: string) => Promise<CSSStyleSheet> = null;
let replaceSync: (text?: string) => void = null;

export function start(): void {
reset();

if (replace === null) {
replace = CSSStyleSheet.prototype.replace;
CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
Expand Down Expand Up @@ -44,7 +43,8 @@ export function compute(): void {
}

export function reset(): void {
state = [];
sheetAdoptionState = [];
sheetUpdateState = [];
}

export function stop(): void {
Expand Down
9 changes: 4 additions & 5 deletions packages/clarity-js/src/layout/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,23 @@ export default async function (type: Event, timer: Timer = null, ts: number = nu
region.reset();
break;
case Event.StyleSheetAdoption:
for (let entry of style.state) {
case Event.StyleSheetUpdate:
for (let entry of style.sheetAdoptionState) {
tokens = [entry.time, entry.event];
tokens.push(entry.data.id);
tokens.push(entry.data.operation);
tokens.push(entry.data.newIds);
queue(tokens);
}
style.reset();
break;
case Event.StyleSheetUpdate:
for (let entry of style.state) {
for (let entry of style.sheetUpdateState) {
tokens = [entry.time, entry.event];
tokens.push(entry.data.id);
tokens.push(entry.data.operation);
tokens.push(entry.data.cssRules);
queue(tokens);
}
style.reset();
break;
case Event.Animation:
for (let entry of animation.state) {
tokens = [entry.time, entry.event];
Expand Down
13 changes: 7 additions & 6 deletions packages/clarity-js/src/layout/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { getId, getNode } from "@src/layout/dom";
import * as core from "@src/core";
import { getCssRules } from "./node";
import * as metric from "@src/data/metric";
import { schedule } from "@src/core/task";

export let state: StyleSheetState[] = [];
export let sheetUpdateState: StyleSheetState[] = [];
export let sheetAdoptionState: StyleSheetState[] = [];
let replace: (text?: string) => Promise<CSSStyleSheet> = null;
let replaceSync: (text?: string) => void = null;
const styleSheetId = 'claritySheetId';
Expand All @@ -17,8 +19,6 @@ let styleSheetMap = {};
let styleTimeMap: {[key: string]: number} = {};

export function start(): void {
reset();

if (replace === null) {
replace = CSSStyleSheet.prototype.replace;
CSSStyleSheet.prototype.replace = function(): Promise<CSSStyleSheet> {
Expand Down Expand Up @@ -96,7 +96,8 @@ export function compute(): void {
}

export function reset(): void {
state = [];
sheetAdoptionState = [];
sheetUpdateState = [];
}

export function stop(): void {
Expand All @@ -106,7 +107,7 @@ export function stop(): void {
}

function trackStyleChange(time: number, id: string, operation: StyleSheetOperation, cssRules?: string): void {
state.push({
sheetUpdateState.push({
time,
event: Event.StyleSheetUpdate,
data: {
Expand All @@ -120,7 +121,7 @@ function trackStyleChange(time: number, id: string, operation: StyleSheetOperati
}

function trackStyleAdoption(time: number, id: number, operation: StyleSheetOperation, newIds: string[]): void {
state.push({
sheetAdoptionState.push({
time,
event: Event.StyleSheetAdoption,
data: {
Expand Down
2 changes: 1 addition & 1 deletion packages/clarity-visualize/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-visualize",
"version": "0.7.34",
"version": "0.7.35",
"description": "An analytics library that uses web page interactions to generate aggregated insights",
"author": "Microsoft Corp.",
"license": "MIT",
Expand Down

0 comments on commit dd016d8

Please sign in to comment.