---
updatedAt: 2026-05-14T18:17:11.000Z
---

# ConnectCustomEvent

Use `ConnectCustomEvent` to instrument the Connect iOS library and capture custom events, errors, exceptions, network activity, geolocation, UI control interactions, and screen views.

**Platform:** iOS 15.1+
**Languages:** Swift and Objective-C
**Declared in:** `ConnectCustomEvent.h`

***

## Getting the shared instance

### sharedInstance

Returns the singleton instance of `ConnectCustomEvent`. Use this instance for all logging calls.

```swift
import Connect

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

+ (ConnectCustomEvent *)sharedInstance;
```

***

## Logging custom events

Log a named event, optionally with a values dictionary and a monitoring level.

### logEvent

```swift
logEvent(_ eventName: String?) -> Bool

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

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

- (BOOL)logEvent:(NSString *)eventName
          values:(NSDictionary *)values;

- (BOOL)logEvent:(NSString *)eventName
          values:(NSDictionary *)values
           level:(kConnectMonitoringLevelType)level;
```

| Parameter   | Required? | Description                                                                                                                      |
| :---------- | :-------- | :------------------------------------------------------------------------------------------------------------------------------- |
| `eventName` | Required  | The name of the event. Must not contain `=`, `[`, or `]`.                                                                        |
| `values`    | Optional  | Additional key-value pairs to log with the event. Values must be `NSDictionary`, `NSArray`, `NSString`, `NSNumber`, or `NSNull`. |
| `level`     | Optional  | Overrides the event's configured monitoring level. See [Monitoring levels](#monitoring-levels).                                  |

Returns `true` if the event was successfully logged.

> 📘 Note
>
> To be convertible to JSON, dictionary values must be `NSDictionary`, `NSArray`, `NSString`, `NSNumber`, or `NSNull`.

### logSignal

Logs a signal event with a values dictionary.

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

logSignal(_ values: [AnyHashable: Any]?,
          level: kConnectMonitoringLevelType) -> Bool
```
```objectivec
- (BOOL)logSignal:(NSDictionary *)values;

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

| Parameter | Required? | Description                                                                                                            |
| :-------- | :-------- | :--------------------------------------------------------------------------------------------------------------------- |
| `values`  | Required  | Key-value pairs to log with the signal. Values must be `NSDictionary`, `NSArray`, `NSString`, `NSNumber`, or `NSNull`. |
| `level`   | Optional  | Overrides the configured monitoring level. See [Monitoring levels](#monitoring-levels).                                |

Returns `true` if the signal was successfully logged.

***

## Monitoring levels

The `kConnectMonitoringLevelType` enum controls when an event is posted to the collector, based on network conditions.

| Constant                                 | Value | Description                                             |
| :--------------------------------------- | :---- | :------------------------------------------------------ |
| `kConnectMonitoringLevelIgnore`          | `0`   | The event is dropped.                                   |
| `kConnectMonitoringLevelCellularAndWiFi` | `1`   | The event is posted over cellular or Wi-Fi *(default)*. |
| `kConnectMonitoringLevelWiFi`            | `2`   | The event is posted over Wi-Fi only.                    |

Monitoring levels are nested: events with lower levels are considered more important. Defined in `ConnectPublicDefinitions.h`.

***

## Logging errors

### logNSErrorEvent

Logs an `NSError` instance.

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

logNSErrorEvent(_ error: (any Error)?,
                message: String?,
                file: UnsafePointer<Int8>?,
                line: UInt,
                level: kConnectMonitoringLevelType) -> Bool
```
```objectivec
- (BOOL)logNSErrorEvent:(NSError *)error
                message:(NSString *)message
                  level:(kConnectMonitoringLevelType)level;

- (BOOL)logNSErrorEvent:(NSError *)error
                message:(NSString *)message
                   file:(const char *)file
                   line:(unsigned int)line
                  level:(kConnectMonitoringLevelType)level;
```

| Parameter | Required? | Description                                                        |
| :-------- | :-------- | :----------------------------------------------------------------- |
| `error`   | Required  | The `NSError` to log.                                              |
| `message` | Required  | Additional information about the error.                            |
| `level`   | Required  | The monitoring level. See [Monitoring levels](#monitoring-levels). |
| `file`    | Optional  | The source file where the error occurred. Pass `__FILE__`.         |
| `line`    | Optional  | The source line where the error occurred. Pass `__LINE__`.         |

Returns `true` if the event was successfully logged.

#### Example JSON output

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

***

## Logging exceptions

### logNSExceptionEvent

Logs an `NSException`. Use this from your own exception handler — the Cocoa runtime is not exception-safe, so the SDK does not catch exceptions automatically.

```swift
logNSExceptionEvent(_ exception: NSException?) -> Bool

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

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

- (BOOL)logNSExceptionEvent:(NSException *)exception
             dataDictionary:(NSDictionary *)dataDictionary;

- (BOOL)logNSExceptionEvent:(NSException *)exception
             dataDictionary:(NSDictionary *)dataDictionary
                isUnhandled:(BOOL)unhandled;
```

| Parameter        | Required? | Description                                                                                                             |
| :--------------- | :-------- | :---------------------------------------------------------------------------------------------------------------------- |
| `exception`      | Required  | The caught `NSException`.                                                                                               |
| `dataDictionary` | Optional  | Additional data to log with the exception.                                                                              |
| `unhandled`      | Optional  | Indicates whether the exception was caught by an exception handler. Defaults to `false` in the two-parameter overloads. |

Returns `true` if the event was successfully logged.

### Logging exceptions in Swift

Swift does not support throwing `NSException` directly. To log exception data from Swift, wrap an `NSException` instance inside an `NSError`'s `userInfo` and catch it:

```swift
enum MyError: Error {
    case runtimeError(String)
    case outOfIndex(String)
}

func throwException(message: String) throws {
    let info: [String: Any] = ["context": "any"]
    let exceptionInfo: [String: NSException] = [
        "ExceptionObject": NSException(
            name: NSExceptionName("TheException"),
            reason: "Unable to complete operation",
            userInfo: info
        )
    ]
    throw NSError(domain: "exception", code: 10, userInfo: exceptionInfo)
}

@IBAction func generateUnhandledException(sender: UIButton) {
    do {
        try throwException(message: "exception")
    } catch let err as NSError {
        if let ex = err.userInfo["ExceptionObject"] as? NSException {
            ConnectCustomEvent.sharedInstance().logNSExceptionEvent(
                ex,
                dataDictionary: err.userInfo,
                isUnhandled: true
            )
        }
        ConnectCustomEvent.sharedInstance().logNSErrorEvent(
            err,
            message: "error",
            level: kConnectMonitoringLevelCellularAndWiFi
        )
    }
}
```

***

## Logging Swift assert and precondition events

These methods log Swift error conditions and flush any buffered capture data immediately.

### logAssertErrorEvent

Logs a Swift `assert` failure.

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

| Parameter   | Required? | Description                                 |
| :---------- | :-------- | :------------------------------------------ |
| `error`     | Required  | The error to log.                           |
| `condition` | Required  | The condition that failed.                  |
| `message`   | Required  | Additional information about the assertion. |
| `file`      | Required  | The source file. Pass `__FILE__`.           |
| `line`      | Required  | The source line. Pass `__LINE__`.           |

Returns `true` if the event was successfully logged.

### logPreconditionErrorEvent

Logs a Swift `precondition` failure.

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

| Parameter   | Required? | Description                                    |
| :---------- | :-------- | :--------------------------------------------- |
| `error`     | Required  | The error to log.                              |
| `condition` | Required  | The condition that failed.                     |
| `message`   | Required  | Additional information about the precondition. |
| `file`      | Required  | The source file. Pass `__FILE__`.              |
| `line`      | Required  | The source line. Pass `__LINE__`.              |

Returns `true` if the event was successfully logged.

### logAssertionFailureErrorEvent

Logs a Swift `assertionFailure`.

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

| Parameter | Required? | Description                               |
| :-------- | :-------- | :---------------------------------------- |
| `error`   | Required  | The error to log.                         |
| `message` | Required  | Additional information about the failure. |
| `file`    | Required  | The source file. Pass `__FILE__`.         |
| `line`    | Required  | The source line. Pass `__LINE__`.         |

Returns `true` if the event was successfully logged.

### logPreconditionFailureErrorEvent

Logs a Swift `preconditionFailure`.

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

| Parameter | Required? | Description                               |
| :-------- | :-------- | :---------------------------------------- |
| `error`   | Required  | The error to log.                         |
| `message` | Required  | Additional information about the failure. |
| `file`    | Required  | The source file. Pass `__FILE__`.         |
| `line`    | Required  | The source line. Pass `__LINE__`.         |

Returns `true` if the event was successfully logged.

### logFatalErrorEvent

Logs a Swift `fatalError`.

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

| Parameter | Required? | Description                                   |
| :-------- | :-------- | :-------------------------------------------- |
| `error`   | Required  | The error to log.                             |
| `message` | Required  | Additional information about the fatal error. |
| `file`    | Required  | The source file. Pass `__FILE__`.             |
| `line`    | Required  | The source line. Pass `__LINE__`.             |

Returns `true` if the event was successfully logged.

***

## Logging network activity

### logNSURLSession

Logs information about an `NSURLSession` request, response, or error.

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

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

logNSURLSession(_ urlSession: Any?,
                request: URLRequest?) -> Bool
```
```objectivec
- (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;
```

| Parameter      | Required? | Description                               |
| :------------- | :-------- | :---------------------------------------- |
| `urlSession`   | Required  | The `NSURLSession` object.                |
| `error`        | Optional  | The `NSError` returned by the request.    |
| `request`      | Optional  | The `NSURLRequest`.                       |
| `response`     | Optional  | The `NSURLResponse`.                      |
| `responseTime` | Optional  | The server response time in milliseconds. |

Returns `true` if the event was successfully logged.

### logConnectionWithInitTime

Logs detailed connection timing and payload information.

```swift
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
```
```objectivec
- (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;
```

| Parameter    | Required? | Description                                           |
| :----------- | :-------- | :---------------------------------------------------- |
| `initTime`   | Required  | Time duration since the start of the current session. |
| `loadTime`   | Required  | Time taken to load the resource.                      |
| `connection` | Optional  | The `NSURLSession` object. Can be `nil`.              |
| `request`    | Required  | The `NSURLRequest` associated with the connection.    |
| `response`   | Required  | The `NSURLResponse`.                                  |
| `data`       | Optional  | The `NSData` object from the request or response.     |
| `error`      | Optional  | The `NSError` returned by the request.                |

Returns `true` if the event was successfully logged.

***

## Logging geolocation

Location events are not captured automatically. Log them only when your app has a reason to access location — this avoids unnecessary location updates and respects user privacy. Your app must link the Core Location framework.

### logLocation

Logs a `CLLocation` instance. Call from your `CLLocationManagerDelegate`.

```swift
logLocation(_ location: CLLocation?) -> Bool
```
```objectivec
- (BOOL)logLocation:(CLLocation *)location;
```

| Parameter  | Required? | Description                                                |
| :--------- | :-------- | :--------------------------------------------------------- |
| `location` | Required  | A `CLLocation` object containing the location of interest. |

Returns `true` if the event was successfully logged.

#### Example

```swift
func locationManager(_ manager: CLLocationManager,
                     didUpdateLocations locations: [CLLocation]) {
    if let location = locations.last {
        ConnectCustomEvent.sharedInstance().logLocation(location)
    }
}
```
```objectivec
- (void)locationManager:(CLLocationManager *)manager
     didUpdateLocations:(NSArray<CLLocation *> *)locations {
    CLLocation *location = locations.lastObject;
    [[ConnectCustomEvent sharedInstance] logLocation:location];
}
```

### logLocationUpdateEventWithLatitude

Logs a location using raw latitude and longitude values.

```swift
logLocationUpdateEvent(withLatitude lat: Double,
                       longitude lng: Double,
                       level: kConnectMonitoringLevelType) -> Bool
```
```objectivec
- (BOOL)logLocationUpdateEventWithLatitude:(double)lat
                                 longitude:(double)lng
                                     level:(kConnectMonitoringLevelType)level;
```

| Parameter | Required? | Description                                                        |
| :-------- | :-------- | :----------------------------------------------------------------- |
| `lat`     | Required  | The geographic latitude.                                           |
| `lng`     | Required  | The geographic longitude.                                          |
| `level`   | Required  | The monitoring level. See [Monitoring levels](#monitoring-levels). |

Returns `true` if the event was successfully logged.

***

## Logging UI control events

### logClickEvent

Logs a click event on a `UIControl` or `UIView`. A click event is a normalized form of "touch up inside".

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

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

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

| Parameter   | Required? | Description                                    |
| :---------- | :-------- | :--------------------------------------------- |
| `view`      | Required  | The `UIView` on which the click occurred.      |
| `controlId` | Optional  | The ID of the control.                         |
| `data`      | Optional  | Additional custom data to send with the event. |

Returns `true` if the event was successfully logged.

### logValueChangeEvent

Logs a content change on a `UITableViewCell` or `UICollectionViewCell`.

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

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

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

| Parameter   | Required? | Description                                    |
| :---------- | :-------- | :--------------------------------------------- |
| `view`      | Required  | The `UIView` whose value changed.              |
| `controlId` | Optional  | The ID of the control.                         |
| `data`      | Optional  | Additional custom data to send with the event. |

Returns `true` if the event was successfully logged.

### logTextChangeEvent

Logs an edit event on a `UITextView`, `UITextViewSecure`, `UITextField`, or `UITextFieldSecure`.

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

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

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

| Parameter   | Required? | Description                                    |
| :---------- | :-------- | :--------------------------------------------- |
| `view`      | Required  | The text view or field being edited.           |
| `controlId` | Optional  | The ID of the control.                         |
| `data`      | Optional  | Additional custom data to send with the event. |

Returns `true` if the event was successfully logged.

### logUILabelTextChange

Logs a text change on a `UILabel`. The captured event includes both the previous and current label text.

```swift
logUILabelTextChange(_ label: UILabel?) -> Bool

logUILabelTextChange(_ label: UILabel?,
                     controlId: String?) -> Bool
```
```objectivec
- (BOOL)logUILabelTextChange:(UILabel *)label;

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

| Parameter   | Required? | Description                       |
| :---------- | :-------- | :-------------------------------- |
| `label`     | Required  | The `UILabel` whose text changed. |
| `controlId` | Optional  | The ID of the control.            |

Returns `true` if the event was successfully logged.

### logFormCompletion

Logs a form completion event.

```swift
logFormCompletion(_ submitted: Bool) -> Bool

logFormCompletion(_ submitted: Bool,
                  withValidData isValid: Bool) -> Bool
```
```objectivec
- (BOOL)logFormCompletion:(BOOL)submitted;

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

| Parameter   | Required? | Description                                     |
| :---------- | :-------- | :---------------------------------------------- |
| `submitted` | Required  | Indicates whether form data was submitted.      |
| `isValid`   | Optional  | Indicates whether the submitted data was valid. |

Returns `true` if the event was successfully logged.

***

## Logging screen views

### logScreenViewPageName

Sets the logical page name for screen layout captures. Used in React Native apps.

```swift
logScreenViewPageName(_ logicalPageName: String?) -> Bool
```
```objectivec
- (BOOL)logScreenViewPageName:(NSString *)logicalPageName;
```

| Parameter         | Required? | Description                                                                       |
| :---------------- | :-------- | :-------------------------------------------------------------------------------- |
| `logicalPageName` | Required  | The page name or title, for example `"Login View Controller"`. Must not be empty. |

Returns `true` if the event was successfully logged.

### logScreenViewContext

Logs an application context for a screen.

```swift
logScreenViewContext(_ logicalPageName: String?,
                     withClass clsss: String?,
                     applicationContext screenViewType: ConnectScreenViewType,
                     referrer: String?) -> Bool
```
```objectivec
- (BOOL)logScreenViewContext:(NSString *)logicalPageName
                   withClass:(NSString *)clsss
          applicationContext:(ConnectScreenViewType)screenViewType
                    referrer:(NSString *)referrer;
```

| Parameter         | Required? | Description                                                 |
| :---------------- | :-------- | :---------------------------------------------------------- |
| `logicalPageName` | Required  | The page name or title. Must not be empty.                  |
| `clsss`           | Required  | The `UIViewController` class name. Must not be empty.       |
| `screenViewType`  | Required  | A value from [`ConnectScreenViewType`](#screen-view-types). |
| `referrer`        | Optional  | The page name or title that loaded this page.               |

Returns `true` if the event was successfully logged.

### logPrintScreenEvent

Logs a print-screen event. The current screenshot is automatically associated.

```swift
logPrintScreenEvent() -> Bool
```
```objectivec
- (BOOL)logPrintScreenEvent;
```

Returns `true` if the event was successfully logged.

***

## Screen view types

The `ConnectScreenViewType` enum identifies the kind of screen-view event. Defined in `ConnectPublicDefinitions.h`.

| Constant                      | Value | Description                    |
| :---------------------------- | :---- | :----------------------------- |
| `ConnectScreenViewTypeNil`    | `0`   | No screen view.                |
| `ConnectScreenViewTypeUnload` | `1`   | The screen is being dismissed. |
| `ConnectScreenViewTypeLoad`   | `2`   | The screen is being presented. |
| `ConnectScreenViewTypeVisit`  | `3`   | A logical visit event.         |

***

## Logging screen layouts

These methods manually log screen layouts for session replay. For guidance on when and how to call them, see [Manually log screen layouts in a native iOS app](https://developer.goacoustic.com/acoustic-connect/docs/log-screen-layouts-manually).

### logScreenLayoutWithImage

Logs an image as the background of a screen layout capture.

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

| Parameter | Required? | Description                                    |
| :-------- | :-------- | :--------------------------------------------- |
| `image`   | Required  | The `UIImage` to use as the layout background. |

Returns `true` if the event was successfully logged.

### logScreenLayoutWithViewController

Logs the layout of a view controller. Supports optional delay, custom name, and related views.

```swift
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]?) -> Bool

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

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

logScreenLayout(with viewController: UIViewController?,
                andRelatedViews views: [AnyHashable]?,
                andDelay delay: CGFloat,
                andName name: String?) -> Bool
```
```objectivec
- (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;

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

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

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

| Parameter        | Required? | Description                                                                                       |
| :--------------- | :-------- | :------------------------------------------------------------------------------------------------ |
| `viewController` | Required  | The `UIViewController` whose layout to log.                                                       |
| `delay`          | Optional  | Seconds to wait before capturing. Useful when animations or data reloads must complete first.     |
| `name`           | Optional  | A custom name for the captured layout. Useful when one view controller serves multiple functions. |
| `views`          | Optional  | Additional views outside the main view hierarchy to include — for example, alerts or overlays.    |

Returns `true` if the event was successfully logged.

***

## Logging JSON, images, and performance data

### logJSONMessagePayloadStr

Logs a Connect JSON message coming from JavaScript. The string must follow the Connect JSON message format.

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

| Parameter | Required? | Description                                        |
| :-------- | :-------- | :------------------------------------------------- |
| `payload` | Required  | A string matching the Connect JSON message format. |

Returns `true` if the event was successfully logged.

### logImageUrl

Associates a URL with a `UIImage` so it can be referenced during session replay.

```swift
logImageUrl(_ image: UIImage?,
            withUrl url: String?) -> Bool
```
```objectivec
- (BOOL)logImageUrl:(UIImage *)image
            withUrl:(NSString *)url;
```

| Parameter | Required? | Description           |
| :-------- | :-------- | :-------------------- |
| `image`   | Required  | The `UIImage`.        |
| `url`     | Required  | The URL of the image. |

Returns `true` if the URL was successfully associated with the image.

### logPerformance

Logs page performance timing data. The parameter list matches the W3C Navigation Timing API. See the [W3C Navigation Timing specification](https://www.w3.org/TR/navigation-timing/) for parameter definitions.

```swift
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
```
```objectivec
- (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;
```

The `perNavType` parameter accepts a value from the `ConnectPerformanceNavigationType` enum:

| Constant              | Value | Description                   |
| :-------------------- | :---- | :---------------------------- |
| `ConnectNavigate`     | `0`   | A standard navigation.        |
| `ConnectReload`       | `1`   | A page reload.                |
| `ConnectBack_Forward` | `2`   | A back or forward navigation. |
| `ConnectReserved`     | `255` | Reserved.                     |

Returns `true` if the event was successfully logged.