File tree Expand file tree Collapse file tree 7 files changed +37
-0
lines changed Expand file tree Collapse file tree 7 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 15
15
#include " installations/src/android/installations_android.h"
16
16
17
17
#include " app/src/util.h"
18
+ #include " app/src/util_android.h"
18
19
#include " installations/src/common.h"
19
20
20
21
namespace firebase {
@@ -186,6 +187,19 @@ void InstallationsInternal::Cleanup() {
186
187
}
187
188
}
188
189
190
+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {
191
+ // Calling the native getter is sufficient to cause a Heartbeat to be logged.
192
+ JNIEnv* env = app.GetJNIEnv ();
193
+ jobject platform_app = app.GetPlatformApp ();
194
+ jclass installations_class = installations::GetClass ();
195
+ jobject installations_instance_local = env->CallStaticObjectMethod (
196
+ installations_class,
197
+ installations::GetMethodId (installations::kGetInstance ), platform_app);
198
+ firebase::util::CheckAndClearJniExceptions (env);
199
+ env->DeleteLocalRef (installations_instance_local);
200
+ env->DeleteLocalRef (platform_app);
201
+ }
202
+
189
203
Future<std::string> InstallationsInternal::GetId () {
190
204
const auto handle =
191
205
future_impl_.SafeAlloc <std::string>(kInstallationsFnGetId );
Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ class InstallationsInternal {
34
34
explicit InstallationsInternal (const firebase::App& app);
35
35
~InstallationsInternal ();
36
36
37
+ // Platform-specific method that causes a heartbeat to be logged.
38
+ // See go/firebase-platform-logging-design for more information.
39
+ static void LogHeartbeat (const firebase::App& app);
40
+
37
41
Future<std::string> GetId ();
38
42
Future<std::string> GetIdLastResult ();
39
43
Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ Installations* Installations::GetInstance(App* app) {
32
32
// Return the Installations if it already exists.
33
33
Installations* existing_installations = FindInstallations (app);
34
34
if (existing_installations) {
35
+ // Log heartbeat data when instance getters are called.
36
+ // See go/firebase-platform-logging-design for more information.
37
+ InstallationsInternal::LogHeartbeat (*app);
35
38
return existing_installations;
36
39
}
37
40
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ class InstallationsInternal {
42
42
explicit InstallationsInternal (const firebase::App& app);
43
43
~InstallationsInternal ();
44
44
45
+ // Platform-specific method that causes a heartbeat to be logged.
46
+ // See go/firebase-platform-logging-design for more information.
47
+ static void LogHeartbeat (const firebase::App& app);
48
+
45
49
Future<std::string> GetId ();
46
50
Future<std::string> GetIdLastResult ();
47
51
Original file line number Diff line number Diff line change 40
40
// Destructor is necessary for ARC garbage collection.
41
41
}
42
42
43
+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {
44
+ // Calling the native getter is sufficient to cause a Heartbeat to be logged.
45
+ FIRApp *platform_app = app.GetPlatformApp ();
46
+ [FIRInstallations installationsWithApp: platform_app];
47
+ }
48
+
43
49
bool InstallationsInternal::Initialized () const {
44
50
return true ;
45
51
}
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ InstallationsInternal::InstallationsInternal(const firebase::App& app)
26
26
27
27
InstallationsInternal::~InstallationsInternal () {}
28
28
29
+ void InstallationsInternal::LogHeartbeat (const firebase::App& app) {}
30
+
29
31
bool InstallationsInternal::Initialized () const { return true ; }
30
32
31
33
void InstallationsInternal::Cleanup () {}
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ class InstallationsInternal {
31
31
explicit InstallationsInternal (const firebase::App& app);
32
32
~InstallationsInternal ();
33
33
34
+ // Platform-specific method that causes a heartbeat to be logged.
35
+ // See go/firebase-platform-logging-design for more information.
36
+ static void LogHeartbeat (const firebase::App& app);
37
+
34
38
Future<std::string> GetId ();
35
39
Future<std::string> GetIdLastResult ();
36
40
You can’t perform that action at this time.
0 commit comments