npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pps-h5-lib

v1.0.8

Published

this is a qoe project of pps

Downloads

7

Readme

团队公共模块lib

Usage


使用指南指南


npm 使用

  • npm install --save pps-h5-lib

提供的工具类以及使用方法:


Application

  • import { Application } from 'pps-h5-lib'
  • 实现自己项目的 Application mock 和 baseApiUrl必须重写,用来匹配打包环境
 import { Application } from 'pps-h5-lib'
 
 export default {
   ...Application,
   mock: true && process.env.NODE_ENV == 'development',
   baseApiUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//toutiao.iqiyi.com') : 'http://10.16.171.78:8085',
   baseHttpWebUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//static.iqiyi.com/nadou') : (process.env.NODE_ENV == 'qa' ? 'http://nadouh5.iqiyi.com/nadou' : 'http://localhost:8080'),
   baseWebUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//static.iqiyi.com/nadou') : (process.env.NODE_ENV == 'qa' ? 'http://nadouh5.iqiyi.com/nadou' : 'http://localhost:8080')
 }
  • 使用 Application.init()应用项目重写后的 Application ;执行init()后会自动获取用户信息、设备信息;自动发送页面展示pingback
import Application from 'root/common/Application';

Application.pageInfo = {
       pingBack: {
         rpage: 'template',//产品定义rpage
         pageName: 'templatepps'//Grafana实时统计页面PV
       }
     };
Application.init(() => {
       let self = this;
       if (Application.appInfo.ppuid) {
         self.isLogin = true;
       } else {
         self.isLogin = false;
       }
       if (process.env.NODE_ENV == 'development') {
         self.isLogin = true;
       }
       self.init();
     });
  • Application.appInfo init执行后存取应用用户信息设备信息
appInfo: {
   ppuid: '',
   authCookie: '',
   deviceId: '',
   appVersion: '',
   'user-agent': window.userAgent,
   client_ip: '',
   key: '',
   deviceType: '',
   /**
    * 风控侧平台定义
    0:其他 
    1:android(安卓端)
    2:ios 
    3:PCW(PC网页) 
    4:H5
    5: PCA
    6: 微信小程序
    7: android tv
    8: UWP
    */
   platform: '',
   dfp: '',
   appChannel: '',
   networkStatus: '',
   qyID: '',
   sign: '',
   timestamp: '',
   userIcon: '',
   userName: '',

   appIdNaDou: 'wx3c55020afc58a8fc',
   appIdHaoDUo: 'wx03071aa0b1ab1541',
   appIdPPS: 'wx3b61b7eb6946daf5',
 },
  • Application.browser 存取平台浏览器型号信息如 Application.browser.chrome Application.browser.version
browser: {
   qq: /qqbrowser|QQ|QQbrowser/.test(navigator.userAgent),
   weixin: /MicroMessenger/i.test(navigator.userAgent),
   uc: /ucbrowser|ucweb/i.test(navigator.userAgent),
   baidubox: /baiduboxapp/i.test(navigator.userAgent),
   baidubrowser: /baidubrowser/i.test(navigator.userAgent),
   weibo: /weibo/i.test(navigator.userAgent),
   ios_egt_9: /iPhone OS (\d+)/i.exec(navigator.userAgent) && /iPhone OS (\d+)/i.exec(navigator.userAgent)[1] >= 9,
   ios_egt_10: /iPhone OS (\d+)/i.exec(navigator.userAgent) && /iPhone OS (\d+)/i.exec(navigator.userAgent)[1] > 9,
   qiyinews: /QYNews/.test(navigator.userAgent) && !(/IqiyiApp\/pps/.test(navigator.userAgent)), //爱奇艺头条webview //兼容pps图文详情页打开后两个ua头都有的情况 9.8.5后修复
   pps: /IqiyiApp\/pps/.test(navigator.userAgent), //PPSwebview
   iqiyiAPP: /IqiyiApp\/iqiyi/.test(navigator.userAgent), //只用来判断是否为爱奇艺系列app内(含头条)
   ...Detect.browser
 }
  • Application.os.android Application.os.ios Application.os.version

Api 负责发送ajax的工具类 引用到项目中需要重写根据环境切换baseApiUrl

  • _request: function (url, params, option) {} 返回一个promise
  • extendParams: object 页面统计信息扩展参数
  • consuming: 分别监控用户操作触发的、或者有可能多次被访问的异步请求
  • ajax: 监控页面一组 ajax 请求(组件初始化、影响页面展示的请求等)的总耗时
  • sampleRate: number{0-100}发送比例 默认%1比例发送
  • p1: string 业务线名称
  • bc: string 同一个p1下区分字业务线