Skip to content

Commit

Permalink
feat: add setChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
hehex9 committed Aug 17, 2021
1 parent 0117055 commit 8aae066
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"enabled": false,
"enabled": true,
"extends": ["@youjinbu"]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function SomeScreen() {
```ts
declare const Analytics: {
start(appKey: string, debug?: boolean): void;
setChannel(channel: string): void;
setUserId(userId: string): void;
pageStart(pageName: string): void;
pageEnd(pageName: string): void;
Expand Down
5 changes: 5 additions & 0 deletions android/src/main/java/com/youjinbu/baidumtj/BaiduMtjModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class BaiduMtjModule(private val reactContext: ReactApplicationContext) : ReactC
StatService.start(reactContext)
}

@ReactMethod
fun setChannel(channel: String) {
StatService.setAppChannel(reactContext, channel, true)
}

@ReactMethod
fun setUserId(userId: String) {
StatService.setUserId(reactContext, userId)
Expand Down
5 changes: 5 additions & 0 deletions ios/BaiduMtj.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class BaiduMtj: NSObject {
BaiduMobStat.default().start(withAppId: appKey)
}

@objc(setChannel:)
func setChannel(channel: String) {
BaiduMobStat.default().channelId = channel
}

@objc(setUserId:)
func setUserId(userId: String) {
BaiduMobStat.default().userId = userId
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@youjinbu/react-native-baidu-mtj",
"version": "0.1.5",
"version": "0.1.6",
"description": "react-native wrapper for baidu mtj sdk",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
4 changes: 4 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const Analytics = {
BaiduMtj.start(appKey, __DEV__ ? debug : false)
},

setChannel(channel: string) {
BaiduMtj.setChannel(channel)
},

setUserId(userId: string) {
BaiduMtj.setUserId(userId)
},
Expand Down

0 comments on commit 8aae066

Please sign in to comment.