Advanced configuration
The PAPulse SDK offers a host of config methods (starting with configSet) that allow you to pass additional values to get more accurate data with more detail or change predefined business logic.
Configuration methods
All of the required and optional methods, listed below, should be called before initiating a session by calling PAAnalytics.start().
configSet(appName:)
The PAPulse SDK requires the invocation of a single mandatory method during initialization, which is configSetAppName or configSetAppName:groupName. This method sets the app name (Bundle ID), which is a necessary parameter on the backend side for retrieving the corresponding Remote Settings. The optional groupName parameter is used for an app group (App Group), facilitating data sharing between the main app and related App Extensions through shared UserDefaults or shared keychain.
PAAnalytics.configSet(appName: "com.yourappname.studio")
or
PAAnalytics.configSet(appName: "com.yourappname.studio", groupName: "group.com.yourappname.studio")
configSet(allowIDFA:)
In compliance with policies such as ATT (App Tracking Transparency) or GDPR (General Data Protection Regulation), the PAPulse SDK does not collect or transmit an IDFA (Identifier for Advertisers) identifier by default. However, if you wish to obtain more precise reporting regarding user behavior and engagement, you can enable the collection and transmission of this data using the configSetAllowIDFA method.
PAAnalytics.configSet(allowIDFA: true)
In the Swift Package Manager distribution the SDK is built with PA_NOATT, so it never links AppTrackingTransparency/AdSupport and never reads the system IDFA. There, configSet(allowIDFA:) on its own resolves to an empty advertising identifier. If the host app already resolves the IDFA itself, hand it to the SDK through configSet(attProvider:) instead — see below.
Please note that the collection and usage of PII (Personally Identifiable Information), such as the IDFA (Identifier for Advertisers), can potentially violate user privacy and lead to legal issues in certain countries, including the European Union (EU). It is crucial to strictly adhere to all government laws and regulations before invoking the configSetAllowIDFA function or engaging in any data collection practices.
configSet(attProvider:)
Supplies an external source of advertising-identifier information instead of letting the SDK query ASIdentifierManager itself. The provider must conform to AdvertisingAnalyticsProtocol. This is the only way to report an IDFA from a PA_NOATT build.
This method is Swift-only (@nonobjc): AdvertisingAnalyticsProtocol is deliberately not exposed to Objective-C so that the advertisingIdentifier selector never enters a consuming binary, which would otherwise be reported as IDFA usage by App Store Connect's static scan (ITMS-90683).
struct MyATTProvider: AdvertisingAnalyticsProtocol {
var isTrackingEnabled: Bool { ATTrackingManager.trackingAuthorizationStatus == .authorized }
var advertisingIdentifier: String? { ASIdentifierManager.shared().advertisingIdentifier.uuidString }
}
PAAnalytics.configSet(attProvider: MyATTProvider())
Pass nil to remove a previously configured provider and fall back to the SDK's built-in behavior.
configSet(analyticsEnabled:)
To enable Analytics Tracking (events logging), simply call the configSetAnalyticsEnabled method with the appropriate parameter to set it to true before starting the session. By default, Analytics Tracking logging is enabled. It means all external and internal calls of logEvent() methods are processed by the PAPulse SDK. The fired events are then saved in a local database, and the SDK transmits them to the analytics backend. However, the actual transmission of events occurs when a certain threshold count is reached.
PAAnalytics.configSet(analyticsEnabled: true)
configSet(analyticsURL:)
The analytics endpoint has no built-in default — triggered events and attributes are only sent once you configure the URL assigned to your application, using the configSetAnalyticsURL function. This function allows you to specify the URL for sending the analytics data.
PAAnalytics.configSet(analyticsURL: URL(string: "https://your-assigned-url.example.com")!)
configSet(apiKey:)
If you have an associated API key, you can pass it to the SDK using the configSetApiKey method. This allows the SDK to prepare the fetching of a special edition of Remote Settings.
PAAnalytics.configSet(apiKey: "3892002133321")
configSet(asyncSettingsFetchingBehavior:)
Configures the behavior for async tagged settings requests when timeout is exceeded. This method sets how the Analytics SDK handles situations where fetching tagged settings takes longer than the specified timeout period. The behavior determines whether the SDK should terminate the request or continue fetching in the background. The default SDK behavior is .terminateOnExpectation if this method is not called.
.terminateOnExpectation- Terminates the settings request when the timeout is exceeded. When this behavior is selected, the Analytics SDK will terminate the outgoing tagged settings request if the fetching time exceeds the timeout specified by the user in the corresponding function call. In this case, the SDK will immediately call the completion block with either:- The default value (if provided)
- An outdated value from the old cache (if available)
nil(if no default or cached value exists) The network request will be cancelled.
.continueUntilFinished- Continues the settings request even when the timeout is exceeded. When this behavior is selected, the Analytics SDK will continue the outgoing tagged settings request regardless of whether the fetching time exceeds the timeout specified by the user. The SDK will immediately call the completion block with either:- The default value (if provided)
- An outdated value from the old cache (if available)
nil(if no default or cached value exists) However, the network request will continue running in the background. Once the request completes successfully, the new settings will be saved into the temporal cache for future use.
PAAnalytics.configSet(asyncSettingsFetchingBehavior: .continueUntilFinished)
configSet(attributeLoggingEnabled:)
To enable User Attributes logging, simply call the configSetAttributeLoggingEnabled method with the appropriate parameter to set it to true before starting the session. By default, User Attributes logging is disabled. It means all external and internal calls of logAttribute() methods are ignored by the PAPulse SDK.
PAAnalytics.configSet(attributeLoggingEnabled: true)
configSet(autoEventsConfig:)
To enable automatic event logging, simply call the configSetAutoEventsConfig method with the appropriate parameter that specifies the types of auto events to be logged by the SDK. The autoEventsConfig parameter holds a set of granular auto event types related to specific UIKit controls and user interactions.
| Auto event type | Purpose |
|---|---|
viewController | Allow "page_load" and "page_view" event tracking for all UIViewController instances |
buttonClick | Allow "click" event tracking for all UIButton instances |
switchControlClick | Allow "click" event tracking for all UISwitch instances |
sliderControlClick | Allow "click" event tracking for all UISlider instances |
stepperControlClick | Allow "click" event tracking for all UIStepper instances |
segmentedControlClick | Allow "click" event tracking for all UISegmentedControl instances |
barButtonClick | Allow "click" event tracking for all UIBarButtonItem instances |
tableViewClick | Allow "click" event tracking when the user taps any cell in a UITableView instance |
collectionViewClick | Allow "click" event tracking when the user taps any cell in a UICollectionView instance |
tableViewImpression | Allow "items_impression" event tracking when UITableView cells remain visible on the screen |
collectionViewImpression | Allow "items_impression" event tracking when UICollectionView cells remain visible on the screen |
scroll | Allow "scroll" event tracking when the user scrolls any UIScrollView or its subclass |
gesture | Allow "gesture" event tracking when any gesture recognizer detects a "tap", "pinch", or "move" gesture |
revenueTracking | Allow various IAP-related events associated with transactions processed via StoreKit |
localisation | Allow localisation-related event tracking (localized string keys resolved via Bundle) |
pushNotificationClick | Allow "click" event tracking when the user opens the app from a push notification |
deepLink | Allow "deeplink_opened" event tracking by swizzling deep link delegate callbacks. Off by default — without it, report deep links manually with PAAnalytics.logDeepLink(deeplinkURL:) (see Events tracking). Don't combine both mechanisms for the same URLs, as this produces duplicate events |
PAAnalytics.configSet(autoEventsConfig: PAAutoEventsConfig(autoEventTypes: [.viewController, .buttonClick, .deepLink]))
configSet(backendExperimentTrackingEnabled:)
Enables or disables backend experiment tracking through HTTP response headers. When enabled, the SDK inspects HTTP responses for experiment information sent by backend services and automatically tracks experiment participation.
PAAnalytics.configSet(backendExperimentTrackingEnabled: true)
configSet(deepLinkAutoTracking:)
Turns automatic deeplink_opened tracking on or off. It is off by default, so out of the box the SDK does not swizzle the host app's deep link delegate callbacks and you report deep links yourself with PAAnalytics.logDeepLink(deeplinkURL:) (see Events tracking).
Passing true is equivalent to adding .deepLink to PAAutoEventsConfig. Unlike the other auto-event types, this one can also be switched back off during the current session, which restores the original delegate implementations.
PAAnalytics.configSet(deepLinkAutoTracking: true)
configSet(debugConsoleLogging:)
It is very important for app developers and QA engineers to have the ability to investigate debug message logs in order to identify various types of issues and understand the current workflow or user behavior. The SDK provides a method called configSetDebugConsoleLogging, which allows to specify the destination of the debug messages generated by the SDK during its operation.
There are several options for the destination of debug messages:
.disablethis is the default option, where service debug messages from the SDK are not displayed..systemthe debug messages are directed to the system console within the Xcode IDE..consoleAppthe debug messages are sent to a special app within the Xcode IDE called "Console App". This provides a dedicated interface for viewing and analyzing the debug messages separately from other system logs.
PAAnalytics.configSet(debugConsoleLogging: .consoleApp)
configSet(debugModeEnabled:)
To enable Debug Mode, simply call the configSetDebugModeEnabled method with the appropriate parameter to set it to true before starting the session. By default, Debug Mode is disabled. Enabling Debug Mode adds a special flag to all fired events and attributes, marking them for distinct processing on the analytics backend.
PAAnalytics.configSet(debugModeEnabled: true)
configSet(directSendEnabled:)
To enable Direct Send Mode, simply call the configSetDirectSendEnabled method with the appropriate parameter to set it to true before starting the session. By default, Direct Send Mode is disabled.
Enabling Direct Send Mode in the PAPulse SDK switches the SDK to an alternative logic where each fired event is immediately sent to the backend server as soon as it is tracked, without waiting for the batch threshold to be reached. Direct Send Mode is useful in scenarios where real-time event tracking and immediate backend processing are required for debug purposes.
PAAnalytics.configSet(directSendEnabled: true)
It is recommended to use Direct Send mode for testing and debugging purposes only, particularly in QA and Enterprise builds. Enabling Direct Send mode allows for immediate transmission of each fired event to the backend server as it occurs. However, it is important to exercise caution when enabling this mode for live users. Direct Send mode can generate a higher volume of requests and may impact server load and data processing. If you decide to enable Direct Send mode for live users, it is crucial to closely monitor and control the process to ensure it does not negatively impact the user experience or overall system performance.
configSet(doNotTrackDeepLinkWithURLs:)
Excludes URLs from deeplink_opened tracking. The supplied strings are matched as prefixes against the deep link URL, and the exclusion applies to both the manual logDeepLink(deeplinkURL:) call and automatic deep link tracking.
PAAnalytics.configSet(doNotTrackDeepLinkWithURLs: ["myapp://internal", "https://example.com/private"])
configSet(eventsBatchSize:)
The analytics data, which includes fired events, attributes, and network metrics, is sent in batches. This batching approach is implemented to optimize network traffic and manage backend high load. To initiate the sending of a batch, there is a minimum threshold that needs to be reached. By default, it is set to 100. You have the option to modify this number by using the configSetEventsBatchSize configuration method.
PAAnalytics.configSet(eventsBatchSize: 25)
configSet(eventsSendingTimeout:)
Delays the start of event sending by the given number of seconds after the session starts, which is useful when the host app wants to keep the network quiet during launch. The value is clamped to the 0...10 seconds range.
PAAnalytics.configSet(eventsSendingTimeout: 3)
configSet(httpReportEnabled:)
To enable HTTP Reporting feature, simply call the configSetHTTPReportEnabled method with the appropriate parameter to set it to true before starting the session. By default, HTTP Reporting Mode is disabled.
Enabling the HTTP Reporting feature allows for the collection of network request metrics, specifically HTTP/HTTPS request and response metrics (response times, request sizes, and status codes). By enabling HTTP Reporting, you can gather these metrics and transmit them to the analytics backend. The collected network request metrics are valuable for monitoring and optimizing the performance.
PAAnalytics.configSet(httpReportEnabled: true)
configSet(httpReporterURL:)
The HTTP-reporting endpoint has no built-in default — network metrics (HTTP\HTTPS request and response metrics) are only sent once you configure the URL assigned to your application, using the configSetHTTPReporterURL function. This function allows you to specify the URL for sending this data.
PAAnalytics.configSet(httpReporterURL: URL(string: "https://your-assigned-url.example.com")!)
configSet(languageCode:)
You can use this method to prepare a request for fetching Remote Settings specific to a particular language group. By invoking this method with the appropriate parameters, you can tailor the request to retrieve the desired Remote Settings.
PAAnalytics.configSet(languageCode: "fr")
configSet(ntpTimeEnabled:)
Chooses the clock the SDK stamps events with. When enabled, timestamps come from an NTP-synchronised clock instead of the device clock, which protects event ordering against users with a wrong or manually-shifted device time.
PAAnalytics.configSet(ntpTimeEnabled: true)
configSet(options:)
You can use the configSetOptions method to configure several parameters within a single call, instead of using multiple configuration methods sequentially. Another use case is supporting multiple configurations or projects, such as beta and live versions of the app. The options parameter is an instance of the PAAnalyticsOptions object, which is initialized with the path to a prepared .plist file located in the main bundle. This file contains supported key-value pairs with predefined keys that the Analytics SDK can read and use to configure itself during the initialization phase. All key-value pairs inside the mentioned plist file are considered optional.
PAAnalyticsOptions has a single failable initializer that takes a file path; it returns nil if the file cannot be read or parsed as a property list:
guard let path = Bundle.main.path(forResource: "PulseOptions", ofType: "plist"),
let options = PAAnalyticsOptions(contentOfFile: path) else {
return
}
PAAnalytics.configSet(options: options)
List of supported self-describing keys. Any key in the plist that is not on this list is ignored and reported as a warning in the SDK debug log:
| Plist key | Value type | Equivalent config method |
|---|---|---|
APP_BUNDLE | String | configSet(appName:) |
APP_GROUP | String | configSet(appName:groupName:) — APP_BUNDLE must be set as well |
API_KEY | String | configSet(apiKey:) |
LANGUAGE_CODE | String | configSet(languageCode:) |
ANALYTICS_URL | String URL | configSet(analyticsURL:) |
SETTINGS_URL | String URL | configSet(settingsURL:) |
HTTP_REPORTER_URL | String URL | configSet(httpReporterURL:) |
APNS_TOKEN_TRACKING | Bool | Allows the SDK to collect and transfer the APNS token for push notification delivery |
BATCHING_TIME_INTERVAL | UInt | configSet(timeInterval:) |
SESSION_TIMEOUT | UInt | configSet(sessionTimeout:) |
EVENTS_BATCH_COUNT | UInt | configSet(eventsBatchSize:) |
DEBUG_MODE | Bool | configSet(debugModeEnabled:) |
REVENUE_DEBUG | Bool | configSet(revenueDebugEnabled:) |
DIRECT_SEND | Bool | configSet(directSendEnabled:) |
HTTP_REPORTS | Bool | configSet(httpReportEnabled:) |
WKWEBVIEW_HTTP_REPORTS | Bool | configSet(webViewHTTPReportEnabled:) |
ATTRIBUTE_LOGGING | Bool | configSet(attributeLoggingEnabled:) |
ANALYTICS | Bool | configSet(analyticsEnabled:) |
DEBUG_CONSOLE_LOGGING | UInt | configSet(debugConsoleLogging:) — 0 = .disable, 1 = .system, 2 = .consoleApp |
TRACK_VIEW_ENVIRONMENT | Bool | configSet(trackViewEnvironment:) |
configSet(personalisation:url:)
Turns the personalisation provider on or off and points it at its endpoint. When enabled with a valid network URL, the SDK fetches personalisation attributes and feeds them into the Remote Settings request. Passing false, or an invalid URL, detaches the provider.
PAAnalytics.configSet(personalisation: true, url: URL(string: "https://your-personalisation-url.example.com")!)
Personalisation attributes can be refreshed later with PAAnalytics.refreshPersonalisationAttributes() (see Management methods).
configSet(requestsBatchSize:)
The counterpart of configSet(eventsBatchSize:) for HTTP reporting: it sets the minimum number of collected network-metric records that must accumulate before a batch is sent. The default is 100. Values of 0 or less are ignored, and the call has no effect while the SDK is running in Debug Preview Mode.
PAAnalytics.configSet(requestsBatchSize: 25)
configSet(revenueDebugEnabled:)
To enable Debug Mode for Revenue Tracking in the PAPulse SDK, you can use the configSetRevenueDebugEnabled method. By default, this mode is disabled. By calling the configSetRevenueDebugEnabled method with the appropriate parameter set to true before starting the session, you can enable Debug Mode for Revenue Tracking.
Enabling Debug Mode for Revenue Tracking provides you with the ability to inspect all revenue-related events on the Analytics Debug Screen. This screen can be accessed from the SDK debug UI returned by PAAnalytics.analyticsDebugUI(), which allows to analyze revenue-related events in a debugging context.
Note: Revenue Tracking is not part of the Swift Package Manager integration — the
PAPulseRevenueTrackingmodule is not exposed as an SPM product, so the revenue-relatedconfigSetand enable/disable methods are unavailable when integrating via SPM.
PAAnalytics.configSet(revenueDebugEnabled: true)
configSet(revenueTracking:)
To enable revenue tracking, which involves updating StoreKit and StoreKit2 transaction statuses without any your private or financial information, you can use the configSetRevenueTracking method.
To track the status updating of all In-App Purchases (IAP):
PAAnalytics.configSet(revenueTracking:[])
or to track the status updating of specific In-App Purchases (IAPs) only:
PAAnalytics.configSet(revenueTracking:["com.example.exampleapp.exampleSubscription1", "com.example.exampleapp.exampleConsumable1"])
configSet(sessionTimeout:)
The PAPulse SDK uses the concept of a session as a common parameter for all events triggered while the current session is active. It can be likened to an umbrella term that encompasses multiple events within a specific timeframe. When a user transitions from the foreground to the background mode and then returns to the foreground, the session may change if the user remained in the background for an extended period of time.
You have the ability to define a time threshold using the configSetSessionTimeout method. This threshold in seconds determines whether the session remains the same or gets updated based on the duration the application spent in the background mode. Default value is 5 mins (300 seconds).
On the backend side, sessions are a primary pattern for analyzing the sequential chain of tracked events. They provide insights to describe or predict user behavior, allowing for comprehensive analysis and understanding of user interactions with the application.
PAAnalytics.configSet(sessionTimeout: 600)
configSet(settingsURL:)
The Remote Settings endpoint has no built-in default (the production URL is typically https://optifyr.com/api/settings) — settings are only fetched once you configure the URL assigned to your application, using the configSetSettingsURL function. This function allows you to specify the URL for corresponding Remote Settings getting.
PAAnalytics.configSet(settingsURL: URL(string: "https://optifyr.com/api/settings")!)
configSet(settingsTrackingEnabled:)
Controls whether the SDK records which Remote Settings keys your app actually reads. This usage data helps identify settings that are no longer consumed. The current state is readable through PAAnalytics.isSettingsTrackingEnabled.
PAAnalytics.configSet(settingsTrackingEnabled: true)
configSet(subscriptionStatus:)
To include subscription status information in the Remote Settings request, you should provide it before starting the session. Additionally, whenever there is a change in this status, you need to provide it to the SDK again. And this udated status might be used for Remote Settings updating in background mode. It's important to note that this value is not persisted between app launches. Therefore, your app should provide the status as soon as possible after launch and invoke the method again with the new status once it is obtained. By default, the status is set to unknown.
PAAnalytics.configSet(subscriptionStatus: .subscribed)
configSet(subscriptionStatusUpdate:)
Instead of making an explicit configSet(subscriptionStatus:) API call to set the current subscription status, you can configure a closure that the Analytics SDK will call to retrieve the current subscription status from the app on demand.
PAAnalytics.configSet(subscriptionStatusUpdate: {
Store.isSubscribed ? .subscribed : .notSubscribed
}
)
configSet(timeInterval:)
The PAPulse SDK respects the specified time interval between the sending of analytics data, including fired events and attributes, to the analytics backend for further processing. The default time interval is set to 120 seconds, meaning that events are transmitted to the backend every 120 seconds. However, you have the flexibility to adjust this time interval by using the configSetTimeInterval configuration method. This allows you to customize the frequency at which the events are sent to the backend according to your specific needs.
PAAnalytics.configSet(timeInterval: 10)
configSet(trackViewEnvironment:)
Controls whether the SDK keeps a history of the view-controller environment (the screens the user passed through). This history is what populates the sources_info, parent_info and sub_sids fields of auto events, so it is switched on automatically when the .viewController auto-event type is enabled.
PAAnalytics.configSet(trackViewEnvironment: true)
configSet(userID:)
If you have a logged in user, you can attach their ID to logged events by supplying user ID to the SDK with configSetUserID. Call it every time the user changes (logs in or logs out), passing nil when the user is logged out.
PAAnalytics.configSet(userID: "160817609001102")
configSet(userRegistrationDate:)
Sets the registration date of the currently logged-in user. It is sent as the reg_date header of the Remote Settings request, formatted as epoch milliseconds (the same format as the install-date header).
Unlike configSet(subscriptionStatus:), this value is persisted in the SDK's shared UserDefaults, so it survives app launches and is also sent by app extensions. The SDK does not clear it together with configSet(userID:) — set it on login and pass nil on logout.
PAAnalytics.configSet(userRegistrationDate: user.registrationDate) // login
PAAnalytics.configSet(userRegistrationDate: nil) // logout
configSet(webViewHTTPReportEnabled:)
Enables or disables HTTP monitoring of registered WKWebView instances. WebView monitoring is a sub-feature of HTTP reporting, so it is only effective while configSet(httpReportEnabled:) is also true. The current state is readable through PAAnalytics.isWebViewMonitoringEnabled. See WebView HTTP monitoring below for how to register individual web views.
PAAnalytics.configSet(webViewHTTPReportEnabled: true)
configSet(webViewRedactedHeaders:)
Adds header names to mask in monitored WebView records, on top of the built-in denylist (Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key). Matching is case-insensitive. Each call replaces the previously configured list.
PAAnalytics.configSet(webViewRedactedHeaders: ["X-Session-Token", "X-Internal-Trace"])
Management methods
The optional methods listed below can be called at any time.
disableAnalytics() and enableAnalytics()
When you need to disable the collection, storage, and sending of analytics data(events, attributes, network metrics), you can call the disableAnalytics method:. Invoking this method will effectively disable the entire analytics functionality of the SDK, ensuring that no data is collected, saved, or transmitted to the backend server.
PAAnalytics.disableAnalytics()
After disabling the analytics functionality, you can enable it again
PAAnalytics.enableAnalytics()
disableAttributeLogging() and enableAttributeLogging()
If you have already configured the Pulse SDK Attribute Logging feature using the configSetAttributeLoggingEnabled method, you have the ability to manage the logging logic for user attributes. By default, this feature is disabled, which means that all external and internal calls to logAttribute() methods are rejected by the PAPulse SDK and not tracked.
PAAnalytics.disableAttributeLogging()
After disabling the Attribute Logging functionality, you can enable it again
PAAnalytics.enableAttributeLogging()
disableDebugMode() and enableDebugMode()
If you want to disable Debug Mode, which is disabled by default, you can achieve this by calling the disableDebugMode method. Enabling Debug Mode logic adds a special flag to all fired events and attributes, and causes a distinct processing pipeline on the analytics backend. Disabling Debug Mode removes this special flag and reverts to the standard processing pipeline for events and attributes.
PAAnalytics.disableDebugMode()
After disabling the Debug Mode functionality, you can enable it again
PAAnalytics.enableDebugMode()
disableDirectSend() and enableDirectSend()
You have the flexibility to choose the most suitable mode for sending the collected analytics data. By default, the SDK follows the Batch Send mode, where it waits to accumulate a certain threshold of events before sending them as a batch in one packet to the backend server. You have the option to enable Direct Send mode. In Direct Send mode, each fired event is immediately sent to the backend server as soon as it is tracked, without waiting for the batch threshold. By default, Direct Send mode is disabled. You can enable Direct Send mode by calling the enableDirectSend method.
PAAnalytics.disableDirectSend()
After disabling the Direct Send Mode functionality, you can enable it again
PAAnalytics.enableDirectSend()
disableHTTPReport() and enableHTTPReport()
If you want to disable HTTP reporting, which involves collecting network request metrics, you can do so by calling the disableHTTPReport method.
PAAnalytics.disableHTTPReport()
After disabling the HTTP reporting functionality, you can enable it again
PAAnalytics.enableHTTPReport()
disableHTTPDebugReport() and enableHTTPDebugReport()
Enables advanced (debug) data collection for HTTP reporting. On top of the regular metrics it attaches the HTTP header parameters of both requests and responses to the collected data. This can increase the size of uploaded data significantly, so it is intended for debugging rather than production.
PAAnalytics.enableHTTPDebugReport()
PAAnalytics.disableHTTPDebugReport()
disableWebViewHTTPReport() and enableWebViewHTTPReport()
The runtime equivalents of configSet(webViewHTTPReportEnabled:). They only take effect while HTTP reporting is enabled — WebView monitoring is a sub-feature of it.
PAAnalytics.enableWebViewHTTPReport()
PAAnalytics.disableWebViewHTTPReport()
disableRevenueTracking() and enableRevenueTracking()
If you have already configured the Pulse SDK Revenue Tracking feature and started collecting events, you have the option to pause the collection of Revenue Tracking events for a specific period of time. When the Revenue Tracking collection is paused, all In-App Purchases and Subscriptions emitted by StoreKit will be ignored by the SDK.
PAAnalytics.disableRevenueTracking()
After disabling the Revenue Tracking functionality, you can enable it again
PAAnalytics.enableRevenueTracking()
forceFlush()
To send all collected events and attributes immediately, you can call the following method forceFlush. Invoking this method triggers the immediate sending of all accumulated events and attributes frol local database to the backend server. This can be useful in scenarios where you want to ensure that the data is sent promptly instead of waiting for the regular batch sending interval.
PAAnalytics.forceFlush()
flushNetworkMonitoring()
forceFlush() covers events and attributes. Collected HTTP metrics are sent by their own reporter, which is flushed separately:
PAAnalytics.flushNetworkMonitoring()
refreshPersonalisationAttributes()
Triggers a refresh of personalisation attributes. Call it after settings have been applied and user attributes are up to date, so the personalisation provider fetches the latest data. Safe to call multiple times, and a no-op unless personalisation was configured with configSet(personalisation:url:).
PAAnalytics.refreshPersonalisationAttributes()
WebView HTTP monitoring
HTTP reporting covers traffic made by the host app itself. Requests issued from inside a WKWebView are invisible to it, so web views are monitored separately and opt in one instance at a time.
Monitoring requires three things: HTTP reporting enabled, WebView HTTP reporting enabled, and the web view registered.
PAAnalytics.configSet(httpReportEnabled: true)
PAAnalytics.configSet(webViewHTTPReportEnabled: true)
// On the MAIN thread, AFTER assigning your own navigationDelegate (if any)
PAAnalytics.startMonitoring(webView: webView)
startMonitoring(webView:) wraps the web view's navigationDelegate. Call it on the main thread and after you assign your own delegate. If you replace the navigation delegate later, call the method again to repair the monitoring wrap.
You can attach a host-app payload that is copied into every record of that web view inside the webview_params field:
PAAnalytics.startMonitoring(webView: webView, data: ["screen": "checkout", "variant": "b"])
- Only JSON-serializable values are kept — anything else (
Date,URL,NSNull, custom objects) is silently dropped. - The reserved keys
initiator,is_main_frameandpage_urlcannot be overridden. - Each call replaces the previously stored payload for that web view.
- The payload is duplicated into every persisted record of the web view, so keep it small.
To opt a web view back out and restore its original navigation delegate:
PAAnalytics.stopMonitoring(webView: webView)
Sensitive headers are masked before records are persisted. The built-in denylist is Authorization, Proxy-Authorization, Cookie, Set-Cookie and X-Api-Key; extend it with configSet(webViewRedactedHeaders:).
Advanced tuning
sampleWith(sampleSize:)
The PAPulse SDK provides a sampling mechanism, allowing you to target a fraction of users based on their Device ID. This sampling mechanism remains consistent between launches. It can be particularly useful when you want to test a new feature on only a fraction of the devices. Users are evenly divided into 10,000 buckets, and you have the flexibility to choose how many of those buckets will execute the provided code. This enables you to control the percentage of users who will experience the specific functionality or feature.
| Sampling value | Percentage of affected devices |
|---|---|
| 1 | 0.01% |
| 10 | 0.1% |
| 100 | 1% |
| 2500 | 25% |
| 5000 | 50% |
| 10000 | 100% |
PAAnalytics.sampleWith(sampleSize: 100) {
// code that will be run just for `100 / 10000` of the users, so for `1%` of the users
}
Advanced Behavior
PA_NOATT
The App Store has different policies for certain countries. For instance, the use of AppTrackingTransparency may be restricted to comply with local laws prohibiting device tracking. By default, the PAPulse SDK imports and calls methods from this system framework. However, you can disable this behavior to prevent the import and usage of the AppTrackingTransparency framework.
The desired behavior is controlled via the PA_NOATT user-defined build setting:
- If
PA_NOATTis defined,AppTrackingTransparencyis not imported. - If
PA_NOATTis not defined,AppTrackingTransparencyis imported and used as expected.
Configuring PA_NOATT in Swift Package Manager
The default SPM distribution of PAPulse (Package.swift) already ships with the PA_NOATT flag enabled. All SPM products — PAPulse, PAPulseSwiftUI, and PAPulseAppExtension — are built without the App Tracking Transparency framework.