Crittercism

Initialization

+ enableWithAppID:

Initializes Workspace ONE Intelligence SDK with the given App ID (found on the Workspace ONE Intelligence web portal).

Objective-C

+ (void)enableWithAppID:(NSString *)appId

Swift

// Swift 3.x
class func enable(withAppID: appID)

appId

Your iOS appId

+ enableWithAppID:andConfig:

Initializes Workspace ONE Intelligence SDK with the given App ID (found on the Workspace ONE Intelligence web portal). After this call completes, changes to the config object will have no affect on the behavior of Workspace ONE Intelligence SDK.

Objective-C

+ (void)enableWithAppID:(NSString *)appId andConfig:(CrittercismConfig *)config

Swift

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. Workspace ONE Intelligence SDK will automatically insert a breadcrumb marked session_start on each initial launch, or foreground of your app.

Objective-C

+ (void)leaveBreadcrumb:(NSString *)breadcrumb

Swift

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.

Objective-C

+ (void)setAsyncBreadcrumbMode:(BOOL)writeAsync

Swift

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 Workspace ONE Intelligence portal.

Objective-C

+ (BOOL)logError:(NSError *)error;

Swift

class func logError(error: Error)

error

Error to log

+ logError:stacktrace:

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 Workspace ONE Intelligence portal.

Objective-C

+ (BOOL)logError:(NSError *)error stacktrace:(NSArray *)stacktrace;

Swift

class func logError(error: Error stacktrace: Stacktrace)

error

Error to log

stacktrace

Array of strings representing a stacktrace

Introduced in SDK v5.9.1

+ 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 Workspace ONE Intelligence portal.

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

Objective-C

+ (BOOL)logHandledException:(NSException *)exception

Swift

class func logHandledException(exception: NSException)

exception

Exception to log

Logging Network Request

Network Insights data for NSURLSession and NSURLConnection is automatically captured and reported to Workspace ONE Intelligence simply by initializing the SDK. See Network Insights

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.

Objective-C

+ (void)addFilter:(CRFilter *)filter

Swift

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 Network Insights data for custom network libraries which fall outside Workspace ONE Intelligence’s monitoring of NSURLConnection and ASIHTTPRequest and NSURLSession method calls.

Objective-C

+ (BOOL)logNetworkRequest:(NSString *)method
                      url:(NSURL *)url
                  latency:(NSTimeInterval)latency
                bytesRead:(NSUInteger)bytesRead
                bytesSent:(NSUInteger)bytesSent
             responseCode:(NSInteger)responseCode
                    error:(NSError *)error

Swift

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 Network Insights data for custom network libraries which fall outside Workspace ONE Intelligence’s monitoring of NSURLConnection and ASIHTTPRequest and NSURLSession method calls.

Objective-C

+ (BOOL)logNetworkRequest:(NSString *)method
                urlString:(NSString *)urlString
                  latency:(NSTimeInterval)latency
                bytesRead:(NSUInteger)bytesRead
                bytesSent:(NSUInteger)bytesSent
             responseCode:(NSInteger)responseCode
                    error:(NSError *)error

Swift

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 Workspace ONE Intelligence SDK of the device’s most recent location for use with performance monitoring.

Objective-C

+ (void)updateLocation:(CLLocation *)location

Swift

class func update(location: CLLocation)

location

Location of the user / device

Introduced in SDK v4.1.1 Deprecated in SDK v5.9.3

+ updateLocationToLatitude:longitude:

Inform Workspace ONE Intelligence SDK of the device’s most recent location for use with event reporting.

Objective-C

+ (void)updateLocationToLatitude:(double)location longitude:(double)longitude

Swift

class func updateLocation(toLatitude: double, longitude: double)

latitude

Location of the user / device

longitude

Location of the user / device

Introduced in SDK v5.9.3

Logging User Metadata

Developers can set user metadata to tracking information about individual users. For an introduction, see User Name.

+ setUsername:

Setting a username will allow the ability to monitor app performance for each user. We recommend setting a username to a value that can be tied back to your customer support system.

Objective-C

+ (void)setUsername:(NSString *)username

Swift

class func setUsername(username: String)

username

The new username

+ setValue:forKey:

Associate user data with the Workspace ONE Intelligence UUID of this device. This will send the association to Workspace ONE Intelligence’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.

Objective-C

+ (void)setValue:(NSString *)value forKey:(NSString *)key

Swift

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 Workspace ONE Intelligence 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 Workspace ONE Intelligence portal except for cancelled user flows.

User flows with the same name are aggregated together in the portal by Workspace ONE Intelligence. 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.

Objective-C

+ (void)beginUserflow:(NSString *)name

Swift

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 Workspace ONE Intelligence 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 Workspace ONE Intelligence portal except for cancelled user flows.

User flows with the same name are aggregated together in the portal by Workspace ONE Intelligence. 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.

Objective-C

+ (void)beginUserflow:(NSString *)name withValue:(NSInteger)value

Swift

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.

Objective-C

+ (void)cancelUserflow:(NSString *)name

Swift

class func cancelUserflow(name: String)

name

The name of the user flow

+ endUserflow:

End an already begun user flow successfully.

Objective-C

+ (void)endUserflow:(NSString *)name

Swift

class func endUserflow(name: String)

name

The name of the user flow

+ failUserflow:

End an already begun user flow as a failure.

Objective-C

+ (void)failUserflow:(NSString *)name

Swift

class func failUserflow(name: String)

name

The name of the user flow

+ setValue:forUserflow:

Set the currency cents value of a user flow.

Objective-C

+ (void)setValue:(int)value forUserflow:(NSString*)name;

Swift

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.

Objective-C

+ (NSInteger)valueForUserflow:(NSString*)name

Swift

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:

Objective-C

+ (BOOL)didCrashOnLastLoad

Swift

class func didCrashOnLastLoad -> Bool

Returns YES if the app crashed on the last load, returns NO otherwise.

Delay Sending App Load Data

+ sendAppLoadData

Tell Workspace ONE Intelligence SDK to send an app load event that was previously delayed. By default, Workspace ONE Intelligence SDK 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.

Objective-C

+ (void)sendAppLoadData

Swift

class func sendAppLoadData()

Opt Out Status

Workspace ONE Intelligence SDK provides an opt-out setting that disables all reporting to Workspace ONE Intelligence. This allows developers to implement code that asks end users whether they want to opt out of Workspace ONE Intelligence. For an introduction, see Opt Out of Workspace ONE Intelligence.

+ getOptOutStatus

Retrieve current opt out status.

Objective-C

+ (BOOL)getOptOutStatus

Swift

class func getOptOutStatus -> Bool

Return YES if the user has opted out of reporting Workspace ONE Intelligence data.

+ setOptOutStatus:

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

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

Objective-C

+ (void)setOptOutStatus:(BOOL)status

Swift

class func setOptOutStatus(status: Bool)

status

set to YES to disable Workspace ONE Intelligence

Setting Log Verbosity Of Workspace ONE Intelligence SDK

+ loggingLevel

Objective-C

+ (CRLoggingLevel)loggingLevel

Swift

class func loggingLevel() -> CRLoggingLevel

The current logging level of the verbosity of Workspace ONE Intelligence SDK log messages.

+ setLoggingLevel:

Set the logging level to tune the verbosity log messages from Workspace ONE Intelligence SDK. The default value is CRLoggingLevelWarning.

See CrittercismLoggingLevel to see various logging levels.

Objective-C

+ (void)setLoggingLevel:(CRLoggingLevel)loggingLevel

Swift

class func setLoggingLevel(loggingLevel: CRLoggingLevel)

loggingLevel

The log verbosity of Workspace ONE Intelligence SDK

Workspace ONE Intelligence Device UUID

+ getUserUUID

Get the unique identifier for this device generated by Workspace ONE Intelligence SDK. This is NOT the device’s UDID.

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

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

Objective-C

+ (NSString *)getUserUUID

Swift

class func getUserUUID -> String