text: //
  //  POSHockeyAppTracker.h
  //  POSHockeyAppExtension
  //
  //  Created by Pavel Osipov on 04.07.16.
  //  Copyright © 2016 Pavel Osipov. All rights reserved.
  //
  
  #import <CrashReporter/CrashReporter.h>
  
  NS_ASSUME_NONNULL_BEGIN
  
  @class BITCrashManager;
  
  /// Builds network request to HockeyApp Web service.
  @protocol POSHockeyAppTracker <NSObject>
  
  ///
  /// @brief        Path to a directory to backup pending crash logs.
  ///
  /// @discussion   Setup nonnull path to a folder if you want guaranted crash logs delivery.
  ///               It will be used for storing crash logs if HockeyApp service is
  ///               unavailable (for example, device now is worling in airplane mode).
  ///               Use sendPendingCrashLogs to deliver them all.
  ///
  @property (nonatomic, nullable) NSString *backupDirectoryPath;
  
  ///
  /// @brief        Sends pending crash logs from backup directory or does nothing
  ///               if backupDirectoryPath property is nil.
  ///
  - (void)sendPendingCrashReports;
  
  ///
  /// @brief        Sends event to HockeyApp service with autogenerated crash report.
  ///
  /// @discussion   Methods generates report by itself. The downside of this method is that
  ///               all reports on the HockeyApp dashboard will have the same call stack and
  ///               that is why they will be groupped by HockeyApp in the same crash group.
  ///               At the same time they can be distinguished by app traces, so may be it is
  ///               exactly what you want.
  ///
  /// @param        error Optional error out parameter which will contain possible error of live
  ///                     crash report generation.
  ///
  - (BOOL)sendLiveCrashReport:(NSError **)error;
  
  ///
  /// @brief        Sends event to HockeyApp service with autogenerated crash report
  ///               and prepends any string you want to application logs.
  ///
  /// @discussion   Method generates report as sendLiveCrashReport: does. The only difference
  ///               that you can add some human readable string which describes the context
  ///               of the event. @see sendLiveCrashReport: for more info.
  ///
  /// @param        payload Any string you want which you'll see on the "Description" tab on the
  ///                       page with crash log details.
  /// @param        error   Optional error parameter which will contain possible error of live
  ///                       crash report generation.
  ///
  - (BOOL)sendLiveCrashReportWithPayload:(nullable NSString *)payload
                                   error:(NSError **)error;
  
  ///
  /// @brief        Sends event to HockeyApp service with user-generated report.
  ///
  /// @discussion   Method takes result of one of "generateLiveReport" methods of BITPLCrashReporter.
  ///               Althought this method requires some work on the client side, it makes it possible
  ///               to build reports with different call stacks which will be groupped in different
  ///               crash groups on the HockeyApp dashboard.
  ///               Look at PLCrashReporter.h header for all available methods. You can find it in
  ///               CrashReporter framework embedded in the HockeyApp SDK.
  ///
  /// @param        report Mandatory crash report generated by BITPLCrashReporter.
  ///
  - (BOOL)sendCrashReport:(NSData *)report
                    error:(NSError **)error;
  
  ///
  /// @brief        Sends event to HockeyApp service with user-generated report
  ///               and prepends any string you want to application logs.
  ///
  /// @discussion   Method takes result of one of "generateLiveReport" methods of BITPLCrashReporter
  ///               and extends application logs attribute with payload. @see sendCrashReport:
  ///               for more info about pros and cons of this method.
  ///
  /// @param        report  Mandatory crash report generated by BITPLCrashReporter.
  /// @param        payload Optional human readable string which describes the context of the event.
  ///                       It will be found under "Description" tab on the crash log details page.
  ///
  - (BOOL)sendCrashReport:(NSData *)report
              withPayload:(nullable NSString *)payload
                    error:(NSError **)error;
  
  ///
  /// @brief        Sends event to HockeyApp service with user-generated report
  ///               and prepends formatted string to application logs.
  ///
  /// @discussion   Method takes result of one of "generateLiveReport" methods of BITPLCrashReporter
  ///               and extends application logs attribute with payload. @see sendCrashReport:
  ///               for more info about pros and cons of this method.
  ///
  /// @param        report  Mandatory crash report generated by BITPLCrashReporter.
  /// @param        payload Optional human readable string which describes the context of the event.
  ///                       It will be found under "Description" tab on the crash log details page.
  ///
  - (void)fireAssertReport:(NSData *)report withPayload:(NSString *)payload, ...;
  
  @end
  
  /// Default implementation for POSHockeyAppRequestBuilder protocol.
  @interface POSHockeyAppTracker : NSObject <POSHockeyAppTracker>
  
  ///
  /// @brief        The designated initializer.
  ///
  /// @param        crashManager Configured instance of BITCrashManager.
  ///                            Be sure that you have called its configure method before.
  ///
  /// @return       Instance of POSHockeyAppRequestBuilder.
  ///
  - (instancetype)initWithCrashManager:(BITCrashManager *)crashManager;
  
  // Hidden deadly initializers.
  + (instancetype)new NS_UNAVAILABLE;
  - (instancetype)init NS_UNAVAILABLE;
  
  @end
  
  /// Sends report with specified description to HockeyApp service if condition is false.
  #define POS_TRACKABLE_ASSERT_EX(tracker, condition, description, ...) \
  do { \
      NSAssert((condition), description, ##__VA_ARGS__); \
      if (!(condition)) { \
          NSData *report = [[BITPLCrashReporter sharedReporter] generateLiveReportAndReturnError:nil]; \
          if (report) { \
              [tracker fireAssertReport:report withPayload:description, ##__VA_ARGS__]; \
          } \
      } \
  } while (0)
  
  /// Sends report to HockeyApp service if condition is false.
  #define POS_TRACKABLE_ASSERT(tracker, condition) \
          POS_TRACKABLE_ASSERT_EX(tracker, condition, ([NSString stringWithFormat:@"'%s' is false.", #condition]))
  
  NS_ASSUME_NONNULL_END
  