Giter Site home page Giter Site logo

994914624 / react-native-sa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shimo-react-native/react-native-sa

0.0 2.0 0.0 303 KB

神策 React Native SDK

License: MIT License

JavaScript 17.38% Python 5.66% Java 48.27% Objective-C 27.50% Ruby 1.19%

react-native-sa's Introduction

react-native-sa

神策 React Native SDK

安装

npm i react-native-sa --save

iOS

Podfile 中添加 pod 'SensorsAnalyticsSDK'pod install

Android

参考 Android SDK 使用说明 配置 Project 级别的 build.gradle 和主 module 的 build.gradle

方法

参考 index.js 的注释

init(properties) SDK 初始化

  • serverUrl: 数据接收地址
  • configureURL: 配置分发地址
  • debugMode: 调试模式。 0: off, 1: debug, 2: debug and track
  • networkTypes: 同步数据时的网络策略。 ['2G', '3G', '4G', 'WIFI', 'ALL']

login(loginId) 登录

logout() 注销

set(profile) 设置用户属性

setOnce(profile) 记录初次设定的属性

enableAutoTrack(eventTypeList) 开启自动追踪

  • eventTypeList 自动采集的类型, eg: ['AppStart', 'AppEnd', 'AppClick', 'AppViewScreen']

enableReactNativeAutoTrack() 开启自动追踪,支持 React Native

只支持 Android。iOS 把 Podfile 改成 pod 'SensorsAnalyticsSDK', :subspecs => ['ENABLE_REACT_NATIVE_APPCLICK']

track(event, properties) 追踪事件

trackBegin(event) 事件开始

trackEnd(event, properties) 事件结束

trackInstallation(event, properties = null) 渠道追踪

用例

import SensorsAnalytics from 'react-native-sa';

// 初始化
SensorsAnalytics.init({
  serverUrl: Config.serverUrl,
  configureURL: Config.configureURL,
  debugMode: 0,
  networkTypes: ['WIFI']
});

// 登录
SensorsAnalytics.login(me.id.toString());

// 设置用户数据
SensorsAnalytics.set({
  email: me.email,
  mobile: me.mobile,
  name: me.name
});

// 追踪事件
SensorsAnalytics.track('test', { type: 'doc', status: '2' });

react-native-sa's People

Contributors

greedbell avatar wsong910 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.