thinkingdata-ruby 2.0.0 → 2.0.1

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.
data/demo/demo.rb CHANGED
@@ -1,104 +1,104 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
-
3
- require 'thinkingdata-ruby'
4
- require 'time'
5
-
6
- if __FILE__ == $0
7
-
8
- class MyErrorHandler < ThinkingData::TDErrorHandler
9
- def handle(error)
10
- puts error
11
- raise error
12
- end
13
- end
14
-
15
- def logger_consumer
16
- ThinkingData::TDLoggerConsumer.new('./log', 'hourly')
17
- end
18
-
19
- def debug_consumer
20
- ThinkingData::TDDebugConsumer.new("serverUrl", "appId", device_id: "123456789")
21
- end
22
-
23
- def batch_consumer
24
- consumer = ThinkingData::TDBatchConsumer.new("serverUrl", "appId", 50)
25
- consumer._set_compress(false)
26
- consumer
27
- end
28
-
29
- ThinkingData::set_stringent(false)
30
- ThinkingData::set_enable_log(true)
31
- my_error_handler = MyErrorHandler.new
32
-
33
- td_sdk = ThinkingData::TDAnalytics.new(logger_consumer, my_error_handler, uuid: false)
34
- # td_sdk = ThinkingData::TDAnalytics.new(debug_consumer, my_error_handler, uuid: true)
35
- # td_sdk = ThinkingData::TDAnalytics.new(batch_consumer, my_error_handler, uuid: true)
36
-
37
- DEMO_ACCOUNT_ID = '123'
38
- DEMO_DISTINCT_ID = 'aaa'
39
-
40
- super_properties = {
41
- super_string: 'super_string',
42
- super_int: 1,
43
- super_bool: false,
44
- super_date: Time.rfc2822("Thu, 26 Oct 2019 02:26:12 +0545"),
45
- '#app_id': "123123123123123"
46
- }
47
-
48
- td_sdk.set_super_properties(super_properties)
49
-
50
- properties = {
51
- array: ["str1", "11", Time.now, "2020-02-11 17:02:52.415"],
52
- prop_date: Time.now,
53
- prop_double: 134.1,
54
- prop_string: 'hello world',
55
- prop_bool: true,
56
- '#ip': '123.123.123.123',
57
- }
58
-
59
- td_sdk.set_dynamic_super_properties do
60
- {:dynamic_time => Time.now}
61
- end
62
-
63
- td_sdk.track(event_name: 'test_event', distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: properties)
64
-
65
- td_sdk.clear_dynamic_super_properties
66
- td_sdk.clear_super_properties
67
-
68
- td_sdk.track(event_name: 'test_event', distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: properties)
69
-
70
- user_data = {
71
- array: ["str1", 11, 22.22],
72
- prop_date: Time.now,
73
- prop_double: 134.12,
74
- prop_string: 'hello',
75
- prop_int: 666,
76
- }
77
- td_sdk.user_set(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_data)
78
-
79
- user_append_data = {
80
- array: %w[33 44]
81
- }
82
- td_sdk.user_append(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_append_data)
83
-
84
- user_uniq_append_data = {
85
- array: %w[44 55]
86
- }
87
- td_sdk.user_uniq_append(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_uniq_append_data)
88
-
89
- user_set_once_data = {
90
- prop_int_new: 888,
91
- }
92
- td_sdk.user_set_once(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_set_once_data)
93
-
94
- td_sdk.user_add(distinct_id: DEMO_DISTINCT_ID, properties: {prop_int: 10, prop_double: 15.88})
95
-
96
- td_sdk.user_unset(distinct_id: DEMO_DISTINCT_ID, property: [:prop_string, :prop_int])
97
-
98
- td_sdk.user_del(distinct_id: DEMO_DISTINCT_ID)
99
-
100
- td_sdk.flush
101
-
102
- td_sdk.close
103
- end
104
-
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'thinkingdata-ruby'
4
+ require 'time'
5
+
6
+ if __FILE__ == $0
7
+
8
+ class MyErrorHandler < ThinkingData::TDErrorHandler
9
+ def handle(error)
10
+ puts error
11
+ raise error
12
+ end
13
+ end
14
+
15
+ def logger_consumer
16
+ ThinkingData::TDLoggerConsumer.new('./log', 'hourly')
17
+ end
18
+
19
+ def debug_consumer
20
+ ThinkingData::TDDebugConsumer.new("serverUrl", "appId", device_id: "123456789")
21
+ end
22
+
23
+ def batch_consumer
24
+ consumer = ThinkingData::TDBatchConsumer.new("serverUrl", "appId", 50)
25
+ consumer._set_compress(false)
26
+ consumer
27
+ end
28
+
29
+ ThinkingData::set_stringent(false)
30
+ ThinkingData::set_enable_log(true)
31
+ my_error_handler = MyErrorHandler.new
32
+
33
+ td_sdk = ThinkingData::TDAnalytics.new(logger_consumer, my_error_handler, uuid: false)
34
+ # td_sdk = ThinkingData::TDAnalytics.new(debug_consumer, my_error_handler, uuid: true)
35
+ # td_sdk = ThinkingData::TDAnalytics.new(batch_consumer, my_error_handler, uuid: true)
36
+
37
+ DEMO_ACCOUNT_ID = '123'
38
+ DEMO_DISTINCT_ID = 'aaa'
39
+
40
+ super_properties = {
41
+ super_string: 'super_string',
42
+ super_int: 1,
43
+ super_bool: false,
44
+ super_date: Time.rfc2822("Thu, 26 Oct 2019 02:26:12 +0545"),
45
+ '#app_id': "123123123123123"
46
+ }
47
+
48
+ td_sdk.set_super_properties(super_properties)
49
+
50
+ properties = {
51
+ array: ["str1", "11", Time.now, "2020-02-11 17:02:52.415"],
52
+ prop_date: Time.now,
53
+ prop_double: 134.1,
54
+ prop_string: 'hello world',
55
+ prop_bool: true,
56
+ '#ip': '123.123.123.123',
57
+ }
58
+
59
+ td_sdk.set_dynamic_super_properties do
60
+ {:dynamic_time => Time.now}
61
+ end
62
+
63
+ td_sdk.track(event_name: 'test_event', distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: properties)
64
+
65
+ td_sdk.clear_dynamic_super_properties
66
+ td_sdk.clear_super_properties
67
+
68
+ td_sdk.track(event_name: 'test_event', distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: properties)
69
+
70
+ user_data = {
71
+ array: ["str1", 11, 22.22],
72
+ prop_date: Time.now,
73
+ prop_double: 134.12,
74
+ prop_string: 'hello',
75
+ prop_int: 666,
76
+ }
77
+ td_sdk.user_set(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_data)
78
+
79
+ user_append_data = {
80
+ array: %w[33 44]
81
+ }
82
+ td_sdk.user_append(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_append_data)
83
+
84
+ user_uniq_append_data = {
85
+ array: %w[44 55]
86
+ }
87
+ td_sdk.user_uniq_append(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_uniq_append_data)
88
+
89
+ user_set_once_data = {
90
+ prop_int_new: 888,
91
+ }
92
+ td_sdk.user_set_once(distinct_id: DEMO_DISTINCT_ID, account_id: DEMO_ACCOUNT_ID, properties: user_set_once_data)
93
+
94
+ td_sdk.user_add(distinct_id: DEMO_DISTINCT_ID, properties: {prop_int: 10, prop_double: 15.88})
95
+
96
+ td_sdk.user_unset(distinct_id: DEMO_DISTINCT_ID, property: [:prop_string, :prop_int])
97
+
98
+ td_sdk.user_del(distinct_id: DEMO_DISTINCT_ID)
99
+
100
+ td_sdk.flush
101
+
102
+ td_sdk.close
103
+ end
104
+