-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
384 lines (358 loc) · 14.7 KB
/
index.html
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>JS SDK Sanity</title>
<script>
rudderanalytics = window.rudderanalytics = [];
var methods = [
"load",
"page",
"track",
"identify",
"alias",
"group",
"ready",
"reset",
"getAnonymousId",
"setAnonymousId",
"getUserId",
"getUserTraits",
"getGroupId",
"getGroupTraits",
"startSession",
"endSession",
"getSessionId"
];
for (var i = 0; i < methods.length; i++) {
var method = methods[i];
rudderanalytics[method] = (function (methodName) {
return function () {
rudderanalytics.push(
[methodName].concat(Array.prototype.slice.call(arguments))
);
};
})(method);
}
rudderanalytics.ready(() => {
console.log("All set!");
});
</script>
</head>
<style>
/* CSS to style the form */
form {
display: flex;
flex-wrap: wrap;
gap: 10px;
padding: 20px;
border-radius: 5px;
max-width: 500px;
margin: 0;
}
.form-field {
flex: 1 1 100%;
display: flex;
align-items: center;
}
.form-field label {
min-width: 200px;
font-weight: bold;
}
.form-field input,
.form-field select {
flex: 1;
width: 100%;
padding: 15px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
}
.form-field input[type="text"],
.form-field select {
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
}
.form-field input[type="text"] {
width: 100%;
}
/* Additional styling for the button */
/* Button styling */
button {
margin-top: 30px;
padding: 10px 20px;
border: none;
border-radius: 4px;
background-color: rgb(52, 93, 227); /* Change button color to blue */
color: #fff;
cursor: pointer;
}
/* Styling for the navigation buttons */
.nav-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.nav-buttons button {
padding: 10px 20px;
border: none;
border-radius: 4px;
background-color: rgb(52, 93, 227);
color: #fff;
cursor: pointer;
}
.nav-buttons {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.nav-buttons button {
padding: 10px 20px;
border: none;
border-radius: 4px;
background-color: rgb(52, 93, 227);
color: #fff;
cursor: pointer;
}
/* Additional style for the form field with custom event */
.form-field-custom-event {
flex: 1;
width: 200%; /* Enhance the width to fill its container */
max-width: 500px; /* Set a maximum width to ensure responsiveness */
padding: 15px;
border: 1px solid #374e6f;
border-radius: 4px;
font-size: 14px;
resize: vertical; /* Allow vertical resizing of the textarea */
}
.form-field-custom-event label {
min-width: 200px;
font-weight: bold;
margin-bottom: 5px; /* Add a little space below the label */
}
.form-field-custom-event textarea {
flex: 1;
width: 100%;
padding: 15px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
resize: vertical; /* Allow vertical resizing of the textarea */
}
</style>
</head>
<body>
<h2>Configure Your Web SDK Test Page</h2>
<form>
<div class="form-field">
<label for="writekey-input">Source WriteKey</label>
<input type="text" id="writekey-input" placeholder="Enter WRITE_KEY" />
</div>
<div class="form-field">
<label for="data-plane-url-input">Dataplane URL</label>
<input type="text" id="data-plane-url-input" placeholder="Enter DATA_PLANE_URL" />
</div>
<div class="form-field">
<label for="optional-load-options">Optional Load Options (JSON)</label>
<textarea id="optional-load-options" rows="6" placeholder="Enter optional load options JSON here"></textarea>
</div>
<div class="form-field">
<label for="config-url-input">Config URL</label>
<select id="config-url-dropdown" onchange=handleConfigUrlSelection()>
<option value="https://api.rudderlabs.com">Prod Config Url</option>
<option value="https://api.dev.rudderlabs.com">Dev Config Url</option>
<option value="Other">Other</option>
</select>
<input type="text" id="config-url-input" placeholder="Enter CONFIG_URL" style="display: none;" />
</div>
<div class="form-field">
<label for="integration-name-input">Integration Name To Exclude (optional)</label>
<input type="text" id="integration-name-input" placeholder="Enter integration name" />
</div>
<div class="form-field">
<label for="dest-sdk-base-url-input">destSDKBaseURL (Used only for local testing)</label>
<input type="text" id="dest-sdk-base-url-input" placeholder="Enter destSDKBaseURL" />
</div>
<div class="form-field">
<label for="cdn-dropdown">CDN URL for RudderAnalytics</label>
<select id="cdn-dropdown" onchange=handleCdnUrlSelection()>
<option value="https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js">Prod CDN</option>
<option value="https://cdn.rudderlabs.com/staging/latest/rudder-analytics-staging.min.js">Staging CDN</option>
<option value="Other">Other</option>
</select>
<input type="text" id="cdn-text-input" placeholder="Enter CDN URL" style="display: none;" />
</div>
<button type="button" onclick="window.updateRudderAnalytics(); cacheValues();">Update SDK configuration</button>
</form>
<!-- The script tag with the configurable CDN URL -->
<script id="rudder-analytics-script"></script>
<div style="display: flex; justify-content: space-between; margin-top: 20px;"></div>
<div style="margin-top: 30px; max-width: 500px;">
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr>
<th style="border: 1px solid #ccc; padding: 8px;">Event Type</th>
<th style="border: 1px solid #ccc; padding: 8px;">Popular Scenario</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Identify</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="identify">
<option value="make_choice">choose your scenario </option>
<option value="fire_all_types_of_identify">fire all types Identify events</option>
<option value="userId_as_int">userId as int</option>
<option value="no_userId_only_traits">no userId only traits</option>
<option value="traits_no_email">Traits without email</option>
<option value="traits_with_email">Traits with email</option>
<option value="only_userId_no_traits"> only userId</option>
<option value="traits_and_context"> traits plus context object</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
<!-- Add more rows for other events -->
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Track</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="track">
<option value="make_choice">choose your scenario </option>
<option value="fire_all_types_of_track">fire all types Track events</option>
<option value="only_event_name">Only event name</option>
<option value="event_name_and_props">Event names and properties</option>
<option value="event_with_empty_props">event with empty properties</option>
<option value="props_and_traits">event with properties and traits</option>
<option value="props_and_product">event with properties and product</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
<!-- Add more rows for other events -->
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Page</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="page">
<option value="make_choice">choose your scenario </option>
<option value="fire_all_types_of_page">fire all types Page events</option>
<option value="page_name">with only page name</option>
<option value="page_category">with only page category</option>
<option value="page_name_and_category">with page name and category</option>
<option value="page_name_and_props_and_category">with page name category and properties</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Group</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="group">
<option value="make_choice">choose your scenario </option>
<option value="fire_all_types_of_group">fire all types Group events</option>
<option value="string_group_Id">Only group Id as string</option>
<option value="int_group_Id">Only group Id as int</option>
<option value="group_Id_and_traits">With group traits</option>
<option value="group_Id_and_traits_and_context">With group traits and context traits</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Alias</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="alias">
<option value="make_choice">choose your scenario </option>
<option value="alias">Simple Alias Call</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
<tr>
<td style="border: 1px solid #ccc; padding: 8px;">Ecommerce</td>
<td style="border: 1px solid #ccc; padding: 8px;">
<select id="ecommerce">
<option value="Scenario A">Scenario A</option>
<option value="Scenario B">Scenario B</option>
<option value="Scenario C">Scenario C</option>
<!-- Add more scenarios here as needed -->
</select>
</td>
</tr>
</tbody>
</table>
</div>
<!-- New div to display function bodies for different event types -->
<div id="function-bodies" style="flex: 1; padding-left: 20px;">
<div id="track-function-bodies">
<!-- Function bodies for the "track" event type will be dynamically updated here -->
</div>
<div id="identify-function-bodies">
<!-- Function bodies for the "identify" event type will be dynamically updated here -->
</div>
<div id="page-function-bodies">
<!-- Function bodies for the "page" event type will be dynamically updated here -->
</div>
<div id="group-function-bodies">
<!-- Function bodies for the "group" event type will be dynamically updated here -->
</div>
<div id="alias-function-bodies">
<!-- Function bodies for the "alias" event type will be dynamically updated here -->
</div>
<div id="ecommerce-function-bodies">
<!-- Function bodies for the "ecommerce" event type will be dynamically updated here -->
</div>
</div>
</div>
<div class="form-field" style="margin-top: 50px; max-width: 500px;">
<label for="custom-javascript">Custom Event</label>
<textarea id="custom-javascript" rows="6" placeholder="Enter your JavaScript code here"></textarea>
</div>
<div class="form-field">
<button type="button" onclick="executeCustomJavaScript()">Apply</button>
</div>
<script>
function handleConfigUrlSelection() {
const dropdown = document.getElementById("config-url-dropdown");
const inputField = document.getElementById("config-url-input");
if (dropdown.value === "Other") {
inputField.style.display = "block";
} else {
inputField.style.display = "none";
}
}
// Function to handle CDN URL selection
function handleCdnUrlSelection() {
var cdnDropdown = document.getElementById("cdn-dropdown");
var cdnTextInput = document.getElementById("cdn-text-input");
var selectedOption = cdnDropdown.value;
if (selectedOption === "Other") {
cdnTextInput.style.display = "block";
} else {
cdnTextInput.style.display = "none";
cdnTextInput.value = "";
}
}
// Function to execute custom JavaScript code entered by the user
function executeCustomJavaScript() {
try {
const code = document.getElementById("custom-javascript").value;
eval(code);
} catch (error) {
console.error("Error executing custom JavaScript:", error);
}
}
window.cacheValues = () => {
cacheValues();
};
window.handleScenarioSelection = (selectId) => {
handleScenarioSelection(selectId);
};
</script>
<script src="events.js" type="module"></script>
<script src="util.js" type="module"></script>
<script src="main.js" type="module"></script>
</body>
</html>