npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@smadey/react-native-growingio

v0.0.1

Published

GrowingIO SDK for ReactNative

Downloads

2

Readme

GrowingIO React Native SDK Reference

npm version MIT licensed


一、说明

react-native-growingio 用于RN开发者手动发送数据。

二、引入

  • npm install --save https://github.com/growingio/react-native-growingio.git
  • npm install
  • react-native link react-native-growingio

三、配置

iOS

  • 如果react-native link react-native-growingio失败(成功则忽略此步骤),即发现Libraries中没有GrowingIORNPlugin.xcodeproj,则可手动配置; a.打开XCode's工程中, 右键点击Libraries文件夹 ➜ Add Files to <...> b.去node_modules ➜ react-native-growingio ➜ ios ➜ 选择 GrowingIORNPlugin.xcodeproj c.在工程Build Phases ➜ Link Binary With Libraries中添加libGrowingIORNPlugin.a

  • 添加初始化函数: 在 AppDelegate 中引入#import "Growing.h"并添加启动方法

      - (BOOL)application:(UIApplication *)application
      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
          ...
          // 启动GrowingIO
          [Growing startWithAccountId:@"项目ID"];
    
          // 其他配置
          // 开启Growing调试日志 可以开启日志
          // [Growing setEnableLog:YES];
      }
  • 添加官网配置, 从步骤三开始

android

  • 在Application中的onCreate方法中初始化:

      GrowingIO.startWithConfiguration(this, new Configuration()
              .useID()
              .trackAllFragments()
              .setChannel("**应用商店"));
  • AndroidManifest.xml以及module级别build.gradle中android defaultConfig 中添加的属性,请见官网配置。 添加官网配置

四、方法说明

| 方法名 | 参数 | 说明| |:-----:|-----|:-------:| | track|(String eventId, Object eventLevelVariable(optional))| 自定义事件(计数器类型)| | trackWithNumber|(String eventId, Number number, Object eventLevelVariable(optional))| 自定义事件(数值类型)| | page | (String page)| 页面浏览事件 | | setUserId | (String userId)| 设置登录用户ID | | clearUserId | | 清除登录用户ID | | setPageVariable |(String page, Object pageLevelVariables) | 设置页面级变量 | | setEvar | (Object conversionVariables) | 设置转化变量 | | setPeopleVariable | (Object peopleVariables)| 设置用户变量 |

五、JS中调用方式:

  • 在定义Component之前引入

      import {
        NativeModules
      } from 'react-native';
  • 之后就可以使用GrowingIO的方法,例如在js中调用自定义事件方法:

      NativeModules.GrowingIO.track("registerSuccess", {"gender":"male"});

Tips

  • 由于最新的ReactNative 打包gradlew存在bug,所以android在打debug包和releae包时要进行如下操作:
  1. 在工程目录下

     mkdir Android/app/assets
  2. 在app build.gradle android中添加:

     sourceSets {
         main {
             assets.srcDirs = ['assets']
         }
     }
  3. 在工程目录下:

     react-native bundle --platform android --dev false --entry-file App.js --bundle-output android/app/assets/index.android.bundle  --assets-dest android/app/src/main/res/
  4. demo 可见 examples/App.js