3.9.1 • Published 4 months ago

react-native-mrangers-log v3.9.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

react-native-mrangers-log

npm version

此仓库基于rangers_applog_reactnative_plugin

3.0.0 版本支持ALink,并且调整集成与初始化方式。最后一个老版本为2.2.1

Android SDK Version: 6.17.0

iOS SDK Version: 6.17.2

TODO 对于风控子库的解释,后期看官网集成文档,看能否移除,暂时做保留

「和后端同学确认,目前官网反作弊的库已经下掉了,已经不在官网展示了,这边用之前的就可以,不需要更新子库的版本,对功能是没有影响」

开始

$ npm install react-native-mrangers-log -E

在使用 RangersAppLog SDK 前,你需要先注册DataRangers账号并且创建一个应用。

插件安装与初始化

iOS

  1. 打开ios/Podfile文件,添加以下
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
·······
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/volcengine/volcengine-specs.git'
source 'https://github.com/bytedance/cocoapods_sdk_source_repo.git'


·······
target
  1. 添加 rangersapplog.XXXXXXX 的UrlScheme,注意替换XXXXXXX为自己的
  2. 添加Universal Link,注意替换xxx为自己的
<string>applinks:xxx.volctracer.com</string>
  1. 打开ios/XXX/AppDelegate.h,添加BDAutoTrackAlinkRouting(ALink所需)
...
#import <RangersAppLog/RangersAppLog.h>
  
@interface AppDelegate : UIResponder <UIApplicationDelegate, BDAutoTrackAlinkRouting>

@property (nonatomic, strong) UIWindow *window;

@end
  1. 打开ios/XXX/AppDelegate.m,添加(ALink所需)
...
#import "RangersAppLogModule.h"
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  // 如果需要测试alink的延迟深度链接,需要改渠道或者版本号
  [RangersAppLogModule initializeSDK:self launchOptions:launchOptions appId:@"appId" appName:@"appName" channel:@"channel"];
  ...
}

...
// 末尾添加
//************************************************头条ALink监听回调************************************************
#pragma mark --BDAutoTrackAlinkRouting--
- (void)onAttributionData:(nullable NSDictionary *)routingInfo error:(nullable NSError *)error {
  [RangersAppLogModule onAttributionData:routingInfo error:error];
}

- (void)onALinkData:(nullable NSDictionary *)routingInfo error:(nullable NSError *)error {
  [RangersAppLogModule onALinkData:routingInfo error:error];
}

/// 开启剪切板读取,裂变所需
- (bool)shouldALinkSDKAccessPasteBoard {
    return true;
}
//************************************************头条ALink监听回调************************************************

@end

Android

  1. 在 android 根目录 的 build.gradle 中添加:
buildscript {
  repositories {
    ...
    maven {
      url 'https://artifact.bytedance.com/repository/Volcengine/'
    }
  }
  dependencies {
    ...
    // 头条火山,每次升级记得调整版本
    classpath 'com.bytedance.applog:RangersAppLog-All-plugin:6.17.0'
  }
}

allprojects {
  repositories {
    ...
    maven {
      url 'https://artifact.bytedance.com/repository/Volcengine/'
    }
  }
}
  1. 在 app module 的 build.gradle 并在 defaultConfig 中添加:
defaultConfig {
  ...
  manifestPlaceholders.put("APPLOG_SCHEME", "rangersapplog.XXXXXXXXX".toLowerCase())
}

....

apply plugin: 'com.bytedance.std.tracker'
  1. 打开android/app/src/main/AndroidManifest.xml配置AppLinks(ALink所需)
@@ -1,101 +1,112 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.XXXX">

    ...
    <application>
        <activity
            android:name=".MainActivity"
            android:configChanges="screenLayout|smallestScreenSize|keyboard|keyboardHidden|orientation|screenSize|uiMode"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="adjustResize">
            .......
            <!--添加下面-->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
              
                <!-- XXXXX.volctracer.com 此处的网址为ALink后台的链接-->
                <data
                    android:scheme="https"
                    android:host="XXXXX.volctracer.com"
                    android:pathPrefix="/a" />
            </intent-filter>
            <!--添加上面-->
        </activity>
        .......
    </application>

</manifest>
  1. 打开android/app/src/main/java/com/XXXX/MainApplication.java,添加初始化代码
...
import com.reactnativerangersapplogreactnativeplugin.RangersApplogReactnativePluginModule;
...

public class MainApplication extends MultiDexApplication implements ReactApplication {
 ...
   @Override
   public void onCreate() {
    // 如果需要测试alink的延迟深度链接,需要改渠道或者版本号,隐私合规需要注意下方的Bool值
    RangersApplogReactnativePluginModule.initializeSDK(this, "appId", "channel", true, true, true, false);
   }
 ...
}

插件接口文档

基础接口

接口名功能参数支持平台
init初始化参数:字典,不可空,参考index.jsiOS,Android
onEvent生成自定义埋点参数1:string,非空。事件名。 参数2:字典,可空。事件参数。iOS, Android
startinit 之后需要调用start,为了隐私合规iOS, Android
flush主动触发上报。SDK有频率限制,每10s最多可以触发一次iOS, Android

用户属性

接口名功能参数支持平台
profileSet设置用户属性,存在则覆盖,不存在则创建参数:字典,不可空。iOS, Android
profileSetOnce设置用户属性,存在则不设置,不存在则创建,适合首次相关的用户属性,比如首次访问时间等参数:字典,不可空。iOS, Android
profileIncrement设置数值类型的属性,可进行累加参数:字典,不可空。iOS, Android
profileAppend向用户的某个 List 类型的属性添加属性,比如爱好参数:字典,不可空。iOS, Android
profileUnset删除用户的属性参数:字符串,不可空iOS, Android

事件公共属性

接口名功能参数支持平台
setHeaderInfo自定义header信息 设置用户公共属性参数1:字典,可空。自定义header信息。iOS, Android
removeHeaderInfo移除自定义事件公共属性参数:字符串,不可空iOS, Android

A/B测试

接口名功能参数支持平台
getAbSdkVersion获取全部客户端和服务端已曝光参数参数:无 返回:striOS, Android
getABTestConfigValueForKey【异步】获取AB测试的配置,若不存在返回nil参数1: str, ABTest配置的key 返回:str或niliOS, Android
getABTestConfigValueForKeySync【同步】获取AB测试的配置,若不存在返回nil参数1: str, ABTest配置的key 返回:str或niliOS, Android
getAllAbTestConfigs获取ABTest相关配置,此接口不会触发曝光,可以随意读取。如果正常为了做实验,请勿使用此接口,请使用getABTestConfigValueForKey、getABTestConfigValueForKeySync接口参数: 无返回:objectiOS, Android

用户信息

接口名功能参数支持平台
setUserUniqueId设置用户UUID参数1:string,可空。user_unique_idiOS, Android
getUserUniqueID获取绑定后的UUID参数:无 返回:str、null、undefinediOS, Android
getUserUniqueIDSync获取绑定后的UUID参数:无 返回:str、null、undefinediOS, Android
clearUserUniqueId清除UUID参数:无 返回:无iOS, Android

设备信息

接口名功能参数支持平台
getDeviceID获取did参数:无 返回:str。iOS, Android
getSsid获取ssid参数:无 返回:str、null、undefinediOS, Android
getDeviceIDSync获取did参数:无 返回:str。iOS, Android
getSsidSync获取ssid参数:无 返回:str、null、undefinediOS, Android

ALink

接口名功能参数支持平台
getAttributionData获取延迟深度链接的归因数据参数:无 返回:object、null、undefined。iOS, Android
addALinkDataListener添加深度链接唤醒监听,需要配合RN的Link与模块的initALinkUrl参数:function(ret){}iOS, Android
addAttributionDataListener添加首次启动归因监听参数:function(ret){}iOS, Android
initALinkUrl深度链接,此方法符合条件会触发addALinkDataListener,需配合RN的Link参数:字符串iOS, Android

ALink接口的调用顺序为先添加监听,再调用模块的start方法

License

MIT

3.9.1

4 months ago

3.9.0

4 months ago

3.8.5

8 months ago

3.8.4

1 year ago

3.8.3

2 years ago

3.8.2

2 years ago

3.8.1

2 years ago

3.8.0

2 years ago

3.7.0

3 years ago

3.6.0

3 years ago

3.5.1

3 years ago

3.4.0

3 years ago

3.3.1

3 years ago

3.5.0

3 years ago

3.3.0

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago