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

js-sls-logger

v2.0.2

Published

"基于webtracking进行数据批量采集

Downloads

178

Readme

SLS WebTracking JavaScript Logging SDK(Deprecated)

本项目已过期(Deprecated)

最新 SDK:

浏览器参见 @aliyun-sls/web-track-browser

小程序参见 @aliyun-sls/web-track-mini

背景信息

Web Tracking 可以采集各种浏览器、iOS APP 或 Android APP 的用户信息,例如:

  • 用户使用的浏览器、操作系统、分辨率等信息。
  • 用户浏览行为记录(例如:用户在网站上的单击行为、购买行为等)。
  • 用户在 APP 中的停留时间、是否活跃等。

注意事项

  • 使用 Web Tracking 则表示该 Logstore 打开互联网匿名写入权限,没有经过有效鉴权,可能产生脏数据。
  • POST 请求每次写入的日志数量上限为 3MB 或者 4096 条,详情请参见PutLogs

数据采集

控制台方式

  1. 登录日志服务控制台
  2. 单击目标 Project。
  3. 找到目标 Logstore,单击pic下的修改
  4. Logstore 属性页面,单击右上方的修改
  5. 打开WebTracking开关,并单击保存

通过 JavaScript SDK 方式进行数据的采集

1.安装依赖包

npm install --save js-sls-logger

2.import在您的应用程序模块。

import SlsWebLogger from "js-sls-logger";

3.配置参数 opts。

| 参数 | 说明 | 是否填写 | | :----------: | :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------: | | host | 日志服务所在地域的 Endpoint,详情请参见服务入口 | 必填 | | project | 控制台创建的 project 名称。 | 必填 | | logstore | 控制台创建的 logstore 名称。 | 必填 | | time | 发送消息的时间间隔,数据格式为 Number 的方式,time*1000(毫秒)。 | 选填(默认是 10 秒) | | count | 发送消息的数量大小,数据格式为 Number 的方式。 | 选填(默认是 10 条数据) | | compress | 是否启用压缩。 | 选填(默认为 true) |

const opts = {
  host: "${host}", // 所在区域的host
  project: "${project}", // project名称
  logstore: "${logstore}", // logstore名称
  time: 10, // 定义时间,默认是10秒,number类型,选填
  count: 10, // 定义数据条数,默认是10条,number类型,选填
  compress: true, // 是否启用压缩,默认为true
};

4.创建 SlsWebLogger 对象。

const logger = new SlsWebLogger(opts);

5.上传日志。

logger.send({
  customer: "zhangsan",
  product: "iphone 12",
  price: 7998,
});

核心功能

send()

说明:  实现数据批量处理并执行数据上传。

参数:Object 类型

示例:

logger.send({
  customer: "zhangsan",
  product: "iphone 12",
  price: 7998,
});