@@ -47,7 +47,7 @@ Or install it yourself as:
4747To get your * API KEY* , login to your SecureNative account and go to project settings page:
4848
4949### Option 1: Initialize via Config file
50- SecureNative can automatically load your config from * securenative.cfg * file or from the file that is specified in your * SECURENATIVE_CONFIG_FILE* env variable:
50+ SecureNative can automatically load your config from * securenative.yml * file or from the file that is specified in your * SECURENATIVE_CONFIG_FILE* env variable:
5151
5252``` ruby
5353require ' securenative'
@@ -69,7 +69,8 @@ securenative = SecureNative.init_with_api_key('YOUR_API_KEY')
6969require ' securenative'
7070
7171
72- securenative = SecureNative .init_with_options(SecureNative .config_builder(api_key = ' API_KEY' , max_event = 10 , log_level = ' ERROR' ))
72+ options = ConfigurationBuilder .new (api_key: ' API_KEY' , max_events: 10 , log_level: ' ERROR' )
73+ SecureNative .init_with_options(options)
7374```
7475
7576## Getting SecureNative instance
@@ -88,42 +89,46 @@ instance. Make sure you build event with the EventBuilder:
8889
8990 ``` ruby
9091require ' securenative'
91- require ' securenative/enums/event_types'
92- require ' securenative/event_options_builder'
93- require ' securenative/models/user_traits'
94- require ' securenative/context/context_builder'
92+ require ' models/event_options'
93+ require ' enums/event_types'
94+ require ' models/user_traits'
9595
9696
97- securenative = SecureNative .instance
98-
99- context = securenative.context_builder(ip = ' 127.0.0.1' , client_token = ' SECURED_CLIENT_TOKEN' ,
100- headers = { ' user-agent' => ' Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405' })
101-
102- event_options = EventOptions (event_type = EventTypes ::LOG_IN ,
103- user_id = ' 1234' , user_traits = UserTraits (' Your Name' , ' name@gmail.com' , ' +1234567890' ),
104- context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
105-
106- securenative.track(event_options)
97+ def track
98+ securenative = SecureNative .instance
99+ context = SecureNativeContext .new (client_token: ' 2a980d872b939c7e4f4378aa111a5eeffb22808b58b5372f658d34904ebd5b05fff0daab91921243ac08b72442a5b3992e402dc21df16aa7cc0e19f8bffa9d6cc59996d480d70aa22b857189403675d37fd144ebaf9dc697fed149b907678f2b1f964d73b332dc8ea7df63fcfc3c11f7bbb51ba2672652ca7d5d43f36a62e15db8b13dfd794a5eccfc5968ca514dd7cce59f2df2b9d8184d076eba808c81b311' , ip: ' 127.0.0.1' ,
100+ headers: { ' user-agent' => ' Mozilla: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.3 Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/43.4' })
101+
102+ event_options = EventOptions .new (event: EventTypes ::LOG_IN , user_id: ' 1234' , context: context,
103+ user_traits: UserTraits .new (name: ' Your Name' , email: ' name@gmail.com' , phone: ' +1234567890' ),
104+ properties: { custom_param1: ' CUSTOM_PARAM_VALUE' , custom_param2: true , custom_param3: 3 })
105+
106+ securenative.track(event_options)
107+
108+ @message = ' tracked'
109+ end
107110 ```
108111
109112You can also create request context from requests:
110113
111114``` ruby
112115require ' securenative'
113- require ' securenative/enums/event_types '
114- require ' securenative/event_options_builder '
115- require ' securenative/ models/user_traits'
116+ require ' models/event_options '
117+ require ' enums/event_types '
118+ require ' models/user_traits'
116119
117120
118- def track ( request )
121+ def track
119122 securenative = SecureNative .instance
120- context = SecureNative .context_builder. from_http_request(request).build
121-
122- event_options = EventOptions (event_type = EventTypes ::LOG_IN ,
123- user_id = ' 1234 ' , user_traits = UserTraits ( ' Your Name' , ' name@gmail.com' , ' +1234567890' ),
124- context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
123+ context = SecureNativeContext . from_http_request(request)
124+
125+ event_options = EventOptions . new ( event: EventTypes ::LOG_IN , user_id: ' 1234 ' , context: context ,
126+ user_traits: UserTraits . new ( name: ' Your Name' , email: ' name@gmail.com' , phone: ' +1234567890' ),
127+ properties: { custom_param1: ' CUSTOM_PARAM_VALUE' , custom_param2: true , custom_param3: 3 })
125128
126129 securenative.track(event_options)
130+
131+ @message = ' tracked'
127132end
128133```
129134
@@ -133,18 +138,18 @@ end
133138
134139``` ruby
135140require ' securenative'
136- require ' securenative/enums/event_types '
137- require ' securenative/event_options_builder '
138- require ' securenative/ models/user_traits'
141+ require ' models/event_options '
142+ require ' enums/event_types '
143+ require ' models/user_traits'
139144
140145
141146def verify (request )
142147 securenative = SecureNative .instance
143- context = SecureNative .context_builder. from_http_request(request).build
148+ context = SecureNativeContext . from_http_request(request)
144149
145- event_options = EventOptions (event_type = EventTypes ::LOG_IN ,
146- user_id = ' 1234 ' , user_traits = UserTraits ( ' Your Name' , ' name@gmail.com' , ' +1234567890' ),
147- context = context, properties = {prop1 => ' CUSTOM_PARAM_VALUE' , prop2 => true , prop3 => 3 }).build
150+ event_options = EventOptions . new ( event: EventTypes ::LOG_IN , user_id: ' 1234 ' , context: context ,
151+ user_traits: UserTraits . new ( name: ' Your Name' , email: ' name@gmail.com' , phone: ' +1234567890' ),
152+ properties: { custom_param1: ' CUSTOM_PARAM_VALUE' , custom_param2: true , custom_param3: 3 })
148153
149154 verify_result = securenative.verify(event_options)
150155 verify_result.risk_level # Low, Medium, High
0 commit comments