-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
323 lines (308 loc) · 12.6 KB
/
index.html
File metadata and controls
323 lines (308 loc) · 12.6 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hawk JavaScript example</title>
<link
href="https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap"
rel="stylesheet"
/>
<style>
body {
font-family: Roboto, system-ui, sans-serif;
margin: 0;
padding: 0;
background: #2f3341;
color: #dbe6ff;
font-size: 13px;
}
header {
padding: 30px;
background: #242732;
}
h1 {
font-weight: bold;
font-size: 20px;
margin: 0 0 15px;
}
a {
color: inherit;
}
section {
padding: 15px;
border: 1px solid rgba(219, 230, 255, 0.1);
border-radius: 4px;
margin: 15px;
}
h2 {
font-weight: 500;
margin: 0 0 10px;
font-size: 13px;
color: rgba(219, 230, 255, 0.6);
letter-spacing: 0.24px;
text-align: left;
text-transform: uppercase;
}
h2 small {
text-transform: none;
font-size: 14px;
opacity: 0.6;
font-weight: normal;
margin-left: 15px;
}
button {
display: inline-block;
padding: 8px 20px;
border: 0;
border-radius: 5px;
background: #4979e4;
color: #dbe6ff;
font-weight: 500;
font-size: 14px;
cursor: pointer;
}
button:hover {
background: #4869d2;
}
label {
display: block;
margin-bottom: 10px;
font-size: 15px;
}
input,
select {
background: rgba(36, 39, 50, 0.68);
border: 1px solid rgba(0, 0, 0, 0.18);
border-radius: 3px;
padding: 10px 15px;
font-size: 15px;
color: inherit;
}
</style>
</head>
<body>
<header>
<h1>Hawk JavaScript Catcher</h1>
<a href="https://github.com/codex-team/hawk.javascript"
>https://github.com/codex-team/hawk.javascript</a
>
</header>
<section>
<h2>Send test event</h2>
<button onclick="window.hawk.test()">hawk.test()</button>
</section>
<section>
<h2>Send real error</h2>
<button id="btn-real-error">Real error</button>
</section>
<section>
<h2>Send Unhandled promise rejection error</h2>
<button id="btn-promise-rejection">Unhandled promise rejection</button>
</section>
<section>
<h2>
Send event manually
<small> Through the <code>.send(error, context)</code> method </small>
</h2>
<label for="errorContext">Error context</label>
<input type="text" id="errorContext" placeholder="Any data you want" />
<br />
<br />
<button id="btn-manual-sending">Send manual message</button>
</section>
<section>
<h2>Send the specified number of errors</h2>
<label for="errorsNumber">Enter the number of errors to send</label>
<input type="number" id="errorsNumber" value="1000" />
<br /><br />
<label for="errorType">Select errors type</label>
<select id="errorType">
<option value="TypeError">TypeError</option>
<option value="RangeError">RangeError</option>
<option value="Error">Error</option>
</select>
<br /><br />
<button id="btn-send-many">Send errors</button>
</section>
<section>
<h2>Test console catcher</h2>
<label for="consoleCatcherTestTextInput">Enter text</label>
<input type="text" id="consoleCatcherTestTextInput" />
<br /><br />
<label for="consoleMethod" style="display: inline">console.</label>
<select id="consoleMethod">
<option value="log">log</option>
<option value="error">error</option>
<option value="info">info</option>
<option value="debug">debug</option>
<option value="warn">warn</option>
</select>
<br /><br />
<button id="btn-console-test">Make</button>
</section>
<section>
<h2>User Management</h2>
<label for="userId">User ID</label>
<input type="text" id="userId" placeholder="user123" />
<br /><br />
<label for="userName">User Name</label>
<input type="text" id="userName" placeholder="John Doe" />
<br /><br />
<label for="userUrl">User URL</label>
<input type="text" id="userUrl" placeholder="/users/123" />
<br /><br />
<button id="btn-set-user">Set User</button>
<button id="btn-clear-user">Clear User</button>
</section>
<section>
<h2>Context Management</h2>
<label for="contextKey">Context Key</label>
<input type="text" id="contextKey" placeholder="feature" />
<br /><br />
<label for="contextValue">Context Value</label>
<input type="text" id="contextValue" placeholder="user-dashboard" />
<br /><br />
<button id="btn-set-context">Set Context</button>
</section>
<section>
<h2>Breadcrumbs Management</h2>
<label for="breadcrumbMessage">Breadcrumb Message</label>
<input type="text" id="breadcrumbMessage" placeholder="User performed action" />
<br /><br />
<label for="breadcrumbType">Type</label>
<select id="breadcrumbType">
<option value="default">default</option>
<option value="request">request</option>
<option value="ui">ui</option>
<option value="navigation">navigation</option>
<option value="logic">logic</option>
<option value="error">error</option>
</select>
<br /><br />
<label for="breadcrumbLevel">Level</label>
<select id="breadcrumbLevel">
<option value="info">info</option>
<option value="debug">debug</option>
<option value="warning">warning</option>
<option value="error">error</option>
<option value="fatal">fatal</option>
</select>
<br /><br />
<label for="breadcrumbCategory">Category (optional)</label>
<input type="text" id="breadcrumbCategory" placeholder="ui.click" />
<br /><br />
<button id="btn-add-breadcrumb">Add Breadcrumb</button>
<button id="btn-get-breadcrumbs">Get Breadcrumbs</button>
<button id="btn-clear-breadcrumbs">Clear Breadcrumbs</button>
<div id="breadcrumbs-output" style="margin-top: 15px; margin-bottom: 30px; padding: 10px; background: rgba(36, 39, 50, 0.68); border-radius: 3px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; font-family: monospace; font-size: 12px;"></div>
<h2>Test All Breadcrumb Types <small>Quick examples for each type</small></h2>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;">
<button id="btn-test-default">Default Event (Manual)</button>
<button id="btn-test-request">Request (Auto via Fetch)</button>
<button id="btn-test-ui">UI Click (Auto)</button>
<button id="btn-test-navigation">Navigation (Auto)</button>
<button id="btn-test-logic">Logic Operation (Manual)</button>
<button id="btn-test-error">Error Event (Manual)</button>
</div>
<div style="margin-top: 10px; display: flex; gap: 10px;">
<button id="btn-test-all-types" style="flex: 1; background: #2ecc71;">▶Run All Types Sequence</button>
</div>
</section>
<script src="https://unpkg.com/vue@2"></script>
<section>
<h2>Test Vue integration: $root</h2>
<div id="vue-app-1">
<button @click="buttonClicked">{{ label }}</button>
</div>
<script>
new Vue({
el: '#vue-app-1',
data: {
label: 'Error in Vue $root',
},
methods: {
buttonClicked() {
foo();
},
},
});
</script>
</section>
<section>
<h2>Test Vue integration: <test-component></h2>
<div id="vue-app-2">
<test-component :title="label" />
</div>
<script>
class Editor {}
const tag = document.createElement('div');
tag.classList.add('my-class', 'my-class--second');
tag.setAttribute('title', 'My title');
tag.dataset.index = 123;
tag.innerHTML = document.body.innerHTML;
Vue.component('test-component', {
data() {
return {
number: 1,
bool: false,
arr: [1, 2, 3, [new Editor(), tag.cloneNode()], { foo: 'bar' }],
el: tag,
instance: new Editor(),
classProto: Editor,
longText:
"Upvoting this, given it's simplicity. In my use case I need to check all the attributes in an object for dodgy values-NaNs, nulls, undefined (they were points on a graph and these values prevented the graph from drawing). To get the value instead of the name, in the loop you would just do obj[someVariable]. Perhaps the reason it was downvoted so much is because it is not recursive. So this would not be an adequate solution if you have a highly structured object.Upvoting this, given it's simplicity. In my use case I need to check all the attributes in an object for dodgy values-NaNs, nulls, undefined (they were points on a graph and these values prevented the graph from drawing). To get the value instead of the name, in the loop you would just do obj[someVariable]. Perhaps the reason it was downvoted so much is because it is not recursive. So this would not be an adequate solution if you have a highly structured object.Upvoting this, given it's simplicity. In my use case I need to check all the attributes in an object for dodgy values-NaNs, nulls, undefined (they were points on a graph and these values prevented the graph from drawing). To get the value instead of the name, in the loop you would just do obj[someVariable]. Perhaps the reason it was downvoted so much is because it is not recursive. So this would not be an adequate solution if you have a highly structured object.Upvoting this, given it's simplicity. In my use case I need to check all the attributes in an object for dodgy values-NaNs, nulls, undefined (they were points on a graph and these values prevented the graph from drawing). To get the value instead of the name, in the loop you would just do obj[someVariable]. Perhaps the reason it was downvoted so much is because it is not recursive. So this would not be an adequate solution if you have a highly structured object.Upvoting this, given it's simplicity. In my use case I need to check all the attributes in an object for dodgy values-NaNs, nulls, undefined (they were points on a graph and these values prevented the graph from drawing). To get the value instead of the name, in the loop you would just do obj[someVariable]. Perhaps the reason it was downvoted so much is because it is not recursive. So this would not be an adequate solution if you have a highly structured object.",
};
},
props: {
title: String,
},
computed: {
changedItem() {
return this.number + 1;
},
},
template:
'<button @click="buttonClicked" :data-item="number" data-changed-item="changedItem">{{ title }} - {{ changedItem }}</button>',
methods: {
buttonClicked() {
bar();
},
},
});
new Vue({
el: '#vue-app-2',
data: {
label: 'Error in Vue-component',
},
});
</script>
</section>
<script src="sample-errors.js"></script>
<script src="breadcrumbs-tests.js"></script>
<script type="module">
import HawkCatcher from '../src';
window.hawk = new HawkCatcher({
token:
'eyJpbnRlZ3JhdGlvbklkIjoiNWU5OTE1MzItZTdiYy00ZjA0LTliY2UtYmIzZmE5ZTUwMTg3Iiwic2VjcmV0IjoiMTBlMTA4MjQtZTcyNC00YWFkLTkwMDQtMzExYTU1OWMzZTIxIn0=',
// collectorEndpoint: 'ws://localhost:3000/ws',
vue: window.Vue,
context: {
rootContextSample: '12345',
},
// breadcrumbs: {
// maxBreadcrumbs: 20, // Maximum breadcrumbs to store (default: 15)
// trackFetch: true, // Track fetch/XHR requests (default: true)
// trackNavigation: true, // Track navigation events (default: true)
// trackClicks: true, // Track UI clicks (default: true)
// beforeBreadcrumb: (breadcrumb, hint) => {
// // Filter or modify breadcrumbs before storing
// if (breadcrumb.category === 'fetch' && breadcrumb.data?.url?.includes('/sensitive')) {
// return false; // Discard this breadcrumb
// }
// return breadcrumb;
// }
// }
});
</script>
</body>
</html>