forked from segmentio/analytics-python
-
Notifications
You must be signed in to change notification settings - Fork 4
/
example_context_library_integration.py
97 lines (85 loc) · 1.62 KB
/
example_context_library_integration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import logging
import rudderstack.analytics as analytics
from rudderstack.analytics.get_env import TEST_DATA_PLANE_URL
from rudderstack.analytics.get_env import TEST_WRITE_KEY
logging.basicConfig()
logging.getLogger('rudder').setLevel('DEBUG')
analytics.write_key = TEST_WRITE_KEY
analytics.host = "some_random_url" # Do not use this
analytics.dataPlaneUrl = TEST_DATA_PLANE_URL
analytics.debug = True
properties = {
"library": {
"application": 'Rudder Desktop',
"version": '1.1.0',
"platform": 'osx'
}
}
traits = {
"firstname": 'First',
"lastname": 'Last',
"Role": 'Jedi',
"age": 25
}
context = {
"screen": {
"width": 852,
"height": 393,
"density": 3
},
"os": {
"name": 'macOS',
"version": '11'
},
"locale": 'en-US'
}
context_with_library = {
"screen": {
"width": 852,
"height": 393,
"density": 3
},
"os": {
"name": 'macOS',
"version": '11'
},
"locale": 'en-US',
'library': {
'name': 'analytics-random-sdk',
'version': '1.0.0.beta.1'
}
}
user_id = '123456'
anonymous_id = 'uid'
analytics.track(
user_id= user_id,
event= 'Test Track',
anonymous_id= anonymous_id,
properties= properties
)
analytics.screen(
user_id= user_id,
name= 'Test Screen',
anonymous_id= anonymous_id,
properties= properties
)
analytics.identify(
user_id= '654321',
traits= traits
)
analytics.group(
user_id= user_id,
group_id= "uid",
anonymous_id= anonymous_id,
traits= traits
)
analytics.alias(
user_id= user_id,
previous_id= '654321'
)
analytics.page(
user_id= user_id,
name= 'Test Page',
anonymous_id= anonymous_id,
properties= properties
)