Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-tracker-browser

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-tracker-browser

用户行为、应用性能、应用异常一体化采集

  • 1.0.1-r1
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

天眼FAST探针(Browser)

安装

使用Yarn进行安装(推荐)

yarn add fast-tracker-browser

使用npm进行安装

npm install fast-tracker-browser

使用

建议登录天眼平台按照前端应用接入指引使用

如对该工具比较熟悉,可自行进行配置,请在应用程序入口添加以下代码

// 引入探针
import fastTracker from 'fast-tracker-browser';
// 引入配置文件
import fastTrackerConfig from '这里需要自行创建一个JSON配置文件';

// 使用配置执行探针初始化
fastTracker(config);

JSON配置文件内容

{
	"endpoint": "",
	"app": "",
	"is_spa": true,
	"include_search": false,
	"log_content_attribute": "data-log",
	"log_event_attribute": "data-event",
	"log_module_attribute": "data-module",
	"report_api_params": false,
	"api_ignore_urls": [],
	"ignore_pages": [],
	"collect_event_types": ["event","page","click","api","error","crash"],
	"tenant_reader": {
		"key": "",
		"range": ["url","localstorage","sessionstorage","cookie","window"]
	},
	"real_user_reader": {
		"key": "",
		"range": ["url","localstorage","sessionstorage","cookie","window"]
	},
	"user_group_reader": {
		"key": "",
		"range": ["url","localstorage","sessionstorage","cookie","window"]
	},
	"app_version_reader": {
		"key": "",
		"range": ["url","localstorage","sessionstorage","cookie","window"]
	},
	"trace_config": {
		"rules": [],
		"headers": []
	},
	"replay": {
		"error": false
	}
}

探针配置清单

配置项配置描述是否必填默认值说明配置示例
endpoint探针上报地址在天眼平台下载的配置会自动注入当前所属产品前端日志库的上报地址"https://fast-logstore.mypaas.com/xxxxxx"
app应用名称在天眼平台下载的配置中会自动注入创建产品时填写的名称"analysis"
include_search开启页面地址参数采集true开启后将页面URL的参数(search)部分上报为page_search字段true
ignore_pages按页面禁用日志采集[]将屏蔽配置的列表中匹配到的页面的所有事件采集[".mypaas.com",".baidu.com"]
tenant_reader租户读取{key: "",range:["url","localstorage","sessionstorage","cookie","window"]}根据配置的key在range指定的范围内按先后顺序读取作为tenant字段上报{key:"org_code",range:[”localstorage“]}
real_user_reader用户读取{key: "",range:["url","localstorage","sessionstorage","cookie","window"]}根据配置的key在range指定的范围内按先后顺序读取作为real_user_id字段上报{key:"userinfo.code",range:[”localstorage“]}
user_group_reader用户分组读取{key: "",range:["url","localstorage","sessionstorage","cookie","window"]}根据配置的key在range指定的范围内按先后顺序读取作为user_group字段上报{key:"userinfo.role",range:[”localstorage“]}
app_version_reader应用版本读取{key: "",range:["url","localstorage","sessionstorage","cookie","window"]}根据配置的key在range指定的范围内按先后顺序读取作为app_version字段上报{key:"version",range:[”window“]}
log_event_attribute申明式埋点事件名称属性名称data-eventclick事件中指定作为event字段上报的由DOM读取的属性名data-eventname
log_content_attribute申明式埋点事件内容属性名称data-logclick事件中指定作为logs字段上报的由DOM读取的属性名data-content
log_module_attribute申明式埋点事件模块属性名称data-moduleclick事件中指定作为module字段上报的由DOM读取的属性名data-mod
collect_event_types采集事件类型!!#ff9900 ["page","api","click","error","crash","event"]!!按照事件类型指定需要采集的日志["page","api"]
is_spa开启单页应用页面切换采集true开启后将增加history.pushState、history.replaceState、hashchange事件、popstate事件的监听,用于单页应用路由切换监听true
report_api_params开启API调用参数采集false开启后将开始采集api的参数,包含querystring以及requestbody部分true
api_ignore_urls忽略采集的API地址[]列表中匹配到的API地址不采集API日志,默认屏蔽endpoint以及其他同类产品的采集请求["fast.mypaas.com/api/log"]
api_url_regxAPI地址截取""这个配置还需要继续改造,暂未在配置表单中体现""
trace_config打通前后端调用链路!!#ff9900 {rules:[],headers:[]}!!开启后针对rules中匹配域名的API,将添加headers中的自定义请求头,默认会添加x-fast-trace-id请求头{rules:["fast.mypaas.com"],headers:[{name:"x-fast-uid",type:"built-in",value:"u"}]}
replay开启前端错误视频录制{error:false}开启后,发生前端错误时,将同时采集错误发生前一小段时间的视频{error: true}
debug开启调试模式false目前暂时没有明确作用,不在配置表单中体现false

探针API

API名称API描述参数说明
registUser({tenant_code,user_account,user_group})注册用户信息参数与上报字段对应关系:tenant_code→tenant,user_account→real_user_id,user_group→user_group
setBasicInfo({custom_data,app_hotupdate_version})设置附加日志内容custom_data公共附加信息,!!#ff9900 作为cd字段上报,!! 追加至logs字段中
report(eventName, logs, eventModule, forceMode)上报埋点日志eventName事件名称(event字段),logs日志内容(需要JSON OBJECT,追加到logs中),eventModule事件所属模块(module字段),forceMode强制上报模式(0普通,1创建日志后立即异步上报,2创建日志后立即同步上报)
reportError(errorData, extraInfo)上报前端错误errorData错误对象(需要使用new Error等方式创建),extraInfo错误附加信息(作为logs.extraInfo上报)

版本日志

1.0.1

1、修复传递给MFastLog插件的endpoint缺少env参数的问题 2、修复回放日志上报endpoint缺少env参数的问题 3、修复fetch方法传递通过Headers构造的请求头参数时在添加trace-id请求头后原请求头丢失的问题

1.0.0

1、适配天眼3.0新的日志结构 2、对接天眼3.0日志服务 3、适配新的Cordova插件MFastLog 4、修复在页面LOAD事件触发前使用Image上报导致页面LOAD事件被推迟的问题

Keywords

FAQs

Package last updated on 20 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc