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

Implement Firebase CoreDiagnostics #3129

Merged
merged 121 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
d16f13c
Implement CoreDiagnostics interop
mikehaney24 May 25, 2019
31ac624
Add CoreDiagnosticsInterop to the Example Podfile
mikehaney24 May 27, 2019
559dab3
Style and xcodeproj updates
mikehaney24 May 27, 2019
abbb63e
Update Podfiles that dep on FirebaseCore
mikehaney24 Jun 3, 2019
7a9590e
ran pod deintegrate to remove unintended xcodeproj changes
mikehaney24 Jun 3, 2019
0bba31a
Fix Podfile paths
mikehaney24 Jun 4, 2019
2c4134c
Add FCD to if_changed and travis.yml
mikehaney24 Jun 4, 2019
b7d0d08
Fix building with Firestore
mikehaney24 Jun 4, 2019
d5608af
Style
mikehaney24 Jun 4, 2019
d5b9994
Whitespace
mikehaney24 Jun 4, 2019
669f559
Fix a changed internal API
mikehaney24 Jun 4, 2019
c08b8c8
Make pod paths consistent
mikehaney24 Jun 5, 2019
993c1c5
Merge branch 'master' into mph-master
mikehaney24 Jun 6, 2019
b24b109
Restore connectivity_monitor_noop.cc style
mikehaney24 Jun 7, 2019
06c1f6a
Remove logging prior to [FIRApp configure]
mikehaney24 Jun 12, 2019
13491b9
style
mikehaney24 Jun 12, 2019
488cade
Remove nil checks from diagnostics data
mikehaney24 Jun 12, 2019
e3e0cc5
Put back some deleted symbols
mikehaney24 Jun 12, 2019
ac3c700
Restore the sendLogsWithServiceName:version: method, but as a no-op
mikehaney24 Jun 12, 2019
9339939
Restore the original version of sendLogs...
mikehaney24 Jun 12, 2019
31b853e
Allow an unused parameter
mikehaney24 Jun 12, 2019
3a0e3ce
Remove obsolete nsnotificationcenter related stuff
mikehaney24 Jun 12, 2019
a17a79c
Whoops, missed the header change.
mikehaney24 Jun 12, 2019
c099b91
Final changes to support FIRCoreDiagnostics
mikehaney24 Jun 14, 2019
ea08328
Add nanopb and project generation infrastructure
mikehaney24 Jun 14, 2019
1e17441
Convert FIRCoreDiagnostics to canonical nanopb, and move to OSS.
mikehaney24 Jun 17, 2019
9adaaff
Remove custom build steps for CoreDiagnostics
mikehaney24 Jun 17, 2019
a3f621a
Addressing review comments
mikehaney24 Jun 17, 2019
ff5fcbc
Update versions, tags, and port the relevant unit tests for FIRCD
mikehaney24 Jun 19, 2019
120eb36
Version and platform fixes
mikehaney24 Jun 20, 2019
643f8ca
Fix podspec expected tags
mikehaney24 Jun 20, 2019
4106333
A hack to solve a chicken-and-egg problem with pod lib linting.
mikehaney24 Jun 20, 2019
95573be
Heartbeat implementation
maksymmalyhin Jun 20, 2019
8c5e98c
FIRDiagnosticsDateFileStorageTests
maksymmalyhin Jun 20, 2019
64bbb49
Fix tests for non-iOS platforms
mikehaney24 Jun 20, 2019
044b96f
Heartbeat tests
maksymmalyhin Jun 20, 2019
6c5aded
Fix initialization.
maksymmalyhin Jun 20, 2019
67090df
Cleanup Installation ID.
maksymmalyhin Jun 20, 2019
712ae83
Fix testProtoPopulation.
maksymmalyhin Jun 20, 2019
d803c7b
Merge branch 'mph-master6' into mm/cd-heartbeat-7
maksymmalyhin Jun 20, 2019
52a5349
Merge conflict fix
maksymmalyhin Jun 20, 2019
d7b4722
Typo fix.
maksymmalyhin Jun 20, 2019
928e7df
Remove FIRCore dep from FIRCD unit tests and move symbols to interop
mikehaney24 Jun 20, 2019
aaf48a8
Run ./scripts/style.sh
maksymmalyhin Jun 20, 2019
b6aec9a
Typo
maksymmalyhin Jun 20, 2019
bbd2722
Merge branch 'mph-master6' into mm/cd-heartbeat-7
maksymmalyhin Jun 20, 2019
106eea7
#ifdef comment
maksymmalyhin Jun 20, 2019
cc27324
File license header.
maksymmalyhin Jun 20, 2019
8b1b6f9
Import FIRDiagnosticsDateFileStorage.h using relative path.
maksymmalyhin Jun 20, 2019
c0902e9
FIRDiagnostics -> FIRCoreDiagnostics
maksymmalyhin Jun 20, 2019
1f60777
Docs syntax
maksymmalyhin Jun 20, 2019
9a8897e
Docs
maksymmalyhin Jun 20, 2019
7a5d6ee
Docs typo
maksymmalyhin Jun 20, 2019
e03f204
Add shared variables to the interop lib
mikehaney24 Jun 20, 2019
c0178e4
Fix comment
mikehaney24 Jun 20, 2019
9205321
Style
mikehaney24 Jun 20, 2019
4a0365c
Removed lib version passing.
mikehaney24 Jun 20, 2019
2173c96
Remove env checking for conditional deps
mikehaney24 Jun 20, 2019
3a407e2
Merge remote-tracking branch 'origin/mm/cd-heartbeat-7' into mph-master6
mikehaney24 Jun 21, 2019
0764f49
Merge branch 'mph-master5' into mph-master4
mikehaney24 Jun 21, 2019
19497b6
Merge branch 'mph-master4' into mph-master3
mikehaney24 Jun 21, 2019
a3adca1
Merge branch 'mph-master3' into mph-master2
mikehaney24 Jun 21, 2019
bdedb72
Merge branch 'master' into mph-master
mikehaney24 Jun 21, 2019
cf28e6a
Style
mikehaney24 Jun 21, 2019
ee86ff9
Address whitespace issues
mikehaney24 Jun 21, 2019
0902411
Add copyright notice
mikehaney24 Jun 21, 2019
174f787
Add new deps to Podfiles
mikehaney24 Jun 21, 2019
3e7f30f
Fix trailing space
mikehaney24 Jun 21, 2019
8fd0c16
Some changes to fix working in an extension.
mikehaney24 Jun 24, 2019
d4150af
Fix type in Podfile
mikehaney24 Jun 24, 2019
10e95ff
GDT: begin/end background task only for iOS and TVOS applications.
maksymmalyhin Jun 24, 2019
770cc1b
Fix typo
mikehaney24 Jun 24, 2019
d740533
Style
mikehaney24 Jun 24, 2019
59febdc
Stop sharing kFIRService strings across pods
paulb777 Jun 24, 2019
6e7655f
Travis test
paulb777 Jun 24, 2019
efb9fba
Change all TARGET_OS_TVOS macros to TARGET_OS_TV
mikehaney24 Jun 24, 2019
7f78f62
style
paulb777 Jun 24, 2019
458e220
Merge branch 'mph-master' into pb-cleanup-firservice
mikehaney24 Jun 25, 2019
fbc3dbc
Update all Podfiles with deps on FIRCore
mikehaney24 Jun 25, 2019
4e59eb9
Fix trailing whitespace
mikehaney24 Jun 25, 2019
a4cadc6
Merge branch 'pb-cleanup-firservice' into mph-master
mikehaney24 Jun 25, 2019
30f0a9d
Update Firestore cmake
mikehaney24 Jun 25, 2019
c796400
Fix FIAM build break (#3254)
paulb777 Jun 25, 2019
ea17e78
Additional cmake changes
mikehaney24 Jun 25, 2019
232b859
Fix linker issue with deprecated CoreDiagnostics (#3257)
paulb777 Jun 25, 2019
6fe1982
Adding more deps to cmake
mikehaney24 Jun 25, 2019
03824d8
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jun 25, 2019
b4694d0
Fix linker error (#3266)
paulb777 Jun 26, 2019
2d26359
Add support for expanding PODS_TARGET_SRCROOT in CMake (#3267)
wilhuff Jun 26, 2019
af071cd
Merge branch 'master' into mph-master
mikehaney24 Jun 27, 2019
2cd11f9
Remove typed enum and fix a comment.
mikehaney24 Jun 27, 2019
0f4429f
Fix an import
mikehaney24 Jun 27, 2019
a248f45
Change a line so it's not altered by Copybara
mikehaney24 Jun 27, 2019
02db971
More changes to stop copybara from altering the wrong sources
mikehaney24 Jun 27, 2019
4a17d67
Remove trailing whitespace
mikehaney24 Jun 27, 2019
c11a30f
Fix copybara modifying python.
mikehaney24 Jun 27, 2019
8934d34
Merge branch 'master' into mph-master
mikehaney24 Jun 27, 2019
9788b8e
Add additional field in firebasecore.proto (#3273)
mikehaney24 Jun 27, 2019
5e68863
Merge branch 'master' into mph-master
mikehaney24 Jun 28, 2019
33079bf
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jun 28, 2019
b01adee
Remove the dependency on interop to populate a shared variable.
mikehaney24 Jun 28, 2019
1b88ff1
style
mikehaney24 Jun 28, 2019
c855226
Merge branch 'master' into mph-master
mikehaney24 Jul 8, 2019
6e0b462
Create travis jobs for FirebaseCoreDiagnostics (#3245)
mikehaney24 Jul 10, 2019
d2b21a3
Merge branch 'mph-master' of github.com:firebase/firebase-ios-sdk int…
mikehaney24 Jul 10, 2019
c7a5303
Remove mph-master from travis
mikehaney24 Jul 10, 2019
f28f1db
Fix constant name conflic between old and new diagnostics (#3329)
maksymmalyhin Jul 10, 2019
3f0910c
Rempve mph-master again
mikehaney24 Jul 10, 2019
49f013a
Fix imports in FIRCDConnector
mikehaney24 Jul 10, 2019
56c9279
Fix another import
mikehaney24 Jul 10, 2019
ef521aa
Fix yet another import
mikehaney24 Jul 10, 2019
2842b24
Merge branch 'master' into mph-master
mikehaney24 Jul 11, 2019
da1c4ab
Attempt to read crashing test logs from disk
mikehaney24 Jul 11, 2019
9266085
Implement printing of failed/crashed test logs.
mikehaney24 Jul 12, 2019
40a85ba
Print only crashed tests, rmdir between runs
mikehaney24 Jul 12, 2019
1fedd3a
Revert reading crashing log changes
mikehaney24 Jul 16, 2019
cac286b
Write CHANGELOG for all new FIRCD associated libraries
mikehaney24 Jul 16, 2019
e258fce
Change all GUL deps to >= 6.2
mikehaney24 Jul 16, 2019
34f064c
Merge branch 'master' into mph-master
mikehaney24 Jul 17, 2019
c3059fe
Revert ZipBuilder changes and do some last bits of cleanup
mikehaney24 Jul 17, 2019
ad5071c
Remove an assertion and populate an error instead
mikehaney24 Jul 18, 2019
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
4 changes: 3 additions & 1 deletion Example/Core/Tests/FIRAppTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#import "FIRTestCase.h"
#import "FIRTestComponents.h"

#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>

#import <FirebaseCore/FIRAnalyticsConfiguration.h>
#import <FirebaseCore/FIRAppInternal.h>
#import <FirebaseCore/FIROptionsInternal.h>
Expand Down Expand Up @@ -620,7 +622,7 @@ - (void)testGlobalDataCollectionNoDiagnosticsSent {
// Add an observer for the diagnostics notification. Currently no object is sent, but in the
// future that could change so leave it as OCMOCK_ANY.
[self.notificationCenter addMockObserver:self.observerMock
name:kFIRAppDiagnosticsNotification
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
name:kFIRDiagnosticsNotification
object:OCMOCK_ANY];

// Stub out reading from user defaults since stubbing out the BOOL has issues. If the data
Expand Down
48 changes: 48 additions & 0 deletions Example/Core/Tests/FIRDiagnosticsDataTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2019 Google
*
* 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.
*/

#import <XCTest/XCTest.h>

#import <FirebaseCore/FIRDiagnosticsData.h>

@interface FIRDiagnosticsDataTest : XCTestCase

@end

@implementation FIRDiagnosticsDataTest

/** Tests initialization. */
- (void)testInit {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertNotNil(data);
}

/** Tests that -diagnosticObjects returns a valid default dictionary. */
- (void)testFIRCoreDiagnosticsData {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertNotNil(data.diagnosticObjects);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDllAppsCountKey]);
XCTAssertNotNil(data.diagnosticObjects[kFIRCDFirebaseUserAgentKey]);
}

/** Tests that setting diagnosticObjects throws. */
- (void)testSettingDiagnosticObjectsThrows {
FIRDiagnosticsData *data = [[FIRDiagnosticsData alloc] init];
XCTAssertThrows(data.diagnosticObjects = @{});
}

@end
2,232 changes: 2,232 additions & 0 deletions Example/Firebase.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use_frameworks!
pod 'FirebaseAnalyticsInterop', :path => '../'
pod 'FirebaseAuthInterop', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'GoogleUtilities', :path => '../'

target 'Core_Example_iOS' do
Expand Down Expand Up @@ -127,6 +128,7 @@ target 'Auth_Sample' do
platform :ios, '8.0'
pod 'FirebaseAuth', :path => '../'
pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FBSDKLoginKit'
pod 'GoogleSignIn'
pod 'FirebaseInstanceID', :path => '../'
Expand All @@ -146,6 +148,7 @@ target 'Core_Example_macOS' do
platform :osx, '10.11'

pod 'FirebaseCore', :path => '../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'

target 'Core_Tests_macOS' do
inherit! :search_paths
Expand Down
1 change: 1 addition & 0 deletions Example/tvOSSample/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ target 'tvOSSample' do

# Pods for tvOSSample
pod 'FirebaseCore', :path => '../../'
pod 'FirebaseCoreDiagnosticsInterop', :path => '../'
pod 'FirebaseAuth', :path => '../../'
pod 'FirebaseDatabase', :path => '../../'
pod 'FirebaseStorage', :path => '../../'
Expand Down
98 changes: 64 additions & 34 deletions Firebase/Core/FIRApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
#include <sys/utsname.h>

#import "FIRApp.h"

#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>

#import "Private/FIRAnalyticsConfiguration.h"
#import "Private/FIRAppInternal.h"
#import "Private/FIRBundleUtil.h"
#import "Private/FIRComponentContainerInternal.h"
#import "Private/FIRConfigurationInternal.h"
#import "Private/FIRDiagnosticsData.h"
#import "Private/FIRLibrary.h"
#import "Private/FIRLogger.h"
#import "Private/FIROptionsInternal.h"
Expand Down Expand Up @@ -54,10 +58,7 @@
NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey =
@"FirebaseDataCollectionDefaultEnabled";

NSString *const kFIRAppDiagnosticsNotification = @"FIRAppDiagnosticsNotification";

NSString *const kFIRAppDiagnosticsConfigurationTypeKey = @"ConfigType";
NSString *const kFIRAppDiagnosticsErrorKey = @"Error";
NSString *const kFIRAppDiagnosticsFIRAppKey = @"FIRApp";
NSString *const kFIRAppDiagnosticsSDKNameKey = @"SDKName";
NSString *const kFIRAppDiagnosticsSDKVersionKey = @"SDKVersion";
Expand Down Expand Up @@ -107,15 +108,22 @@ + (void)configure {
// since the app isn't configured at all, so only rely on the Info.plist value.
NSNumber *collectionEnabledPlistValue = [[self class] readDataCollectionSwitchFromPlist];
if (collectionEnabledPlistValue == nil || [collectionEnabledPlistValue boolValue]) {
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
[[NSNotificationCenter defaultCenter]
postNotificationName:kFIRAppDiagnosticsNotification
object:nil
userInfo:@{
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
kFIRAppDiagnosticsErrorKey : [FIRApp errorForMissingOptions]
}];
if (NSClassFromString(@"FIRDiagnostics")) {
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
[diagnosticsData insertValueIfNotNil:collectionEnabledPlistValue
forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
[diagnosticsData insertValueIfNotNil:[FIRApp firebaseUserAgent]
forKey:kFIRCDFirebaseUserAgentKey];
[diagnosticsData insertValueIfNotNil:@(FIRConfigTypeCore)
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
forKey:kFIRCDConfigurationTypeKey];
[[NSNotificationCenter defaultCenter]
postNotificationName:kFIRDiagnosticsNotification
object:nil
userInfo:@{
kFIRDiagnosticsDataNotifKey : diagnosticsData,
}];
}
}

[NSException raise:kFirebaseCoreErrorDomain
format:@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find "
@"a valid GoogleService-Info.plist in your project. Please download one "
Expand Down Expand Up @@ -293,26 +301,39 @@ - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)opti
- (BOOL)configureCore {
[self checkExpectedBundleID];
if (![self isAppIDValid]) {
if (_options.usingOptionsFromDefaultPlist && [self isDataCollectionDefaultEnabled]) {
if (_options.usingOptionsFromDefaultPlist && [self isDataCollectionDefaultEnabled] &&
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
NSClassFromString(@"FIRDiagnostics")) {
FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
[diagnosticsData insertValueIfNotNil:@([self isDataCollectionDefaultEnabled])
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
[diagnosticsData insertValueIfNotNil:[FIRApp firebaseUserAgent]
forKey:kFIRCDFirebaseUserAgentKey];
[diagnosticsData insertValueIfNotNil:@(FIRConfigTypeCore) forKey:kFIRCDConfigurationTypeKey];
[[NSNotificationCenter defaultCenter]
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
postNotificationName:kFIRAppDiagnosticsNotification
postNotificationName:kFIRDiagnosticsNotification
object:nil
userInfo:@{
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
kFIRAppDiagnosticsErrorKey : [FIRApp errorForInvalidAppID],
}];
userInfo:@{kFIRDiagnosticsDataNotifKey : diagnosticsData}];
}
return NO;
}

if ([self isDataCollectionDefaultEnabled]) {
if ([self isDataCollectionDefaultEnabled] && NSClassFromString(@"FIRDiagnostics")) {
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
[diagnosticsData insertValueIfNotNil:@([self isDataCollectionDefaultEnabled])
forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
[diagnosticsData insertValueIfNotNil:[FIRApp firebaseUserAgent]
forKey:kFIRCDFirebaseUserAgentKey];
[diagnosticsData insertValueIfNotNil:@(FIRConfigTypeCore) forKey:kFIRCDConfigurationTypeKey];
[diagnosticsData insertValueIfNotNil:self.options.googleAppID forKey:kFIRCDGoogleAppIDKey];
[diagnosticsData insertValueIfNotNil:self.options.bundleID forKey:kFIRCDBundleIDKey];
[diagnosticsData insertValueIfNotNil:@(self.options.usingOptionsFromDefaultPlist)
forKey:kFIRCDUsingOptionsFromDefaultPlistKey];
[diagnosticsData insertValueIfNotNil:self.options.libraryVersionID
forKey:kFIRCDLibraryVersionIDKey];
[[NSNotificationCenter defaultCenter]
postNotificationName:kFIRAppDiagnosticsNotification
postNotificationName:kFIRDiagnosticsNotification
object:nil
userInfo:@{
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeCore),
kFIRAppDiagnosticsFIRAppKey : self
}];
userInfo:@{kFIRDiagnosticsDataNotifKey : diagnosticsData}];
}

#if TARGET_OS_IOS
Expand Down Expand Up @@ -817,18 +838,27 @@ - (void)sendLogsWithServiceName:(NSString *)serviceName
return;
}

NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] initWithDictionary:@{
kFIRAppDiagnosticsConfigurationTypeKey : @(FIRConfigTypeSDK),
kFIRAppDiagnosticsSDKNameKey : serviceName,
kFIRAppDiagnosticsSDKVersionKey : version,
kFIRAppDiagnosticsFIRAppKey : self
}];
if (error) {
userInfo[kFIRAppDiagnosticsErrorKey] = error;
if (NSClassFromString(@"FIRDiagnostics")) {
FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
[diagnosticsData insertValueIfNotNil:@([self isDataCollectionDefaultEnabled])
forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
[diagnosticsData insertValueIfNotNil:[FIRApp firebaseUserAgent]
forKey:kFIRCDFirebaseUserAgentKey];
[diagnosticsData insertValueIfNotNil:@(FIRConfigTypeSDK) forKey:kFIRCDConfigurationTypeKey];
[diagnosticsData insertValueIfNotNil:serviceName forKey:kFIRCDSdkNameKey];
[diagnosticsData insertValueIfNotNil:version forKey:kFIRCDSdkVersionKey];
[diagnosticsData insertValueIfNotNil:self.options.googleAppID forKey:kFIRCDGoogleAppIDKey];
[diagnosticsData insertValueIfNotNil:self.options.bundleID forKey:kFIRCDBundleIDKey];
[diagnosticsData insertValueIfNotNil:@(self.options.usingOptionsFromDefaultPlist)
forKey:kFIRCDUsingOptionsFromDefaultPlistKey];
[diagnosticsData insertValueIfNotNil:self.options.libraryVersionID
forKey:kFIRCDLibraryVersionIDKey];

[[NSNotificationCenter defaultCenter]
postNotificationName:kFIRDiagnosticsNotification
object:nil
userInfo:@{kFIRDiagnosticsDataNotifKey : diagnosticsData}];
}
[[NSNotificationCenter defaultCenter] postNotificationName:kFIRAppDiagnosticsNotification
object:nil
userInfo:userInfo];
}

@end
63 changes: 63 additions & 0 deletions Firebase/Core/FIRDiagnosticsData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2019 Google
*
* 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.
*/

#import "Private/FIRDiagnosticsData.h"

#import <FirebaseCore/FIRApp.h>

#import "Private/FIRAppInternal.h"
#import "Private/FIROptionsInternal.h"

@implementation FIRDiagnosticsData {
/** Backing ivar for the diagnosticObjects property. */
NSMutableDictionary<NSString *, id> *_diagnosticObjects;
}

- (instancetype)init {
self = [super init];
if (self) {
_diagnosticObjects = [[NSMutableDictionary alloc] init];
}
return self;
}

- (void)insertValueIfNotNil:(nullable id)value forKey:(NSString *)key {
if (value && key) {
_diagnosticObjects[key] = value;
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
}
}

#pragma mark - FIRCoreDiagnosticsData

- (NSDictionary<NSString *, id> *)diagnosticObjects {
if (!_diagnosticObjects[kFIRCDllAppsCountKey]) {
_diagnosticObjects[kFIRCDllAppsCountKey] = @([FIRApp allApps].count);
}
if (!_diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]) {
_diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey] =
@([[FIRApp defaultApp] isDataCollectionDefaultEnabled]);
}
if (!_diagnosticObjects[kFIRCDFirebaseUserAgentKey]) {
mikehaney24 marked this conversation as resolved.
Show resolved Hide resolved
_diagnosticObjects[kFIRCDFirebaseUserAgentKey] = [FIRApp firebaseUserAgent];
}
return _diagnosticObjects;
}

- (void)setDiagnosticObjects:(NSDictionary<NSString *, id> *)diagnosticObjects {
NSAssert(NO, @"Please use -insertValue:forKey:");
}

@end
5 changes: 0 additions & 5 deletions Firebase/Core/Private/FIRAppInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
*/
extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;

/**
* A notification fired containing diagnostic information when SDK errors occur.
*/
extern NSString *const kFIRAppDiagnosticsNotification;

/** @var FIRAuthStateDidChangeInternalNotification
@brief The name of the @c NSNotificationCenter notification which is posted when the auth state
changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
Expand Down
35 changes: 35 additions & 0 deletions Firebase/Core/Private/FIRDiagnosticsData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2019 Google
*
* 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.
*/

#import <Foundation/Foundation.h>

#import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h>

NS_ASSUME_NONNULL_BEGIN

/** Implements the FIRCoreDiagnosticsData protocol to log diagnostics data. */
@interface FIRDiagnosticsData : NSObject <FIRCoreDiagnosticsData>

/** Inserts values into the diagnosticObjects dictionary if the value isn't nil.
*
* @param value The value to insert if it's not nil.
* @param key The key to associate it with.
*/
- (void)insertValueIfNotNil:(nullable id)value forKey:(NSString *)key;

@end

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions FirebaseCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration
s.framework = 'Foundation'
s.dependency 'GoogleUtilities/Environment', '~> 6.0'
s.dependency 'GoogleUtilities/Logger', '~> 6.0'
s.dependency 'FirebaseCoreDiagnosticsInterop', '~> 0.1'

s.pod_target_xcconfig = {
'GCC_C_LANGUAGE_STANDARD' => 'c99',
'GCC_PREPROCESSOR_DEFINITIONS' =>
Expand Down
29 changes: 29 additions & 0 deletions FirebaseCoreDiagnosticsInterop.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Pod::Spec.new do |s|
s.name = 'FirebaseCoreDiagnosticsInterop'
s.version = '0.1.0'
s.summary = 'Interfaces that allow other Firebase SDKs to use CoreDiagnostics functionality.'

s.description = <<-DESC
Not for public use.

A set of protocols that other Firebase SDKs can use to interoperate with FirebaseCoreDiagnostics
in a safe manner.
DESC

s.homepage = 'https://firebase.google.com'
s.license = { :type => 'Apache', :file => 'LICENSE' }
s.authors = 'Google, Inc.'

# NOTE that these should not be used externally, this is for Firebase pods to depend on each
# other.
s.source = {
:git => 'https://github.com/firebase/firebase-ios-sdk.git',
:tag => 'CoreDiagnostics-' + s.version.to_s
}
s.social_media_url = 'https://twitter.com/Firebase'
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.11'
s.tvos.deployment_target = '10.0'
s.source_files = 'Interop/CoreDiagnostics/**/*.h'
s.public_header_files = 'Interop/CoreDiagnostics/Public/*.h'
end
Loading