小编Mil*_*lia的帖子

Flutter - New Relic 不跟踪来自 Flutter 的 API 请求

我想要的是:

我想在 Flutter 应用程序中集成New Relic以跟踪从我的应用程序执行的 GraphQL API 请求(对于 GraphQL 请求,我使用了graphql_flutter包)

我做了什么:

我在 Android 和 iOS 中添加了用于 New Relic 集成的本机代码

我为 New Relic 添加了一个自定义插件(从此处找到该插件)

根据 New Relic Android SDK,我在MainActivity.kt文件中添加了以下代码

NewRelic.withApplicationToken("-------APIKEY------")
  .withAnalyticsEvents(true).withDistributedTraceListener(traceListener)
  .withCrashReportingEnabled(true).withInteractionTracing(true)
  .withDefaultInteractions(true).withHttpResponseBodyCaptureEnabled(true)
  .start(this.applicationContext)
         

        NewRelic.enableFeature(FeatureFlag.NetworkRequests)
        NewRelic.enableFeature(FeatureFlag.NetworkErrorRequests)
        NewRelic.enableFeature(FeatureFlag.DefaultInteractions)
        NewRelic.enableFeature(FeatureFlag.InteractionTracing)
        NewRelic.enableFeature(FeatureFlag.DistributedTracing)
        NewRelic.enableFeature(FeatureFlag.HttpResponseBodyCapture)
Run Code Online (Sandbox Code Playgroud)

根据 New Relic iOS SDK,我遵循此处列出的步骤

我面临的问题:

  1. 从 Flutter 代码执行的 API 请求未记录在 New Relic 仪表板中
  2. 只有从使用 MethodChannel 进行 API 请求的 Flutter 包执行的 API 请求才会记录在 New Relic 仪表板中

android newrelic flutter

6
推荐指数
0
解决办法
367
查看次数

Flutter GraphQL - OperationException(linkException: ResponseFormatException(originalException: FormatException: 意外字符(在字符 1 处)

我在使用 graphql_flutter 包的 mutate 方法时收到此错误。

尝试使用以下版本的qraphql_flutter包:

错误:

I/flutter (13946): //// EXCEPTION: OperationException(linkException: ResponseFormatException(originalException: FormatException: Unexpected character (at character 1)
I/flutter (13946): <!DOCTYPE html>
I/flutter (13946): ^
<html>
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="refresh" content="0;url='https://xxx.xxx.dev/login'" />

        <title>Redirecting to https://xxx.xxx.dev/login</title>
    </head>
    <body>
        Redirecting to <a href="https://xxx.xxx.dev/login">https://xxx.xxx.dev/login</a>.
    </body>
</html>
I/flutter (13946): ), graphqlErrors: [])
Run Code Online (Sandbox Code Playgroud)

我尝试使用相同的代码运行查询。此代码与查询完美配合,仅在使用突变时引发异常。我创建了一个 graphql 帮助器类,它可以帮助使用此帮助器类执行项目中的每个 graphql 操作。

GraphQL 助手类:

import 'package:flutter/foundation.dart';
import 'package:graphql_demo/app_exception.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

class AppGraphQlClient {
  late GraphQLClient _client;

  AppGraphQlClient(String graphqlUrl) {
    final httpLink …
Run Code Online (Sandbox Code Playgroud)

graphql flutter flutter-graphql graphql-flutter

5
推荐指数
1
解决办法
2340
查看次数