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

eli-fe-track

v1.0.0-beta.2

Published

eli fe track tool

Downloads

2

Readme

日志上报SDK

安装依赖包 install


  npm install --save eli-fe-track

引入


  import Logger from 'eli-fe-track'

配置 config

// 配置
const defaultConfig = {
  Base: {
    platform: 'mini',
    version: '1.0.0',
    appId: '', // 应用唯一标识
    traceId: '', // 用户唯一id,默认是自动生成,放置在缓存内
    showConfigInfo: false, // config 完成后打印配置信息
    SlsImmediate: 'true', // 字符串类型,立即上报Sls日志
    Console: true, // 开启控制台日志
    SlsTracker: false, // 开启Sls日志上报
    WxRealTimeLog: false // 开启微信后台实时日志上报
  },
  // SLS 配置信息:https://help.aliyun.com/document_detail/427749.html
  SlsTracker: {
    host: '', // 所在地域的服务入口。例如cn-hangzhou.log.aliyuncs.com
    project: '', // Project名称。
    logstore: '', // Logstore名称。
    time: 10, // 发送日志的时间间隔,默认是10秒。
    count: 10, // 发送日志的数量大小,默认是10条。
    topic: 'topic', // 自定义日志主题。
    source: 'source',
    tags: {
      tags: 'tags',
    },
  },
  WxRealTimeLog: {}
}

// 初始化配置
Logger.config(defaultConfig)

Base 目前支持以下配置项:

| 属性 | 类型 | 必填 | 默认值 | 说明 | |-|-|-|-|-| | platform | string | 否 | mini | web 、mini | | version | string | 是 | 1.0.0 | 应用版本 | | appId | string | 是 | '' | 程序唯一标识 | | traceId | string | 否 | '' | 用户唯一id,默认是自动生成,放置在缓存内 | | showConfigInfo | boolean | 否 | false | config 完成后打印配置信息 | | SlsImmediate | string | 否 | 'true' | 立即上报Sls日志 | | Console | boolean | 否 | true | 是否开启 console 日志 | | SlsTracker | boolean | 否 | false | 是否开启 sls 上报 | | WxRealTimeLog | boolean | 否 | false | 是否开启小程序实时日志|

日志上报


// 日志等级
const LogLevel = {
  Error: 'error',
  Warn: 'warn',
  Info: 'info',
  Log: 'log',
  Debug: 'debug'
}
// 日志类型
const LogType = {
  SysInfo: 'sysInfo',
  LifeCycle: 'lifeCycle',
  FailRequest: 'failRequest',
  ApiRequest: 'apiRequest',
  RenderError: 'renderError',
  SocketEvent: 'socketEvent',
  NetEvent: 'netEvent',
  Action: 'action',
  Custom: 'custom'
}

// 内置方法
1. sendSysInfo // 上报系统日志
2. log
3. logApiRequest // 默认为 apiRequest, 失败的接口会自动转为 failRequest
4. logLifeCycle
5. logAction
6. logSocketEvent
7. logNetEvent
8. logRenderError

// 日志上报,自定义类型 
Logger.log('INTERVIEW_START', {
  type: 'xxx', // 优先级高于默认方法
  level: 'error', // 优先级高于默认方法
  Immediate: 'true', // 优先级高于Base中的配置
  count: 1,
  obj: { a: 1, b: 2 }
})

// 上报系统日志
Logger.sendSysInfo()

// 上报生命周期日志 lifeCycle
Logger.logLifeCycle('INTERVIEW_PHOTO_TAKE', {
  costTime: 120,
  clickTimes: 3
})