Skip to content

Commit d526246

Browse files
author
Inbal Tako
committed
SN-1938 Validate user id
1 parent f1f23eb commit d526246

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Once initialized, sdk will create a singleton instance which you can get:
7575
from securenative.securenative import SecureNative
7676

7777

78-
secureNative = SecureNative.get_instance()
78+
securenative = SecureNative.get_instance()
7979
```
8080

8181
## Tracking events
@@ -85,15 +85,22 @@ instance. Make sure you build event with the EventBuilder:
8585

8686
```python
8787
from securenative.securenative import SecureNative
88-
from securenative.event_options_builder import EventOptionsBuilder
88+
from securenative.context.securenative_context import SecureNativeContext
89+
from securenative.models.event_options import EventOptions
8990
from securenative.enums.event_types import EventTypes
9091
from securenative.models.user_traits import UserTraits
9192

9293

9394
securenative = SecureNative.get_instance()
9495

95-
context = SecureNative.context_builder().with_ip("127.0.0.1").with_client_token("SECURED_CLIENT_TOKEN").with_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"}).build()
96-
event_options = EventOptionsBuilder(EventTypes.LOG_IN).with_user_id("1234").with_user_traits(UserTraits("Your Name", "name@gmail.com", "+1234567890")).with_context(context).with_properties({"prop1": "CUSTOM_PARAM_VALUE", "prop2": True, "prop3": 3}).build()
96+
context = SecureNativeContext(client_token="SECURE_CLIENT_TOKEN",
97+
ip="127.0.0.1",
98+
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"})
99+
event_options = EventOptions(event=EventTypes.LOG_IN,
100+
user_id="1234",
101+
user_traits=UserTraits("Your Name", "name@gmail.com", "+1234567890"),
102+
context=context,
103+
properties={"custom_param1": "CUSTOM_PARAM_VALUE", "custom_param2": True, "custom_param3": 3})
97104

98105
securenative.track(event_options)
99106
```
@@ -102,16 +109,21 @@ You can also create request context from requests:
102109

103110
```python
104111
from securenative.securenative import SecureNative
105-
from securenative.event_options_builder import EventOptionsBuilder
112+
from securenative.context.securenative_context import SecureNativeContext
113+
from securenative.models.event_options import EventOptions
106114
from securenative.enums.event_types import EventTypes
107115
from securenative.models.user_traits import UserTraits
108116

109117

110118
def track(request):
111119
securenative = SecureNative.get_instance()
112120

113-
context = SecureNative.context_builder().from_http_request(request).build()
114-
event_options = EventOptionsBuilder(EventTypes.LOG_IN).with_user_id("1234").with_user_traits(UserTraits("Your Name", "name@gmail.com", "+1234567890")).with_context(context).with_properties({"prop1": "CUSTOM_PARAM_VALUE", "prop2": True, "prop3": 3}).build()
121+
context = SecureNativeContext.from_http_request(request)
122+
event_options = EventOptions(event=EventTypes.LOG_IN,
123+
user_id="1234",
124+
user_traits=UserTraits("Your Name", "name@gmail.com", "+1234567890"),
125+
context=context,
126+
properties={"custom_param1": "CUSTOM_PARAM_VALUE", "custom_param2": True, "custom_param3": 3})
115127

116128
securenative.track(event_options)
117129
```
@@ -122,16 +134,21 @@ def track(request):
122134

123135
```python
124136
from securenative.securenative import SecureNative
125-
from securenative.event_options_builder import EventOptionsBuilder
137+
from securenative.models.event_options import EventOptions
138+
from securenative.context.securenative_context import SecureNativeContext
126139
from securenative.enums.event_types import EventTypes
127140
from securenative.models.user_traits import UserTraits
128141

129142

130143
def track(request):
131144
securenative = SecureNative.get_instance()
132-
context = SecureNative.context_builder().from_http_request(request).build()
133145

134-
event_options = EventOptionsBuilder(EventTypes.LOG_IN).with_user_id("1234").with_user_traits(UserTraits("Your Name", "name@gmail.com", "+1234567890")).with_context(context).with_properties({"prop1": "CUSTOM_PARAM_VALUE", "prop2": True, "prop3": 3}).build()
146+
context = SecureNativeContext.from_http_request(request)
147+
event_options = EventOptions(event=EventTypes.LOG_IN,
148+
user_id="1234",
149+
user_traits=UserTraits("Your Name", "name@gmail.com", "+1234567890"),
150+
context=context,
151+
properties={"custom_param1": "CUSTOM_PARAM_VALUE", "custom_param2": True, "custom_param3": 3})
135152

136153
verify_result = securenative.verify(event_options)
137154
verify_result.risk_level # Low, Medium, High

0 commit comments

Comments
 (0)