Skip to content

Commit

Permalink
👌 Clean up doc from review
Browse files Browse the repository at this point in the history
  • Loading branch information
iujames committed Jul 13, 2022
1 parent 028137b commit 41d64de
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/AppcuesKit/AppcuesKit.docc/AnalyticObserving.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A delegate can be registered to allow for the host application to see all of the

## Registering the AppcuesAnalyticsDelegate

One of the types in your application can adhere to the ``AppcuesAnalyticsDelegate`` protocol. In the usage example below, this is done with an extension on the `AppDelegate`. This protocol defines a single function ``AppcuesAnalyticsDelegate/didTrack(analytic:value:properties:isInternal:)``, which provides access to the analytics tracking being done by the SDK.
One of the types in your application can adhere to the ``AppcuesAnalyticsDelegate`` protocol. In the usage example below, this is done with an extension on the `AppDelegate`. This protocol defines a single function ``AppcuesAnalyticsDelegate/didTrack(analytic:value:properties:isInternal:)``, which provides access to the analytics tracking being done by the SDK.

```swift
extension AppDelegate: AppcuesAnalyticsDelegate {
Expand All @@ -14,33 +14,33 @@ extension AppDelegate: AppcuesAnalyticsDelegate {
}
```

After both the Appcues iOS SDK and the delegate implementation are initialized, set the delegate for the Appcues iOS SDK to use. In the usage example below, this is done in `application(_:didFinishLaunchingWithOptions:)` in the `AppDelegate`.
After both the Appcues iOS SDK and the delegate implementation are initialized, set the delegate for the Appcues iOS SDK to use. In the usage example below, this is done in `application(_:didFinishLaunchingWithOptions:)` in the `AppDelegate`.

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// after other initialization is complete...
Appcues.shared.analyticsDelegate = self
appcues.analyticsDelegate = self

return true
}
```

## Using the Analytics Tracking Data

There are two key types of Appcues analytics tracking data to distinguish.
There are two key types of Appcues analytics tracking data to distinguish.

The first type is the internal SDK events - these capture anything that is generated automatically inside of the Appcues SDK, including flow events, session events, and any automatically tracked screens.

The second type is all other analytics - these are all the screens, events, user or group identities that are passed into the SDK from the host application.
The second type is all other analytics - these are all the screens, events, user or group identities that are passed into the SDK from the host application.

These two types are distinguished using the `isInternal` parameter on ``AppcuesAnalyticsDelegate/didTrack(analytic:value:properties:isInternal:)``.

### Amplitude Integration Example

In this example use case, an application would like to observe and track all of the internal Appcues SDK events and send them to Amplitude as well. The other events that originate in the main application codebase are already integrated elsewhere in the codebase. The primary goal is to be able to analyze Appcues flow events, using Amplitude.
In this example use case, an application would like to observe and track all of the internal Appcues SDK events and send them to Amplitude as well. The other events that originate in the main application codebase are already integrated elsewhere in the codebase. The primary goal is to be able to analyze Appcues flow events, using Amplitude.

In this example, an extension on the `Amplitude` type is created, which adheres to the ``AppcuesAnalyticsDelegate`` protocol. This extension will filter out tracking items so that it is only tracking internal analytics of the `.event` type.
In this example, an extension on the `Amplitude` type is created, which adheres to the ``AppcuesAnalyticsDelegate`` protocol. This extension will filter out tracking items so that it is only tracking internal analytics of the `.event` type.

```swift
extension Amplitude: AppcuesAnalyticsDelegate {
Expand All @@ -57,7 +57,7 @@ extension Amplitude: AppcuesAnalyticsDelegate {
After both SDKs have been initialized, set the ``Appcues/analyticsDelegate`` reference.

```swift
Appcues.shared.analyticsDelegate = self
appcues.analyticsDelegate = Amplitude.instance()
```

Now, all of the internal events from the Appcues SDK will also be sent to Amplitude, using the `logEvent` function call.

0 comments on commit 41d64de

Please sign in to comment.