WeTransfer / Diagnostics

Allow users to easily share Diagnostics with your support team to improve the flow of fixing bugs.
MIT License
953 stars 55 forks source link

Only Include Subset of Logs #66

Closed mergesort closed 4 years ago

mergesort commented 4 years ago

Hi there, loving using the library, but had a question about how to provide less data. Every time a user sends me their diagnostics, they're sending me diagnostics for every session they've ever had. This makes parsing the report cumbersome and unnecessarily large.

I was wondering if it'd be possible to have an option to receive only the last N session logs, via some sort of API in Diagnostics.

Thanks a lot!

AvdLee commented 4 years ago

@mergesort understandable request! It should be easy to built-in. Feel free to open a PR if you like!

alexiscreuzot commented 4 years ago

DiagnosticsLogger

Current state

Right now we can see in DiagnosticsLogger.swift that the size of logs can go up to 2MB, which is quite huge for most projects.

private let maximumSize: ByteCountFormatter.Units.Bytes = 2 * 1024 * 1024 // 2 MB`

Proposition

Being able to edit that value would be interesting, by making it public var.

public var maximumSize: ByteCountFormatter.Units.Bytes = 2 * 1024 * 1024 // 2 MB`

LogsReporter

Current state

In LogsReporter.swift, we do have the sessions handling :

let sessions = logs.addingHTMLEncoding().components(separatedBy: "\n\n---\n\n")
return sessions.reversed().joined(separator: "\n\n---\n\n")

Proposition

Adding something like public var maximumSessionNumber would be a good way to also avoid having to dig in heaps of data.

public var maximumSessionNumber: Int = 100
// ...
return sessions.reversed().prefix(maximumSessionNumber).joined(separator: "\n\n---\n\n")
AvdLee commented 4 years ago

@kirualex both changes make total sense to me. Would you be willing to create a PR with that, including a readme update for both properties?

github-actions[bot] commented 4 years ago

This issue is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.