https://github.com/volcengine/tls-js-sdk
tls js sdk for browser
https://github.com/volcengine/tls-js-sdk
Last synced: about 1 month ago
JSON representation
tls js sdk for browser
- Host: GitHub
- URL: https://github.com/volcengine/tls-js-sdk
- Owner: volcengine
- License: mit
- Created: 2022-09-15T08:20:43.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-25T08:22:53.000Z (over 3 years ago)
- Last Synced: 2025-01-07T15:21:13.904Z (over 1 year ago)
- Language: TypeScript
- Size: 52.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TLS JS SDK
[中文文档](https://github.com/volcengine/tls-js-sdk/blob/master/README.zh_CN.md)
This is TLS JS SDK for browser.
> TLS is short for Tinder Log Service.
# Installation
```shell
npm install -S @volcengine/tls-js-sdk
```
# Basic Usage
Import in the module file
```typescript
import { WebTrackerBrowser } from '@volcengine/tls-js-sdk';
const wtb = new WebTrackerBrowser({
host: 'your host',
projectId: 'your projectId',
topicId: 'your topicId',
});
```
Import directly in the browser
```html
const wtb = new TLS_Browser.WebTrackerBrowser({
host: 'your host',
projectId: 'your projectId',
topicId: 'your topicId',
});
```
# API
## WebTrackerBrowser
Class for web tracker in browser
```typescript
import { WebTrackerBrowser } from '@volcengine/tls-js-sdk';
const wtb = new WebTrackerBrowser({
host: 'your host', // required
projectId: 'your projectId', // required
topicId: 'yourt topicId', // required
protocol: 'your protocol', // optional.The default value is https
time: 'batch log time interval', // optional.The default value is 10s.
count: 'batch log limit', // optional.The default value is 10.
source: 'log source', // optional.
});
```
WebTrackerBrowser instance method below.
### send
send(data)
| params | description |
|:--------|:-------------------------------------------------------------------------------|
| data | (required) like { [index: string]: any } |
```typescript
wtb.send({
key: 'value', // custom key/value
});
```
### sendImmediate
sendImmediate(data)
| params | description |
|:--------|:-------------------------------------------------------------------------------|
| data | (required) like { [index: string]: any } |
```typescript
wtb.sendImmediate({
key: 'value', // custom key/value
});
```
### sendBatchLogs
sendBatchLogs(data)
| params | description |
|:--------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| data | (required) like Array> |
```typescript
wtb.sendBatchLogs([{ key: 'value' }]);
```
### sendBatchLogsImmediate
sendBatchLogsImmediate(data)
| params | description |
|:--------|:-----------------------------------------------------|
| data | (required) like Array< Record[]> |
```typescript
wtb.sendBatchLogsImmediate([{ key: 'value' }])
```
## Security
If you discover a potential security issue in this project, or think you may
have discovered a security issue, we ask that you notify Bytedance Security via our [security center](https://security.bytedance.com/src) or [vulnerability reporting email](sec@bytedance.com).
Please do **not** create a public GitHub issue.
# License
This project is licensed under the [MIT License](./LICENSE).