Skip to content

Commit 35e02e1

Browse files
authored
[CM-1302] Documentation added. (#3)
1 parent 16709de commit 35e02e1

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,63 @@ Documentation is automatically generated from source code comments and rendered
1717
Usage
1818
----------
1919

20+
### `AdobeAnalyticsEngine`
21+
`AdobeAnalyticsEngine` implements the `AnalyticsEngine` protocol, and in its `track(event:)` method it maps the `AnalyticsEvent` enum to the appropriate Adobe methods.
22+
23+
Internally the Adobe SDK is just using singleton objects, but the goal of Y—Analytics is to use Dependency Injection of a generic wrapper. This allows your project code to be loosely coupled to your choice of analytics provider. It also facilitates unit testing and a healthy app architecture.
24+
25+
Just be aware that even if you declare multiple instances of `AdobeAnalyticsEngine`, that they all reference the same Adobe SDK singleton.
26+
27+
When unit testing various components of your project, you should inject an instance of `MockAnalyticsEngine` instead of the Adobe engine. This allows your unit tests to run without any Adobe dependency and allows you to verify which events are tracked and when.
28+
29+
#### Simple use case: app ID
30+
You may initialize `AdobeAnalyticsEngine` by passing an Adobe app ID.
31+
32+
```swift
33+
import YAnalyticsAdobe
34+
35+
final class AppCoordinator {
36+
let engine: AnalyticsEngine = {
37+
let config = AdobeAnalyticsConfiguration(appId: "S3cr3t!")
38+
return AdobeAnalyticsEngine(configuration: config)
39+
}()
40+
41+
func trackSomething(someData: [String: Any]?) {
42+
engine.track(
43+
event: .event(name: "Something", parameters: someData)
44+
)
45+
}
46+
}
47+
```
48+
49+
50+
#### Additional configuration options
51+
In addition to the required app id, `AdobeAnalyticsConfiguration` can be initialized with the following additional parameters:
52+
53+
1. extensions: extensions to register with Adobe.
54+
2. mappings: information for mapping from `AnalyticsEvent` to Adobe events.
55+
3. logLevel: logging level to use
56+
57+
```swift
58+
import YAnalyticsAdobe
59+
60+
final class AppCoordinator {
61+
let extensions: [NSObject.Type] = ...
62+
let logLevel: LogLevel = ...
63+
let mappings: [String: AdobeEventMapping] = ...
64+
65+
let engine: AnalyticsEngine = {
66+
let config = AdobeAnalyticsConfiguration(
67+
extensions: extensions,
68+
appId: "S3cr3t",
69+
logLevel: logLevel,
70+
mappings: mappings
71+
)
72+
return AdobeAnalyticsEngine(configuration: config)
73+
}()
74+
}
75+
```
76+
2077
Dependencies
2178
----------
2279

0 commit comments

Comments
 (0)