取消客户端
JavaScript 库,用于整个 DSP 共享客户端侧分析
概览
此库由自定义解析码在 Data 中导入 科学平台 (DSP) web UIs 如Terra和单细胞门户. 它供应 它们具有整个DSP共同的属性,如"参考器","浏览器"等, "屏幕宽度" 还有更多.
这些自定义分析模块 : 条形服务器,它寄给Mixpanel.
最终,这个图书馆可以扩大,包括两个功能 logToBard
函数,以及或默认的事件工具化,但目前其重点是
将一组事件属性标准化.
安装
安装条形客户端 国家防范机制 像这样:
yarn add @databiosphere/bard-client
使用量
下面是一个简化的自定义分析模块.
通过为Bard客户端添加两行代码 - 导入和调用DefaultProperties - 我们可以增强这些自定义 在所有 DSP 中共享默认属性的分析.
import { getDefaultProperties } from '@databiosphere/bard-client' // Import the function from Bard client
function logToBard(name, customProps={}) {
const appPath = trimPrivateData(window.location.pathname)
const props = Object.assign(customProps, {
appId: 'awesome-dsp-web-ui',
appPath
}, getDefaultProperties()) // Append the default properties to the payload sent to Bard
const body = {
body: JSON.stringify({
event: name,
properties: props
})
}
const defaultInit = {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}
const init = Object.assign(defaultInit, body)
fetch(`${bardDomain}/api/event`, init)