修改了 URL 的 Firebase 崩溃日志

Firebase Crash Logs with URLs redacted

我们目前在我们的应用程序中使用 Firebase 崩溃报告 - 我们注意到了一些奇怪的事情。为了帮助我们调试任何崩溃,我们使用 FirebaseCrash.log 添加有关服务器的信息 requests/responses 正在制作到我们的服务器。

但最近,我们注意到日志正在被编辑。据我们所知,这是在服务器端发生的,给我们留下的日志如下所示:

7:51:11.914 AM gmp_nav20_crash <-- 201 https://[REDACTED_DOMAIN_NAME][REDACTED_URL_BASIC] (287ms, unknown-length body)

7:51:11.626 AM gmp_nav20_crash --> POST https://[REDACTED_DOMAIN_NAME][REDACTED_URL_BASIC] http/1.1 (67-byte body)

有什么方法可以至少对某些域禁用此功能吗?它使得准确地追踪出错的地方比应该的更困难,并且没有为我所看到的用户提供任何有意义的保护。

将URL字符串转换为base64字符串并发送编码后的字符串

        public static String toBase64(String stringToEncode){
        String base64 = null;
        try {
            byte[] data = stringToEncode.getBytes("UTF-8");
            base64 = Base64.encodeToString(data, Base64.DEFAULT);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return base64;
    }

FirebaseCrash.report(new Exception("Error while downloading image with URL (Base 64 encoded):" + StringUtils.toBase64(s)));

由于上面的评论表明这是不可配置的,并且您希望从 Firebase 控制台读取结果,我建议以一种混淆 URL 的方式处理 URL 而让它成为人类可读的。请确保您只对 non-sensitive 信息执行此操作 - 尤其是当您身处欧洲并遵守新的 GDPR 法规时。

它可以像这样简单:

url.replaceAll("\.", "[dot]");

但我建议也屏蔽协议(可能还有斜杠)

url.replaceAll("https://", "[secure]")
   .replaceAll("http://", "")
   .replaceAll("\.", "[dot]");

编辑(回答悬赏问题:"Is it legal to track Base64 encoded URLs and domain names according to Firebase policies?")

根据 Firebase Policies 页面

You will not facilitate the merging of personally-identifiable information with non-personally identifiable information unless you have robust notice of, and the user's prior affirmative (i.e., opt-in) consent to, that merger.

假设您没有征求同意,我认为这意味着您还应该从 URL.

中删除任何查询或可识别信息

同样,这可以像在第一个或最后一个斜杠(如果存在)处拆分字符串一样简单,具体取决于 url 的哪些部分对您很重要