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

react-native-hubbledata-ios

v2.0.6

Published

HubbleData SDK for React Native(iOS).

Downloads

4

Readme

react-native-hubbledata-ios npm version PRs Welcome

如何安装

1. 下载包文件

$ npm i --save react-native-hubbledata-ios

2. 链接库文件到你的项目中

参考 https://reactnative.cn/docs/0.43/linking-libraries-ios.html#content

3. 根据HubbleData SDK文档需要做的一些设置

详见./RCTDATracker/RCTDATracker/HubbleDataSDK/ios.readme.md


添加依赖库
  • AdSupport.framework - 启用 Apple ADID 支持
  • CoreTelephony.framework - 获取运营商
  • Security.framework - 加密支持
  • CoreLocation.framework - 获取定位信息的支持
  • SystemConfiguration.framework - 获取联网方式(wifi, cellular)
  • libsqlite3.dylib - sqlite 支持
  • libz.dylib - gzip 压缩支持

路径:TARGETS -> Build Phases -> Link Binary With Libraries

如何使用

1、iOS工程项目AppDelegate.m配置相关参数

*AppDelegate.m application:didFinishLaunchingWithOptions 方法中调用如下方法,参数依次为 app key,版本和来源渠道。

[[DATracker sharedTracker] startTrackerWithAppKey:@"app-key" appVersion:@"0.1" appChannel:@"AppStore"];

如需要禁用 SDK 自动上传数据功能,调用

[[DATracker sharedTracker] startTrackerWithAppKey:@"app-key" appVersion:@"0.1" appChannel:@"AppStore" autoUpload:NO];

如需要设置只在 wifi 环境下发送数据,调用

[[DATracker sharedTracker] startTrackerWithAppKey:@"app-key" appVersion:@"0.1" appChannel:@"AppStore" autoUpload:YES sendOnWifi:YES];

设置为只在 WIFI 下发送数据,会导致服务器接收数据延迟,对统计系统结果的及时性会产生影响,不建议使用

如需要使用自定义设备标识(比如 UDID),调用

[[DATracker sharedTracker] startTrackerWithAppKey:@"app-key" appVersion:@"0.1" appChannel:@"AppStore" autoUpload:YES sendOnWifi:NO deviceUDID:@"id-set-by-app"];

App Key 可从移动分析系统网站获取,不得使用为空值或者 null

以下所有调用均需发生在 启用 API 之后


手动发送数据请调用

[[DATracker sharedTracker] upload];

设置两次数据发送的最小时间间隔,单位秒。默认定时发送为关闭状态,设置大于0的时间间隔开启定时器,否则关闭定时器

- (void)setUploadInterval:(NSInteger)uploadInterval;

本地缓存的最大事件数目

- (void)setUploadBulkSize:(NSInteger)uploadBulkSize;

手动禁用自动上传

[[DATracker sharedTracker] setAutoUploadOn:NO];

手动开启只在 WIFI 下发送数据

[[DATracker sharedTracker] setSendOnWifiOn:YES];

2、React Native使用

以下接口详细的参数说明,见RCTDATracker.m

获取 Device ID

import DATracker from 'react-native-hubbledata-ios';

DATracker.getDeviceId((res => {
   console.log(res);
}));

用户帐号管理

import DATracker from 'react-native-hubbledata-ios';

var userId = 'xiaoming';
DATracker.loginUser(userId);
DATracker.logoutUser;

用户位置记录

import DATracker from 'react-native-hubbledata-ios';

var lattitude = 32.0;
var longtitude = 128.0;
DATracker.setLocation(latitude, longtitude);

事件捕捉

/**
 *  参数为一个dictionary类型,对应key值需与以下参数一致
 *
 *  @param eventId     事件ID
 *  @param seconds     事件耗时
 *  @param latitude    纬度
 *  @param longitude   经度
 *  @param category    分类
 *  @param label       标签
 *  @param attributes  事件属性
 */

import DATracker from 'react-native-hubbledata-ios';

var dic = {eventId 	  : 'reactnative',
		   attributes : {key : 'value'}};
DATracker.trackEvent(dic);

页面埋点

import DATracker from 'react-native-hubbledata-ios';

var screenName = 'page1';
DATracker.trackScreen(screenName);

统计事件的时长,事件开始的定时器开启

import DATracker from 'react-native-hubbledata-ios';

var eventId = 'reactnative';
DATracker.trackTimer(eventId);

清空统计事件时长的所有定时器

import DATracker from 'react-native-hubbledata-ios';

DATracker.clearTrackTimer;

开启崩溃统计

import DATracker from 'react-native-hubbledata-ios';

DATracker.enableCrashReporting;

手动上传

import DATracker from 'react-native-hubbledata-ios';

DATracker.upload;

设置上传的时间间隔

import DATracker from 'react-native-hubbledata-ios';

DATracker.setUploadInterval(15);

设置上传的最大事件条数

import DATracker from 'react-native-hubbledata-ios';

DATracker.setUploadBulkSize(100);

获取当前公共属性

import DATracker from 'react-native-hubbledata-ios';

DATracker.currentSuperProperties((res => {
   console.log(res);//res为获取的公共属性
}));

设置公共属性

import DATracker from 'react-native-hubbledata-ios';

var dic = {key : 'value'};
DATracker.registerSuperProperties(dic);

删除已经设置的公共属性

import DATracker from 'react-native-hubbledata-ios';

DATracker.unregisterSuperProperty('key');

置用户的地理位置

import DATracker from 'react-native-hubbledata-ios';

DATracker.setPopolationLocation('China', 'Zhejiang', 'Hangzhou');

设置用户的个人信息

import DATracker from 'react-native-hubbledata-ios';

DATracker.setPopulationWithAccount('xiaoming', 'zhouxiaoming', '2017-05-17T06:35:56.045Z', 0);

当前用户添加属性

import DATracker from 'react-native-hubbledata-ios';

DATracker.set({key : 'value'});

当前用户添加属性,不会覆盖已经存在的属性值

import DATracker from 'react-native-hubbledata-ios';

DATracker.setOnce({key : 'value'});

删除属性

import DATracker from 'react-native-hubbledata-ios';

DATracker.unset('key');

删除用户信息

import DATracker from 'react-native-hubbledata-ios';

DATracker.deleteUser;

用户消费记录

import DATracker from 'react-native-hubbledata-ios';

DATracker.trackCharge(50, {key : 'value'});

清空消费记录

import DATracker from 'react-native-hubbledata-ios';

DATracker.clearCharges;