securenative 0.1.22 → 0.1.23

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +62 -64
  3. data/lib/config/configuration_builder.rb +4 -3
  4. data/lib/config/configuration_manager.rb +2 -1
  5. data/lib/config/securenative_options.rb +4 -3
  6. data/lib/utils/request_utils.rb +20 -5
  7. data/out/production/securenative-ruby/api_manager.rb +13 -5
  8. data/out/production/securenative-ruby/config/configuration_builder.rb +6 -9
  9. data/out/production/securenative-ruby/config/configuration_manager.rb +24 -23
  10. data/out/production/securenative-ruby/config/securenative_options.rb +8 -5
  11. data/out/production/securenative-ruby/context/hanami_context.rb +42 -0
  12. data/out/production/securenative-ruby/context/rails_context.rb +44 -0
  13. data/out/production/securenative-ruby/context/securenative_context.rb +35 -8
  14. data/out/production/securenative-ruby/context/sinatra_context.rb +42 -0
  15. data/out/production/securenative-ruby/event_manager.rb +15 -14
  16. data/out/production/securenative-ruby/http/{http_response.rb → secure_native_http_response.rb} +1 -1
  17. data/out/production/securenative-ruby/http/securenative_http_client.rb +23 -5
  18. data/out/production/securenative-ruby/models/event_options.rb +23 -1
  19. data/out/production/securenative-ruby/models/request_context.rb +2 -2
  20. data/out/production/securenative-ruby/models/sdk_event.rb +22 -6
  21. data/out/production/securenative-ruby/models/user_traits.rb +1 -1
  22. data/out/production/securenative-ruby/models/verify_result.rb +5 -1
  23. data/out/production/securenative-ruby/securenative.rb +2 -10
  24. data/out/production/securenative-ruby/utils/date_utils.rb +1 -1
  25. data/out/production/securenative-ruby/utils/encryption_utils.rb +38 -24
  26. data/out/production/securenative-ruby/utils/request_utils.rb +53 -7
  27. data/out/production/securenative-ruby/utils/secure_native_logger.rb +6 -6
  28. data/out/production/securenative-ruby/utils/version_utils.rb +5 -6
  29. data/out/test/securenative-ruby/spec_api_manager.rb +37 -31
  30. data/out/test/securenative-ruby/spec_context_builder.rb +52 -34
  31. data/out/test/securenative-ruby/spec_encryption_utils.rb +13 -13
  32. data/out/test/securenative-ruby/spec_event_manager.rb +49 -15
  33. data/out/test/securenative-ruby/spec_helper.rb +8 -0
  34. data/out/test/securenative-ruby/spec_request_utils.rb +25 -0
  35. data/out/test/securenative-ruby/spec_sdk_event.rb +24 -0
  36. data/out/test/securenative-ruby/spec_securenative.rb +35 -39
  37. data/out/test/securenative-ruby/spec_securenative_http_client.rb +13 -5
  38. data/out/test/securenative-ruby/spec_signature_utils.rb +1 -1
  39. data/out/test/securenative-ruby/spec_version_util.rb +10 -0
  40. data/securenative.gemspec +1 -1
  41. metadata +9 -4
  42. data/out/production/securenative-ruby/event_options.rb +0 -32
@@ -4,23 +4,23 @@ require 'utils/encryption_utils'
4
4
  require 'rspec'
5
5
 
6
6
  RSpec.describe EncryptionUtils do
7
- let(:SECRET_KEY) { 'B00C42DAD33EAC6F6572DA756EA4915349C0A4F6' }
8
- let(:PAYLOAD) { '{"cid":"198a41ff-a10f-4cda-a2f3-a9ca80c0703b","vi":"148a42ff-b40f-4cda-a2f3-a8ca80c0703b","fp":"6d8cabd95987f8318b1fe01593d5c2a5.24700f9f1986800ab4fcc880530dd0ed"}' }
9
- let(:CID) { '198a41ff-a10f-4cda-a2f3-a9ca80c0703b' }
10
- let(:FP) { '6d8cabd95987f8318b1fe01593d5c2a5.24700f9f1986800ab4fcc880530dd0ed' }
11
-
12
- it 'decrypts' do
13
- result = EncryptionUtils.encrypt(:PAYLOAD, :SECRET_KEY)
7
+ it 'encrypts' do
8
+ secret_key = 'AFD16D89150FD7FB19EE9E936DC1AE3547CE119B'
9
+ payload = '{"cid":"198a41ff-a10f-4cda-a2f3-a9ca80c0703b","vi":"148a42ff-b40f-4cda-a2f3-a8ca80c0703b","fp":"6d8cabd95987f8318b1fe01593d5c2a5.24700f9f1986800ab4fcc880530dd0ed"}'
10
+ result = EncryptionUtils.encrypt(payload, secret_key)
14
11
 
15
12
  expect(result).not_to be_nil
16
- expect(result.length).to eq(:PAYLOAD.length)
17
13
  end
18
14
 
19
- it 'encrypts' do
20
- encrypted_payload = '5208ae703cc2fa0851347f55d3b76d3fd6035ee081d71a401e8bc92ebdc25d42440f62310bda60628537744ac03f200d78da9e61f1019ce02087b7ce6c976e7b2d8ad6aa978c532cea8f3e744cc6a5cafedc4ae6cd1b08a4ef75d6e37aa3c0c76954d16d57750be2980c2c91ac7ef0bbd0722abd59bf6be22493ea9b9759c3ff4d17f17ab670b0b6fc320e6de982313f1c4e74c0897f9f5a32d58e3e53050ae8fdbebba9009d0d1250fe34dcde1ebb42acbc22834a02f53889076140f0eb8db1'
21
- result = EncryptionUtils.decrypt(encrypted_payload, :SECRET_KEY)
15
+ it 'decrypts' do
16
+ secret_key = 'AFD16D89150FD7FB19EE9E936DC1AE3547CE119B'
17
+ encrypted_payload = 'dfcc35bc71653771d4541f08937c35cbc98faea2c061ff7904f80abf7c072f0029157ed97a55b00efe09fb0d2f86f5693ecbba3f6339862ed3908f0d746533133c8c838be641dad76cf3f9cce67dc1b48cbc8574f24637be4aa90f802ec4b7e5d50b5f9cb3d64e6887ef99b8b941e69370ac7994ccafaf17ceff1d7a68ac30e4b0fe4eb1b844460d5f7687f16902cea61d0ccc085f7ea6087fae38482cd1ee1c7574dc4b0e996bc4e5946eeb8e8509fbdd9f1884eb3f02cbbaefe4566c999d50'
18
+ cid = '12946065-65af-4825-9893-fce901c8da49'
19
+ fp = '9a6e6a7d636ca772924bd2219853d73c.24700f9f1986800ab4fcc880530dd0ed'
20
+
21
+ result = EncryptionUtils.decrypt(encrypted_payload, secret_key)
22
22
 
23
- expect(result.cid).to eq(:CID)
24
- expect(result.fp).to eq(:FP)
23
+ expect(result.cid).to eq(cid)
24
+ expect(result.fp).to eq(fp)
25
25
  end
26
26
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'event_manager'
4
4
  require 'config/configuration_builder'
5
+ require 'models/user_traits'
6
+ require 'models/request_context'
5
7
  require 'rspec'
6
8
  require 'webmock/rspec'
7
9
 
@@ -13,47 +15,79 @@ class SampleEvent
13
15
  @timestamp = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%Z')
14
16
  @rid = '432532'
15
17
  @user_id = '1'
16
- @user_traits = UserTraits('some user', 'email@securenative.com', '+1234567890')
17
- @request = RequestContext()
18
+ @user_traits = UserTraits.new(name: 'some user', email: 'email@securenative.com', phone: '+1234567890')
19
+ @request = RequestContext.new
18
20
  @properties = []
19
21
  end
20
22
  end
21
23
 
22
24
  RSpec.describe EventManager do
23
- let(:event) { SampleEvent() }
24
-
25
25
  it 'successfully sends sync event with status code 200' do
26
26
  options = ConfigurationBuilder.new(api_key: 'YOUR_API_KEY', api_url: 'https://api.securenative-stg.com/collector/api/v1')
27
+ event = SampleEvent.new
28
+
29
+ stub_request(:post, "https://api.securenative-stg.com/collector/api/v1/some-path/to-api").
30
+ with(
31
+ headers: {
32
+ 'Accept'=>'*/*',
33
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
34
+ 'Authorization'=>'YOUR_API_KEY',
35
+ 'Content-Type'=>'application/json',
36
+ 'Sn-Version'=>'0.1.22',
37
+ 'User-Agent'=>'SecureNative-ruby'
38
+ }).
39
+ to_return(status: 200, body: "", headers: {})
27
40
 
28
- res_body = '{"data": true}'
29
- stub_request(:post, 'https://api.securenative-stg.com/collector/api/v1/some-path/to-api')
30
- .with(body: JSON.parse(res_body)).to_return(status: 200)
31
41
  event_manager = EventManager.new(options)
32
42
 
33
43
  event_manager.start_event_persist
34
- data = event_manager.send_sync(:event, 'some-path/to-api', false)
44
+ res = event_manager.send_sync(event, 'some-path/to-api', false)
35
45
  event_manager.stop_event_persist
36
46
 
37
- expect(res_body).to eq(data.text)
47
+ expect(res.code).to eq('200')
38
48
  end
39
49
 
40
50
  it 'fails when send sync event status code is 401' do
41
51
  options = ConfigurationBuilder.new(api_key: 'YOUR_API_KEY', api_url: 'https://api.securenative-stg.com/collector/api/v1')
52
+ event = SampleEvent.new
53
+
54
+ stub_request(:post, "https://api.securenative-stg.com/collector/api/v1/some-path/to-api").
55
+ with(
56
+ headers: {
57
+ 'Accept'=>'*/*',
58
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
59
+ 'Authorization'=>'YOUR_API_KEY',
60
+ 'Content-Type'=>'application/json',
61
+ 'Sn-Version'=>'0.1.22',
62
+ 'User-Agent'=>'SecureNative-ruby'
63
+ }).
64
+ to_return(status: 401, body: "", headers: {})
42
65
 
43
- stub_request(:post, 'https://api.securenative-stg.com/collector/api/v1/some-path/to-api').to_return(status: 401)
44
66
  event_manager = EventManager.new(options)
45
- res = event_manager.send_sync(:event, 'some-path/to-api', false)
67
+ res = event_manager.send_sync(event, 'some-path/to-api', false)
46
68
 
47
- expect(res.status_code).to eq(401)
69
+ expect(res.code).to eq('401')
48
70
  end
49
71
 
50
72
  it 'fails when send sync event status code is 500' do
51
73
  options = ConfigurationBuilder.new(api_key: 'YOUR_API_KEY', api_url: 'https://api.securenative-stg.com/collector/api/v1')
74
+ event = SampleEvent.new
75
+
76
+ stub_request(:post, "https://api.securenative-stg.com/collector/api/v1/some-path/to-api").
77
+ with(
78
+ headers: {
79
+ 'Accept'=>'*/*',
80
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
81
+ 'Authorization'=>'YOUR_API_KEY',
82
+ 'Content-Type'=>'application/json',
83
+ 'Sn-Version'=>'0.1.22',
84
+ 'User-Agent'=>'SecureNative-ruby'
85
+ }).
86
+ to_return(status: 500, body: "", headers: {})
52
87
 
53
- stub_request(:post, 'https://api.securenative-stg.com/collector/api/v1/some-path/to-api').to_return(status: 500)
54
88
  event_manager = EventManager.new(options)
55
- res = event_manager.send_sync(:event, 'some-path/to-api', false)
89
+ res = event_manager.send_sync(event, 'some-path/to-api', false)
56
90
 
57
- expect(res.status_code).to eq(500)
91
+ expect(res.code).to eq('500')
58
92
  end
59
93
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/setup'
4
+ require 'webmock/rspec'
4
5
  require 'simplecov'
5
6
  require 'codecov'
6
7
 
@@ -17,4 +18,11 @@ RSpec.configure do |config|
17
18
  config.expect_with :rspec do |c|
18
19
  c.syntax = :expect
19
20
  end
21
+
22
+ config.mock_with :rspec do |mocks|
23
+ # Prevents you from mocking or stubbing a method that does not exist on
24
+ # a real object. This is generally recommended, and will default to
25
+ # `true` in RSpec 4.
26
+ mocks.verify_partial_doubles = true
27
+ end
20
28
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'config/securenative_options'
4
+ require 'utils/request_utils'
5
+ require 'webmock/rspec'
6
+ require 'rspec'
7
+
8
+ RSpec.describe RequestUtils do
9
+ it 'extract a request with proxy headers' do
10
+ options = SecureNativeOptions.new
11
+ options.proxy_headers = [
12
+ 'CF-Connecting-IP'
13
+ ]
14
+
15
+ stub_request(:get, 'http://www.example.com/').with(
16
+ headers: {
17
+ 'Accept' => '*/*',
18
+ 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
19
+ 'User-Agent' => 'Ruby'
20
+ }).to_return(status: 200, body: '', headers: { 'CF-Connecting-IP' => 'CF-Connecting-IP: 203.0.113.1' })
21
+
22
+ request = Net::HTTP.get_response('www.example.com', '/')
23
+ RequestUtils.get_client_ip_from_request(request, options)
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'models/sdk_event'
4
+ require 'models/event_options'
5
+ require 'config/securenative_options'
6
+ require 'enums/event_types'
7
+ require 'errors/securenative_invalid_options_error'
8
+ require 'rspec'
9
+
10
+ RSpec.describe SDKEvent do
11
+ it 'throws when event created without user id' do
12
+ event_options = EventOptions.new(event: EventTypes::LOG_IN, user_id: nil)
13
+ options = SecureNativeOptions.new
14
+
15
+ expect { SDKEvent.new(event_options, options) }.to raise_error(SecureNativeInvalidOptionsError)
16
+ end
17
+
18
+ it 'throws when event created without event type' do
19
+ event_options = EventOptions.new(event: nil, user_id: '1234')
20
+ options = SecureNativeOptions.new
21
+
22
+ expect { SDKEvent.new(event_options, options) }.to raise_error(SecureNativeInvalidOptionsError)
23
+ end
24
+ end
@@ -20,46 +20,42 @@ RSpec.describe SecureNative do
20
20
  expect { SecureNative.init_with_api_key('') }.to raise_error(SecureNativeConfigError)
21
21
  end
22
22
 
23
- # TODO: fix event manager
24
- # it 'inits sdk with api key and defaults' do
25
- # SecureNative._flush
26
- # api_key = 'API_KEY'
27
- # securenative = SecureNative.init_with_api_key(api_key)
28
- # options = securenative.options
29
- #
30
- # expect(options.api_key).to eq(api_key)
31
- # expect(options.api_url).to eq('https://api.securenative.com/collector/api/v1')
32
- # expect(options.interval).to eq(1000)
33
- # expect(options.timeout).to eq(1500)
34
- # expect(options.max_events).to eq(100)
35
- # expect(options.auto_send).to eq(true)
36
- # expect(options.disable).to eq(false)
37
- # expect(options.log_level).to eq('FATAL')
38
- # expect(options.fail_over_strategy).to eq(FailOverStrategy::FAIL_OPEN)
39
- # end
23
+ it 'inits sdk with api key and defaults' do
24
+ SecureNative._flush
25
+ api_key = 'API_KEY'
26
+ securenative = SecureNative.init_with_api_key(api_key)
27
+ options = securenative.options
28
+
29
+ expect(options.api_key).to eq(api_key)
30
+ expect(options.api_url).to eq('https://api.securenative.com/collector/api/v1')
31
+ expect(options.interval).to eq(1000)
32
+ expect(options.timeout).to eq(1500)
33
+ expect(options.max_events).to eq(1000)
34
+ expect(options.auto_send).to eq(true)
35
+ expect(options.disable).to eq(false)
36
+ expect(options.log_level).to eq('FATAL')
37
+ expect(options.fail_over_strategy).to eq(FailOverStrategy::FAIL_OPEN)
38
+ end
39
+
40
+ it 'inits sdk twice and throws' do
41
+ expect { SecureNative.init_with_api_key('API_KEY') }.to raise_error(SecureNativeSDKError)
42
+ end
40
43
 
41
- # TODO: fix event manager
42
- # it 'inits sdk twice and throws' do
43
- # expect { SecureNative.init_with_api_key('API_KEY') }.to raise_error(SecureNativeSDKError)
44
- # end
44
+ it 'inits sdk with api key and gets instance' do
45
+ SecureNative._flush
46
+ api_key = 'API_KEY'
47
+ securenative = SecureNative.init_with_api_key(api_key)
45
48
 
46
- # TODO: fix event manager
47
- # it 'inits sdk with api key and gets instance' do
48
- # SecureNative._flush
49
- # api_key = 'API_KEY'
50
- # securenative = SecureNative.init_with_api_key(api_key)
51
- #
52
- # expect(securenative).to eq(SecureNative.instance)
53
- # end
49
+ expect(securenative).to eq(SecureNative.instance)
50
+ end
51
+
52
+ it 'inits sdk with builder' do
53
+ SecureNative._flush
54
+ securenative = SecureNative.init_with_options(ConfigurationBuilder.new(api_key: 'API_KEY', max_events: 10, log_level: 'ERROR'))
55
+ options = securenative.options
54
56
 
55
- # TODO: fix event manager
56
- # it 'inits sdk with builder' do
57
- # SecureNative._flush
58
- # securenative = SecureNative.init_with_options(SecureNative.config_builder(api_key: 'API_KEY', max_events: 10, log_level: 'ERROR'))
59
- # options = securenative.options
60
- #
61
- # expect(options.api_key).to eq('API_KEY')
62
- # expect(options.max_events).to eq(10)
63
- # expect(options.log_level).to eq('ERROR')
64
- # end
57
+ expect(options.api_key).to eq('API_KEY')
58
+ expect(options.max_events).to eq(10)
59
+ expect(options.log_level).to eq('ERROR')
60
+ end
65
61
  end
@@ -9,15 +9,23 @@ RSpec.describe SecureNativeHttpClient do
9
9
  it 'makes a simple post call' do
10
10
  options = ConfigurationBuilder.new(api_key: 'YOUR_API_KEY', api_url: 'https://api.securenative-stg.com/collector/api/v1')
11
11
 
12
- stub_request(:post, 'https://api.securenative-stg.com/collector/api/v1/track')
13
- .with(body: { event: 'SOME_EVENT_NAME' }).to_return(status: 200)
12
+ stub_request(:post, "https://api.securenative-stg.com/collector/api/v1/track").
13
+ with(
14
+ body: "{\"event\": \"SOME_EVENT_NAME\"}",
15
+ headers: {
16
+ 'Accept'=>'*/*',
17
+ 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
18
+ 'Authorization'=>'YOUR_API_KEY',
19
+ 'Content-Type'=>'application/json',
20
+ 'Sn-Version'=>'0.1.22',
21
+ 'User-Agent'=>'SecureNative-ruby'
22
+ }).
23
+ to_return(status: 200, body: "", headers: {})
14
24
  client = SecureNativeHttpClient.new(options)
15
25
  payload = '{"event": "SOME_EVENT_NAME"}'
16
26
 
17
27
  res = client.post('track', payload)
18
28
 
19
- expect(res.ok).to eq(true)
20
- expect(res.status_code).to eq(200)
21
- expect(res.text).to eq(payload)
29
+ expect(res.code).to eq('200')
22
30
  end
23
31
  end
@@ -15,4 +15,4 @@ RSpec.describe SignatureUtils do
15
15
  it 'verifies request empty signature' do
16
16
  expect(SignatureUtils.valid_signature?('', '', 'B00C42DAD33EAC6F6572DA756EA4915349C0A4F6')).to be_falsey
17
17
  end
18
- end
18
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'utils/version_utils'
4
+ require 'rspec'
5
+
6
+ RSpec.describe VersionUtils do
7
+ it 'checks that parsing version is valid' do
8
+ expect(VersionUtils.version).not_to eq('unknown')
9
+ end
10
+ end
@@ -4,7 +4,7 @@ require_relative "lib/utils/version_utils"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "securenative"
7
- spec.version = "0.1.22"
7
+ spec.version = "0.1.23"
8
8
  spec.authors = ["SecureNative"]
9
9
  spec.email = ["support@securenative.com"]
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: securenative
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - SecureNative
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2020-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,7 +101,10 @@ files:
101
101
  - out/production/securenative-ruby/config/configuration_builder.rb
102
102
  - out/production/securenative-ruby/config/configuration_manager.rb
103
103
  - out/production/securenative-ruby/config/securenative_options.rb
104
+ - out/production/securenative-ruby/context/hanami_context.rb
105
+ - out/production/securenative-ruby/context/rails_context.rb
104
106
  - out/production/securenative-ruby/context/securenative_context.rb
107
+ - out/production/securenative-ruby/context/sinatra_context.rb
105
108
  - out/production/securenative-ruby/enums/api_route.rb
106
109
  - out/production/securenative-ruby/enums/event_types.rb
107
110
  - out/production/securenative-ruby/enums/failover_strategy.rb
@@ -114,8 +117,7 @@ files:
114
117
  - out/production/securenative-ruby/errors/securenative_sdk_Illegal_state_error.rb
115
118
  - out/production/securenative-ruby/errors/securenative_sdk_error.rb
116
119
  - out/production/securenative-ruby/event_manager.rb
117
- - out/production/securenative-ruby/event_options.rb
118
- - out/production/securenative-ruby/http/http_response.rb
120
+ - out/production/securenative-ruby/http/secure_native_http_response.rb
119
121
  - out/production/securenative-ruby/http/securenative_http_client.rb
120
122
  - out/production/securenative-ruby/models/client_token.rb
121
123
  - out/production/securenative-ruby/models/device.rb
@@ -141,9 +143,12 @@ files:
141
143
  - out/test/securenative-ruby/spec_event_manager.rb
142
144
  - out/test/securenative-ruby/spec_helper.rb
143
145
  - out/test/securenative-ruby/spec_ip_utils.rb
146
+ - out/test/securenative-ruby/spec_request_utils.rb
147
+ - out/test/securenative-ruby/spec_sdk_event.rb
144
148
  - out/test/securenative-ruby/spec_securenative.rb
145
149
  - out/test/securenative-ruby/spec_securenative_http_client.rb
146
150
  - out/test/securenative-ruby/spec_signature_utils.rb
151
+ - out/test/securenative-ruby/spec_version_util.rb
147
152
  - securenative.gemspec
148
153
  homepage: https://www.securenative.com
149
154
  licenses:
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class EventOptions
4
- MAX_PROPERTIES_SIZE = 10
5
-
6
- def initialize(event_type, user_id, user_traits, user_name, email, phone, created_at, context, properties, timestamp)
7
- traits = UserTraits(user_name)
8
- if user_name && email && phone && created_at
9
- traits = UserTraits(user_name, email, phone, created_at)
10
- elsif user_name && email && phone
11
- traits = UserTraits(user_name, email, phone)
12
- elsif user_name && email
13
- traits = UserTraits(user_name, email)
14
- end
15
-
16
- @event_options = EventOptions(event_type)
17
- @event_options.user_id = user_id
18
- @event_options.user_traits = user_traits if user_traits
19
- @event_options.user_traits = traits
20
- @event_options.context = context
21
- @event_options.properties = properties
22
- @event_options.timestamp = timestamp
23
- end
24
-
25
- def build
26
- if !@event_options.properties.nil? && @event_options.properties.length > MAX_PROPERTIES_SIZE
27
- raise SecureNativeInvalidOptionsError('You can have only up to {} custom properties', MAX_PROPERTIES_SIZE)
28
- end
29
-
30
- @event_options
31
- end
32
- end