@cutyai/bq-query
v0.0.8
Published
## 使用
Downloads
138
Readme
BQQuery SDK
使用
import { BQInstance } from '@cutyai/bq-query'
const credentialsStr = `{
"type": "service_account",
"project_id": "xxx",
"private_key_id": "xx",
"private_key": "xxx",
"client_email": "xxxx",
"client_id": "xxxx",
"auth_uri": "xxxx",
"token_uri": "xxxx",
"auth_provider_x509_cert_url": "xxxx",
"client_x509_cert_url": "xxxx",
"universe_domain": "xxxx"
}`
const bqOptions = {
projectId: 'xxx',
credentials: credentialsStr, // 服务账号的用户密钥 可在google cloud 控制台iam 服务账号新增或者下载
datasetId: 'web_tracker',
tableId: 'event_logs',
app_type: 'webtracker_test',
}
BQInstance.init(bqOptions)
// 获取 SDK 实例
const bqInstance = BQInstance.getInstance()
bqInstance.insertEventLogs([{
eventId: 'purchase_event',
eventType: 'business',
}])
bqInstance.createEventLogsTable() //创建与当前埋点事件字段对应的表
bqInstance.insertEventLogs([]) //插入数据到bq