From c2b4b91349a1869a720c79c2d65e057f09b56191 Mon Sep 17 00:00:00 2001 From: Yuxuan Lin Date: Tue, 16 Aug 2022 18:50:47 +0800 Subject: [PATCH] style: update --- .vscode/settings.json | 2 ++ README.md | 2 +- index.html | 59 ++++++++++++++++++------------------- src/core/index.ts | 6 ++-- src/lib/device.ts | 5 ++-- src/lib/fmp.ts | 1 - src/utils/fingerprinting.ts | 2 -- src/utils/report.ts | 2 +- 8 files changed, 37 insertions(+), 42 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7d499e0..5b62ba1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,9 @@ // Extension configs "cSpell.words": [ "antfu", + "dpss", "pnpm", + "Tian", "ttfb", "vitegil" ], diff --git a/README.md b/README.md index fe36637..1a9301e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Vitegil SDK +# Vitegil SDK 💉 [![npm](https://img.shields.io/npm/v/vitegil-sdk?color=3c8cff)](https://www.npmjs.com/package/vitegil-sdk) [![node compatibility](https://img.shields.io/node/v/vitegil-sdk?color=0F9D58)](https://nodejs.org/en/about/releases/) diff --git a/index.html b/index.html index 40b5dc9..4b8122f 100644 --- a/index.html +++ b/index.html @@ -1,36 +1,33 @@ - - - - - Document - + + + + + Document + - - + + - - + + - - - - \ No newline at end of file + + + diff --git a/src/core/index.ts b/src/core/index.ts index a39a71c..67dc3e2 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -133,7 +133,7 @@ export default class Tracker { event: 'uv-event', targetKey: 'uv-event', data: this.data.uuid, - }, 'useruv', true) + }, 'userid', true) return } this.sendTracker({ @@ -189,7 +189,7 @@ export default class Tracker { */ private jsErrorEvent(): void { window.addEventListener('error', (e) => { - if (this.isResourseError(e)) + if (this.isResourceError(e)) return if (this.data.lazyReport) { this.saveTracker({ @@ -222,7 +222,7 @@ export default class Tracker { * @param event 事件对象 * @returns boolean 是否是资源错误 */ - private isResourseError(event: ErrorEvent): boolean { + private isResourceError(event: ErrorEvent): boolean { const target = event.target || event.srcElement const isElementTarget = target instanceof HTMLScriptElement || target instanceof HTMLLinkElement || target instanceof HTMLImageElement if (!isElementTarget) diff --git a/src/lib/device.ts b/src/lib/device.ts index e409abd..7aabb11 100644 --- a/src/lib/device.ts +++ b/src/lib/device.ts @@ -109,7 +109,7 @@ function getLanguage(navigator: any) { return navigator.browserLanguage || navigator.language } -function getOrientationStatu(_window: any) { +function getOrientationStatus(_window: any) { let orientationStatus = '' const orientation = _window.matchMedia('(orientation: portrait)') if (orientation.matches) @@ -172,11 +172,10 @@ export function getDeviceData() { screenWidth: _window.screen.width, language: getLanguage(navigator), netWork: getNetwork(navigator), - orientation: getOrientationStatu(_window), + orientation: getOrientationStatus(_window), browser: getValue(map, BrowserType), browserInfo: getBrowserInfo(map, ua), } - // console.log(data) return data } else { diff --git a/src/lib/fmp.ts b/src/lib/fmp.ts index aa0b52f..52878ae 100644 --- a/src/lib/fmp.ts +++ b/src/lib/fmp.ts @@ -153,7 +153,6 @@ export default class FMPTiming { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error const resultEls: FMP.Els = this.filterResult(tp.els) - console.log('最终节点集合', tp, resultEls) const fmpTiming: number = this.getFmpTime(resultEls) saveToStorage({ firstMeaningfulPaint: fmpTiming }, 'performance') diff --git a/src/utils/fingerprinting.ts b/src/utils/fingerprinting.ts index 07324f4..c66b579 100644 --- a/src/utils/fingerprinting.ts +++ b/src/utils/fingerprinting.ts @@ -27,7 +27,5 @@ export default function fingerprinting(): string { // 通过sha256算法得出唯一的canvas指纹 const fingerprint: string = CryptoES.SHA256(canvasImageData).toString() - console.log(`指纹 ${fingerprint}`) - return fingerprint } diff --git a/src/utils/report.ts b/src/utils/report.ts index ea68ac8..1ea32b6 100644 --- a/src/utils/report.ts +++ b/src/utils/report.ts @@ -29,7 +29,7 @@ export const reportStorageInfo = (url: string) => { const time = localStorage.getItem('timing') || undefined time && reportData.push(time) - const uv = localStorage.getItem('useruv') || undefined + const uv = localStorage.getItem('userid') || undefined uv && reportData.push(uv) const device = localStorage.getItem('device') || undefined