Skip to content

Commit

Permalink
Add basic Glean integration (mozilla-lockwise#1129)
Browse files Browse the repository at this point in the history
This adds the basic Glean dependency to the Cartfile.

This also includes a minimal initialization for Glean and ties it to the telemetry preference in order to opt out.

This just activates the Glean baseline ping and doesn't include any events or other metrics yet, those will be included in a subsequent commit/PR.

Use Glean v21.0.0

Update metrics.md
  • Loading branch information
travis79 committed Nov 19, 2019
1 parent 5b0e586 commit 81d6302
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ github "getsentry/sentry-cocoa" "4.3.4"
github "jrendel/SwiftKeychainWrapper" "3.3.0"
github "mozilla-mobile/MappaMundi" "02b6f0b404d0a7178c47c073550936016f42981e"
github "mozilla-mobile/telemetry-ios" "1.1.1"
github "mozilla/application-services" "v0.42.3"
github "mozilla/application-services" "v0.42.3"
github "mozilla/glean" "v21.0.0"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ github "jrendel/SwiftKeychainWrapper" "3.3.0"
github "mozilla-mobile/MappaMundi" "02b6f0b404d0a7178c47c073550936016f42981e"
github "mozilla-mobile/telemetry-ios" "1.1.1"
github "mozilla/application-services" "v0.42.3"
github "mozilla/glean" "v21.0.0"
6 changes: 6 additions & 0 deletions Lockbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
08454B9A21486BCF00328040 /* TelemetryStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08454B9921486BCE00328040 /* TelemetryStore.swift */; };
08454B9B21486BCF00328040 /* TelemetryStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08454B9921486BCE00328040 /* TelemetryStore.swift */; };
1F33DE14237E32500002BA6B /* Glean.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33DE0D237E036B0002BA6B /* Glean.framework */; };
22336C7221111087004E7B50 /* OnboardingConfirmationPresenterSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22336C7121111087004E7B50 /* OnboardingConfirmationPresenterSpec.swift */; };
224A6C7D212C8C2B008C7A3F /* UIFont+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 224A6C7C212C8C2B008C7A3F /* UIFont+.swift */; };
226E3FF02127759C00185D11 /* ExternalLinkStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 226E3FEF2127759C00185D11 /* ExternalLinkStore.swift */; };
Expand Down Expand Up @@ -379,6 +380,7 @@
/* Begin PBXFileReference section */
08454B9621486AAC00328040 /* CredentialUserDefaultStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CredentialUserDefaultStore.swift; sourceTree = "<group>"; };
08454B9921486BCE00328040 /* TelemetryStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TelemetryStore.swift; path = Shared/Store/TelemetryStore.swift; sourceTree = SOURCE_ROOT; };
1F33DE0D237E036B0002BA6B /* Glean.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Glean.framework; path = Carthage/Build/iOS/Glean.framework; sourceTree = "<group>"; };
22336C7121111087004E7B50 /* OnboardingConfirmationPresenterSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingConfirmationPresenterSpec.swift; sourceTree = "<group>"; };
224A6C7C212C8C2B008C7A3F /* UIFont+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+.swift"; sourceTree = "<group>"; };
226E3FEF2127759C00185D11 /* ExternalLinkStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -746,6 +748,7 @@
7D5F1D7C20866A9400688DEA /* RxOptional.framework in Frameworks */,
7D5F1D7D20866A9400688DEA /* RxSwift.framework in Frameworks */,
7D1E758D224A7B3F00C06B4C /* SwiftProtobuf.framework in Frameworks */,
1F33DE14237E32500002BA6B /* Glean.framework in Frameworks */,
7DDEAA6C2124B7A700A7D521 /* AuthenticationServices.framework in Frameworks */,
7D4396572135D79800B96FA9 /* Sentry.framework in Frameworks */,
7D897EAD2260FFA800257946 /* Reachability.framework in Frameworks */,
Expand Down Expand Up @@ -1076,6 +1079,7 @@
7D1B1A8A1F98F86400C1F5FF /* Frameworks */ = {
isa = PBXGroup;
children = (
1F33DE0D237E036B0002BA6B /* Glean.framework */,
7DF455DB22A1D3D200207285 /* RxRelay.framework */,
7D897EAC2260FFA800257946 /* Reachability.framework */,
7D11623E225FDD27009097C7 /* SystemConfiguration.framework */,
Expand Down Expand Up @@ -1575,6 +1579,7 @@
"$(SRCROOT)/Carthage/Build/iOS/SwiftProtobuf.framework",
"$(SRCROOT)/Carthage/Build/iOS/Reachability.framework",
"$(SRCROOT)/Carthage/Build/iOS/RxRelay.framework",
"$(SRCROOT)/Carthage/Build/iOS/Glean.framework",
);
name = "Run Script";
outputPaths = (
Expand All @@ -1590,6 +1595,7 @@
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Sentry.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Reachability.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxRelay.framework",
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Glean.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
13 changes: 10 additions & 3 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ _Last Updated: May 1, 2018_
<!-- TOC depthFrom:2 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 -->

- [Analysis](#analysis)
- [Collection](#collection)
- [Collection](#collection-legacy)
- [List of Proposed Events](#list-of-proposed-events)
- [Mozilla Glean SDK](#mozilla-glean-sdk)
- [References](#references)

<!-- /TOC -->
Expand Down Expand Up @@ -52,7 +53,7 @@ In service to validating the above hypothesis, we plan on answering these specif

In addition to answering the above questions that directly concern actions in the app, we will also be analyzing telemetry emitted from the password manager that exists in the the Firefox desktop browser. These analyses will primarily examine whether users of Lockbox start active curation of their credentials in the desktop browser (Lockbox users will not be able to edit credentials directly from the app).

## Collection
## Collection (legacy)

Data will be collected using this library:

Expand Down Expand Up @@ -157,9 +158,15 @@ https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/c
* `value`: nil
* `extras`: nil

## Mozilla Glean SDK

Lockwise for Android uses the [Glean SDK](https://mozilla.github.io/glean/book/index.html) to collect telemetry. The Glean SDK provides a handful of [pings and metrics out of the box](https://mozilla.github.io/glean/book/user/pings/index.html). The data review for using the Glean SDK is available at [this link](TODO).

## References

[Library used to collect and send telemetry on iOS](https://github.com/mozilla-mobile/telemetry-ios/)
[Glean SDK repository, used to collect and send telemetry](https://github.com/mozilla/glean/)

[Legacy library used to collect and send telemetry on iOS](https://github.com/mozilla-mobile/telemetry-ios/)

[Description of the "Core" ping](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/data/core-ping.html)

Expand Down
16 changes: 16 additions & 0 deletions lockbox-ios/Common/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import UIKit
import Telemetry
import SwiftKeychainWrapper
import Glean

let PostFirstRunKey = "firstrun"

Expand Down Expand Up @@ -49,6 +50,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

setupAdjust()

setupGlean()

Dispatcher.shared.dispatch(action: LifecycleAction.startup)

return true
Expand All @@ -69,6 +72,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private func setupAdjust() {
_ = AdjustManager.shared
}

let glean = Glean.shared
private func setupGlean() {
_ = UserDefaultStore.shared.recordUsageData.subscribe(
onNext: { uploadEnabled in
self.glean.setUploadEnabled(uploadEnabled)
},
onError: nil,
onCompleted: nil,
onDisposed: nil
)
glean.initialize()
}
}

extension AppDelegate {
Expand Down

0 comments on commit 81d6302

Please sign in to comment.