UNPKG

@sdc-monitor/demo

Version:

<div align="center"> <a href="#" target="_blank"> <img src="https://i.loli.net/2021/07/28/EvPwd4NjVH3tBfO.jpg" alt="mito-logo" height="90"> </a> <p>A Lightweight SDK For Monitor Web</p>

28 lines (23 loc) 783 B
import { setUrlQuery, variableTypeDetection, generateUUID } from '@sdc-monitor/utils' import { STORAGE_KEY } from '../constant' export function noop() {} // wx export function getDeviceId(): string { const deviceId: string = wx.getStorageSync(STORAGE_KEY.deviceId) if (!deviceId) { const deviceId = generateUUID() wx.setStorageSync(STORAGE_KEY.deviceId, deviceId) } return deviceId } export function getPageUrl(setQuery = true) { if (!variableTypeDetection.isFunction(getCurrentPages)) { return '' } const pages = getCurrentPages() // 在App里调用该方法,页面还没有生成,长度为0 if (!pages.length) { return 'App' } const page = pages[pages.length - 1] return setQuery ? setUrlQuery(page.route, page.options) : page.route }