การติดตามเครือข่าย

Network tracing allows you to see network activities relating to the Google Mobile Ads SDK. This can be useful in debugging your Google Mobile Ads implementation.

A key reason to use network tracing instead of tools such as Charles Proxy is that it will work on all iOS versions and devices without trusting any third party security certificate profiles. This is not the case with proxying tools due certificate profile requirements in place since iOS 10.3.

This guide explains how to enable network tracing for debugging purposes.

Enable tracing

To enable network tracing, set the GADEnableNetworkTracing key to YES in your plist file.

When network tracing is enabled, the Google Mobile Ads SDK logs network events to the console. You can then provide copies of the logs to our engineers for analysis as a private reply on the developer forum.

Logging

Standard platform-appropriate console logs are used to output the network logs.

Console log messages always begin with the string GMA Debug BEGIN, GMA Debug CONTENT, or GMA Debug FINISH so that it can be searched for or filtered out. For each network log, the first log message is GMA Debug BEGIN, the last log message is GMA Debug FINISH, and the network log content begins with GMA Debug CONTENT. If a network log content is too long to fit on a line, it is split among multiple lines, each line beginning with GMA Debug CONTENT.

Sample output

<Your App Name>[2710:30568] <Google> GMA Debug BEGIN
2017-12-06 09:47:09.268020-0800 <Your App Name>[2710:30568] <Google> GMA Debug CONTENT: {
  "components" : [
    "network_request_31107D12-E54E-45D6-AEA9-4A303C659EDF"
  ],
  "timestamp" : 1512582429267.2629,
  "event" : "onNetworkRequest",
  "params" : {
    "firstline" : {
      "uri" : "<encoded text>",
      "verb" : "<encoded text>"
    },
    "headers" : [
      {
        "name" : "<encoded text>",
        "value" : "<encoded text>"
      }
    ]
  }
}
2017-12-06 09:47:09.275742-0800 <Your App Name>[2710:30568] <Google> GMA Debug FINISH

You can then provide copies of the logs to our engineers for analysis.