@youjinbu/react-native-baidu-mtj
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

react-native-baidu-mtj [WIP]

react-native wrapper for Baidu Mobile Analytics SDK(百度移动统计)

Installation

yarn add @youjinbu/react-native-baidu-mtj

Usage

Basic Usage

(see example)

import BaiduMtj from "@youjinbu/react-native-baidu-mtj"

BaiduMtj.start('app key')

export function SomeScreen() {
  useEffect(() => {
    // listen to focus event
    navigation.onFocus(() => {
      BaiduMtj.pageStart('home')
    })
    return () => BaiduMtj.pageEnd('home')
  }, [])

  return <View />
}

Supported Methods

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;
  event(eventId: string, label: string): void;
  eventStart(eventId: string, label: string): void;
  eventEnd(eventId: string, label: string): void;
};

Requirements

  • react-native >= 0.60.0

License

MIT

Package Sidebar

Install

npm i @youjinbu/react-native-baidu-mtj

Weekly Downloads

1

Version

0.1.6

License

MIT

Unpacked Size

26.4 kB

Total Files

19

Last publish

Collaborators

  • hehex