@aem-sdk/tracker-plugin-longtask 0.1.0-beta.0
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/README.md +21 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @aem-sdk/tracker-plugin-longtask
|
|
2
|
+
|
|
3
|
+
Browser LongTask 插件。保留旧 `@ali/aes-tracker-plugin-longtask` 的核心采集能力。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @aem-sdk/tracker @aem-sdk/tracker-plugin-longtask@next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 用法
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import AES from "@aem-sdk/tracker";
|
|
15
|
+
import LongTaskPlugin from "@aem-sdk/tracker-plugin-longtask";
|
|
16
|
+
|
|
17
|
+
const aes = new AES({ pid: "demo" });
|
|
18
|
+
aes.use(LongTaskPlugin);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
插件只在注册后监听 Long Tasks API,不会在 import 时注册监听、创建 observer 或发送日志。上报字段直接使用新平台最终存储字段:`p1` 为 `startTime`,`p2` 为 `duration`,`p3` 为最近交互节点 selector。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e)return;if(Object.prototype.toString.call(e)===`[object Array]`)return t(e);let n=[],r=e;for(;r;)n.push(r),r=r.parentNode;return t(n)}function t(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(typeof window<`u`&&r===window||typeof document<`u`&&r===document)break;let i=r;if(i.id){t.push(`#${String(i.id)}`);break}if(typeof i.className==`string`&&i.className){let e=i.className.split(/\s+/).filter(e=>!!e).join(`.`);if(e){t.push(`.${e}`);continue}}i.nodeName&&t.push(String(i.nodeName))}return t.reverse().join(` `)||void 0}const n=[`pointerdown`,`touchstart`,`mousedown`,`keydown`,`mouseover`],r=e=>{if(!i())return;let t=a();if(!t)return;let r,u;try{u=new t(t=>{t.getEntries().forEach(t=>{c(()=>{s(e,t,r)})})}),u.observe({entryTypes:[`longtask`]})}catch(e){return}n.forEach(e=>{try{document.addEventListener(e,e=>{r=o(e)},{capture:!0,passive:!0})}catch(e){return}}),l(e=>{if(!e){u.disconnect();return}setTimeout(()=>{try{u.observe({entryTypes:[`longtask`]})}catch(e){return}},100)})};function i(){return typeof window<`u`&&typeof document<`u`&&window.PerformanceLongTaskTiming!==void 0}function a(){if(typeof window>`u`)return;let e=window.PerformanceObserver;return typeof e==`function`?e:void 0}function o(e){let t=e.composedPath;return typeof t==`function`?t.call(e):e.path||e.target}function s(t,n,r){try{t.log(`longtask`,{p1:n.startTime,p2:n.duration,p3:e(r||void 0)})}catch(e){return}}function c(e){try{let t=globalThis.requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function l(e){let t=u();if(t)try{document.addEventListener(t.eventName,()=>{e(!document[t.hidden])})}catch(e){return}}function u(){if(typeof document>`u`)return;if(document.hidden!==void 0)return{eventName:`visibilitychange`,hidden:`hidden`};let e=document;if(e.webkitHidden!==void 0)return{eventName:`webkitvisibilitychange`,hidden:`webkitHidden`};if(e.msHidden!==void 0)return{eventName:`msvisibilitychange`,hidden:`msHidden`}}module.exports=r;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AESPluginFactory } from "@aem-sdk/tracker";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface LongTaskPluginOptions {}
|
|
5
|
+
declare const AESPluginLongTask: AESPluginFactory<void, LongTaskPluginOptions>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { LongTaskPluginOptions, AESPluginLongTask as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e)return;if(Object.prototype.toString.call(e)===`[object Array]`)return t(e);let n=[],r=e;for(;r;)n.push(r),r=r.parentNode;return t(n)}function t(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(typeof window<`u`&&r===window||typeof document<`u`&&r===document)break;let i=r;if(i.id){t.push(`#${String(i.id)}`);break}if(typeof i.className==`string`&&i.className){let e=i.className.split(/\s+/).filter(e=>!!e).join(`.`);if(e){t.push(`.${e}`);continue}}i.nodeName&&t.push(String(i.nodeName))}return t.reverse().join(` `)||void 0}const n=[`pointerdown`,`touchstart`,`mousedown`,`keydown`,`mouseover`],r=e=>{if(!i())return;let t=a();if(!t)return;let r,u;try{u=new t(t=>{t.getEntries().forEach(t=>{c(()=>{s(e,t,r)})})}),u.observe({entryTypes:[`longtask`]})}catch(e){return}n.forEach(e=>{try{document.addEventListener(e,e=>{r=o(e)},{capture:!0,passive:!0})}catch(e){return}}),l(e=>{if(!e){u.disconnect();return}setTimeout(()=>{try{u.observe({entryTypes:[`longtask`]})}catch(e){return}},100)})};function i(){return typeof window<`u`&&typeof document<`u`&&window.PerformanceLongTaskTiming!==void 0}function a(){if(typeof window>`u`)return;let e=window.PerformanceObserver;return typeof e==`function`?e:void 0}function o(e){let t=e.composedPath;return typeof t==`function`?t.call(e):e.path||e.target}function s(t,n,r){try{t.log(`longtask`,{p1:n.startTime,p2:n.duration,p3:e(r||void 0)})}catch(e){return}}function c(e){try{let t=globalThis.requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function l(e){let t=u();if(t)try{document.addEventListener(t.eventName,()=>{e(!document[t.hidden])})}catch(e){return}}function u(){if(typeof document>`u`)return;if(document.hidden!==void 0)return{eventName:`visibilitychange`,hidden:`hidden`};let e=document;if(e.webkitHidden!==void 0)return{eventName:`webkitvisibilitychange`,hidden:`webkitHidden`};if(e.msHidden!==void 0)return{eventName:`msvisibilitychange`,hidden:`msHidden`}}export{r as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aem-sdk/tracker-plugin-longtask",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "AEM Web SDK browser long task plugin",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@aem-sdk/tracker": "0.1.0-beta.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@aem-sdk/tracker": "^0.1.0-beta.0"
|
|
31
|
+
},
|
|
32
|
+
"aemSizeBudget": {
|
|
33
|
+
"gzipBytes": 3072
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsdown",
|
|
37
|
+
"clean": "rm -rf dist dist-types",
|
|
38
|
+
"typecheck": "tsc -b tsconfig.json"
|
|
39
|
+
}
|
|
40
|
+
}
|