diff --git a/lerna.json b/lerna.json index 2e6245da..f1fcc0c8 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "packages/*" ], - "version": "0.7.1", + "version": "0.7.2", "npmClient": "yarn", "useWorkspaces": true } diff --git a/package.json b/package.json index f5ef8d7c..2208f361 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "clarity", "private": true, - "version": "0.7.1", + "version": "0.7.2", "repository": "https://github.com/microsoft/clarity.git", "author": "Sarvesh Nagpal ", "license": "MIT", diff --git a/packages/clarity-decode/package.json b/packages/clarity-decode/package.json index 66ace9cc..1289a036 100644 --- a/packages/clarity-decode/package.json +++ b/packages/clarity-decode/package.json @@ -1,6 +1,6 @@ { "name": "clarity-decode", - "version": "0.7.1", + "version": "0.7.2", "description": "An analytics library that uses web page interactions to generate aggregated insights", "author": "Microsoft Corp.", "license": "MIT", @@ -26,7 +26,7 @@ "url": "https://github.com/Microsoft/clarity/issues" }, "dependencies": { - "clarity-js": "^0.7.1" + "clarity-js": "^0.7.2" }, "devDependencies": { "@rollup/plugin-commonjs": "^19.0.1", diff --git a/packages/clarity-devtools/package.json b/packages/clarity-devtools/package.json index a36c4de0..29c8fe53 100644 --- a/packages/clarity-devtools/package.json +++ b/packages/clarity-devtools/package.json @@ -1,6 +1,6 @@ { "name": "clarity-devtools", - "version": "0.7.1", + "version": "0.7.2", "private": true, "description": "Adds Clarity debugging support to browser devtools", "author": "Microsoft Corp.", @@ -24,9 +24,9 @@ "url": "https://github.com/Microsoft/clarity/issues" }, "dependencies": { - "clarity-decode": "^0.7.1", - "clarity-js": "^0.7.1", - "clarity-visualize": "^0.7.1" + "clarity-decode": "^0.7.2", + "clarity-js": "^0.7.2", + "clarity-visualize": "^0.7.2" }, "devDependencies": { "@rollup/plugin-node-resolve": "^13.0.2", diff --git a/packages/clarity-devtools/static/manifest.json b/packages/clarity-devtools/static/manifest.json index 7f9a0056..53d7f8e7 100644 --- a/packages/clarity-devtools/static/manifest.json +++ b/packages/clarity-devtools/static/manifest.json @@ -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.1", - "version_name": "0.7.1", + "version": "0.7.2", + "version_name": "0.7.2", "minimum_chrome_version": "50", "devtools_page": "devtools.html", "icons": { diff --git a/packages/clarity-js/package.json b/packages/clarity-js/package.json index fbeb41db..b5e4029f 100644 --- a/packages/clarity-js/package.json +++ b/packages/clarity-js/package.json @@ -1,6 +1,6 @@ { "name": "clarity-js", - "version": "0.7.1", + "version": "0.7.2", "description": "An analytics library that uses web page interactions to generate aggregated insights", "author": "Microsoft Corp.", "license": "MIT", diff --git a/packages/clarity-js/src/clarity.ts b/packages/clarity-js/src/clarity.ts index 6fa8779d..94a09cbe 100644 --- a/packages/clarity-js/src/clarity.ts +++ b/packages/clarity-js/src/clarity.ts @@ -22,6 +22,7 @@ export function start(config: Config = null): void { core.start(); data.start(); modules.forEach(x => measure(x.start)()); + executeQueue(); } } @@ -53,3 +54,10 @@ export function stop(): void { core.stop(); } } + +export function executeQueue(): void { + const w = window as any; + const c = 'clarity'; + const queue = w[c] ? (w[c].q || []) : []; + while (queue.length > 0) { w[c](...queue.shift()); } +} \ No newline at end of file diff --git a/packages/clarity-js/src/core/index.ts b/packages/clarity-js/src/core/index.ts index 1bae028a..ca5caf74 100644 --- a/packages/clarity-js/src/core/index.ts +++ b/packages/clarity-js/src/core/index.ts @@ -73,6 +73,12 @@ export function suspend(): void { } } +export function queue(functionName: string, args: IArguments): void { + const w = window as any; + const c = 'clarity'; + (w[c].q=w[c].q||[]).push([functionName].concat(Array.from(args))); +} + function restart(): void { clarity.start(); custom.event(Constant.Clarity, Constant.Restart); diff --git a/packages/clarity-js/src/core/version.ts b/packages/clarity-js/src/core/version.ts index 9b109b75..5aea4c98 100644 --- a/packages/clarity-js/src/core/version.ts +++ b/packages/clarity-js/src/core/version.ts @@ -1,2 +1,2 @@ -let version = "0.7.1"; +let version = "0.7.2"; export default version; diff --git a/packages/clarity-js/src/data/metadata.ts b/packages/clarity-js/src/data/metadata.ts index b3f50f8a..cc83cdea 100644 --- a/packages/clarity-js/src/data/metadata.ts +++ b/packages/clarity-js/src/data/metadata.ts @@ -100,6 +100,8 @@ export function consent(): void { if (core.active()) { config.track = true; track(user(), BooleanFlag.True); + } else { + core.queue("consent", arguments); } } diff --git a/packages/clarity-js/src/data/variable.ts b/packages/clarity-js/src/data/variable.ts index 1c4d760d..fe94a3de 100644 --- a/packages/clarity-js/src/data/variable.ts +++ b/packages/clarity-js/src/data/variable.ts @@ -9,14 +9,23 @@ export function start(): void { } export function set(variable: string, value: string | string[]): void { - let values = typeof value === Constant.String ? [value as string] : value as string[]; - log(variable, values); + if (core.active()) { + let values = typeof value === Constant.String ? [value as string] : value as string[]; + log(variable, values); + } else { + core.queue("set", arguments); + } } export function identify(userId: string, sessionId: string = null, pageId: string = null): void { - log(Constant.UserId, [userId]); - log(Constant.SessionId, [sessionId]); - log(Constant.PageId, [pageId]); + if (core.active()) { + log(Constant.UserId, [userId]); + log(Constant.SessionId, [sessionId]); + log(Constant.PageId, [pageId]); + } else { + core.queue("identify", arguments); + } + } function log(variable: string, value: string[]): void { diff --git a/packages/clarity-js/src/global.ts b/packages/clarity-js/src/global.ts index 8f943ddd..e603080b 100644 --- a/packages/clarity-js/src/global.ts +++ b/packages/clarity-js/src/global.ts @@ -17,6 +17,7 @@ import * as clarity from "@src/clarity"; const queue = w[c] ? (w[c].q || []) : []; w[c] = function(method: string, ...args: any[]): void { return clarity[method](...args); } w[c].v = clarity.version; - while (queue.length > 0) { w[c](...queue.shift()); } + w[c].q = queue; + clarity.executeQueue(); } })(); diff --git a/packages/clarity-visualize/package.json b/packages/clarity-visualize/package.json index 806be32d..0664fbf2 100644 --- a/packages/clarity-visualize/package.json +++ b/packages/clarity-visualize/package.json @@ -1,6 +1,6 @@ { "name": "clarity-visualize", - "version": "0.7.1", + "version": "0.7.2", "description": "An analytics library that uses web page interactions to generate aggregated insights", "author": "Microsoft Corp.", "license": "MIT", @@ -27,7 +27,7 @@ "url": "https://github.com/Microsoft/clarity/issues" }, "dependencies": { - "clarity-decode": "^0.7.1" + "clarity-decode": "^0.7.2" }, "devDependencies": { "@rollup/plugin-commonjs": "^19.0.1",