tycho-components 0.36.7 → 0.36.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/AppClarity/AppClarity.d.ts +16 -0
- package/dist/common/AppClarity/AppClarity.js +48 -0
- package/dist/common/AppClarity/index.d.ts +2 -0
- package/dist/common/AppClarity/index.js +2 -0
- package/dist/common/AppForm/AppFormInfo.js +1 -1
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
clarity?: (...args: unknown[]) => void;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Microsoft Clarity loader — mirrors {@link AppAnalytics} (null render, injects
|
|
8
|
+
* the vendor tag on mount from a Vite env var). Set `VITE_APP_CLARITY_ID`.
|
|
9
|
+
*
|
|
10
|
+
* On top of the plain snippet it stitches every session of the logged-in Tycho
|
|
11
|
+
* user under their stable `uid` (decoded client-side from the `jwt_token_tycho`
|
|
12
|
+
* cookie) via `clarity('identify', …)`, so cross-module full-page navigations
|
|
13
|
+
* count as ONE identified user instead of N anonymous ones. The friendly name is
|
|
14
|
+
* PII — drop the last `identify` argument for a stricter privacy posture.
|
|
15
|
+
*/
|
|
16
|
+
export default function AppClarity(): null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Microsoft Clarity loader — mirrors {@link AppAnalytics} (null render, injects
|
|
4
|
+
* the vendor tag on mount from a Vite env var). Set `VITE_APP_CLARITY_ID`.
|
|
5
|
+
*
|
|
6
|
+
* On top of the plain snippet it stitches every session of the logged-in Tycho
|
|
7
|
+
* user under their stable `uid` (decoded client-side from the `jwt_token_tycho`
|
|
8
|
+
* cookie) via `clarity('identify', …)`, so cross-module full-page navigations
|
|
9
|
+
* count as ONE identified user instead of N anonymous ones. The friendly name is
|
|
10
|
+
* PII — drop the last `identify` argument for a stricter privacy posture.
|
|
11
|
+
*/
|
|
12
|
+
export default function AppClarity() {
|
|
13
|
+
const CLARITY_ID = import.meta.env.VITE_APP_CLARITY_ID;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!CLARITY_ID) {
|
|
16
|
+
console.warn('Microsoft Clarity project ID not set.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Inject the official Clarity loader (same shape as Clarity's install snippet).
|
|
20
|
+
const loader = document.createElement('script');
|
|
21
|
+
loader.innerHTML =
|
|
22
|
+
`(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};` +
|
|
23
|
+
`t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;` +
|
|
24
|
+
`y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y)})` +
|
|
25
|
+
`(window,document,"clarity","script","${CLARITY_ID}");`;
|
|
26
|
+
document.head.appendChild(loader);
|
|
27
|
+
// Identify the logged-in Tycho user so sessions stitch under one real id.
|
|
28
|
+
try {
|
|
29
|
+
const match = document.cookie.match(/(?:^|;\s*)jwt_token_tycho=([^;]+)/);
|
|
30
|
+
if (match) {
|
|
31
|
+
let b64 = match[1].split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
32
|
+
b64 += '==='.slice((b64.length + 3) % 4);
|
|
33
|
+
const payload = JSON.parse(decodeURIComponent(atob(b64)
|
|
34
|
+
.split('')
|
|
35
|
+
.map((ch) => '%' + ('00' + ch.charCodeAt(0).toString(16)).slice(-2))
|
|
36
|
+
.join('')));
|
|
37
|
+
if (payload?.uid) {
|
|
38
|
+
window.clarity?.('identify', payload.uid, undefined, undefined, payload.name || undefined);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
window.clarity?.('consent');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
/* not logged in / unparseable — track anonymously */
|
|
45
|
+
}
|
|
46
|
+
}, [CLARITY_ID]);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as AppAnalytics } from './AppAnalytics';
|
|
2
|
+
export { default as AppClarity } from './AppClarity';
|
|
2
3
|
export { default as AppCard } from './AppCard/AppCard';
|
|
3
4
|
export { default as AppClipboard } from './AppClipboard';
|
|
4
5
|
export { default as AppColorpicker } from './AppColorpicker';
|
package/dist/common/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as AppAnalytics } from './AppAnalytics';
|
|
2
|
+
export { default as AppClarity } from './AppClarity';
|
|
2
3
|
export { default as AppCard } from './AppCard/AppCard';
|
|
3
4
|
export { default as AppClipboard } from './AppClipboard';
|
|
4
5
|
export { default as AppColorpicker } from './AppColorpicker';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycho-components",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.36.
|
|
4
|
+
"version": "0.36.9",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"react-i18next": "^13.0.2",
|
|
83
83
|
"react-router-dom": "^6.14.2",
|
|
84
84
|
"react-toastify": "^9.1.3",
|
|
85
|
-
"tycho-storybook": "0.10.
|
|
85
|
+
"tycho-storybook": "0.10.13",
|
|
86
86
|
"wavesurfer-react": "^2.2.2",
|
|
87
87
|
"wavesurfer.js": "^6.6.3"
|
|
88
88
|
},
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"react-toastify": "^9.1.3",
|
|
112
112
|
"sass-embedded": "^1.97.2",
|
|
113
113
|
"storybook": "^10.1.11",
|
|
114
|
-
"tycho-storybook": "^0.10.
|
|
114
|
+
"tycho-storybook": "^0.10.13",
|
|
115
115
|
"typescript": "^5.7.3",
|
|
116
116
|
"vite": "^7.0.0",
|
|
117
117
|
"vitest": "^3.2.6",
|