-
Notifications
You must be signed in to change notification settings - Fork 0
/
rageshake.js
322 lines (302 loc) · 15.9 KB
/
rageshake.js
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
test_1 = {
"id": "2023-03-23/114756-SI2J4XWZ",
"user_text": "Sample",
"app": "schildichat-android",
"data": {
"User-Agent": "SchildiChat dbg/1.5.26.sc64 (Google sdk_gphone64_x86_64; Android 13; sdk_gphone64_x86_64-userdebug 13 TPB4.220624.004 8808248 dev-keys; Flavour FDroid; MatrixAndroidSdk2 1.5.28)",
"Version": "1.5.26.sc64 [40101040] (F-5bbd462c-2023-03-12 14:20:47 +0100)",
"app_language": "en_US",
"branch_name": "sc",
"can_contact": "true",
"default_app_language": "en_US",
"device": "sdk_gphone64_x86_64",
"device_density": "2.625",
"device_height_dp": "920.7619",
"device_height_px": "2417",
"device_id": "CBSRAONTCW",
"device_width_dp": "437.33334",
"device_width_px": "1148",
"enabledDebugSettings": "",
"experimentalSettingsDisabled": "",
"experimentalSettingsEnabled": "SETTINGS_LABS_DEFERRED_DM_KEY",
"is_debug_build": "true",
"locale": "en_US",
"matrix_sdk_version": "1.5.28 (5bbd462c)",
"multi_window": "OFF",
"olm_version": "3.2.12 - olm version (3.2.11) - 92769ce-2022-05-30 13:55:34 -0400",
"os": "13 (API 33) 8808248-REL",
"packageName": "de.spiritcroc.riotx.debug",
"reportTime": "2023-03-23 12:47:55 +0100",
"server_version": "Synapse - 1.79.0",
"theme": "sc_light",
"unifiedpush_distributor_name": "Background synchronization",
"unifiedpush_endpoint": "null",
"unifiedpush_is_embedded_distributor": "false",
"user_id": "@spiritbot:spiritcroc.de",
"verbose_log": "OFF"
},
"labels": [
"1.5.26.sc64",
"FDroid",
"sc",
"debug_build",
"unifiedpush:none",
"hs:spiritcroc.de",
"mxid:@spiritbot:spiritcroc.de",
"debug"
],
"logs": [
"logcat.log.gz",
"logs.0.txt.gz",
"logs.1.txt.gz",
"logs.2.txt.gz",
"logs.3.txt.gz",
"logs.4.txt.gz",
"logs.5.txt.gz",
"logs.6.txt.gz"
],
"logErrors": null,
"files": null,
"fileErrors": null,
"report_url": "https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/968",
"listing_url": "https://s2.spiritcroc.de/api/listing/2023-03-23/114756-SI2J4XWZ"
};
test_2 = {
"id": "2023-03-23/134806-C7B7MK37",
"user_text": "<h1>formatted test</h1>",
"app": "schildichat-android",
"data": {
"User-Agent": "SchildiChat dbg/1.5.26.sc64 (Google sdk_gphone64_x86_64; Android 13; sdk_gphone64_x86_64-userdebug 13 TPB4.220624.004 8808248 dev-keys; Flavour FDroid; MatrixAndroidSdk2 1.5.28)",
"Version": "1.5.26.sc64 [40101040] (F-5bbd462c-2023-03-12 14:20:47 +0100)",
"app_language": "en_US",
"branch_name": "sc",
"can_contact": "false",
"default_app_language": "en_US",
"device": "sdk_gphone64_x86_64",
"device_density": "2.625",
"device_height_dp": "920.7619",
"device_height_px": "2417",
"device_id": "CBSRAONTCW",
"device_width_dp": "437.33334",
"device_width_px": "1148",
"enabledDebugSettings": "",
"experimentalSettingsDisabled": "",
"experimentalSettingsEnabled": "SETTINGS_LABS_DEFERRED_DM_KEY",
"is_debug_build": "true",
"locale": "en_US",
"matrix_sdk_version": "1.5.28 (5bbd462c)",
"multi_window": "OFF",
"olm_version": "3.2.12 - olm version (3.2.11) - 92769ce-2022-05-30 13:55:34 -0400",
"os": "13 (API 33) 8808248-REL",
"packageName": "de.spiritcroc.riotx.debug",
"reportTime": "2023-03-23 14:48:05 +0100",
"server_version": "Synapse - 1.79.0",
"theme": "sc_light",
"unifiedpush_distributor_name": "Background synchronization",
"unifiedpush_endpoint": "null",
"unifiedpush_is_embedded_distributor": "false",
"user_id": "@spiritbot:spiritcroc.de",
"verbose_log": "OFF"
},
"labels": [
"1.5.26.sc64",
"FDroid",
"sc",
"debug_build",
"unifiedpush:none",
"hs:spiritcroc.de",
"mxid:@spiritbot:spiritcroc.de",
"debug"
],
"logs": null,
"logErrors": null,
"files": null,
"fileErrors": null,
"report_url": "https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/969",
"listing_url": "https://s2.spiritcroc.de/api/listing/2023-03-23/134806-C7B7MK37"
};
test_3 = {
"id": "2023-03-23/140855-RFSUIA2D",
"user_text": "crash test 2\n\n\n\n--------------------------------- crash call stack ---------------------------------\nElement Build : 40101040\nElement Version : 1.5.26.sc64 [40101040] (F-5bbd462c-2023-03-12 14:20:47 +0100)\nSDK Version : 1.5.28 (5bbd462c)\nPhone : sdk_gphone64_x86_64 (8808248 13 REL)\nMemory statuses \nusedSize 136 MB\nfreeSize 4 MB\ntotalSize 141 MB\nThread: main, Exception: java.lang.RuntimeException: TEST\n\tat im.vector.app.features.home.room.detail.composer.PlainTextComposerLayout.expand(PlainTextComposerLayout.kt:144)\n\tat im.vector.app.features.home.room.detail.composer.PlainTextComposerLayout.renderSpecialMode(PlainTextComposerLayout.kt:236)\n\tat im.vector.app.features.home.room.detail.composer.PlainTextComposerLayout.renderComposerMode(PlainTextComposerLayout.kt:154)\n\tat im.vector.app.features.home.room.detail.composer.MessageComposerFragment.renderSpecialMode(MessageComposerFragment.kt:466)\n\tat im.vector.app.features.home.room.detail.composer.MessageComposerFragment.access$renderSpecialMode(MessageComposerFragment.kt:113)\n\tat im.vector.app.features.home.room.detail.composer.MessageComposerFragment$onViewCreated$6.invokeSuspend(MessageComposerFragment.kt:229)\n\tat im.vector.app.features.home.room.detail.composer.MessageComposerFragment$onViewCreated$6.invoke(Unknown Source:13)\n\tat im.vector.app.features.home.room.detail.composer.MessageComposerFragment$onViewCreated$6.invoke(Unknown Source:6)\n\tat com.airbnb.mvrx.MavericksViewModelExtensionsKt$_internal2$2.invokeSuspend(MavericksViewModelExtensions.kt:41)\n\tat com.airbnb.mvrx.MavericksViewModelExtensionsKt$_internal2$2.invoke(Unknown Source:8)\n\tat com.airbnb.mvrx.MavericksViewModelExtensionsKt$_internal2$2.invoke(Unknown Source:4)\n\tat kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(Merge.kt:214)\n\tat kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Unknown Source:13)\n\tat kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Unknown Source:4)\n\tat kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:34)\n\tat kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:8)\n\tat kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Unknown Source:4)\n\tat kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)\n\tat kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)\n\tat kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)\n\tat kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)\n\tat kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)\n\tat kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)\n\tat kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)\n\tat kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:33)\n\tat kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)\n\tat kotlinx.coroutines.flow.internal.SafeCollectorKt$emitFun$1.invoke(SafeCollector.kt:15)\n\tat kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:87)\n\tat kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:66)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$transform$1.invokeSuspend(MavericksLifecycleAwareFlow.kt:36)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$transform$1.invoke(Unknown Source:13)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$transform$1.invoke(Unknown Source:10)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$1$4.invokeSuspend(MavericksLifecycleAwareFlow.kt:56)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$1$4.invoke(Unknown Source:8)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$1$4.invoke(Unknown Source:2)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$invokeSuspend$lambda-2$$inlined$onReceive$2.invokeSuspend(MavericksLifecycleAwareFlow.kt:94)\n\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)\n\tat kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)\n\tat kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)\n\tat kotlinx.coroutines.channels.AbstractChannel$ReceiveSelect.completeResumeReceive(AbstractChannel.kt:979)\n\tat kotlinx.coroutines.channels.AbstractSendChannel.offerInternal(AbstractChannel.kt:56)\n\tat kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:134)\n\tat kotlinx.coroutines.channels.ChannelCoroutine.send(Unknown Source:2)\n\tat com.airbnb.mvrx.MavericksLifecycleAwareFlowKt$flowWhenStarted$1$1$flowChannel$1$1.emit(MavericksLifecycleAwareFlow.kt:32)\n\tat kotlinx.coroutines.flow.DistinctFlowImpl$collect$2.emit(Distinct.kt:81)\n\tat com.airbnb.mvrx.MavericksViewModelExtensionsKt$_internal2$$inlined$map$1$2.emit(Emitters.kt:224)\n\tat kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)\n\tat kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)\n\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)\n\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)\n\tat android.os.Handler.handleCallback(Handler.java:942)\n\tat android.os.Handler.dispatchMessage(Handler.java:99)\n\tat android.os.Looper.loopOnce(Looper.java:201)\n\tat android.os.Looper.loop(Looper.java:288)\n\tat android.app.ActivityThread.main(ActivityThread.java:7898)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)\n\tSuppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@cd684af, Dispatchers.Main.immediate]\n",
"app": "schildichat-android",
"data": {
"User-Agent": "SchildiChat dbg/1.5.26.sc64 (Google sdk_gphone64_x86_64; Android 13; sdk_gphone64_x86_64-userdebug 13 TPB4.220624.004 8808248 dev-keys; Flavour FDroid; MatrixAndroidSdk2 1.5.28)",
"Version": "1.5.26.sc64 [40101040] (F-5bbd462c-2023-03-12 14:20:47 +0100)",
"app_language": "en_US",
"branch_name": "sc",
"can_contact": "false",
"default_app_language": "en_US",
"device": "sdk_gphone64_x86_64",
"device_density": "2.625",
"device_height_dp": "920.7619",
"device_height_px": "2417",
"device_id": "CBSRAONTCW",
"device_width_dp": "437.33334",
"device_width_px": "1148",
"enabledDebugSettings": "",
"experimentalSettingsDisabled": "",
"experimentalSettingsEnabled": "SETTINGS_LABS_DEFERRED_DM_KEY",
"is_debug_build": "true",
"locale": "en_US",
"matrix_sdk_version": "1.5.28 (5bbd462c)",
"multi_window": "OFF",
"olm_version": "3.2.12 - olm version (3.2.11) - 92769ce-2022-05-30 13:55:34 -0400",
"os": "13 (API 33) 8808248-REL",
"packageName": "de.spiritcroc.riotx.debug",
"reportTime": "2023-03-23 15:08:54 +0100",
"server_version": "Synapse - 1.79.0",
"theme": "sc_light",
"unifiedpush_distributor_name": "Background synchronization",
"unifiedpush_endpoint": "null",
"unifiedpush_is_embedded_distributor": "false",
"user_id": "@spiritbot:spiritcroc.de",
"verbose_log": "OFF"
},
"labels": [
"1.5.26.sc64",
"FDroid",
"sc",
"debug_build",
"unifiedpush:none",
"hs:spiritcroc.de",
"mxid:@spiritbot:spiritcroc.de",
"debug",
"crash"
],
"logs": [
"crash.log.gz",
"logcat.log.gz",
"logs.0.txt.gz",
"logs.1.txt.gz",
"logs.2.txt.gz",
"logs.3.txt.gz",
"logs.4.txt.gz",
"logs.5.txt.gz",
"logs.6.txt.gz"
],
"logErrors": null,
"files": null,
"fileErrors": null,
"report_url": "https://github.com/SchildiChat/SchildiChat-android-rageshakes/issues/971",
"listing_url": "https://s2.spiritcroc.de/api/listing/2023-03-23/140855-RFSUIA2D"
};
test_x1 = {
"id": "2023-09-27/093003-YPDKCZZC",
"user_text": "aaaaaaaaaaaa",
"app": "schildichat-android-next",
"data": {
"User-Agent": "SchildiNext dbg/0.2.2.sc1 (OnePlus ONEPLUS A5000; Android 13; TQ3A.230705.001; Sdk TODO)",
"can_contact": "false",
"device": "ONEPLUS A5000",
"device_id": "ZXHJFDGLOG",
"locale": "en_DE",
"multi_window": "OFF",
"olm_version": "undefined",
"server_version": "",
"user_id": "@spiritcroc:matrix.org"
},
"labels": [
"0.2.2.sc1"
],
"logs": [
"logcat.log.gz"
],
"logErrors": null,
"files": null,
"fileErrors": null,
"report_url": "https://github.com/SchildiChat/schildinext-rageshakes/issues/2",
"listing_url": "https://rageshake.spiritcroc.de/api/listing/2023-09-27/093003-YPDKCZZC"
};
require('fs').writeFile("test.html", "", (err) => { if (err) throw err; });
[test_1, test_2, test_3, test_x1].forEach(data => {
// HEADER END
// https://stackoverflow.com/a/66481918
function escapeHTML(unsafe) {
if (!unsafe) {
return "";
}
return unsafe.replace(
/[\u0000-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u00FF]/g,
c => '&#' + ('000' + c.charCodeAt(0)).slice(-4) + ';'
)
}
plain_user = data.data.user_id;
if (data.data.can_contact != "true") {
// Make unclickable and gray
plain_user = plain_user.replace(":", "/");
html_user = escapeHTML(plain_user) + ": ";
html_user = '<font color="#808080">' + html_user.replace(":", "/") + "</font>";
} else {
html_user = escapeHTML(plain_user) + ": ";
}
// If contains for newlines, omit that (could be huge stack trace)
plain = plain_user + ": " + data.user_text.replace(/\n\n\n\n.*/s, ' [...]');
html = html_user + data.user_text.replace(/\n\n\n\n(.*)/s, '');
if (data.user_text.includes("\n\n\n\n")) {
html += "<br/>" + data.user_text.replace(/.*\n\n\n\n(.*)/s, ' <details><summary>[...]</summary><pre><code>$1</code></pre></details>');
}
/*
if (data.data.is_debug_build == "true") {
html = '<font color="#00ffff">' + html + "</font>";
}
*/
function appendValue(key, value = undefined, html_value = undefined, omitIfEmpty = false) {
if (value === undefined) {
value = Reflect.get(data.data, key);
}
if (omitIfEmpty && !value) {
return;
}
if (html_value === undefined) {
html_value = "<code>" + escapeHTML(value) + "</code>";
}
if (key === undefined) {
key = "";
} else {
key += ": ";
}
//html += "<li>" + key + html_value + "</li>\n";
html += key + html_value + "<br/>\n";
plain += key + value + "\n";
}
//html += "\n<ul>\n";
html += "<hr/>";
plain += "\n\n";
//appendValue("Version");
labels = data.labels.filter(label =>
!label.startsWith("mxid:") &&
!label.startsWith("hs:")
).join(", ") + " | " + data.app;
appendValue(undefined, labels);
appendValue("os", undefined, undefined, true);
//appendValue("can_contact");
issue_name = data.report_url.replace(new RegExp(".*issues/"), '#');
if (issue_name == data.report_url) {
issue_name = "Report";
}
html += '<a href="' + escapeHTML(data.report_url) + '">' + escapeHTML(issue_name) + "</a><br/>";
if (data.logs) {
log_count = data.logs.length;
} else {
log_count = 0;
}
//appendValue("logs", log_count, '<a href="' + data.listing_url + '">' + log_count + "</a>");
plain += log_count + " logs\n";
html += '<a href="' + escapeHTML(data.listing_url) + '">' + log_count + " logs</a>";
//html += "\n</ul>\n";
plain += "\n\n";
html += "\n<p><details><summary>Raw data</summary><pre><code class=\"language-json\">" +
JSON.stringify(data, null, 2) +
"</code></pre></details>";
result = {
"version": "v2",
"empty": false,
"plain": plain,
"html": html,
//"msgtype": "m.notice",
"msgtype": "m.text",
}
// FOOTER START
console.log(result);
require('fs').appendFile("test.html", html, (err) => { if (err) throw err; });
});