Connect iOS SDK public API reference

You can instrument the Connect iOS library to capture various events, including error, exception, location and custom. Each event type has a method for instrumenting the SDK. There are several classes with public APIs.

ConnectCustomEvent

Declared in ConnectCustomEvent.h.

sharedInstance

Returns a shared instance of ConnectCustomEvent. Use this instance when logging custom events.

import Connect

ConnectCustomEvent.sharedInstance()
#import <Connect/ConnectCustomEvent.h>

- (TLFCustomEvent \*)sharedInstance

Logging custom events

You can log a specified event with or without also logging an associated value or dictionary.

logEvent

Logs a named event with no additional information or with a dictionary of key values.

logEvent(_ eventName: String?) -> Bool

logEvent(_ eventName: String?, 
         values: [AnyHashable : Any]?) -> Bool

logEvent(_ eventName: String?, 
         values: [AnyHashable : Any]?, 
         level: kConnectMonitoringLevelType) -> Bool
- (void)logEvent:(NSString *)eventName

- (void)logEvent:(NSString _)eventName 
					values:(NSDictionary _)values;

- (void)logEvent:(NSString _)eventName
          values:(NSDictionary _)values
           level:(kTLFMonitoringLevelType)level;

Supported parameters:

ParameterFormatRequired?Description
eventNameString. Must not contain =, [ or ].RequiredThe name of the event
levelInteger. Valid values:

- 1 (default)
- 2
- 3
OptionalThe minimum logging level for the event.

The logging levels are nested. For example, all level 1 elements are included in level 2. Therefore, assign low logging levels to the most important items.
valuesOptionalMore data items that are associated with the event

Logs a named event and associated dictionary. The dictionary is converted to its JSON representation.

📘

Note

To be convertible to a JSON representation, the values of the dictionary must be NSDictionary, NSArray, NSString, NSNumber or SNull objects.

Declared in ConnectCustomEvent.h. kConnectMonitoringLevelType is declared in ConnectPublicDefinitions.h.

logSignal

Logs signal events and data.

logSignal(_ values: [AnyHashable : Any]?) -> Bool

logSignal(_ values: [AnyHashable : Any]?, 
          level: kConnectMonitoringLevelType) -> Bool

- (BOOL)logSignal:(NSDictionary *)values;

- (BOOL)logSignal:(NSDictionary *)values 
            level:(kConnectMonitoringLevelType)level;

Supported parameters:

ParameterFormatRequired?Description
levelInteger. Valid values:

- 1 (default)
- 2
- 3
OptionalThe minimum logging level for the event.

The logging levels are nested. For example, all level 1 elements are included in level 2. Therefore, assign low logging levels to the most important items.
valuesRequiredMore data items that are associated with the event

Logging error events

You can enable the library to log errors and exceptions.

logNSErrorEvent

Logs an error as described in the NSError instance.

logNSErrorEvent(_ error: (any Error)?, 
                message: String?, 
                level: kConnectMonitoringLevelType) -> Bool

logNSErrorEvent(_ error: (any Error)?, 
                message: String?, 
                file: UnsafePointer<Int8>?, 
                line: UInt, level: kConnectMonitoringLevelType) -> Bool

- (BOOL)logNSErrorEvent:(NSError _)error message:(NSString _)message [file:(const] char *)file line:(unsigned int)line level:(kTLFMonitoringLevelType)level;
                                                                      
- (BOOL)logNSErrorEvent:(NSError _)error message:(NSString _)message level:(kTLFMonitoringLevelType)level;

Declared in ConnectCustomEvent.h. kConnectMonitoringLevelType is declared in ConnectPublicDefinitions.h.

This example shows expected JSON output:

{
  "exception": {
    "unhandled": false,
    "data": {
      "message": "Custom Message"
    },
    "name": "(null)",
    "stackTrace": "",
    "description": "An Error Occured,"
  },
  "fromWeb": false,
  "count": 4,
  "screenviewOffset": 23,
  "offset": 39,
  "type": 6,
  "line": 1,
  "fileName": "/path/to/file/AppDelegate.m"
}

Supported JSON parameters:

ParameterRequired?Description
errorRequiredThe NSError returned by the SDK or your own method.
filenameOptionalThe original file where the error occurred. The source code file name, usually from the FILE preprocessor macro.
levelRequiredThe monitoring level of the event. The minimum logging level at which this error is logged.
lineOptionalThe source code line number, usually from the LINE preprocessor macro.
messageRequiredAn associated message for your own
returnRequiredShows whether the event was successfully logged or not.

Logging exception events

Use this method to log exceptions.

logNSExceptionEvent

Enables the framework to log exceptions trapped by your own exception handler. These methods do not use the Cocoa SDK, which is not exception-safe. Sets the Unhandled flag to false.

This example shows how to call the method:

logNSExceptionEvent(_ exception: NSException?) -> Bool

logNSExceptionEvent(_ exception: NSException?, 
                    dataDictionary: [AnyHashable : Any]?) -> Bool

logNSExceptionEvent(_ exception: NSException?, 
                    dataDictionary: [AnyHashable : Any]?, 
                    isUnhandled unhandled: Bool) -> Bool
- (BOOL)logNSExceptionEvent:(NSException *)exception;
- (BOOL)logNSExceptionEvent:(NSException *)exception
             dataDictionary:(NSDictionary *)dataDictionary;
- (BOOL)logNSExceptionEvent:(NSException *)exception
             dataDictionary:(NSDictionary *)dataDictionary
                isUnhandled:(BOOL)unhandled;

Supported parameters:

ParameterDescription
exceptionThe caught NSexception instance. This value shows whether the event was successfully logged.
dataDictionaryAdditional data about the exception
unhandledIndicates whether the exception was caught by an exception handler.

Logging exceptions in Swift

NSException codes are not supported for logging exceptions in Swift. Use the following code snippet instead.

enum MyError: ErrorType {
  case RuntimeError(String)
  case OutofIndex(String)
}

func throwError(message: String) throws {
  throw MyError.RuntimeError(message)
}

func throwException(message: String) throws {
  let info: [Int: String] = [1: "any"]
  let exceptionInfo: [String: NSException] = [
    "ExceptionObject": NSException(
      name:
        "TheException", reason: "WantToThrowNSException", userInfo: info)
  ]
  throw NSError(domain: "exception", code: 10, userInfo: exceptionInfo)
}

@IBAction func generateUnhandledException(sender: UIButton) {

  /* catching NSError with embedded NSException */
  do {
    try throwException("exceptionexception")
  } catch let err as NSError {
    let ex = err.userInfo["ExceptionObject"] as! NSException
    ConnectCustomEvent.sharedInstance().logNSExceptionEvent(
      ex, dataDictionary: info,
      isUnhandled:
        true)
    ConnectCustomEvent.sharedInstance().logNSErrorEvent(
      err, message: "error",
      level:
        kConnectMonitoringLevelType.ConnectMonitoringLevel1)
  } catch let ex as NSException {
    ConnectCustomEvent.sharedInstance().logNSExceptionEvent(
      ex, dataDictionary: info,
      isUnhandled:
        true)
  } catch {
    print("unhandled")
  }
}

Swift assert errors and exceptions

logAssertErrorEvent

Logs a named event with no additional information.

logAssertErrorEvent(_ error: (any Error)?, 
                    condition: Bool, 
                    message: String?, 
                    file: UnsafePointer<Int8>?, 
                    line: UInt) -> Bool
- (BOOL)logAssertErrorEvent:(NSError *)error 
                  condition:(Boolean)condition 
                    message:(NSString *)message 
                       file:(const char *)file 
                       line:(unsigned int)line;

Required parameters:

ParameterDescription
conditionCondition to be logged.
errorThe error to be logged.
fileThe file in which the error occurred. Can be caputured by passing FILE to the parameter.
lineThe line in which the error occurred. Can be caputured by passing LINE to the paramater.
messageAdditional information to be logged with the error.

logPreconditionErrorEvent

In the event of a precondition, this API enables logging of the error and flushing back captured data.

logPreconditionErrorEvent(_ error: (any Error)?, 
                          condition: Bool, 
                          message: String?, 
                          file: UnsafePointer<Int8>?, 
                          line: UInt) -> Bool

- (BOOL)logPreconditionErrorEvent:(NSError *)
                  error condition:(Boolean)condition 
                          message:(NSString *)message 
                             file:(const char *)file 
                             line:(unsigned int)line;

Required parameters:

ParameterDescription
errorThe error to be logged.
conditionCondition to be logged.
fileThe file in which the error occurred. Can be captured by passing FILE to the parameter.
lineThe line in which the error occurred. Can be captured by passing LINE to the parameter.
messageAdditional information to be logged with the error.

logAssertionFailureErrorEvent

In the event of an AssertionFailure, this API allows for the logging of the error and flushing back captured data.

logAssertionFailureErrorEvent(_ error: (any Error)?, 
                              message: String?, 
                              file: UnsafePointer<Int8>?, 
                              line: UInt) -> Bool

- (BOOL)logAssertionFailureErrorEvent:(NSError *)error 
                              message:(NSString *)message 
                                 file:(const char *)file 
                                 line:(unsigned int)line;

Required parameters:

ParameterDescription
errorThe error to be logged.
fileThe file in which the error occurred. Can be captured by passing FILE to the parameter.
lineThe line in which the error occurred. Can be captured by passing LINE to the parameter.
messageAdditional information to be logged with the error.

logPreconditionFailureErrorEvent

In the event of a PreconditionFailure, this API allows for the logging of the error and flushing back captured data.

logPreconditionFailureErrorEvent(_ error: (any Error)?, 
                          message: String?, 
                          file: UnsafePointer<Int8>?, 
                          line: UInt) -> Bool

- (BOOL)logPreconditionFailureErrorEvent:(NSError *)error 
                                 message:(NSString *)message 
                                    file:(const char *)file 
                                    line:(unsigned int)line;

Required parameters:

ParameterDescription
errorThe error to be logged.
fileThe file in which the error occurred. Can be captured by passing FILE to the parameter.
lineThe line in which the error occurred. Can be captured by passing LINE to the parameter.
messageAdditional information to be logged with the error.

logFatalErrorEvent

In the event of a fatalError, this API allows for the logging of the error and flushing back captured data.

logFatalErrorEvent(_ error: (any Error)?,
                          message: String?, 
                          file: UnsafePointer<Int8>?, 
                          line: UInt) -> Bool

- (BOOL)logFatalErrorEvent:(NSError *)error 
                   message:(NSString *)message 
                      file:(const char *)file 
                      line:(unsigned int)line;

Required parameters:

ParameterDescription
errorThe error to be logged.
fileThe file in which the error occurred. Can be caputured by passing FILE to the paramater.
lineThe line in which the error occurred. Can be captured by passing LINE to the parameter.
messageAdditional information to be logged with the error.

Example

NSException codes are not supported for logging exceptions in Swift. Use the following code snippet instead.

enum MyError: ErrorType {
  case RuntimeError(String)
  case OutofIndex(String)
}

func throwError(message: String) throws {
  throw MyError.RuntimeError(message)
}

func throwException(message: String) throws {
  let info: [Int: String] = [1: "any"]
  let exceptionInfo: [String: NSException] = [
    "ExceptionObject": NSException(
      name:
        "TheException", reason: "WantToThrowNSException", userInfo: info)
  ]
  throw NSError(domain: "exception", code: 10, userInfo: exceptionInfo)
}

@IBAction func generateUnhandledException(sender: UIButton) {

  /* catching NSError with embedded NSException */
  do {
    try throwException("exceptionexception")
  } catch let err as NSError {
    let ex = err.userInfo["ExceptionObject"] as! NSException
    ConnectCustomEvent.sharedInstance().logNSExceptionEvent(
      ex, dataDictionary: info,
      isUnhandled:
        true)
    ConnectCustomEvent.sharedInstance().logNSErrorEvent(
      err, message: "error",
      level:
        kConnectMonitoringLevelType.ConnectMonitoringLevel1)
  } catch let ex as NSException {
    ConnectCustomEvent.sharedInstance().logNSExceptionEvent(
      ex, dataDictionary: info,
      isUnhandled:
        true)
  } catch {
    print("unhandled")
  }
}

Network logging

logNSURLSession

Requests that the framework logs the connection information.

logNSURLSession(_ urlSession: Any?, 
                error: (any Error)?) -> Bool

logNSURLSession(_ urlSession: Any?, 
                response: URLResponse?, 
                responseTimeInMilliseconds responseTime: Int64) -> Bool

logNSURLSession(_ urlSession: Any?, 
                request: URLRequest?) -> Bool

-(BOOL)logNSURLSession:(id)urlSession 
                 error:(NSError*)error;

-(BOOL)logNSURLSession:(id)urlSession 
              response:(NSURLResponse*)response
responseTimeInMilliseconds:(long long)responseTime;

-(BOOL)logNSURLSession:(id)urlSession 
               request:(NSURLRequest*)request;

Required parameters:

ParameterDescription
errorThe error to be logged
requestNSURLRequest object
responseThe NSURLResponse object from the connection request
responseTimeThe amount of time taken by the server to respond
urlSessionThe NSURLSession object

logConnectionWithInitTime

Enables the framework to log connection information.

logConnection(withInitTime initTime: NSNumber?, 
              loadTime: NSNumber?, 
              connection: Any?, 
              request: URLRequest?, 
              response: URLResponse?, 
              error: (any Error)?) -> Bool

logConnection(withInitTime initTime: NSNumber?, 
              loadTime: NSNumber?, 
              connection: Any?, 
              request: URLRequest?, 
              response: URLResponse?, 
              data: Data?, 
              error: (any Error)?) -> Bool

- (BOOL)logConnectionWithInitTime:(NSNumber*)initTime 
                         loadTime:(NSNumber*)loadTime 
                       connection:(id)connection  
                          request:(NSURLRequest*)request 
                         response:(NSURLResponse*)response 
                            error:(NSError*)error;

- (BOOL)logConnectionWithInitTime:(NSNumber*)initTime 
                         loadTime:(NSNumber*)loadTime 
                       connection:(id)connection  
                          request:(NSURLRequest*)request 
                         response:(NSURLResponse*)response 
                             data:(NSData*)data 
                            error:(NSError*)error;

Required parameters:

ParameterDescription
connectionThe NSURLSession object, can be nil.
dataThe NSData object from the connection request or response.
errorNSError object.
initTimeTime duration since the start of the current session
loadTimeThe amount of time it takes to load
requestThe NSURLRequest object associated with the connection.
responseThe NSURLResponse object from the connection request.

Geolocation logging

Use this method to have the framework log a geographic location at a specific point in your application. Location events aren't enabled by default. Location must be reported only when the application has a reason to request it. This helps avoid making unnecessary location updates and to protect the privacy of your application users.

Here is an example of how to use this API:

logLocation(_ location: CLLocation?) -> Bool

logLocationUpdateEvent(withLatitude lat: Double, 
                       longitude lng: Double, 
                       level: kConnectMonitoringLevelType) -> Bool






CLLocationDegrees myLatitude=37.7888024;    
     CLLocationDegrees myLongitude=-122.40031809;    
     CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:myLatitude longitude:myLongitude]; 
     [[ConnectCustomEvent sharedInstance] logLocation:myLocation];





// Call this method inside your handler for `locationManager:didUpdateToLocation:fromLocation:`. Your application must include the Core Location framework (`CoreLocation.framework`).

#import "CoreLocation/CoreLocation.h"
#import "ConnectCustomEvent.h"

...

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
  CLLocationCoordinate2D c = newLocation.coordinate;
  ... [[ConnectCustomEvent sharedInstance]
      logLocationUpdateEventWithLatitude:c.latitude
                               longitude:longitude];
}

- (void)logLocationUpdateEventWithLatitude:(double)latitude
                                 longitude:(double)longitude
                                     level:(kConnectMonitoringLevelType)level
-(BOOL)logLocation:(CLLocation *)location;

-(BOOL)logLocationUpdateEventWithLatitude:(double)lat 
                                longitude:(double)lng 
                                    level:(kConnectMonitoringLevelType)level;

Required parameters:

ParameterDescription
latitudeThe latitude to log
levelThe minimum logging level for locations
locationA CLLocation Object containing a location of interest
longitudeThe longitude to log

UIControls events

logClickEvent

Enables the framework to log tclick events on any UIControl or UIView. A click event is a normalized form of touch up inside event.

logClickEvent(_ view: UIView?, 
              data: [AnyHashable : Any]?) -> Bool

logClickEvent(_ view: UIView?, 
              controlId: String?, 
              data: [AnyHashable : Any]?) -> Bool

-(BOOL)logClickEvent:(UIView*)view 
                data:(NSDictionary*)data;

-(BOOL)logClickEvent:(UIView*)view 
           controlId:(NSString*)controlId 
                data:(NSDictionary*)data;

Required parameters:

ParameterDescription
controlIdThe ID of the control to be used.
dataAny additional custom data that needs to be sent as a dictionary along with the click event.
viewUIView object on which click event occurred.

logValueChangeEvent

Requests that the framework logs the UITableViewCell or UICollectionViewCell's content changed event.

logValueChangeEvent(_ view: UIView?, 
              data: [AnyHashable : Any]?) -> Bool

logValueChangeEvent(_ view: UIView?, 
              controlId: String?, 
              data: [AnyHashable : Any]?) -> Bool

-(BOOL)logValueChangeEvent:(UIView*)view 
                      data:(NSDictionary*)data;

-(BOOL)logValueChangeEvent:(UIView*)view 
                 controlId:(NSString*)controlId 
                      data:(NSDictionary*)data;

Required parameters:

ParameterDescription
controlIdThe ID of the control to be used
dataAny additional custom data that needs to be sent as a dictionary along with the click event
viewUIView object on which click event occurred

logTextChangeEvent

Requests that the framework logs the edit event on UITextView, UITextViewSecure, UITextField or UITextFieldSecure.

logTextChangeEvent(_ view: UIView?, 
              data: [AnyHashable : Any]?) -> Bool

logTextChangeEvent(_ view: UIView?, 
              controlId: String?, 
              data: [AnyHashable : Any]?) -> Bool
-(BOOL)logTextChangeEvent:(UIView*)view 
                     data:(NSDictionary*)data;

-(BOOL)logTextChangeEvent:(UIView*)view 
                controlId:(NSString*)controlId 
                     data:(NSDictionary*)data;

Required parameters:

ParameterDescription
controlIdThe ID of the control to be used.
dataAny additional custom data that needs to be sent as a dictionary along with the click event.
viewUIView object on which a click event occurred.

logUILabelTextChange

Used to log when a label changes.

logUILabelTextChange(_ label: UILabel?) -> Bool

logUILabelTextChange(_ label: UILabel?,
                     controlId: String?) -> Bool

- (BOOL)logUILabelTextChange:(UILabel*)label;

- (BOOL)logUILabelTextChange:(UILabel*)label 
                   controlId:(NSString*)controlId;

Required parameters:

ParameterDescription
controlIdThe ID of the control to be used.
labelThe UILabel to be logged.

logFormCompletion

Message type to indicate form completion on view.

logFormCompletion(_ submitted: Bool) -> Bool

logFormCompletion(_ submitted: Bool, 
                  withValidData isValid: Bool) -> Bool

-(BOOL)logFormCompletion:(BOOL)submitted;

-(BOOL)logFormCompletion:(BOOL)submitted 
           withValidData:(BOOL)isValid;

Required parameters:

ParameterDescription
isValidIndicates if the submitted input data was valid or not.
submittedIndicates if form/input data was submitted or not.

Screenview

logScreenViewPageName

Set the page name for type 10 data. This is used for React Native captures.

logScreenViewPageName(_ logicalPageName: String?) -> Bool

-(BOOL)logScreenViewPageName:(NSString*)logicalPageName;

Required parameters:

ParameterDescription
logicalPageNamePage name or title e.g. "Login View Controller". Must not be empty.

logScreenViewContext

Requests that the framework logs an application context.

logScreenViewContext(_ logicalPageName: String?,
                     withClass clsss: String?,
                     applicationContext screenViewType: ConnectScreenViewType,
                     referrer: String?) -> Bool

-(BOOL)logScreenViewContext:(NSString*)logicalPageName
                  withClass:(NSString *)clsss
         applicationContext:(ConnectScreenViewType)screenViewType
                   referrer:(NSString*)referrer;

Required parameters:

ParameterDescription
applicationContextValid values are ConnectScreenViewTypeLoad or ConnectScreenViewTypeUnload. Must not be empty.
logicalPageNamePage name or title e.g. "Login View Controller". Must not be empty.
referrerPage name or title that loads logicalPageName. Can be empty.
withClassClass of UIViewcontroller. Must not be empty.

logPrintScreenEvent

Requests that the framework logs a Print Screen event. The screenshot in that moment is automatically associated.

logPrintScreenEvent() -> Bool
- (BOOL)logPrintScreenEvent;

logScreenLayoutWithImage

Requests that the framework log an image as a background in a type 10 screen layout event.

logScreenLayout(with image: UIImage?) -> Bool
- (BOOL)logScreenLayoutWithImage:(UIImage *)image;

Required parameters:

ParameterDescription
imageUIImage object that needs to be added as a background for the layout.

logScreenLayoutWithViewController

Enables the framework to log the layout of the screen.

logScreenLayout(with viewController: UIViewController?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andName name: String?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andDelay delay: CGFloat) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andDelay delay: CGFloat, 
                andName name: String?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andRelatedViews views: [AnyHashable]?, 
                andDelay delay: CGFloat) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andRelatedViews views: [AnyHashable]?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andRelatedViews views: [AnyHashable]?, 
                andName name: String?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andRelatedViews views: [AnyHashable]?,
                andName name: String?) -> Bool

logScreenLayout(with viewController: UIViewController?, 
                andRelatedViews views: [AnyHashable]?, 
                andDelay delay: CGFloat, 
                andName name: String?) -> Bool

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                                 andName:(NSString*)name;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                                andDelay:(CGFloat)delay;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                                andDelay:(CGFloat)delay 
                                 andName:(NSString*)name;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                         andRelatedViews:(NSArray*)views 
                                andDelay:(CGFloat)delay;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                         andRelatedViews:(NSArray*)views;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController 
                         andRelatedViews:(NSArray*)views 
                                 andName:(NSString*)name;

-(BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                         andRelatedViews:(NSArray*)views 
                                andDelay:(CGFloat)delay 
                                 andName:(NSString*)name;

Required parameters:

ParameterDescription
delayThe number of seconds to wait before logging the view.
nameThe custom name to associate with the view controller.
viewControllerThe UIViewController object which layout needs to be logged.
viewsArray of views that will be logged along with the provided viewController.

logJSONMessagePayloadStr

Enables the framework to log the Connect JSON Message coming over from JavaScript. Must follow the JSON message format.

logJSONMessagePayloadStr(_ payload: String?) -> Bool
-(BOOL)logJSONMessagePayloadStr:(NSString*)payload;

Required parameters:

ParameterDescription
payloadNSString object that matches the Connect JSON Message type format.

logImageUrl

Add URL to UIImage to be used as a reference for replay.

logImageUrl(_ image: UIImage?, 
            withUrl url: String?) -> Bool

-(BOOL)logImageUrl:(UIImage*)image 
           withUrl:(NSString*)url;

Required parameters:

ParameterDescription
imageUIImage used
urlThe URL of the image

logPerformance

Log performance data.

logPerformance(_ navigationStart: NSNumber?, 
               unloadEventStart: NSNumber?, 
               unloadEventEnd: NSNumber?, 
               redirectStart: NSNumber?, 
               redirectEnd: NSNumber?, 
               fetchStart: NSNumber?, 
               domainLookupStart: NSNumber?, 
               domainLookupEnd: NSNumber?, 
               connectStart: NSNumber?,
               connectEnd: NSNumber?, 
               secureConnectionStart: NSNumber?, 
               requestStart: NSNumber?, 
               responseStart: NSNumber?, 
               responseEnd: NSNumber?, 
               domLoading: NSNumber?, 
               domInteractive: NSNumber?,
               domContentLoadedEventStart: NSNumber?, 
               domContentLoadedEventEnd: NSNumber?, 
               domComplete: NSNumber?, 
               loadEventStart: NSNumber?, 
               loadEventEnd: NSNumber?, 
               renderTime: NSNumber?, 
               perNavType: NSNumber?,
               redirectCount: NSNumber?) -> Bool

-(BOOL)logPerformance:(NSNumber*)navigationStart 
     unloadEventStart:(NSNumber*)unloadEventStart 
       unloadEventEnd:(NSNumber*)unloadEventEnd 
        redirectStart:(NSNumber*)redirectStart 
          redirectEnd:(NSNumber*)redirectEnd 
           fetchStart:(NSNumber*)fetchStart 
    domainLookupStart:(NSNumber*)domainLookupStart 
      domainLookupEnd:(NSNumber*)domainLookupEnd 
         connectStart:(NSNumber*)connectStart 
           connectEnd:(NSNumber*)connectEnd 
secureConnectionStart:(NSNumber*)secureConnectionStart 
         requestStart:(NSNumber*)requestStart 
        responseStart:(NSNumber*)responseStart 
          responseEnd:(NSNumber*)responseEnd 
           domLoading:(NSNumber*)domLoading 
       domInteractive:(NSNumber*)domInteractive 
domContentLoadedEventStart:(NSNumber*)domContentLoadedEventStart
domContentLoadedEventEnd:(NSNumber*)domContentLoadedEventEnd 
         domComplete:(NSNumber*)domComplete 
      loadEventStart:(NSNumber*)loadEventStart 
        loadEventEnd:(NSNumber*)loadEventEnd 
          renderTime:(NSNumber*)renderTime 
          perNavType:(ConnectPerformanceNavigationType)perNavType 
       redirectCount:(NSNumber*)redirectCount;

Required parameters:

ParameterDescription
connectEndThis attribute must return the time immediately after the user agent finishes establishing the connection to the server to retrieve the current document. If a persistent connection [RFC 2616] is used or the current document is retrieved from relevant application caches or local resources, this attribute must return the value of domainLookupEnd.
connectStartThis attribute must return the time immediately before the user agent starts establishing the connection to the server to retrieve the document. If a persistent connection [RFC 2616] is used or the current document is retrieved from relevant application caches or local resources, this attribute must return value of domainLookupEnd.
domainLookupEndThis attribute must return the time immediately after the user agent finishes the domain name lookup for the current document. If a persistent connection [RFC 2616] is used or the current document is retrieved from relevant application caches or local resources, this attribute must return the same value as fetchStart.
domainLookupStartThis attribute must return the time immediately before the user agent starts the domain name lookup for the current document. If a persistent connection [RFC 2616] is used or the current document is retrieved from relevant application caches or local resources, this attribute must return the same value as fetchStart.
domCompleteThis attribute must return the time immediately before the user agent sets the current document readiness to "complete".
domContentLoadedEventEndThis attribute must return the time immediately after the document's DOMContentLoaded event completes.
domContentLoadedEventStartThis attribute must return the time immediately before the user agent fires the DOMContentLoaded event at the Document.
domInteractiveThis attribute must return the time immediately before the user agent sets the current document readiness to "interactive".
domLoadingThis attribute must return the time immediately before the user agent sets the current document readiness to "loading".
fetchStartIf the new resource is to be fetched using HTTP GET or equivalent, fetchStart must return the time immediately before the user agent starts checking any relevant application caches. Otherwise, it must return the time when the user agent starts fetching the resource.
loadEventEndThis attribute must return the time when the load event of the current document is completed. It must return zero when the load event is not fired or is not completed.
loadEventStartThis attribute must return the time immediately before the load event of the current document is fired. It must return zero when the load event is not fired yet.
navigationStartThis attribute must return the time immediately after the user agent finishes prompting to unload the previous document. If there is no previous document, this attribute must return the same value as fetchStart.
perNavTypeThis attribute must return the type of the last non-redirect navigation in the current browsing context.
redirectCountThis attribute must return the number of redirects since the last non-redirect navigation under the current browsing context. If there is no redirect or there is any redirect that is not from the same origin as the destination document, this attribute must return zero.
redirectEndIf there are HTTP redirects or equivalent when navigating and all redirects and equivalents are from the same origin, this attribute must return the time immediately after receiving the last byte of the response of the last redirect. Otherwise, this attribute must return zero.
redirectStartIf there are HTTP redirects or equivalent when navigating and if all the redirects or equivalent are from the same origin, this attribute must return the starting time of the fetch that initiates the redirect. Otherwise, this attribute must return zero.
renderTimeThe amount of time it took to render the page.
requestStartThis attribute must return the time immediately before the user agent starts requesting the current document from the server, or from relevant application caches or from local resources.
responseEndThis attribute must return the time immediately after the user agent receives the last byte of the current document or immediately before the transport connection is closed, whichever comes first. The document here can be received either from the server, relevant application caches or from local resources.
responseStartThis attribute must return the time immediately after the user agent receives the first byte of the response from the server, or from relevant application caches or from local resources.
unloadEventEndIf the previous document and the current document have the same origin, this attribute must return the time immediately after the user agent finishes the unload event of the previous document. If there is no previous document or the previous document has a different origin than the current document or the unload is not yet completed, this attribute must return zero. If there are HTTP redirects or equivalent when navigating and not all the redirects or equivalent are from the same origin, both unloadEventStart and unloadEventEnd must return zero.
unloadEventStartIf the previous document and the current document have the same origin [IETF RFC 6454], this attribute must return the time immediately before the user agent starts the unload event of the previous document. If there is no previous document or the previous document has a different origin than the current document, this attribute must return zero.

Optional parameters:

ParameterDescription
secureConnectionStartUser agents that don't have this attribute available must set it as undefined. When this attribute is available, if the scheme of the current page is HTTPS, this attribute must return the time immediately before the user agent starts the handshake process to secure the current connection. If this attribute is available but HTTPS is not used, this attribute must return zero.

Log screen layout for iOS mobile app session replay

The screen layouts of the native mobile app sessions are captured in Experience Analytics (Tealeaf) JSON format. The screen layouts are then sent back to replay server. The replay server uses a template engine, which interprets the JSON into HTML format. You can then replay the screen layout from the native mobile app session as HTML pages in Connect.

Replay logging can be automatic, manual, or a combination of the two. Automatic layout logging is enabled by default. This automatically logs a view controller when the view controller's viewDidAppear:(BOOL)animated method is called.

📘

Note:

If the viewController overrode the viewDidAppear, method[super viewDidAppear:animated] must be called.

Correct:

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  // Custom code
}

Incorrect:

- (void)viewDidAppear:(BOOL)animated {
  // Custom code
}

Several methods are included for manual logging of screen layout.

The following is the most basic manual logging method. The following method logs the layout of the viewController passed into it.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController

The following method performs the same action as the first method, but you can pass in a specific name for the screen layout that is logged. This is helpful when you log a view controller that can perform several different functions.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                                  andName:(NSString *)name

The following method performs the same action as the first method, but after the specified delay. This is helpful for logging after certain events, such as reloading the data in a table. The delay is measured in seconds.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                                 andDelay:(CGFloat)delay;

The following method performs the same function as the previous method, but it allows you to pass in a name for the layout.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                                 andDelay:(CGFloat)delay
                                  andName:(NSString *)name

In addition to logging the main view controller passed in, this method allows you to pass in an array of other views to be logged at the same time. This is useful in instances where there are elements on screen that are not part of the same view hierarchy, such as an overlay attached directly to the application's window or an alert view.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                          andRelatedViews:(NSArray *)views

The following method performs the same action as the previous method, but it allows you to pass in a name for the layout.

- (BOOL)logScreenLayoutWithViewController:(UIViewController *)viewController
                          andRelatedViews:(NSArray *)views
                                  andName:(NSString *)name

Where and when to call manual logging

With automatic logging enabled, view controllers are logged during the viewDidAppear stage of the view lifecycle. If the view that is logged is loading remote data, this is not adequate. In this case, the ideal time to call the logging method is when the remote data is done loading and displaying.

- (void)RESTRequestCompleted:(RESTRequest *)request
                responseData:(NSDictionary *)responseData
                    response:(NSHTTPURLResponse *)response {
  [self updateUI:[responseData objectForKey:[self productKeyKey]]];
  [self hideActivityIndicator];
  [[ConnectCustomEvent sharedInstance] logScreenLayoutWithViewController:self];
}

In some cases, you need to delay triggering logging to give time for UI animations to complete or a UITableView reloadData call to complete. The Custom Event provides a method to accomplish this.

- (void)RESTRequestCompleted:(RESTRequest *)request
                responseData:(NSDictionary *)responseData
                    response:(NSHTTPURLResponse *)response {
  items = [responseData objectForKey:[self itemsKey]];
  [self.itemsTable reloadData];
  [self hideActivityIndicator];
  [[ConnectCustomEvent sharedInstance] logScreenLayoutWithViewController:self
                                                            andDelay:0.1];
}

After certain UIEvents, it may be beneficial to trigger logging, such as upon selection of an item on table view that stretches beyond one screen.

- (NSIndexPath *)tableView:(UITableView *)tableView
    willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  [[ConnectCustomEvent sharedInstance] logScreenLayoutWithViewController:self];
  return indexPath;
}

A manual logging call is required to capture an alert view.

- (IBAction)btnSubmitFormClick:(id)sender {
  UIAlertView *alert =
      [[UIAlertView alloc] initWithTitle:@"Thank You!"
                                 message:@"We will be in touch with you soon."
                                delegate:self
                       cancelButtonTitle:@"Ok"
                       otherButtonTitles:nil];
  [alert show];
  [[ConnectCustomEvent sharedInstance]
      logScreenLayoutWithViewController:self
                        andRelatedViews:@[ alert ]];
}

You should also log the screen layout after the alert dialog is dismissed.

- (void)alertView:(UIAlertView *)alertView
    clickedButtonAtIndex:(NSInteger)buttonIndex {
  [[ConnectCustomEvent sharedInstance] logScreenLayoutWithViewController:self];
}

Experience Analytics (Tealeaf) screen layout logging only logs the views and controls that are on screen when the logging call is made. When UITableViewcontains more rows than can be view on a screen at once, call the screen layout logging when an item is selected. This ensures thatde the event matches the row selected. Use the following code in your UITableViewDelegate to make this change.

- (NSIndexPath *)tableView:(UITableView *)tableView
    willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  [[ConnectCustomEvent sharedInstance] logScreenLayoutWithViewController:self];
  return indexPath;
}