//
//  WS1PluginInterface.h
//  Crittercism
//
//  Created by Kieran Crawford on 3/1/21.
//  Copyright © 2021 VMware, Inc. All rights reserved.
//

#ifndef WS1PluginInterface_h
#define WS1PluginInterface_h

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, WS1PluginIdentifier) {
  WS1PluginIdentifierUnity = 0,
  WS1PluginIdentifierXamarin = 1,
  WS1PluginIdentifierCordova = 2,
  WS1PluginIdentifierFlutter = 3,
  WS1PluginIdentifierMax
};

void WS1Intelligence_LogHandledPluginException(const char *name,
                                               const char *reason,
                                               const char *stack,
                                               WS1PluginIdentifier pluginIdentifier);

void WS1Intelligence_LogUnhandledPluginException(const char *name,
                                                 const char *reason,
                                                 const char *stack,
                                                 WS1PluginIdentifier pluginIdentifier);


bool WS1Intelligence_LogNetworkRequest(const char *method,
                                       const char *url,
                                       double latency,
                                       int bytesRead,
                                       int bytesSent,
                                       int responseCode,
                                       int errorCode);

void WS1Intelligence_LeaveBreadcrumb(const char* breadcrumb);

void WS1Intelligence_SetAsyncBreadcrumbMode(bool writeAsync);

void WS1Intelligence_SetUsername(const char* username);

bool WS1Intelligence_GetOptOutStatus(void);

void WS1Intelligence_SetOptOutStatus(bool status);

bool WS1Intelligence_DidCrashOnLastLoad(void);

void WS1Intelligence_BeginUserFlow(const char* name);

void WS1Intelligence_CancelUserFlow(const char* name);

void WS1Intelligence_EndUserFlow(const char* name);

void WS1Intelligence_FailUserFlow(const char* name);

@interface WS1PluginInterface : NSObject

/*!
 * Plugin exceptions are a way of reporting exceptions from non-native
 * development platforms.
 * @param name NSString which identifies the name of the exception
 * @param reason NSString which gives the reason for the exception
 * @param stack NSString newline-separated stack trace for the exception
 * @param WS1PluginIdentifier NSUInteger enum which identifies the platform
 * @param handled Boolean value that indicates if the exception was handled (caught in code and logged) or unhandled
 */
+ (void)logPluginExceptionWithName:(NSString *)name
                            reason:(NSString *)reason
                             stack:(NSString *)stack
                  pluginIdentifier:(WS1PluginIdentifier)pluginIdentifier
                           handled:(BOOL)handled;

@end

NS_ASSUME_NONNULL_END

#endif /* WS1PluginInterface_h */
