We checked for the presence of a matrix client but then went and
called a method on it assuming it existed on the line below, so,
don't do that.
https://github.com/vector-im/riot-web/issues/13624 pointed this out
This reports whether the device has touch input as a primary input mechanism in
rageshakes and analytics.
For analytics, this replaces the identity server (which ends up being reported
as "<redacted>" by default anyway) because Matomo only supports a limited number
of custom variables.
We use `export default` begrudgingly here. Ideally we'd use just `export`, though this entire SDK expects things to be exported as a default. Instead of breaking everything, we'll sacrifice our export pattern for a smaller diff - a later commit can always do the default export -> regular export conversion.
We had two different places in the code that were both trying to
limit to the MAX_LOG_SIZE and doing different things with it.
fetchLogs was keeping each individual file to MAX_LOG_SIZE but then
the outer loop was also discarding the whole file if it would make
the total exceed MAX_LOG_SIZE. This meant that if you ran your client
for a while then refreshed and sent a rageshake, the logic would
omit everything from before the refresh but make sure it included the
tiny amount of useless logging from after the refresh.
This will truncate large files if they would take the whole thing
over the size limit and still include part of them.
We left out later parts if we exceeded the maximum log size, which
was deeply unhelpful since the problem almost certainly happened
just before the user hit the 'submit debug logs' button.
Instead, iterate backwards through the fragments and prepend them,
leaving off the earlier ones if we run over the size.
Also, check we're not going to run over the size before adding
the fragment so we might actually stick to the maximum log size.
May fix https://github.com/vector-im/riot-web/issues/10951
Run the replace on the log line string instead of the separate
parts since we can ensure the line is a string.
Signed-off-by: Jason Robinson <jasonr@matrix.org>
If an individual log is larger than the max size, ignore the rest
of it. Also build the string as we go rather than joining it all
together at the end, that way we only need the whole string + one
chunk in memory at once, rather than the whole string x 2.