Skip to content

Commit d7527bd

Browse files
committed
no enum in heartbeat api
1 parent db30d8e commit d7527bd

File tree

10 files changed

+32
-43
lines changed

10 files changed

+32
-43
lines changed

FirebaseAuth/Tests/Unit/AuthBackendRPCImplementationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,11 @@ class AuthBackendRPCImplementationTests: RPCBaseTests {
562562
return handler()
563563
}
564564

565-
func heartbeatCodeForToday() -> FIRDailyHeartbeatCode {
565+
func heartbeatCodeForToday() -> NSInteger {
566566
// This API should not be used by the below tests because the Auth
567567
// SDK uses only the V2 heartbeat API (`flushHeartbeatsIntoPayload`) for
568568
// getting heartbeats.
569-
return FIRDailyHeartbeatCode.none
569+
return 0
570570
}
571571
}
572572

FirebaseCore.podspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration
3333

3434
s.source_files = [
3535
'FirebaseCore/Sources/**/*.[mh]',
36-
'FirebaseCore/Extension/*.h'
36+
'FirebaseCore/Extension/*.h',
37+
'FirebaseCore/InternalObjC/*.h',
3738
]
3839

3940
s.resource_bundles = {

FirebaseCore/Extension/FIRHeartbeatLogger.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,13 @@ NS_ASSUME_NONNULL_BEGIN
2020
@class FIRHeartbeatsPayload;
2121
#endif // FIREBASE_BUILD_CMAKE
2222

23-
/// Enum representing different daily heartbeat codes.
24-
/// This enum is only used by clients using platform logging V1. This is because
25-
/// the V1 payload only supports a single daily heartbeat.
26-
typedef NS_ENUM(NSInteger, FIRDailyHeartbeatCode) {
27-
/// Represents the absence of a daily heartbeat.
28-
FIRDailyHeartbeatCodeNone = 0,
29-
/// Represents the presence of a daily heartbeat.
30-
FIRDailyHeartbeatCodeSome = 2,
31-
};
32-
3323
@protocol FIRHeartbeatLoggerProtocol <NSObject>
3424

3525
/// Asynchronously logs a heartbeat.
3626
- (void)log;
3727

3828
/// Gets the heartbeat code for today.
39-
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;
29+
- (NSInteger)heartbeatCodeForToday;
4030

4131
#ifndef FIREBASE_BUILD_CMAKE
4232
/// Returns the header value for the heartbeat logger via the given completion handler..
@@ -97,7 +87,7 @@ NSString *_Nullable FIRHeaderValueFromHeartbeatsPayload(FIRHeartbeatsPayload *he
9787
///
9888
/// @note This API is thread-safe.
9989
/// @return Heartbeat code indicating whether or not there is an unsent global heartbeat.
100-
- (FIRDailyHeartbeatCode)heartbeatCodeForToday;
90+
- (NSInteger)heartbeatCodeForToday;
10191

10292
@end
10393

FirebaseCore/Sources/FIRComponentContainerInternal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
*/
1616
#import <Foundation/Foundation.h>
1717

18-
@import FirebaseCoreInternal;
1918
#ifdef SWIFT_PACKAGE
2019
@import FirebaseCoreInternalObjC;
2120
#else
22-
@import FirebaseCoreInternal;
21+
#import "FirebaseCore/InternalObjC/FirebaseCoreInternal.h"
2322
#endif
2423

2524
@class FIRApp;

FirebaseCore/Sources/FIRHeartbeatLogger.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ - (void)flushHeartbeatsIntoPayloadWithCompletionHandler:
9595
}
9696
#endif // FIREBASE_BUILD_CMAKE
9797

98-
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
98+
- (NSInteger)heartbeatCodeForToday {
9999
#ifndef FIREBASE_BUILD_CMAKE
100100
FIRHeartbeatsPayload *todaysHeartbeatPayload = [_heartbeatController flushHeartbeatFromToday];
101101

102102
if ([todaysHeartbeatPayload isEmpty]) {
103-
return FIRDailyHeartbeatCodeNone;
103+
return 0;
104104
} else {
105-
return FIRDailyHeartbeatCodeSome;
105+
return 2;
106106
}
107107
#else
108-
return FIRDailyHeartbeatCodeNone;
108+
return 0;
109109
#endif // FIREBASE_BUILD_CMAKE
110110
}
111111

FirebaseCore/Tests/Unit/FIRHeartbeatLoggerTests.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ - (void)testFlushing_UsingV1API_WhenHeartbeatsAreStored_ReturnsFIRDailyHeartbeat
9696
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
9797
// When
9898
[heartbeatLogger log];
99-
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
99+
NSInteger heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
100100
// Then
101-
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeSome);
101+
XCTAssertEqual(heartbeatInfoCode, 2);
102102
}
103103

104104
- (void)testFlushing_UsingV1API_WhenNoHeartbeatsAreStored_ReturnsFIRDailyHeartbeatCodeNone {
105105
// Given
106106
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
107107
// When
108-
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
108+
NSInteger heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
109109
// Then
110-
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeNone);
110+
XCTAssertEqual(heartbeatInfoCode, 0);
111111
}
112112

113113
- (void)testFlushing_UsingV2API_WhenHeartbeatsAreStored_ReturnsNonEmptyPayload {
@@ -178,10 +178,10 @@ - (void)testLogAndFlushUsingV1API_AndThenFlushAgainUsingV2API_FlushesHeartbeatIn
178178
FIRHeartbeatLogger *heartbeatLogger = self.heartbeatLogger;
179179
[heartbeatLogger log];
180180
// When
181-
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
181+
NSInteger heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
182182
FIRHeartbeatsPayload *heartbeatsPayload = [heartbeatLogger flushHeartbeatsIntoPayload];
183183
// Then
184-
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeSome);
184+
XCTAssertEqual(heartbeatInfoCode, 2);
185185
[self assertHeartbeatsPayloadIsEmpty:heartbeatsPayload];
186186
}
187187

@@ -192,14 +192,14 @@ - (void)testLogAndFlushUsingV2API_AndThenFlushAgainUsingV1API_FlushesHeartbeatIn
192192
[heartbeatLogger log];
193193
// When
194194
FIRHeartbeatsPayload *heartbeatsPayload = [heartbeatLogger flushHeartbeatsIntoPayload];
195-
FIRDailyHeartbeatCode heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
195+
NSInteger heartbeatInfoCode = [heartbeatLogger heartbeatCodeForToday];
196196
// Then
197197
[self assertEncodedPayloadHeader:FIRHeaderValueFromHeartbeatsPayload(heartbeatsPayload)
198198
isEqualToPayloadJSON:@{
199199
@"version" : @2,
200200
@"heartbeats" : @[ @{@"agent" : @"dummy_agent", @"dates" : @[ expectedDate ]} ]
201201
}];
202-
XCTAssertEqual(heartbeatInfoCode, FIRDailyHeartbeatCodeNone);
202+
XCTAssertEqual(heartbeatInfoCode, 0);
203203
}
204204

205205
- (void)testHeartbeatLoggersWithSameIDShareTheSameStorage {

FirebaseFunctions/Tests/Unit/FunctionsTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import Foundation
1616

1717
import FirebaseCore
18+
import FirebaseCoreExtension
1819
@testable import FirebaseFunctions
1920
#if COCOAPODS
2021
import GTMSessionFetcher

FirebaseInstallations/Source/Tests/Unit/FIRInstallationsAPIServiceTests.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ - (nonnull FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
5050
}
5151
}
5252

53-
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
53+
- (NSInteger)heartbeatCodeForToday {
5454
// This API should not be used by the below tests because the Installations
5555
// SDK uses only the V2 heartbeat API (`flushHeartbeatsIntoPayload`) for
5656
// getting heartbeats.
5757
[self doesNotRecognizeSelector:_cmd];
58-
return FIRDailyHeartbeatCodeNone;
58+
return 0;
5959
}
6060

6161
- (void)log {

FirebaseMessaging/Tests/UnitTests/FIRMessagingTokenOperationsTest.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ - (void)performTokenOperation {
7171

7272
/// A fake heartbeat logger used for dependency injection during testing.
7373
@interface FIRHeartbeatLoggerFake : NSObject <FIRHeartbeatLoggerProtocol>
74-
@property(nonatomic, copy, nullable) FIRDailyHeartbeatCode (^onHeartbeatCodeForTodayHandler)(void);
74+
@property(nonatomic, copy, nullable) NSInteger (^onHeartbeatCodeForTodayHandler)(void);
7575
@end
7676

7777
@implementation FIRHeartbeatLoggerFake
@@ -84,11 +84,11 @@ - (nonnull FIRHeartbeatsPayload *)flushHeartbeatsIntoPayload {
8484
return nil;
8585
}
8686

87-
- (FIRDailyHeartbeatCode)heartbeatCodeForToday {
87+
- (NSInteger)heartbeatCodeForToday {
8888
if (self.onHeartbeatCodeForTodayHandler) {
8989
return self.onHeartbeatCodeForTodayHandler();
9090
} else {
91-
return FIRDailyHeartbeatCodeNone;
91+
return 0;
9292
}
9393
}
9494

@@ -404,26 +404,24 @@ - (void)testHTTPAuthHeaderGenerationFromCheckin {
404404
}
405405

406406
- (void)testTokenFetchOperationFirebaseUserAgentAndHeartbeatHeader_WhenHeartbeatNeedsSending {
407-
[self assertTokenFetchOperationRequestContainsFirebaseUserAgentAndHeartbeatInfoCode:
408-
FIRDailyHeartbeatCodeSome];
407+
[self assertTokenFetchOperationRequestContainsFirebaseUserAgentAndHeartbeatInfoCode:2];
409408
}
410409

411410
- (void)testTokenFetchOperationFirebaseUserAgentAndHeartbeatHeader_WhenNoHeartbeatNeedsSending {
412-
[self assertTokenFetchOperationRequestContainsFirebaseUserAgentAndHeartbeatInfoCode:
413-
FIRDailyHeartbeatCodeNone];
411+
[self assertTokenFetchOperationRequestContainsFirebaseUserAgentAndHeartbeatInfoCode:0];
414412
}
415413

416414
#pragma mark - Internal Helpers
417415

418416
- (void)assertTokenFetchOperationRequestContainsFirebaseUserAgentAndHeartbeatInfoCode:
419-
(FIRDailyHeartbeatCode)heartbeatInfoCode {
417+
(NSInteger)heartbeatInfoCode {
420418
XCTestExpectation *completionExpectation =
421419
[self expectationWithDescription:@"completionExpectation"];
422420

423421
FIRHeartbeatLoggerFake *heartbeatLoggerFake = [[FIRHeartbeatLoggerFake alloc] init];
424422
XCTestExpectation *heartbeatExpectation =
425423
[self expectationWithDescription:@"heartbeatExpectation"];
426-
heartbeatLoggerFake.onHeartbeatCodeForTodayHandler = ^FIRDailyHeartbeatCode {
424+
heartbeatLoggerFake.onHeartbeatCodeForTodayHandler = ^NSInteger {
427425
[heartbeatExpectation fulfill];
428426
return heartbeatInfoCode;
429427
};

Firestore/core/src/remote/firebase_metadata_provider_apple.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
return MakeString([FIRApp firebaseUserAgent]);
3636
}
3737

38-
FIRDailyHeartbeatCode GetHeartbeat(FIRApp* app) {
38+
NSInteger GetHeartbeat(FIRApp* app) {
3939
return [app.heartbeatLogger heartbeatCodeForToday];
4040
}
4141

@@ -51,11 +51,11 @@ FIRDailyHeartbeatCode GetHeartbeat(FIRApp* app) {
5151

5252
void FirebaseMetadataProviderApple::UpdateMetadata(
5353
grpc::ClientContext& context) {
54-
FIRDailyHeartbeatCode heartbeat = GetHeartbeat(app_);
54+
NSInteger heartbeat = GetHeartbeat(app_);
5555
// TODO(ncooke3): If support for notifying a heartbeat logger when a
5656
// request fails is implemented, we will need to change the below
5757
// code to place the heartbeat data back into heartbeat storage.
58-
if (heartbeat != FIRDailyHeartbeatCodeNone) {
58+
if (heartbeat != 0) {
5959
context.AddMetadata(kXFirebaseClientLogTypeHeader,
6060
std::to_string(heartbeat));
6161
}

0 commit comments

Comments
 (0)