无法查看 Firebase Analytics Debug View React Native

Unable to view Firebase Analytics Debug View React Native

我已经学习了多篇教程并阅读了多篇 Whosebug 帖子,但无论我做什么,我都无法在使用 RNFireBase 的 iOS 应用程序的 DebugView 中显示任何内容。我真的很感激这方面的帮助。我花了几天时间试图解决这个问题,但我不知道出了什么问题。我在模拟器和物理设备上都试过了,但都没有成功。

我在 XCode 的控制台中收到日志消息,但 Firebase 控制台中没有显示任何内容。以下是我在使用事件时在本地收到的消息:

React Native

<TouchableOpacity
  onPress={() =>
    analytics().logSelectContent({
      content_type: "clothing",
      item_id: "abcd",
    })
  }
>
  <Text>Log message</Text>
</TouchableOpacity>;

日志

2020-05-15 12:22:26.486761-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023051] Logging event: origin, name, params: app, select_content, {
    content_type = clothing;
    ga_event_origin (_o) = app;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.487676-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.500453-0400 Example App[23464:8820959] 6.13.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:26.502567-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): 0.9828788042068481
2020-05-15 12:22:26.502616-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023028] Upload task scheduled to be executed in approx. (s): 0.9828788042068481
2020-05-15 12:22:27.497172-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002001] Measurement timer fired
2020-05-15 12:22:27.497304-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS002003] Measurement timer canceled
2020-05-15 12:22:27.497444-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023033] Starting data upload
2020-05-15 12:22:27.501020-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023105] Event is not subject to real-time event count daily limit. Marking an event as real-time. Event name, parameters: select_content, {
    content_type = clothing;
    ga_debug (_dbg) = 1;
    ga_event_origin (_o) = app;
    ga_realtime (_r) = 1;
    ga_screen_class (_sc) = UIViewController;
    ga_screen_id (_si) = -3307323385789565728;
    item_id = abcd;
}
2020-05-15 12:22:27.511485-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS012018] Saving bundle. size (bytes): 499
2020-05-15 12:22:27.512391-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023116] Bundle added to the upload queue. BundleID, timestamp (ms): 38, 1589559746485
2020-05-15 12:22:27.518879-0400 Example App[23464:8821128] 6.13.0 - [Firebase/Analytics][I-ACS023038] Uploading events. Elapsed time since last successful upload (s): 44.21102094650269
2020-05-15 12:22:27.519180-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS023039] Measurement data sent to network. Timestamp (ms), data: 1589559747518, <APMPBMeasurementBatch: 0x2808513f0>
2020-05-15 12:22:27.524885-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS900000] Uploading data. Host: https://app-measurement.com/a
2020-05-15 12:22:27.607462-0400 Example App[23464:8820960] 6.13.0 - [Firebase/Analytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
2020-05-15 12:22:27.674761-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023044] Successful upload. Got network response. Code, size: 204, -1
2020-05-15 12:22:27.679982-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS002002] Measurement timer scheduled to fire in approx. (s): -0.1942161321640015
2020-05-15 12:22:27.680071-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023028] Upload task scheduled to be executed in approx. (s): -0.1942161321640015
2020-05-15 12:22:27.688291-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS023024] No data to upload. Upload task will not be scheduled
2020-05-15 12:22:27.688364-0400 Example App[23464:8821408] 6.13.0 - [Firebase/Analytics][I-ACS002003] Measurement timer canceled

这是我所做的一切:

我修改了我的AppDelegate.m

// imports
#import <Firebase.h> // Imported Firebase.h
// more imports

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    if ([FIRApp defaultApp] == nil) {
        [FIRApp configure];
    }
// ... rest of my didFinishLaunchingWithOptions

我将 GoogleService-Info.plist 添加到我的应用程序目标中。然后我关注了 this post 和:

Now it doesn't matter much but still for the people who are getting errors on this issue. Debug mode of firebase analytics does not work sometimes due to issue in GoogleServices-Info.plist file Simply makes these 2 changes.

Set IS_ANALYTICS_ENABLED to YES

Set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATE to NO

完全删除 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED

然后我像 建议的那样从我的 .plist 中删除了 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED。还是不行。

确保没有启用 this post 所说的 OS_ACTIVITY_MODE:disable

Make sure to remove the OS_ACTIVITY_MODE:disable from the Environment Variables in your project scheme if you added it at some point.

设置环境变量

Podfile.lock 相关部分

- Firebase/Analytics (6.13.0):
    - Firebase/Core
  - Firebase/Core (6.13.0):
    - Firebase/CoreOnly
    - FirebaseAnalytics (= 6.1.6)
  - Firebase/CoreOnly (6.13.0):
    - FirebaseCore (= 6.4.0)
  - FirebaseAnalytics (6.1.6):
    - FirebaseCore (~> 6.4)
    - FirebaseInstanceID (~> 4.2)
    - GoogleAppMeasurement (= 6.1.6)
    - GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    - GoogleUtilities/MethodSwizzler (~> 6.0)
    - GoogleUtilities/Network (~> 6.0)
    - "GoogleUtilities/NSData+zlib (~> 6.0)"
    - nanopb (= 0.3.9011)
  - FirebaseCore (6.4.0):
    - FirebaseCoreDiagnostics (~> 1.0)
    - FirebaseCoreDiagnosticsInterop (~> 1.0)
    - GoogleUtilities/Environment (~> 6.2)
    - GoogleUtilities/Logger (~> 6.2)
  - FirebaseCoreDiagnostics (1.2.4):
    - FirebaseCoreDiagnosticsInterop (~> 1.2)
    - GoogleDataTransportCCTSupport (~> 3.0)
    - GoogleUtilities/Environment (~> 6.5)
    - GoogleUtilities/Logger (~> 6.5)
    - nanopb (~> 0.3.901)
  - FirebaseCoreDiagnosticsInterop (1.2.0)
  - FirebaseInstanceID (4.2.7):
    - FirebaseCore (~> 6.0)
    - GoogleUtilities/Environment (~> 6.0)
    - GoogleUtilities/UserDefaults (~> 6.0)

我遇到了同样的问题,通过

解决了
  1. 像使用 -FIRDebugEnabled 一样设置环境变量。

  2. 而不是 运行 在 React Native 中设置应用程序(例如:纱线 运行 ios/android),我直接 运行 在 Xcode. (如果你 运行 通过本机反应,它也不会出现在我的调试视图中)。

  3. 然后设备将神奇地出现在调试视图中。我没有按照您提到的任何其他步骤进行操作。

以下是我的版本以防万一。如果还没有解决,希望对你有一点帮助。


"react-native": "^0.63.2",
"@react-native-firebase/app": "^8.4.7",
"@react-native-firebase/analytics": "^7.6.9",

因此,经过数小时的阅读和测试,我想我会在此处留下此注释,供任何想知道他们的设置是否真正有效的人使用。

正如其他答案所建议的那样:运行 您的应用程序通过 Xcode 使用调试标志而不是通过终端,而且 监控调试输出控制台以获取与 firebase 相关的消息。

我的似乎确实有效,你的也可能有效。我还发现的一件事是,它们 'batch' 事件,并且在您将应用程序置于后台后,事件花费了整整一个小时左右的时间才能到达 firebase 控制台调试视图。