forked from Codecademy/EventHub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
executable file
·158 lines (134 loc) · 7.09 KB
/
script.sh
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
URL="http://localhost:8080"
today=`date +'%Y%m%d'`
end_date=`(date -d '+14day' +'%Y%m%d' || date -v '+14d' +'%Y%m%d') 2> /dev/null`
echo -e "\033[1;31m=============== event related endpoints ================\033[0m\n"
echo -e "\033[1;32mtrack event:\033[0m anonymous user (w/ gnerated user id: generated_id_123) visited Codecademy's home page"
curl -X POST ${URL}/events/track --data "event_type=pageview&external_user_id=generated_id_123&page=home&experiment=homepage_v1&treatment=control"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user made a submission to first exercise in the home page \033[0m"
curl -X POST ${URL}/events/track --data "event_type=submission&external_user_id=generated_id_123&exercise=homepage_1"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user made a submission to the second exercise in the home page \033[0m"
curl -X POST ${URL}/events/track --data "event_type=submission&external_user_id=generated_id_123&exercise=homepage_2"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user sign up\033[0m"
curl -X POST ${URL}/events/track --data "event_type=signup&external_user_id=generated_id_123&experiment=signup_v1&treatment=control"
echo ""
echo -e "\033[1;32malias user :\033[0m alias from [email protected] to generated_id_123 \033[0m"
curl -X POST ${URL}/users/alias --data "[email protected]&to_external_user_id=generated_id_123"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user visited Codecademy's tracks page\033[0m"
curl -X POST ${URL}/events/track --data "event_type=pageview&[email protected]&page=tracks"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user started the javascript track\033[0m"
curl -X POST ${URL}/events/track --data "event_type=start_track&[email protected]&track=javascript"
echo ""
echo -e "\033[1;32mtrack event:\033[0m the user made a submission to the first exercise in the javascript track \033[0m"
curl -X POST ${URL}/events/track --data "event_type=submission&[email protected]&exercise=javascript_1"
echo ""
echo -e "\033[1;32mbatch track events for a few other users:\033[0m"
curl -X POST ${URL}/events/batch_track --data "events=[
{
external_user_id: '[email protected]',
event_type: 'pageview',
experiment: 'homepage_v1',
treatment: 'new console',
page: 'home'
}, {
external_user_id: '[email protected]',
event_type: 'signup',
experiment: 'signup_v1',
treatment: 'fancy onboarding'
}, {
external_user_id: '[email protected]',
event_type: 'submission'
}, {
external_user_id: '[email protected]',
event_type: 'signup',
experiment: 'signup_v1',
treatment: 'fancy onboarding'
}, {
external_user_id: '[email protected]',
event_type: 'submission'
}, {
external_user_id: '[email protected]',
event_type: 'pageview',
experiment: 'homepage_v1',
treatment: 'new console',
page: 'home'
}, {
external_user_id: '[email protected]',
event_type: 'signup',
experiment: 'signup_v1',
treatment: 'fancy onboarding'
}, {
external_user_id: '[email protected]',
event_type: 'pageview',
experiment: 'homepage_v1',
treatment: 'new console',
page: 'home'
}]
"
echo ""
echo -e "\033[1;32mshow all event types:\033[0m"
curl ${URL}/events/types
echo ""
echo -e "\033[1;32mshow all event keys for \"signup\" event type:\033[0m"
curl '${URL}/events/keys?event_type=signup'
echo ""
echo -e "\033[1;32mshow all event values for 'treatment' event key and \"signup\" event type:\033[0m"
curl '${URL}/events/values?event_type=signup&event_key=treatment'
echo ""
echo -e "\033[1;32mshow all event values for 'treatment' event key, \"signup\" event type and prefix \"fa\":\033[0m"
curl '${URL}/events/values?event_type=signup&event_key=treatment&prefix=fa'
echo ""
echo -e "\033[1;32mshow all event types:\033[0m"
curl ${URL}/events/types
echo ""
echo -e "\033[1;32mshow server stats:\033[0m"
curl ${URL}/varz
echo ""
echo -e "\033[1;32mshow funnel:\033[0m pageview -> signup -> submission"
curl -X POST "${URL}/events/funnel" --data "start_date=${today}&end_date=${end_date}&funnel_steps[]=pageview&funnel_steps[]=signup&funnel_steps[]=submission&num_days_to_complete_funnel=7"
echo ""
echo -e "\033[1;32mshow cohort:\033[0m signup -> submission"
curl -X POST "${URL}/events/cohort" --data "start_date=${today}&end_date=${end_date}&row_event_type=signup&column_event_type=submission&num_days_per_row=7&num_columns=2"
echo ""
echo -e "\033[1;32mshow A/B testing signup funnel (control):\033[0m pageview -> signup"
curl -X POST "${URL}/events/funnel" --data "start_date=${today}&end_date=${end_date}&funnel_steps[]=pageview&funnel_steps[]=signup&num_days_to_complete_funnel=7&efk0[]=experiment&efv0[]=homepage_v1&efk0[]=treatment&efv0[]=control&efk0[]=page&efv0[]=home"
echo ""
echo -e "\033[1;32mshow A/B testing signup funnel (new console):\033[0m pageview -> signup"
curl -X POST "${URL}/events/funnel" --data "start_date=${today}&end_date=${end_date}&funnel_steps[]=pageview&funnel_steps[]=signup&num_days_to_complete_funnel=7&efk0[]=experiment&efv0[]=homepage_v1&efk0[]=treatment&efv0[]=new console&efk0[]=page&efv0[]=home"
echo ""
echo -e "\033[1;32mshow A/B testing cohort:\033[0m signup -> submission"
curl -X POST "${URL}/events/cohort" --data "start_date=${today}&end_date=${end_date}&row_event_type=signup&column_event_type=submission&num_days_per_row=7&num_columns=2&refk[]=experiment&refv[]=signup_v1&refk[]=treatment&refv[]=control"
echo ""
echo -e "\033[1;32mshow A/B testing cohort:\033[0m signup -> submission"
curl -X POST "${URL}/events/cohort" --data "start_date=${today}&end_date=${end_date}&row_event_type=signup&column_event_type=submission&num_days_per_row=7&num_columns=2&refk[]=experiment&refv[]=signup_v1&refk[]=treatment&refv[]=fancy onboarding"
echo ""
echo -e "\033[1;31m=============== user related endpoints ================\033[0m\n"
echo -e "\033[1;32mshow the first event for [email protected]\033[0m"
curl ${URL}/users/timeline\?external_user_id\[email protected]\&offset\=0\&num_records\=1
echo ""
echo -e "\033[1;32mshow the following 10 events for [email protected]\033[0m"
curl ${URL}/users/timeline\?external_user_id\[email protected]\&offset\=1\&num_records\=10
echo ""
echo -e "\033[1;32mshow ids of users whose email is [email protected]\033[0m"
curl -X POST ${URL}/users/find --data "ufk[]=external_user_id&ufv[][email protected]"
echo ""
echo -e "\033[1;32madd new user information\033[0m"
curl -X POST ${URL}/users/add_or_update --data "[email protected]&foo=bar&hello=world1"
echo ""
echo -e "\033[1;32mupdate user information\033[0m"
curl -X POST ${URL}/users/add_or_update --data "[email protected]&foo=bar&hello=world2"
echo ""
echo -e "\033[1;32mshow all user keys:\033[0m"
curl -X POST ${URL}/users/keys
echo ""
echo -e "\033[1;32mshow all user values for 'hello' user key:\033[0m"
curl -X POST ${URL}/users/values --data "user_key=hello"
echo ""
echo -e "\033[1;32mshow all user values for 'hello' user key and prefix 'w':\033[0m"
curl -X POST ${URL}/users/values --data "user_key=hello&prefix=w"
echo ""