promotedai / ios-metrics-sdk

iOS client library for Promoted.ai metrics tracking.
MIT License
7 stars 1 forks source link

Support AutoView from React Native #156

Closed yunapotamus closed 3 years ago

yunapotamus commented 3 years ago

This PR adds support for sending AutoView messages and IDs through from the React Native library (react-native-metrics). Only basic AutoView support exists in this change. More extensive changes to bring CollectionTracker and AutoView to UIKit are coming later.

  1. Adds support for the AutoView event throughout MetricsLogger and ImpressionTracker classes.
  2. Updates schema protos to latest version.
  3. Removes Swift-side React Native view tracking. This has been moved entirely to TS.
  4. Adds debug logging to ImpressionTracker.

Support for AutoView

Adds the AutoViewState struct, which contains all AutoView-related fields used across events. Both MetricsLogger and ImpressionTracker have been updated to use these structs as part of their logging API. The previous viewID fields are still there, but many of them will be deprecated or removed shortly.

As a departure from the previous design, AutoView is no longer a state in MetricsLogger, but instead a parameter that callers must pass in. This builds support for strong view associations as outlined in the design doc. Going forward, new callers of the logging classes must manage view associations themselves.

The View event can still be logged manually, and it will still cause subsequent viewIDs to be filled in on Actions and Impressions. However, filling in viewID is more of a stopgap measure and should be removed as soon as possible. Instead, relying on the viewID field in AutoView should be the way to scope Actions/Impressions to manually logged Views.

Finally, diagnostics has been updated to fill in history for autoViewID, and debug logging supports AutoView events as well.

Update schema protos

Updates autogenerated files and accommodates package moves (ie. Event_Device -> Common_Device). We now fill in the most up-to-date fields in LogRequest and event protos.

Remove Swift-side support for React Native view tracking

Now that AutoView support is completely on the TS side, we remove the Swift code. This is mostly in the ViewTracker class and test. In the future, we will also refactor/remove ViewTracker itself when AutoView comes to Swift/UIKit, but that's out of scope for this PR.

Debug logging for ImpressionTracker

It's very useful to log the impressions and content as it passes through ImpressionTracker. Added this logging via the delegate, which callers can create and integrate with ImpressionTracker as needed.