Giter Site home page Giter Site logo

square / aardvark Goto Github PK

View Code? Open in Web Editor NEW
257.0 23.0 49.0 10.22 MB

Aardvark is a library that makes it dead simple to create actionable bug reports.

License: Apache License 2.0

Ruby 0.83% Objective-C 76.89% Swift 20.89% C 1.39%
ios bug-reporting logging

aardvark's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aardvark's Issues

Flakey test

-[ARKLogDistributorTests test_distributeAllPendingLogsWithCompletionHandler_informsLogObserversOfAllPendingLogs] failed once in CI. Specifically XCTAssertEqual([ARKLogDistributor defaultDistributor].internalQueueOperationCount, 0); failed because [ARKLogDistributor defaultDistributor].internalQueueOperationCount == 1 when that line ran. Likely due to parallelization of tests. Need to investigate

Provide a mechanism for surfacing highlights from attachments

This stems from a desire to have bug reporters (in particular the ARKEmailBugReporter) treat the log store as just another attachment, rather than special casing it. Currently the only major behavioral difference between the log stores and the other attachments is that the reporter pulls the recent errors out of the logs and surfaces them at the top level. This is vital behavior in the case where attachments aren't available, but it's also very useful when there are attachments to provide a quick hint as to what the problem might be before digging into each attachment.

I think it would be fairly straightforward to introduce a highlightsSummary property (exact naming TBD) to ARKBugReportAttachment so that any attachment could optionally surface highlights at the top level. This would also unblock making the log store be a regular attachment, since the recent error logic could be easily moved to the LogStoreAttachmentGenerator.

Error against building with iOS 9

ARKDataArchive.m:41:17: Method override for the designated initializer of the superclass '-init' not found.

I fixed it locally by removing NS_DESIGNATED_INITIALIZER on ARKDataArchive.h:28

Non-existent path referenced in podspec

The AardvarkLoggingUI podspec has a source file pattern that matches Swift code however the pod is Objective-C only.

  s.source_files = 'Sources/AardvarkLoggingUI/**/*.{h,m,swift}'

Remove dependency between including screenshot and log store

Currently, screenshots are included in bug reports by adding them to a log message. This means that if you don't include a log store in a bug report (either by having the emailAttachmentAdditionsDelegate filter it out or the promptingDelegate removing it from the configuration), the screenshot taken when filing the bug report will not be attached to the email.

Remove dependency between view hierarchy description and screenshot

Currently, the view hierarchy description can only be included when a screenshot is also included.

/// If this bug report includes a screenshot, also attach a description of the view hierarchy. Defaults to YES.
@property (nonatomic) BOOL attachesViewHierarchyDescriptionWithScreenshot;

This dependency is unnecessary and should be removed.

ARK_writeDataBlock uses deprecated writeData that throws Exception

There are several calls to NSFileHandle's writeData inNSFileHandle+ARKAdditions.m which is deprecated.

API_DEPRECATED_WITH_REPLACEMENT("writeData:error:",
                                    macos(10.0, API_TO_BE_DEPRECATED), ios(2.0, API_TO_BE_DEPRECATED),
                                    watchos(2.0, API_TO_BE_DEPRECATED), tvos(9.0, API_TO_BE_DEPRECATED));

The problem here is that this old method will raise an exception in case of an error, especially if the device runs out of disk space:

If the receiver is a file, writing takes place at the file pointer’s current position. After it writes the data, the method advances the file pointer by the number of bytes written. **This method raises an exception if the file descriptor is closed or is not valid, if the receiver represents an unconnected pipe or socket endpoint, if no free space is left on the file system, or if any other writing error occurs.

Using the newer writeData:error: selector would return an error instead of causing an exception.

Logging before the default log store is accessed results in dropped messages

The default log store get lazily created the first time you access the defaultLogStore property. If you follow the one-line setup approach, this happens immediately since we access the default log store in order to create the bug reporter. If you don't use this setup, however, instead opting to create the bug reporter later, calling log(...) will send the message nowhere (or really will send the message to other log observers you've added, but not the default log store).

I think the expected behavior would be to create the default log store the first time log(...) is called if it doesn't already exist.

Swift Package Manager support?

I want my iOS guys to start using this but all our dependencies are SPM. It would be rad if this was also available via Swift Package Manager. πŸ™

Decompose Aardvark into smaller modules

Aardvark currently has a lot of responsibilities - adding log messages, viewing those log messages in the app, generating data for a bug report, and sending that bug report via email. Breaking it down into smaller modules unlocks a couple of distinct advantages:

  • Support including only necessary portions of the bug reporting system based on build configuration. In particular, consumers should be able to include the core parts of the bug reporting functionality (taking a screenshot, generating attachments, etc.) without including the mail dialogs. By modularizing the core components of generating a bug report, we can make it easier to generate more customizable bug reporting workflows, while still supporting the simple-setup case with the existing email bug reporter.
  • Improve extensibility for future additions. In particular, I think there is a lot of power in being able to extend the variety of attachments that can be generated and included in a bug reported, as well as the ways in which that bug report can be shared.

The disadvantage comes in the form of a few extra sets in setting up the dependencies (since there are now more dependencies) and discoverability of new features (since they may be in a not-yet-imported module), but I think these are greatly outweighed by the advantages.

The current frameworks (Aardvark and CoreAardvark) will be broken down into four separate frameworks based on functionality. Frameworks related to the logging functionality with be prefixed with "CoreAardvark" (where CoreAardvark itself is the core logging framework) and frameworks related to the bug reporting functionality will be prefixed with "Aardvark" (where Aardvark itself is the core bug reporting framework). This gives us:

  • CoreAardvark - Core log message distribution and storage functionality. This has no dependencies and can be run in app extensions (no change from the current framework).
  • CoreAardvarkLoggingUI - User interfaces to view log messages inside an app.
  • Aardvark - Core bug reporting functionality. This will include the informational pieces of bug reporting, such as generating a screenshot and view hierarchy description.
  • AardvarkMailUI - User interfaces to submit a bug report via the Mail app.

This provides us with a solid foundation to build out new logging and bug reporting functionality in a modular fashion on top of the two core frameworks, CoreAardvark and Aardvark.

In the interest of making the addition of new bug reporting flows simpler, I think we should keep the bug report "attachment" concept in the main Aardvark framework. Since it isn't inherently tied to the mail concepts right now, the only change to the class will be a rename from ARKEmailAttachment to ARKBugReportAttachment.

We can then begin to add new modules over time, which will generally fall into one of the following categories for most cases:

  • Attachment vendors - Frameworks that provide additional data that can be attached to a bug report.
  • Bug reporting workflows - Frameworks that provide alternate ways to file a bug report. For example, #47 mentions using the Gmail SDK to provide an alternate mail client to the built-in mail dialog. This could be provided as an alternate bug reporter podspec that has a dependency on that SDK. Similarly, we could introduce new bug reporters that connect directly to various services' APIs, for instance to create a new issue on GitHub.

With this, the frameworks will be broken down into small components and restructured as follows:

Current Proposed
Log methods (Aardvark.log(), ARKLog(), ARKLogWithType()) CoreAardvark CoreAardvark
Log message primitives (ARKLogMessage, ARKLogType) CoreAardvark CoreAardvark
Log storage (ARKLogStore, ARKDataArchive, file management utilities) CoreAardvark CoreAardvark
Log distribution (ARKLogDistributor, ARKLogObserver) CoreAardvark CoreAardvark
Exception logging (ARKExceptionLogging) CoreAardvark CoreAardvark
Log formatting (ARKLogFormatter, ARKDefaultLogFormatter Aardvark CoreAardvark
In-app log viewing (view controllers and sharing utilities) Aardvark CoreAardvarkLoggingUI
Screenshot logging (ARKLogScreenshot() and distributor additions) Aardvark Aardvark
Bug reporter protocol (ARKBugReporter) Aardvark Aardvark
Bug report attachments (ARKBugReportAttachment) Aardvark Aardvark
Convenience method to add (generic) bug reporter via gesture Aardvark Aardvark
Email bug reporter (ARKEmailBugReporter, ARKEmailBugReportConfiguration) Aardvark AardvarkMailUI
Convenience method to add email bug reporter via gesture Aardvark AardvarkMailUI

defaultLogStore should have a maximumLogMessageCount set

Currently if you follow the README and use Aardvark.addDefaultBugReportingGestureWithEmailBugReporter() to setup Aardvark you will get an unlimited amount of logs stored to disk. After a while that adds up to a lot of disk and will cause issues. I think it'd be reasonable for defaultLogStore to have maximumLogMessageCount set to a reasonable value (5,000?) to prevent this.

Reenable log distribution performance test

ARKLogDistributorTests.test_logDistribution_performance() was disabled in #80 since it was observed to be flaky on CI builds. Specifically, the tearDown method was timing out while trying to clear the log store after running the test. I could never reproduce this failure locally, and attempts to increase the timeout did not resolve this issue.

We should investigate why this was flaking and reenable the test once we have a fix.

Add persisted parameters to log messages

Currently, persisted log messages contain a date, text, type, and optionally an image. The ARKLogMessage class also has a userInfo dictionary that contains contextual information for log observers, but this is not persisted.

We should add a parameters dictionary used to store consumer-defined key/value pairs that don't have their own properties. Unlike the userInfo, this dictionary will be persisted. This makes it possible to store richer log messages without having to parse the textualized message later.

The ARKDefaultLogFormatter should also be updated to include these parameters in its formatting, e.g.:

Log message
 - key1: value1
 - key2: value2

iOS 9 : can trigger composeBug only once per session

Steps: (I used aardvark sample app)

  • Run aarvark against any iOS 9 device
  • Two finder long tap to trigger a bug report
  • after coming back to the app try and trigger another bug report by a long 2 finger tap.
    Notice that the Compose report code is never called.

Things work again after restart

iOS 9 Crash: -[ARKLogDistributor logScreenshot]

Hit this crash last night on iOS 9 while trying to file a bug:

Thread : Fatal Exception: CALayerInvalidGeometry – sublayer with non-finite position [inf inf]
0  CoreFoundation                 0x00000001826dcf5c __exceptionPreprocess
1  libobjc.A.dylib                0x00000001972cff80 objc_exception_throw
2  CoreFoundation                 0x00000001826dcea4 -[NSException initWithCoder:]
3  QuartzCore                     0x0000000187481a94 -[CALayer _renderSublayersInContext:]
4  QuartzCore                     0x0000000187480ac0 -[CALayer renderInContext:]
5  QuartzCore                     0x0000000187481a60 -[CALayer _renderSublayersInContext:]
6  QuartzCore                     0x0000000187480ac0 -[CALayer renderInContext:]
7  QuartzCore                     0x0000000187481a60 -[CALayer _renderSublayersInContext:]
8  QuartzCore                     0x0000000187480ac0 -[CALayer renderInContext:]
9  QuartzCore                     0x0000000187481a60 -[CALayer _renderSublayersInContext:]
10 QuartzCore                     0x0000000187480ac0 -[CALayer renderInContext:]
11 QuartzCore                     0x0000000187481a60 -[CALayer _renderSublayersInContext:]
12 QuartzCore                     0x0000000187480ac0 -[CALayer renderInContext:]
13 Cash                           0x00000001002d7b8c -[ARKLogDistributor logScreenshot] (ARKLogDistributor.m:249)
14 Cash                           0x00000001002dc8d4 ARKLogScreenshot (Aardvark.m:49)
15 Cash                           0x00000001002d2f48 -[ARKEmailBugReporter composeBugReport] (ARKEmailBugReporter.m:100)
16 Cash                           0x00000001002dde24 -[UIApplication(ARKAdditions) _ARK_didFireBugReportGestureRecognizer:] (UIApplication+ARKAdditions.m:105)
17 UIKit                          0x000000018818bb28 _UIGestureRecognizerSendTargetActions
18 UIKit                          0x0000000187dd2a5c _UIGestureRecognizerSendActions
19 UIKit                          0x0000000187c656ac -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
20 UIKit                          0x000000018818ce78 ___UIGestureRecognizerUpdate_block_invoke809
21 UIKit                          0x0000000187c25118 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks
22 UIKit                          0x0000000187c231ec _UIGestureRecognizerUpdate
23 CoreFoundation                 0x0000000182693c30 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
24 CoreFoundation                 0x00000001826919d4 __CFRunLoopDoObservers
25 CoreFoundation                 0x0000000182691e04 __CFRunLoopRun
26 CoreFoundation                 0x00000001825c0dc0 CFRunLoopRunSpecific
27 GraphicsServices               0x000000018d714088 GSEventRunModal
28 UIKit                          0x0000000187c9af60 UIApplicationMain
29 Cash                           0x00000001002c3d80 main (main.mm:28)
30 libdyld.dylib                  0x0000000197afa8b8 start

Likely a layout bug in the app or iOS 9 – a layer with an infinite size is odd, to say the least. Looking into this today. Plan is to try/catch logging the screenshot so we don't crash on bug-file. I'll also look into whether there are other screen capture mechanisms we could use (short of requiring camera roll access).

This crash was reliably reproducible on one screen in my app. Was not reproducible in other screens.

Xcode 12 Support

Xcode 12 drops support for iOS 8. Release a new version that targets iOS 9+.

From the Xcode 12 Beta Release Notes:

Xcode 12 beta 5 includes SDKs for iOS 14, iPadOS 14, tvOS 14, watchOS 7, and macOS 11. The Xcode 12 beta 5 release supports on-device debugging for iOS 9 and later, tvOS 9 and later, and watchOS 2 and later. Xcode 12 beta 5 requires Apple silicon running macOS Big Sur 11 beta or later, or an Intel-based Mac running macOS Catalina 10.15.4 or later.

Add API to customize the persistedLogFileURL of ARKLogStore's ARKDataArchive

In Aardvark 2, persistedLogFileURL was a public API on ARKLogStore which allowed subclasses to override things and redirect logs to a custom destination, e.g. outside of app support or to a subfolder of app support

In Aardvark 3, persistedLogFileURL was made internal to ARKLogStore which means that subclasses need to redeclare private properties and make a new ARKDataArchive in order to continue to redirect logs

It would be great if Aardvark had an initializer or other API that allowed for the log file path to be customized without the need to subclass things!

Add delegate for adding/modifying attachments on bug report emails

Similar to the ARKEmailBugReporterEmailBodyAdditionsDelegate, we should add an ARKEmailBugReporterEmailAttachmentsDelegate that allows additions/filtering of attached files. This makes it possible to include more app-specific data to bug reports and to filter out default attachments based on context.

Carthage fails to archive project

macOs Big Sur 11.4
Xcode 12.5 (Intel)
Aardvark/4.0.0

Carthage/Checkouts/Aardvark/Sources/CoreAardvark/Logging/ARKExceptionLogging.m:36:52: error: this old-style function definition is not preceded by a prototype [-Werror,-Wstrict-prototypes] NSLock * ARKGetUncaughtExceptionLogDistributorsLock()

Carthage-aardvark.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.