# PostHog iOS SDK

**SDK Version:** 3.34.0

PostHog iOS SDK allows you to automatically capture usage and send events to PostHog from iOS applications.

## Categories

- Initialization
- Identification
- Capture
- Feature flags
- Session replay
- Privacy
- Configuration

## PostHogSDK

The PostHogSDK class

### Identification methods

#### alias()

**Release Tag:** public

Assigns an additional distinct ID to the current user.

**Notes:**

Use this method when you want to associate multiple distinct IDs with a single user,   for example, if a distinct ID used on the frontend is not available in your backend.

### Parameters

- **`alias`** (`Any`) - The new distinct ID to associate with the current user.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.alias(alias: "alias_value")
```

---

#### getAnonymousId()

**Release Tag:** public

getAnonymousId method

### Returns

- `String`

### Examples

```swift
PostHogSDK.shared.getAnonymousId()
```

---

#### getDistinctId()

**Release Tag:** public

Returns the current user’s distinct ID.

**Notes:**

The current user’s distinct ID.

### Returns

- `String`

### Examples

```swift
PostHogSDK.shared.getDistinctId()
```

---

#### identify()

**Release Tag:** public

Associates events with a specific user by their distinct ID.

**Notes:**

This is a convenience method for   without additional properties.   You should call this method as soon as you are able to identify your user, typically after they log in.

### Parameters

- **`distinctId`** (`Any`) - A unique identifier for your user in your database.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.identify(distinctId: "distinctId_value")
```

---

#### identify()

**Release Tag:** public

identify method

### Parameters

- **`distinctId`** (`String`) - The distinctId parameter
- **`userProperties?`** (`[String : Any]? = nil`) - The userProperties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.identify(distinctId: "distinctId_value", userProperties: ["key": "value"])
```

---

#### identify()

**Release Tag:** public

Associates events with a specific user by their distinct ID and sets/updates user properties.

**Notes:**

Use this method to gain insights into how your users interact with your product across sessions,   devices, and platforms. All previously tracked anonymous events will be linked to this user.

### Parameters

- **`distinctId`** (`Any`) - A unique identifier for your user in your database.
- **`userProperties`** (`String`) - Optional. A dictionary with key-value pairs to set on the person profile. These are set using  .
- **`userPropertiesSetOnce`** (`String`) - Optional. A dictionary with key-value pairs to set on the person profile only if they don’t already exist. These are set using  .

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.identify(distinctId: "distinctId_value", userProperties: "userProperties_value", userPropertiesSetOnce: "userPropertiesSetOnce_value")
```

---

### Capture methods

#### capture()

**Release Tag:** public

Captures a custom event without additional properties.

**Notes:**

Use this method to track user behavior or other occurrences in your application.

### Parameters

- **`event`** (`Any`) - The name of the event to capture. We recommend using an   format (e.g.,  ,  ).

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value")
```

---

#### capture()

**Release Tag:** public

capture method

### Parameters

- **`event`** (`String`) - The event parameter
- **`distinctId`** (`String`) - The distinctId parameter
- **`properties?`** (`[String : Any]? = nil,`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", distinctId: "distinctId_value", properties: ["key": "value"])
```

---

#### capture()

**Release Tag:** public

capture method

### Parameters

- **`event`** (`String`) - The event parameter
- **`distinctId`** (`String`) - The distinctId parameter
- **`properties?`** (`[String : Any]? = nil,`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", distinctId: "distinctId_value", properties: ["key": "value"])
```

---

#### capture()

**Release Tag:** public

capture method

### Parameters

- **`event`** (`String`) - The event parameter
- **`properties?`** (`[String : Any]? = nil`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", properties: ["key": "value"])
```

---

#### capture()

**Release Tag:** public

Captures a custom event with optional event properties and user properties.

**Notes:**

Use this method to track user behavior or other occurrences, including additional context about the event and the user.

### Parameters

- **`event`** (`Any`) - The name of the event to capture. We recommend using an   format (e.g.,  ,  ).
- **`properties`** (`String`) - Optional. A dictionary with key-value pairs to include as event properties.
- **`userProperties`** (`String`) - Optional. A dictionary with key-value pairs to set or update on the person profile associated with the event. These are set using  .

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", properties: "properties_value", userProperties: "userProperties_value")
```

---

#### capture()

**Release Tag:** public

capture method

### Parameters

- **`event`** (`String`) - The event parameter
- **`properties?`** (`[String : Any]? = nil,`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", properties: ["key": "value"])
```

---

#### capture()

**Release Tag:** public

capture method

### Parameters

- **`event`** (`String`) - The event parameter
- **`properties?`** (`[String : Any]? = nil,`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.capture(event: "event_value", properties: ["key": "value"])
```

---

#### flush()

**Release Tag:** public

Manually flushes the event queue, sending all stored events to PostHog immediately.

**Notes:**

The SDK normally flushes events automatically based on   and    configuration. Call this method to force an immediate dispatch of events.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.flush()
```

---

#### register()

**Release Tag:** public

register method

### Parameters

- **`properties`** (`[String : Any]`) - The properties parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.register(properties: ["key": "value"])
```

---

#### screen()

**Release Tag:** public

Captures a screen view event with a given title.

**Notes:**

This is a convenience method for   without additional properties.

### Parameters

- **`screenTitle`** (`Any`) - The title or name of the screen being viewed.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.screen(screenTitle: "screenTitle_value")
```

---

#### screen()

**Release Tag:** public

Captures a screen view event with an optional title and properties.

**Notes:**

Use this method to manually track screen changes in your application, especially for SwiftUI apps   where automatic screen view tracking might not provide meaningful names.

### Parameters

- **`screenTitle`** (`Any`) - The title or name of the screen being viewed.
- **`properties`** (`String`) - Optional. A dictionary with key-value pairs to include as event properties.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.screen(screenTitle: "screenTitle_value", properties: "properties_value")
```

---

#### unregister()

**Release Tag:** public

unregister method

### Parameters

- **`key`** (`String`) - The key parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.unregister(key: "key_value")
```

---

### Configuration methods

#### close()

**Release Tag:** public

close method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.close()
```

---

#### debug()

**Release Tag:** public

Toggles verbose logging for the PostHog SDK.

**Notes:**

Enable debug mode to see detailed logs about event capture, feature flag evaluation,   surveys, and other internal workings of the SDK. This is useful for troubleshooting   during development.

### Parameters

- **`enabled`** (`Any`) -   to enable debug mode,   to disable. Defaults to  .

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.debug(enabled: "enabled_value")
```

---

#### group()

**Release Tag:** public

Associates the current session’s events with a specific group.

**Notes:**

Use this method to track user activity within a particular group (e.g., a company or team).

### Parameters

- **`type`** (`String`) - The group type (e.g., “company”, “team”).
- **`key`** (`String`) - A unique identifier for the group in your database.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.group(type: "type_value", key: "key_value")
```

---

#### group()

**Release Tag:** public

Associates the current session’s events with a group and updates that group’s properties.

**Notes:**

This method allows you to track user activity within a group while simultaneously setting   or updating properties associated with that group.

### Parameters

- **`type`** (`String`) - The group type (e.g., “company”, “team”).
- **`key`** (`String`) - A unique identifier for the group in your database.
- **`groupProperties`** (`String`) - Optional. A dictionary with key-value pairs to set or update on the group profile.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.group(type: "type_value", key: "key_value", groupProperties: "groupProperties_value")
```

---

#### didStartNotification()

**Release Tag:** public

didStartNotification method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.didStartNotification()
```

---

#### shared()

**Release Tag:** public

shared method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.shared()
```

---

### Session replay methods

#### endSession()

**Release Tag:** public

endSession method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.endSession()
```

---

#### getSessionId()

**Release Tag:** public

getSessionId method

### Returns

- `String?`

### Examples

```swift
PostHogSDK.shared.getSessionId()
```

---

#### startSession()

**Release Tag:** public

startSession method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.startSession()
```

---

### Feature flags methods

#### getFeatureFlag()

**Release Tag:** public

Retrieves the value of a feature flag.

**Notes:**

The value of the feature flag (e.g.,  ,  ), or   if the flag is not found.

### Parameters

- **`key`** (`Any`) - The key of the feature flag.

### Returns

- `Any?`

### Examples

```swift
PostHogSDK.shared.getFeatureFlag(key: "key_value")
```

---

#### getFeatureFlagPayload()

**Release Tag:** public

Retrieves the payload associated with a feature flag.

**Notes:**

The payload of the feature flag, or   if no payload is associated or the flag is not found.

### Parameters

- **`key`** (`Any`) - The key of the feature flag.

### Returns

- `Any?`

### Examples

```swift
PostHogSDK.shared.getFeatureFlagPayload(key: "key_value")
```

---

#### isFeatureEnabled()

**Release Tag:** public

Checks if a boolean feature flag is enabled for the current user.

**Notes:**

  if the feature flag is enabled,   otherwise.

### Parameters

- **`key`** (`Any`) - The key of the feature flag.

### Returns

- `Bool`

### Examples

```swift
PostHogSDK.shared.isFeatureEnabled(key: "key_value")
```

---

#### reloadFeatureFlags()

**Release Tag:** public

Reloads all feature flags for the current user.

**Notes:**

Feature flag values are cached. Call this method to refetch the latest flag values   from the server if something has changed with your user (e.g., properties updated).

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.reloadFeatureFlags()
```

---

#### reloadFeatureFlags()

**Release Tag:** public

Reloads all feature flags for the current user and executes a completion callback.

**Notes:**

Use this method to refetch the latest flag values and perform actions immediately   after the flags have been successfully reloaded.

### Parameters

- **`callback`** (`Any`) - A closure to be executed after feature flags are reloaded.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.reloadFeatureFlags(callback: "callback_value")
```

---

#### resetGroupPropertiesForFlags()

**Release Tag:** public

Clears all group properties for feature flag evaluation.

**Notes:**

Clears all group properties for feature flag evaluation.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.resetGroupPropertiesForFlags()
```

---

#### resetGroupPropertiesForFlags()

**Release Tag:** public

Clears group properties for feature flag evaluation for a specific group type.

**Notes:**

Clears group properties for feature flag evaluation for a specific group type.

### Parameters

- **`groupType`** (`Any`) - The group type to clear properties for

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.resetGroupPropertiesForFlags(groupType: "groupType_value")
```

---

#### resetPersonPropertiesForFlags()

**Release Tag:** public

Resets all person properties that were set for feature flag evaluation.

**Notes:**

After calling this method, feature flag evaluation will only use server-side person properties   and will not include any locally overridden properties.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.resetPersonPropertiesForFlags()
```

---

#### setGroupPropertiesForFlags()

**Release Tag:** public

Sets properties for a specific group type to include when evaluating feature flags.   These properties supplement the standard group information sent to PostHog for flag evaluation,   providing additional context that can be used in flag targeting conditions.

**Notes:**

Sets properties for a specific group type to include when evaluating feature flags.   These properties supplement the standard group information sent to PostHog for flag evaluation,   providing additional context that can be used in flag targeting conditions.

### Parameters

- **`groupType`** (`Any`) - The group type identifier (e.g., “organization”, “team”)
- **`properties`** (`String`) - Dictionary of properties to set for this group type

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.setGroupPropertiesForFlags(groupType: "groupType_value", properties: "properties_value")
```

---

#### setGroupPropertiesForFlags()

**Release Tag:** public

Sets properties for a specific group type to include when evaluating feature flags.   These properties supplement the standard group information sent to PostHog for flag evaluation,   providing additional context that can be used in flag targeting conditions.

**Notes:**

Sets properties for a specific group type to include when evaluating feature flags.   These properties supplement the standard group information sent to PostHog for flag evaluation,   providing additional context that can be used in flag targeting conditions.

### Parameters

- **`groupType`** (`Any`) - The group type identifier (e.g., “organization”, “team”)
- **`properties`** (`String`) - Dictionary of properties to set for this group type
- **`reloadFeatureFlags`** (`Bool`) - Whether to automatically reload feature flags after setting properties

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.setGroupPropertiesForFlags(groupType: "groupType_value", properties: "properties_value", reloadFeatureFlags: true)
```

---

#### setPersonPropertiesForFlags()

**Release Tag:** public

Sets person properties that will be included in feature flag evaluation requests.

**Notes:**

This method allows you to override server-side person properties for immediate feature flag evaluation,   solving the race condition where person properties from   calls may not have been processed   by the server yet. Properties are merged additively with existing properties. Feature flags are automatically reloaded   after setting properties.

### Parameters

- **`properties`** (`Any`) - Dictionary of person properties to include in flag evaluation

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.setPersonPropertiesForFlags(properties: "properties_value")
```

---

#### setPersonPropertiesForFlags()

**Release Tag:** public

Sets person properties that will be included in feature flag evaluation requests.

**Notes:**

This method allows you to override server-side person properties for immediate feature flag evaluation,   solving the race condition where person properties from   calls may not have been processed   by the server yet. Properties are merged additively with existing properties.

### Parameters

- **`properties`** (`Any`) - Dictionary of person properties to include in flag evaluation
- **`reloadFeatureFlags`** (`Bool`) - Whether to automatically reload feature flags after setting properties

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.setPersonPropertiesForFlags(properties: "properties_value", reloadFeatureFlags: true)
```

---

#### didReceiveFeatureFlags()

**Release Tag:** public

didReceiveFeatureFlags method

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.didReceiveFeatureFlags()
```

---

### Privacy methods

#### isOptOut()

**Release Tag:** public

Checks if the user is currently opted out of data capture.

**Notes:**

  if the user is opted out,   otherwise.

### Returns

- `Bool`

### Examples

```swift
PostHogSDK.shared.isOptOut()
```

---

#### optIn()

**Release Tag:** public

Opts the user back into data capture.

**Notes:**

This method allows a previously opted-out user to resume data capture.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.optIn()
```

---

#### optOut()

**Release Tag:** public

Opts the user out of all data capture.

**Notes:**

When a user is opted out, no events, session replays, or other data will be captured.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.optOut()
```

---

#### reset()

**Release Tag:** public

Resets the user’s distinct ID, anonymous ID, and clears all super properties.

**Notes:**

This method is typically called after a user logs out to disassociate their activity   from previous sessions and prepare for a new, potentially anonymous, user journey.

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.reset()
```

---

### Initialization methods

#### setup()

**Release Tag:** public

setup method

### Parameters

- **`config`** (`PostHogConfig`) - The config parameter

### Returns

- `Void`

### Examples

```swift
PostHogSDK.shared.setup(config: "config_value")
```

---

#### with()

**Release Tag:** public

with method

### Parameters

- **`config`** (`PostHogConfig`) - The config parameter
- **`param1`** (`PostHogSDK`) - The param1 parameter

### Returns

- `PostHogSDK`

### Examples

```swift
PostHogSDK.shared.with(config: "config_value", param1: "param1_value")
```

---

## PostHogDisplaySurvey

A model representing a PostHog survey to be displayed to users

### Configuration methods

#### appearance()

**Release Tag:** public

Optional appearance configuration for customizing the survey’s look and feel

**Notes:**

Optional appearance configuration for customizing the survey’s look and feel

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.appearance()
```

---

#### endDate()

**Release Tag:** public

Optional date indicating when the survey should stop being shown

**Notes:**

Optional date indicating when the survey should stop being shown

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.endDate()
```

---

#### id()

**Release Tag:** public

Unique identifier for the survey

**Notes:**

Unique identifier for the survey

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.id()
```

---

#### name()

**Release Tag:** public

Name of the survey

**Notes:**

Name of the survey

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.name()
```

---

#### questions()

**Release Tag:** public

Array of questions to be presented in the survey

**Notes:**

Array of questions to be presented in the survey

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.questions()
```

---

#### startDate()

**Release Tag:** public

Optional date indicating when the survey should start being shown

**Notes:**

Optional date indicating when the survey should start being shown

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurvey.startDate()
```

---

## PostHogDisplayLinkQuestion

Represents a question with a clickable link

### Configuration methods

#### link()

**Release Tag:** public

The URL that will be opened when the link is clicked

**Notes:**

The URL that will be opened when the link is clicked

### Returns

- `Void`

### Examples

```swift
postHogDisplayLinkQuestion.link()
```

---

## PostHogDisplayChoiceQuestion

Represents a multiple or single choice question where users can select one or more options

### Configuration methods

#### choices()

**Release Tag:** public

The list of options for the user to choose from

**Notes:**

The list of options for the user to choose from

### Returns

- `Void`

### Examples

```swift
postHogDisplayChoiceQuestion.choices()
```

---

#### hasOpenChoice()

**Release Tag:** public

Whether the question includes an “other” option for users to input free-form text

**Notes:**

Whether the question includes an “other” option for users to input free-form text

### Returns

- `Void`

### Examples

```swift
postHogDisplayChoiceQuestion.hasOpenChoice()
```

---

#### isMultipleChoice()

**Release Tag:** public

Whether the user can select multiple options

**Notes:**

Whether the user can select multiple options

### Returns

- `Void`

### Examples

```swift
postHogDisplayChoiceQuestion.isMultipleChoice()
```

---

#### shuffleOptions()

**Release Tag:** public

Whether the options should be shuffled to randomize the order

**Notes:**

Whether the options should be shuffled to randomize the order

### Returns

- `Void`

### Examples

```swift
postHogDisplayChoiceQuestion.shuffleOptions()
```

---

## PostHogNextSurveyQuestion

A model representing the next state of the survey progression.

### Configuration methods

#### isSurveyCompleted()

**Release Tag:** public

Whether all questions have been answered and the survey is complete   Depending on the survey appearance configuration, you may want to show the “Thank you” message or dismiss the survey at this point

**Notes:**

Whether all questions have been answered and the survey is complete   Depending on the survey appearance configuration, you may want to show the “Thank you” message or dismiss the survey at this point

### Returns

- `Void`

### Examples

```swift
postHogNextSurveyQuestion.isSurveyCompleted()
```

---

#### questionIndex()

**Release Tag:** public

The index of the next question to be displayed (0-based)

**Notes:**

The index of the next question to be displayed (0-based)

### Returns

- `Void`

### Examples

```swift
postHogNextSurveyQuestion.questionIndex()
```

---

## PostHogDisplayOpenQuestion

Represents an open-ended question where users can input free-form text

## PostHogEvent

The PostHogEvent class

### Configuration methods

#### distinctId()

**Release Tag:** public

distinctId method

### Returns

- `Void`

### Examples

```swift
postHogEvent.distinctId()
```

---

#### event()

**Release Tag:** public

event method

### Returns

- `Void`

### Examples

```swift
postHogEvent.event()
```

---

#### properties()

**Release Tag:** public

properties method

### Returns

- `Void`

### Examples

```swift
postHogEvent.properties()
```

---

#### timestamp()

**Release Tag:** public

timestamp method

### Returns

- `Void`

### Examples

```swift
postHogEvent.timestamp()
```

---

#### uuid()

**Release Tag:** public

uuid method

### Returns

- `Void`

### Examples

```swift
postHogEvent.uuid()
```

---

## PostHogSurveyResponse

A model representing a user’s response to a survey question

### Configuration methods

#### linkClicked()

**Release Tag:** public

Whether a link was clicked (for link questions)

**Notes:**

Whether a link was clicked (for link questions)

### Returns

- `Void`

### Examples

```swift
postHogSurveyResponse.linkClicked()
```

---

#### ratingValue()

**Release Tag:** public

The numeric rating value (for rating questions)

**Notes:**

The numeric rating value (for rating questions)

### Returns

- `Void`

### Examples

```swift
postHogSurveyResponse.ratingValue()
```

---

#### selectedOptions()

**Release Tag:** public

The selected options (for multiple or single choice questions)

**Notes:**

The selected options (for multiple or single choice questions)

### Returns

- `Void`

### Examples

```swift
postHogSurveyResponse.selectedOptions()
```

---

#### textValue()

**Release Tag:** public

The text response (for open questions)

**Notes:**

The text response (for open questions)

### Returns

- `Void`

### Examples

```swift
postHogSurveyResponse.textValue()
```

---

#### type()

**Release Tag:** public

The type of response (link, rating, text, or multiple choice)

**Notes:**

The type of response (link, rating, text, or multiple choice)

### Returns

- `Void`

### Examples

```swift
postHogSurveyResponse.type()
```

---

#### link()

**Release Tag:** public

Creates a response for a link question

**Notes:**

Creates a response for a link question

### Parameters

- **`clicked`** (`Any`) - Whether the link was clicked

### Returns

- `PostHogSurveyResponse`

### Examples

```swift
postHogSurveyResponse.link(clicked: "clicked_value")
```

---

#### multipleChoice()

**Release Tag:** public

Creates a response for a multiple-choice question

**Notes:**

Creates a response for a multiple-choice question

### Parameters

- **`multipleChoice`** (`Any`) - The selected options

### Returns

- `PostHogSurveyResponse`

### Examples

```swift
postHogSurveyResponse.multipleChoice(multipleChoice: "multipleChoice_value")
```

---

#### openEnded()

**Release Tag:** public

Creates a response for an open-ended question

**Notes:**

Creates a response for an open-ended question

### Parameters

- **`openEnded`** (`Any`) - The text response

### Returns

- `PostHogSurveyResponse`

### Examples

```swift
postHogSurveyResponse.openEnded(openEnded: "openEnded_value")
```

---

#### rating()

**Release Tag:** public

Creates a response for a rating question

**Notes:**

Creates a response for a rating question

### Parameters

- **`rating`** (`Any`) - The selected rating value

### Returns

- `PostHogSurveyResponse`

### Examples

```swift
postHogSurveyResponse.rating(rating: "rating_value")
```

---

#### singleChoice()

**Release Tag:** public

Creates a response for a single-choice question

**Notes:**

Creates a response for a single-choice question

### Parameters

- **`singleChoice`** (`Any`) - The selected option

### Returns

- `PostHogSurveyResponse`

### Examples

```swift
postHogSurveyResponse.singleChoice(singleChoice: "singleChoice_value")
```

---

## PostHogDisplaySurveyQuestion

Base class for all survey question types

### Configuration methods

#### buttonText()

**Release Tag:** public

Optional custom text for the question’s action button

**Notes:**

Optional custom text for the question’s action button

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.buttonText()
```

---

#### id()

**Release Tag:** public

The question ID, empty if none

**Notes:**

The question ID, empty if none

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.id()
```

---

#### isOptional()

**Release Tag:** public

Whether the question can be skipped

**Notes:**

Whether the question can be skipped

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.isOptional()
```

---

#### question()

**Release Tag:** public

The main question text to display

**Notes:**

The main question text to display

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.question()
```

---

#### questionDescription()

**Release Tag:** public

Optional additional description or context for the question

**Notes:**

Optional additional description or context for the question

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.questionDescription()
```

---

#### questionDescriptionContentType()

**Release Tag:** public

Content type for the question description (HTML or plain text)

**Notes:**

Content type for the question description (HTML or plain text)

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyQuestion.questionDescriptionContentType()
```

---

## PostHogSessionManager

The PostHogSessionManager class

### Session replay methods

#### setSessionId()

**Release Tag:** public

setSessionId method

### Parameters

- **`sessionId`** (`String`) - The sessionId parameter

### Returns

- `Void`

### Examples

```swift
postHogSessionManager.setSessionId(sessionId: "sessionId_value")
```

---

### Configuration methods

#### shared()

**Release Tag:** public

shared method

### Returns

- `Void`

### Examples

```swift
postHogSessionManager.shared()
```

---

## PostHogSurveysConfig

The PostHogSurveysConfig class

### Configuration methods

#### surveysDelegate()

**Release Tag:** public

Delegate responsible for managing survey presentation in your app.   Handles survey rendering, response collection, and lifecycle events.   You can provide your own delegate for a custom survey presentation.

**Notes:**

Defaults to   which provides a standard survey UI.

### Returns

- `Void`

### Examples

```swift
postHogSurveysConfig.surveysDelegate()
```

---

## PostHogDisplayRatingQuestion

Represents a rating question where users can select a rating from a scale

### Configuration methods

#### lowerBoundLabel()

**Release Tag:** public

The label for the lower bound of the rating scale

**Notes:**

The label for the lower bound of the rating scale

### Returns

- `Void`

### Examples

```swift
postHogDisplayRatingQuestion.lowerBoundLabel()
```

---

#### ratingType()

**Release Tag:** public

The type of rating scale (numbers, emoji)

**Notes:**

The type of rating scale (numbers, emoji)

### Returns

- `Void`

### Examples

```swift
postHogDisplayRatingQuestion.ratingType()
```

---

#### scaleLowerBound()

**Release Tag:** public

The lower bound of the rating scale

**Notes:**

The lower bound of the rating scale

### Returns

- `Void`

### Examples

```swift
postHogDisplayRatingQuestion.scaleLowerBound()
```

---

#### scaleUpperBound()

**Release Tag:** public

The upper bound of the rating scale

**Notes:**

The upper bound of the rating scale

### Returns

- `Void`

### Examples

```swift
postHogDisplayRatingQuestion.scaleUpperBound()
```

---

#### upperBoundLabel()

**Release Tag:** public

The label for the upper bound of the rating scale

**Notes:**

The label for the upper bound of the rating scale

### Returns

- `Void`

### Examples

```swift
postHogDisplayRatingQuestion.upperBoundLabel()
```

---

## PostHogDisplaySurveyAppearance

Model that describes the appearance customization of a PostHog survey

### Configuration methods

#### backgroundColor()

**Release Tag:** public

Optional background color as web color (e.g. “#FFFFFF” or “white”)

**Notes:**

Optional background color as web color (e.g. “#FFFFFF” or “white”)

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.backgroundColor()
```

---

#### borderColor()

**Release Tag:** public

Optional border color as web color

**Notes:**

Optional border color as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.borderColor()
```

---

#### descriptionTextColor()

**Release Tag:** public

Optional color for description text as web color

**Notes:**

Optional color for description text as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.descriptionTextColor()
```

---

#### displayThankYouMessage()

**Release Tag:** public

Whether to show a thank you message after survey completion

**Notes:**

Whether to show a thank you message after survey completion

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.displayThankYouMessage()
```

---

#### fontFamily()

**Release Tag:** public

Optional font family to use throughout the survey

**Notes:**

Optional font family to use throughout the survey

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.fontFamily()
```

---

#### placeholder()

**Release Tag:** public

Optional placeholder text for input fields

**Notes:**

Optional placeholder text for input fields

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.placeholder()
```

---

#### ratingButtonActiveColor()

**Release Tag:** public

Optional color for active/selected rating buttons as web color

**Notes:**

Optional color for active/selected rating buttons as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.ratingButtonActiveColor()
```

---

#### ratingButtonColor()

**Release Tag:** public

Optional color for rating buttons as web color

**Notes:**

Optional color for rating buttons as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.ratingButtonColor()
```

---

#### submitButtonColor()

**Release Tag:** public

Optional background color for the submit button as web color

**Notes:**

Optional background color for the submit button as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.submitButtonColor()
```

---

#### submitButtonText()

**Release Tag:** public

Optional custom text for the submit button

**Notes:**

Optional custom text for the submit button

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.submitButtonText()
```

---

#### submitButtonTextColor()

**Release Tag:** public

Optional text color for the submit button as web color

**Notes:**

Optional text color for the submit button as web color

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.submitButtonTextColor()
```

---

#### thankYouMessageCloseButtonText()

**Release Tag:** public

Optional text for the close button in the thank you message

**Notes:**

Optional text for the close button in the thank you message

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.thankYouMessageCloseButtonText()
```

---

#### thankYouMessageDescription()

**Release Tag:** public

Optional description text for the thank you message

**Notes:**

Optional description text for the thank you message

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.thankYouMessageDescription()
```

---

#### thankYouMessageDescriptionContentType()

**Release Tag:** public

Optional content type for the thank you message description

**Notes:**

Optional content type for the thank you message description

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.thankYouMessageDescriptionContentType()
```

---

#### thankYouMessageHeader()

**Release Tag:** public

Optional header text for the thank you message

**Notes:**

Optional header text for the thank you message

### Returns

- `Void`

### Examples

```swift
postHogDisplaySurveyAppearance.thankYouMessageHeader()
```

---