Crittercism

Initialization

+ enableWithAppID:
Initializes Crittercism with the given App ID (found on the Crittercism web portal).
+ (void)enableWithAppID:(NSString *)appId
// Swift 2.X
class func enableWithAppID(appID: String)

// Swift 3.x
class func enable(withAppID: appID)
appId Your iOS appId
+ enableWithAppID:andConfig:
Initializes Crittercism with the given App ID (found on the Crittercism web portal). After this call completes, changes to the config object will have no affect on the behavior of Crittercism.
+ (void)enableWithAppID:(NSString *)appId andConfig:(CrittercismConfig *)config
// Swift 2.X
class func enableWithAppID(appID: String,
                andConfig config: CrittercismConfig)

// Swift 3.x
class func enable(withAppID: appID,
                  andConfig: crittercismConfig)
appId Your iOS appId
config Your custom CrittercismConfig

Logging Breadcrumbs

A breadcrumb is a developer-defined text string (up to 140 characters) that allows developers to capture app run-time information. Example breadcrumbs may include variable values, progress through the code, user actions, or low memory warnings. For an introduction, see Breadcrumbs.
+ leaveBreadcrumb:

Breadcrumbs provide the ability to track activity within your app. A breadcrumb is a free form string you supply, which will be timestamped, and stored in case a crash occurs. Crash reports will contain the breadcrumb trail from the run of your app that crashed, as well as that of the prior run.

Breadcrumbs are limited to 140 characters, and only the most recent 100 are kept. Apteligent will automatically insert a breadcrumb marked session_start on each initial launch, or foreground of your app.

+ (void)leaveBreadcrumb:(NSString *)breadcrumb
// Swift 2.X and 3.x
class func leaveBreadcrumb(breadcrumb: String)
breadcrumb The custom string to leave a breadcrumb, maximum of 140 characters
+ setAsyncBreadcrumbMode:
By default, breadcrumbs are flushed to disk immediately when written. This is by design - in order to provide an accurate record of everything that happened up until the point your app crashed. To improve performance you can instruct the library to perform all breadcrumb writes on a background thread.
+ (void)setAsyncBreadcrumbMode:(BOOL)writeAsync
// Swift 2.X and 3.x
class func setAsyncBreadcrumbMode(writeAsync: Bool)
writeAsync YES to write breadcrumbs in a background thread

Logging Errors and Handled Exceptions

+ logError:

Logging errors is a way of reporting NSError errors your app has received. If the method is passed an NSError, the stack trace of the thread that is logging the error will be displayed on the Crittercism web portal.

Logging errors may also be used for tracking NSError errors returned by Apple methods and 3rd party library errors. Errors are grouped by stacktrace, much like crash reports. Errors may be viewed in the “Handled Exceptions” area of the Apteligent portal.

+ (BOOL)logError:(NSError *)error;
// Swift 2.X
class func logError(error: NSError)

// Swift 3.x
class func logError(error: Error)
error Error to log
+ logHandledException:

Handled exceptions may be used for tracking exceptions caught in a try/catch statement, 3rd party library exceptions, and monitoring areas in the code that may currently be using assertions. Handled exceptions can also be used to track error events such as low memory warnings. For an introduction, see Handled Exceptions.

Handled exceptions are grouped by stacktrace, much like crash reports. Handled exceptions may be viewed in the “Handled Exceptions” area of the Apteligent portal.

Reporting of handled exceptions is throttled to once per minute. During that minute period, up to 5 handled exceptions will be buffered.

+ (BOOL)logHandledException:(NSException *)exception
// Swift 2.X and 3.x
class func logHandledException(exception: NSException)
exception Exception to log

Logging Network Request

Network performance data for NSURLSession and NSURLConnection is automatically captured and reported to Apteligent simply by initializing the SDK. See Service Monitoring

If you want to log network requests manually or customize what data gets reported, use these methods.

+ addFilter:
Adds an additional filter for network instrumentation.
+ (void)addFilter:(CRFilter *)filter
// Swift 2.X
class func addFilter(filter: CRFilter)

// Swift 3.x
class func add(filter: CRFilter)
filter CRFilter filter to add
+ logNetworkRequest:url:latency:bytesRead:bytesSent:responseCode:error:
Logging endpoints is a way of manually logging custom network library network access to URL’s which fall outside Crittercism’s monitoring of NSURLConnection and ASIHTTPRequest and NSURLSession method calls.
+ (BOOL)logNetworkRequest:(NSString *)method
                      url:(NSURL *)url
                  latency:(NSTimeInterval)latency
                bytesRead:(NSUInteger)bytesRead
                bytesSent:(NSUInteger)bytesSent
             responseCode:(NSInteger)responseCode
                    error:(NSError *)error
// Swift 2.X and 3.x
class func logNetworkRequest(method: String,
                            url url: NSURL,
                    latency latency: NSTimeInterval,
                bytesRead bytesRead: Int,
                bytesSent bytesSent: Int,
          responseCode responseCode: Int,
                        error error: NSError) -> Bool
method The connection method, such as GET, POST, HEAD, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
url The endpoint URL
latency The time between start of request and receipt of response, in seconds
bytesRead The number of bytes included in response body
bytesSent The number of bytes included in request body
responseCode HTTP status code, generally 100-599, e.g. 200 == OK, 400 == Bad Request, can be 0 if there is an error
error A non-nil error can be logged if network request failed to contact server, etc. Pass nil if there was no error
Returns YES if the request was properly logged. Returns NO otherwise.
+ logNetworkRequest:urlString:latency:bytesRead:bytesSent:responseCode:error:
Logging endpoints is a way of manually logging custom network library network access to URL’s which fall outside Crittercism’s monitoring of NSURLConnection, ASIHTTPRequest and NSURLSession method calls.
+ (BOOL)logNetworkRequest:(NSString *)method
                urlString:(NSString *)urlString
                  latency:(NSTimeInterval)latency
                bytesRead:(NSUInteger)bytesRead
                bytesSent:(NSUInteger)bytesSent
             responseCode:(NSInteger)responseCode
                    error:(NSError *)error
// Swift 2.X and 3.x
class func logNetworkRequest(method: String,
                urlString urlString: NSString,
                    latency latency: NSTimeInterval,
                bytesRead bytesRead: Int,
                bytesSent bytesSent: Int,
          responseCode responseCode: Int,
                        error error: NSError) -> Bool
method The connection method, such as GET, POST, HEAD, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
urlString The endpoint URL in string
latency The time between start of request and receipt of response, in seconds
bytesRead The number of bytes included in response body
bytesSent The number of bytes included in request body
responseCode HTTP status code, generally 100-599, e.g. 200 == OK, 400 == Bad Request, can be 0 if there is an error
error A non-nil error can be logged if network request failed to contact server, etc. Pass nil if there was no error
Returns YES if the request was properly logged. Returns NO otherwise.
+ updateLocation:
Inform Crittercism of the device’s most recent location for use with performance monitoring.
+ (void)updateLocation:(CLLocation *)location
// Swift 2.X
class func updateLocation(location: CLLocation)

// Swift 3.x
class func update(location: CLLocation)
location Location of the user / device
Introduced in SDK v4.1.1

Logging User Metadata

Developers can set user metadata to tracking information about individual users. For an introduction, see User Metadata.
+ setUsername:
Setting a username will allow the ability to monitor app performance for each user. Once a username is set, the Apteligent portal’s “Userviews” feature may be used to lookup a list of crashes and errors a specific user has experienced. We recommend setting a username to a value that can be tied back to your customer support system.
+ (void)setUsername:(NSString *)username
// Swift 2.X and 3.X
class func setUsername(username: String)
username The new username
+ setValue:forKey:

Associate user data with the device’s Crittercism UUID. This will send the association to Crittercism’s back end.

Up to ten key/value pairs of arbitrary metadata may be set for each user. The data will be displayed on the developer portal when viewing a user profile.

+ (void)setValue:(NSString *)value forKey:(NSString *)key
// Swift 2.X
class func setValue(key: String)

// Swift 3.x
class func setValue(value: String, forKey: String)
value the value
key the key

Logging User Flows

User flows allow developers to track key interactions or user flows in their app such as login, account registration, and in app purchase.

For an introduction, see User Flows Monitoring.

+ beginUserflow:

Init and begin a user flow with a default value.

User flows allow developers to track key interactions or user flows in their app such as login, account registration, and in app purchase. The SDK will automatically track application load time as a user flow. You can specify additional user flows by adding code to your application.

Beginning a user flow starts a user flow. Ending, failing, or cancelling a user flow stops a user flow. Otherwise, the user flow will be marked as crashed or timed out. If a crash occurs, all in progress user flows are marked crashed and will be reported with the crash.

All user flows will appear on Apteligent portal except for cancelled user flows.

User flows with the same name are aggregated together in the portal by Apteligent. Only one user flow for a given name can be in progress at a given time. If you begin a second user flow with the same name while another is in progress, the first user flow will be cancelled and the new one will take its place.

+ (void)beginUserflow:(NSString *)name
// Swift 2.X and 3.x
class func beginUserflow(name: String)
name The name of the user flow
+ beginUserflow:withValue:

Init and begin a user flow with a specified value.

User flows allow developers to track key interactions or user flows in their app such as login, account registration, and in app purchase. The SDK will automatically track application load time as a user flow. You can specify additional user flows by adding code to your application.

Beginning a user flow starts a user flow. Ending, failing, or cancelling a user flow stops a user flow. Otherwise, the user flow will be marked as crashed or timed out. If a crash occurs, all in progress user flows are marked crashed and will be reported with the crash.

All user flows will appear on Apteligent portal except for cancelled user flows.

User flows with the same name are aggregated together in the portal by Apteligent. Only one user flow for a given name can be in progress at a given time. If you begin a second user flow with the same name while another is in progress, the first user flow will be cancelled and the new one will take its place.

+ (void)beginUserflow:(NSString *)name withValue:(NSInteger)value
// Swift 2.X and 3.x
class func beginUserflow(name: NSString,
              withValue value: Int)
name The name of the user flow
value The value of the user flow
+ cancelUserflow:
Cancel a user flow as if it never existed. The user flow will not be reported.
+ (void)cancelUserflow:(NSString *)name
// Swift 2.X and 3.x
class func cancelUserflow(name: String)
name The name of the user flow
+ endUserflow:
End an already begun user flow successfully.
+ (void)endUserflow:(NSString *)name
// Swift 2.X and 3.x
class func endUserflow(name: String)
name The name of the user flow
+ failUserflow:
End an already begun user flow as a failure.
+ (void)failUserflow:(NSString *)name
// Swift 2.X and 3.x
class func failUserflow(name: String)
name The name of the user flow
+ setValue:forUserflow:
Set the currency cents value of a user flow.
+ (void)setValue:(int)value forUserflow:(NSString*)name;
// Swift 2.X
class func setValue(int: value,
       forUserflow name: String)

// Swift 3.x
class func setValue(value: int,
       forUserflow: String)
value The value of the user flow
name The name of the user flow
+ valueForUserflow:
Get the currency cents value of a user flow.
+ (NSInteger)valueForUserflow:(NSString*)name
// Swift 2.X
class func valueForUserflow(name: String) -> Int

// Swift 3.x
class func value(forUserflow: String) -> Int
name The name of the user flow

Detecting a Crash Occurred

You can listen to CrittercismDidCrashOnLastLoadNotification to get more app crash information on the previous run.
+ didCrashOnLastLoad:
+ (BOOL)didCrashOnLastLoad
// Swift 2.X and 3.x
class func didCrashOnLastLoad -> Bool
Returns YES if the app crashed on the last load, returns NO otherwise.

Delay Sending App Load Data

+ sendAppLoadData
Tell Crittercism to send app load event. By default, Crittercism will send app load event automatically when your app is started. However, if you set delaySendingAppLoad flag to YES on config, you can call this method to manually send app load event.
+ (void)sendAppLoadData
// Swift 2.X and 3.x
class func sendAppLoadData()

Opt Out Status

Apteligent provides an opt-out setting that disables all reporting to Apteligent. This allows developers to implement code that asks end users whether they want to opt out of Apteligent. For an introduction, see Opt Out of Apteligent.
+ getOptOutStatus
Retrieve current opt out status.
+ (BOOL)getOptOutStatus
// Swift 2.X and 3.x
class func getOptOutStatus -> Bool
Return YES if the user has opted out of reporting Crittercism data.
+ setOptOutStatus:

If you wish to offer your users the ability to opt out of Crittercism crash reporting, you can set the OptOutStatus to YES. there will be no information/requests sent from that user’s app. If you do so, any pending crash reports will be purged.

Typically, a developer would connect this API call to a checkbox in a settings menu.

+ (void)setOptOutStatus:(BOOL)status
// Swift 2.X and 3.x
class func setOptOutStatus(status: Bool)
status set to YES to disable Crittercism

Setting Apteligent’s Log Verbosity

+ loggingLevel
+ (CRLoggingLevel)loggingLevel
// Swift 2.X and 3.x
class func loggingLevel() -> CRLoggingLevel
The current logging level of the verbosity of Apteligent log messages.
+ setLoggingLevel:

Set the logging level to tune the verbosity of Apteligent log messages. The default value is CRLoggingLevelWarning.

See CrittercismLoggingLevel to see various logging levels.

+ (void)setLoggingLevel:(CRLoggingLevel)loggingLevel
// Swift 2.X and 3.x
class func setLoggingLevel(loggingLevel: CRLoggingLevel)
loggingLevel The verbosity of Crittercism logging

Apteligent Device UUID

+ getUserUUID

Get the Crittercism generated unique identifier for this device. This is NOT the device’s UDID.

If called before enabling the library, this will return an empty string. All Crittercism enabled apps on a device will share the UUID created by the first installed Crittercism enabled app.

If all Crittercism enabled applications are removed from a device, a new UUID will be generated when the next one is installed.

+ (NSString *)getUserUUID
// Swift 2.X and 3.x
class func getUserUUID -> String