sensors_analytics_sdk 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58f812db59e708e593a3d3b06ceaae88e8181245
4
- data.tar.gz: 40e304ea9777aff07e886da877b987bbb2b396f5
2
+ SHA256:
3
+ metadata.gz: 88129c2e214d749e7a6254f9fd817045a5855c5f5cfa4fe12ae56b5c64bdf693
4
+ data.tar.gz: 6fd2c123258460a9ca6190c958762e417d6c8a6165d0d136365b130095eaae0c
5
5
  SHA512:
6
- metadata.gz: 00a055c0f04b8d9aa89df60354b9a643ac62d4623cfaa01469179f04ef6e4104f788e9bd17ca922577f2b77f5fcd25828c5ff55b1e3a3fcdb0c14bb8ce0d42f9
7
- data.tar.gz: 4126b6b54f1e52e757c501443e0643aea975ca36f7bcee09972bba092aed9d704813e4a695c5ebad00cba5869b8e0dcf2a0024ff85cced69eecd26bd75c74940
6
+ metadata.gz: 98a9adb753889f1bf6cb645983b69dcaf893b64ae5ac4c70847c747dea5720aa1d64ce46eda49bca019d785c1c304fb601976ebb456381295b62f5383f30bef0
7
+ data.tar.gz: 28071c9b37514fe401352995361841f24a83e017bd8e5d7b33128ea08b8a8bebde16118ee42ba197e825065a23d4a8a6370465a8d67b701b23ae3a12a245f987
data/.gitignore CHANGED
@@ -34,3 +34,5 @@ build/
34
34
 
35
35
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
36
  .rvmrc
37
+
38
+ .DS_Store
data/README.md CHANGED
@@ -1,45 +1,47 @@
1
- # Sensors Analytics
1
+ ![logo](https://opensource.sensorsdata.cn/wp-content/uploads/logo.png)
2
2
 
3
- This is the official Ruby SDK for Sensors Analytics.
3
+ ## 神策简介
4
4
 
5
- ## Easy Installation
5
+ [**神策数据**](https://www.sensorsdata.cn/)
6
+ (Sensors Data),隶属于神策网络科技(北京)有限公司,是一家专业的大数据分析服务公司,大数据分析行业开拓者,为客户提供深度用户行为分析平台、以及专业的咨询服务和行业解决方案,致力于帮助客户实现数据驱动。神策数据立足大数据及用户行为分析的技术与实践前沿,业务现已覆盖以互联网、金融、零售快消、高科技、制造等为代表的十多个主要行业、并可支持企业多个职能部门。公司总部在北京,并在上海、深圳、合肥、武汉等地拥有本地化的服务团队,覆盖东区及南区市场;公司拥有专业的服务团队,为客户提供一对一的客户服务。公司在大数据领域积累的核心关键技术,包括在海量数据采集、存储、清洗、分析挖掘、可视化、智能应用、安全与隐私保护等领域。 [**More**](https://www.sensorsdata.cn/about/aboutus.html)
6
7
 
7
- You can get Sensors Analytics SDK using gem.
8
- Add below to you `Gemfile`
8
+ ## SDK 简介
9
9
 
10
- ```
11
- gem 'sensors_analytics_sdk'
12
- ```
10
+ SensorsAnalytics SDK 是国内第一家开源商用版用户行为采集 SDK,目前支持代码埋点、全埋点、App 点击图、可视化全埋点等。目前已累计有 1500 多家付费客户,2500+ 的 App 集成使用,作为 App 数据采集利器,致力于帮助客户挖掘更多的商业价值,为其精准运营和业务支撑提供了可靠的数据来源。其采集全面而灵活、性能良好,并一直保持稳定的迭代,经受住了时间和客户的考验。
13
11
 
14
- Or execute `gem install` as below.
12
+ ## 集成文档
15
13
 
16
- ```
17
- gem install sensors_analytics_sdk
18
- ```
14
+ 请参考神策官网 [Ruby SDK 集成文档](http://www.sensorsdata.cn/manual/ruby_sdk.html)。
19
15
 
20
- Once the SDK is successfully installed, use the Sensors Analytics SDK likes:
16
+ ## 贡献
21
17
 
22
- ```ruby
23
- require 'sensors_analytics_sdk'
18
+ * 1. 在您的 GitHub 账户下 fork sa-sdk-ruby 开源项目;
19
+ * 2. 根据您的需求在本地 clone 一份 sa-sdk-ruby 源码;
20
+ * 3. 您修改或者新增功能后,push 到您 fork 的远程分支;
21
+ * 4. 创建 pull request,向 sa-sdk-ruby 官方开发分支提交合入请求;
22
+ * 5. 神策 SDK 研发团队会及时 review 代码,测试通过后合入。
24
23
 
25
- SA_URL = 'http://sa_host.com:8006/sa?token=xxx'
24
+ ## 讨论
26
25
 
27
- consumer = SensorsAnalytics::DefaultConsumer.new(SA_URL)
28
- sa = SensorsAnalytics::SensorsAnalytics.new(consumer)
26
+ | 扫码加入神策数据开源社区 QQ 群<br>群号:785122381 | 扫码加入神策数据开源社区微信群 |
27
+ | ------ | ------ |
28
+ |![ QQ 讨论群](https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_1.png) | ![ 微信讨论群 ](https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_2.png) |
29
29
 
30
- distinct_id = "ABCDEF123456"
31
- sa.track(distinct_id, "UserLogin", {"Source" : "HomePage"})
32
- ```
30
+ ## 公众号
33
31
 
34
- Http keepalive is supported now. Add gem `net-http-persistent` to your `Gemfile`. Then it will use http keepalive by default.
32
+ | 扫码关注<br>神策数据开源社区 | 扫码关注<br>神策数据开源社区服务号 |
33
+ | ------ | ------ |
34
+ |![ 微信订阅号 ](https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_3.png) | ![ 微信服务号 ](https://opensource.sensorsdata.cn/wp-content/uploads/ContentCommonPic_4.png) |
35
35
 
36
- ## To learn more
36
+ ## 新书推荐
37
37
 
38
- See our [full manual](http://www.sensorsdata.cn/manual/ruby_sdk.html)
38
+ | 《数据驱动:从方法到实践》 | 《Android 全埋点解决方案》 | 《iOS 全埋点解决方案》
39
+ | ------ | ------ | ------ |
40
+ | [![《数据驱动:从方法到实践》](https://opensource.sensorsdata.cn/wp-content/uploads/data_driven_book_1.jpg)](https://item.jd.com/12322322.html) | [![《Android 全埋点解决方案》](https://opensource.sensorsdata.cn/wp-content/uploads/Android-全埋点thumbnail_1.png)](https://item.jd.com/12574672.html) | [![《iOS 全埋点解决方案》](https://opensource.sensorsdata.cn/wp-content/uploads/iOS-全埋点thumbnail_1.png)](https://item.jd.com/12867068.html)
39
41
 
40
42
  ## License
41
43
 
42
- Copyright 2015-2019 Sensors Data Inc.
44
+ Copyright 2015-2020 Sensors Data Inc.
43
45
 
44
46
  Licensed under the Apache License, Version 2.0 (the "License");
45
47
  you may not use this file except in compliance with the License.
@@ -100,6 +100,16 @@ module SensorsAnalytics
100
100
  _track_event(:profile_unset, distinct_id, distinct_id, nil, property_hash)
101
101
  end
102
102
 
103
+ # 上报 item 数据
104
+ def item_set(item_type, item_id, properties)
105
+ _track_item(:item_set, item_type, item_id, properties)
106
+ end
107
+
108
+ # 删除 item 数据
109
+ def item_delete(item_type, item_id)
110
+ _track_item(:item_delete, item_type, item_id, {})
111
+ end
112
+
103
113
  private
104
114
 
105
115
  def _track_event(event_type, distinct_id, origin_distinct_id, event_name, properties)
@@ -151,6 +161,48 @@ module SensorsAnalytics
151
161
  @consumer.send(event)
152
162
  end
153
163
 
164
+ def _track_item(event_type, item_type, item_id, properties)
165
+ _assert_key_with_regex(:item_type, item_type)
166
+ _assert_key(:item_id, item_id)
167
+
168
+ if event_type == :item_set
169
+ _assert_properties(event_type, properties)
170
+ end
171
+
172
+ # 从事件属性中获取时间配置
173
+ event_time = _extract_time_from_properties(properties)
174
+ properties.delete(:$time)
175
+ properties.delete("$time")
176
+
177
+ lib_properties = _get_lib_properties
178
+
179
+ # event_type 有 item_set 和 item_delete 两种
180
+ event = {
181
+ type: event_type,
182
+ time: event_time,
183
+ item_id: item_id,
184
+ item_type: item_type,
185
+ lib: lib_properties,
186
+ }
187
+
188
+ if event_type == :item_set
189
+ # item_set 有 properties 属性
190
+ item_properties = {}
191
+
192
+ properties.each do |key, value|
193
+ if value.is_a?(Time)
194
+ item_properties[key] = value.strftime("%Y-%m-%d %H:%M:%S.#{(value.to_f * 1000.0).to_i % 1000}")
195
+ else
196
+ item_properties[key] = value
197
+ end
198
+ end
199
+
200
+ event[:properties] = item_properties
201
+ end
202
+
203
+ @consumer.send(event)
204
+ end
205
+
154
206
  def _extract_time_from_properties(properties)
155
207
  properties.each do |key, value|
156
208
  if (key == :$time || key == "$time") && value.is_a?(Time)
@@ -252,11 +304,11 @@ module SensorsAnalytics
252
304
  # profile_append 的属性必须为数组类型,且数组元素必须为字符串
253
305
  if event_type == :profile_append
254
306
  unless value.is_a?(Array)
255
- raise IllegalDataError.new("The properties value of PROFILE INCREMENT must be an instance of Array[String].")
307
+ raise IllegalDataError.new("The properties value of PROFILE APPEND must be an instance of Array[String].")
256
308
  end
257
309
  value.each do |element|
258
310
  unless element.is_a?(String) || element.is_a?(Symbol)
259
- raise IllegalDataError.new("The properties value of PROFILE INCREMENT must be an instance of Array[String].")
311
+ raise IllegalDataError.new("The properties value of PROFILE APPEND must be an instance of Array[String].")
260
312
  end
261
313
  end
262
314
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SensorsAnalytics
3
- VERSION = '1.6.1'
3
+ VERSION = '1.6.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensors_analytics_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuhan ZOU
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-07 00:00:00.000000000 Z
12
+ date: 2020-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -107,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.5.2.3
110
+ rubygems_version: 3.0.3
112
111
  signing_key:
113
112
  specification_version: 4
114
113
  summary: SensorsAnalyticsSDK