Closed7

Next.js の Anonymous Telemetry について調査

TakepepeTakepepe

Next.js はデフォルトで、アプリケーション情報を自動収集しているとの話を同僚から聞き、どういったものを収集しているのか気になり調べてみることにした。公式サイトでも掲載があった。
https://nextjs.org/telemetry

集取内容は以下と記されている。

  • Command invoked (next build, next dev, or next export)
  • Version of Next.js
  • General machine information (e.g. number of CPUs, macOS/Windows/Linux, whether or not the command was run within CI)
  • What Next.js plugins are present in your project
  • Duration of next build and size of application (total number of pages)

公式ドキュメントで触れらている箇所は以下のみ。
https://nextjs.org/docs/api-reference/cli#telemetry

デフォルトで収集が有効になっており、無効にオプトアウトするためには以下を叩けば良い。

npx next telemetry disable
TakepepeTakepepe

next dev を実行すると、以下 payload が https://telemetry.nextjs.org/api/v1/record に post される

{
  "context": {
    "anonymousId": "261b32c0133a1fbd55164...",
    "projectId": "21b2e8177eb176779295db4...",
    "sessionId": "ccada8abd40247e90b2a630..."
  },
  "meta": {
    "systemPlatform": "darwin",
    "systemRelease": "19.6.0",
    "systemArchitecture": "x64",
    "cpuCount": 12,
    "cpuModel": "Intel(R) Core(TM)",
    "cpuSpeed": 3200,
    "memoryInMb": 65536,
    "isDocker": false,
    "isNowDev": false,
    "isWsl": false,
    "isCI": false,
    "ciName": null,
    "nextVersion": "11.1.2"
  },
  "events": [
    {
      "eventName": "NEXT_CLI_SESSION_STARTED",
      "fields": {
        "nextVersion": "11.1.2",
        "nodeVersion": "v14.16.1",
        "cliCommand": "dev",
        "isSrcDir": true,
        "hasNowJson": false,
        "isCustomServer": false,
        "hasNextConfig": false,
        "buildTarget": "default",
        "hasWebpackConfig": false,
        "hasBabelConfig": true,
        "imageEnabled": false,
        "basePathEnabled": false,
        "i18nEnabled": false,
        "locales": null,
        "localeDomainsCount": null,
        "localeDetectionEnabled": null,
        "imageDomainsCount": null,
        "imageSizes": null,
        "imageLoader": undefined,
        "trailingSlashEnabled": false,
        "reactStrictMode": false,
        "webpackVersion": 5
      }
    }
  ]
}

TakepepeTakepepe

next lintの event

{
  "eventName": "NEXT_LINT_CHECK_COMPLETED",
  "fields": {
    "durationInSeconds": 0,
    "eslintVersion": "7.32.0",
    "lintedFilesCount": 107,
    "lintFix": false,
    "nextEslintPluginVersion": "11.1.2",
    "nextEslintPluginErrorsCount": 0,
    "nextEslintPluginWarningsCount": 0,
    "buildLint": false
  }
}

TakepepeTakepepe

next buildの events 抜粋

{
  "events": [
    {
      "eventName": "NEXT_PACKAGE_DETECTED",
      "fields": {
        "packageName": "react-hook-form",
        "packageVersion": "^7.17.2"
      }
    },
    {
      "eventName": "NEXT_PACKAGE_DETECTED",
      "fields": { "packageName": "react-query", "packageVersion": "^3.26.0" }
    },
    {
      "eventName": "NEXT_PACKAGE_DETECTED",
      "fields": { "packageName": "react-select", "packageVersion": "^5.1.0" }
    }
  ]
}

このスクラップは2021/11/20にクローズされました