Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Analytics] Consolidate Analytics and AnalyticsSwift #11959

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: FirebaseAnalytics
run: scripts/third_party/travis/retry.sh pod spec lint FirebaseAnalytics.podspec --platforms=${{ matrix.target }} --sources=https://github.com/firebase/SpecsDev.git,https://github.com/firebase/SpecsStaging.git,https://cdn.cocoapods.org/
- name: FirebaseAnalyticsSwift
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAnalyticsSwift.podspec --platforms=${{ matrix.target }}
run: scripts/third_party/travis/retry.sh scripts/pod_lib_lint.rb FirebaseAnalyticsSwift.podspec --allow-warnings --platforms=${{ matrix.target }}
# The following steps are only run on `ios` due to product availability.
- name: GoogleAppMeasurementOnDeviceConversion
run: scripts/third_party/travis/retry.sh pod spec lint GoogleAppMeasurementOnDeviceConversion.podspec --platforms=ios --sources=https://github.com/firebase/SpecsDev.git,https://github.com/firebase/SpecsStaging.git,https://cdn.cocoapods.org/
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/client_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ on:
# Run every day at 12am (PST) - cron uses UTC times
- cron: "0 8 * * *"

env:
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
client-app-spm:
if: (github.repository == 'Firebase/firebase-ios-sdk' && github.event_name == 'schedule') || github.event_name == 'pull_request'
env:
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
runs-on: macos-12
strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions FirebaseAnalytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This directory open sources select files from the Firebase Analytics SDK. Note
that there is no open source infastructure to build or package them.
2 changes: 1 addition & 1 deletion FirebaseAnalyticsSwift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Firebase Analytics is a free, out-of-the-box analytics solution that inspires ac
'FirebaseAnalyticsSwift/Sources/*.swift',
]

s.dependency 'FirebaseAnalytics', '~> 10.0'
s.dependency 'FirebaseAnalytics', '~> 10.17'

s.test_spec 'swift-unit' do |swift_unit_tests|
swift_unit_tests.platforms = {
Expand Down
7 changes: 7 additions & 0 deletions FirebaseAnalyticsSwift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 10.17.0
- [deprecated] All of the public API from `FirebaseAnalyticsSwift` can now
be accessed through the `FirebaseAnalytics` module. Therefore,
`FirebaseAnalyticsSwift` has been deprecated, and will be removed in a
future release. See https://firebase.google.com/docs/ios/swift-migration for
migration instructions.

# 9.0.0
- [added] **Breaking change:** `FirebaseAnalyticsSwift` has exited beta and is
now generally available for use.
Expand Down
17 changes: 17 additions & 0 deletions FirebaseAnalyticsSwift/Sources/FirebaseAnalyticsSwift.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#warning(
"All of the public API from `FirebaseAnalyticsSwift` can now be accessed through the `FirebaseAnalytics` module. Therefore, the `FirebaseAnalyticsSwift` module is deprecated and will be removed in the future. See https://firebase.google.com/docs/ios/swift-migration for migration instructions."
)
66 changes: 35 additions & 31 deletions FirebaseAnalyticsSwift/Tests/SwiftUnit/AnalyticsAPITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,11 @@
import Foundation
import SwiftUI

@testable import FirebaseAnalyticsSwift
import FirebaseAnalyticsSwift
import SwiftUI
import FirebaseAnalytics

final class AnalyticsAPITests {
@available(iOS 13.0, *)
func loggedAnalyticsModifierUsage(viewModifier: LoggedAnalyticsModifier,
content: LoggedAnalyticsModifier.Content) {
let _: String = viewModifier.screenName
let _: String = viewModifier.screenClass
let _: [String: Any] = viewModifier.extraParameters
let _: any View = viewModifier.body(content: content)
}

@available(iOS 13.0, *)
func viewExtensionUsage(viewModifier: LoggedAnalyticsModifier, view: any View) {
let _: any View = view.analyticsScreen(
name: "name",
class: "class",
extraParameters: ["param": 1]
)
}

func usage() {
// MARK: - Analytics

Expand All @@ -54,24 +37,20 @@ final class AnalyticsAPITests {
Analytics.setDefaultEventParameters(["default": 100])

Analytics.sessionID { sessionID, error in }
#if compiler(>=5.5.2) && canImport(_Concurrency)
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
let _: Int64? = try? await Analytics.sessionID()
}
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
let _: Int64? = try? await Analytics.sessionID()
}
#endif // compiler(>=5.5.2) && canImport(_Concurrency)
}

// MARK: - AppDelegate

Analytics.handleEvents(forBackgroundURLSession: "session_id", completionHandler: {})
#if compiler(>=5.5.2) && canImport(_Concurrency)
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
await Analytics.handleEvents(forBackgroundURLSession: "session_id")
}
if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
Task {
await Analytics.handleEvents(forBackgroundURLSession: "session_id")
}
#endif // compiler(>=5.5.2) && canImport(_Concurrency)
}
Analytics.handleOpen(URL(string: "https://google.com")!)
Analytics.handleUserActivity(NSUserActivity(activityType: "editing"))

Expand Down Expand Up @@ -203,5 +182,30 @@ final class AnalyticsAPITests {
AnalyticsUserPropertyAllowAdPersonalizationSignals,
AnalyticsUserPropertySignUpMethod,
]

// MARK: - Analytics + SwiftUI

@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, *)
@available(watchOS, unavailable)
struct MyView: View {
let name: String
let klass: String
let extraParameters: [String: Any]

var body: some View {
Text("Hello, world!")
.analyticsScreen(name: name,
class: klass,
extraParameters: extraParameters)
Text("Hello, world!")
.analyticsScreen(name: name,
extraParameters: extraParameters)
Text("Hello, world!")
.analyticsScreen(name: name,
class: klass)
Text("Hello, world!")
.analyticsScreen(name: name)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public let shared = Manifest(
Pod("GoogleAppMeasurementOnDeviceConversion", isClosedSource: true, platforms: ["ios"]),
Pod("FirebaseAnalytics", isClosedSource: true),
Pod("FirebaseAnalyticsOnDeviceConversion", platforms: ["ios"], zip: true),
Pod("FirebaseAnalyticsSwift", zip: true),
Pod("FirebaseAnalyticsSwift", allowWarnings: true, zip: true),
Pod("FirebaseABTesting", zip: true),
Pod("FirebaseAppCheck", zip: true),
Pod("FirebaseRemoteConfig"),
Expand Down
Loading