クライアント情報を設定するタイミング
SDK アプリケーションが、ランタイム アクティビティを一貫して属性付けする必要がある個別の製品、サービス、または統合を表す場合に、クライアント情報を設定します。
個別のアプリケーションを表さないスクリプト、1 回限りのツール、ジョブについては、クライアント情報の設定を解除したままにします。 その後、ランタイムは既定の属性を保持します。
クライアント情報には、4 つの省略可能な文字列フィールドがあります。 知っているフィールドを設定し、残りのフィールドを省略します。 SDK には、少なくとも 1 つのフィールドに空以外の値がある場合にのみ、 server.connect ハンドシェイクにクライアント情報が含まれます。
| フィールド | Example | Meaning |
|---|---|---|
applicationName | "vscode" | SDK を使用したアプリケーションの名前 |
application | "1.124.2" | SDK を使用したアプリケーションのバージョン |
integrationName | "copilot-chat" | SDK を使用した拡張機能、プラグイン、またはその他のアプリケーション サブパーツの名前 |
integration | "0.54.0" | その拡張機能、プラグイン、またはアプリケーション サブパートのバージョン |
個別の統合がないスタンドアロン アプリケーションの場合は、アプリケーション フィールドのみを設定します。 たとえば、開発者ポータルでは、 applicationName を "acme-developer-portal" に設定し、 applicationVersion を "2.4.0" に設定し、両方の統合フィールドを未設定のままにすることができます。
SDK は、接続の確立時にクライアント情報を 1 回送信します。 ID は、その接続の有効期間に適用されます。
クライアント情報を構成する
クライアントを作成するときにクライアント情報を渡します。
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient({
clientInfo: {
applicationName: "vscode",
applicationVersion: "1.124.2",
integrationName: "copilot-chat",
integrationVersion: "0.54.0",
},
});
await client.start();
from copilot import CopilotClient
client = CopilotClient(
client_info={
"application_name": "vscode",
"application_version": "1.124.2",
"integration_name": "copilot-chat",
"integration_version": "0.54.0",
},
)
await client.start()
client := copilot.NewClient(&copilot.ClientOptions{
ClientInfo: &copilot.ClientInfo{
ApplicationName: "vscode",
ApplicationVersion: "1.124.2",
IntegrationName: "copilot-chat",
IntegrationVersion: "0.54.0",
},
})
if err := client.Start(ctx); err != nil {
return err
}
using GitHub.Copilot;
await using var client = new CopilotClient(new CopilotClientOptions
{
ClientInfo = new CopilotClientInfo
{
ApplicationName = "vscode",
ApplicationVersion = "1.124.2",
IntegrationName = "copilot-chat",
IntegrationVersion = "0.54.0",
},
});
await client.StartAsync();
var options = new CopilotClientOptions()
.setClientInfo(new ClientInfo()
.setApplicationName("vscode")
.setApplicationVersion("1.124.2")
.setIntegrationName("copilot-chat")
.setIntegrationVersion("0.54.0"));
var client = new CopilotClient(options);
client.start().get();
use github_copilot_sdk::{Client, ClientInfo, ClientOptions};
let client = Client::start(
ClientOptions::new().with_client_info(
ClientInfo::new()
.with_application_name("vscode")
.with_application_version("1.124.2")
.with_integration_name("copilot-chat")
.with_integration_version("0.54.0"),
),
)
.await?;
メモ
- クライアント情報は参考情報です。 ランタイムは、無効なバージョン文字列など、予想される形式と一致しない値を無視できます。
- クライアント情報を設定すると、ランタイムがテレメトリを属性付けする方法が変わります。 ランタイム レコードの内容は変更されません。
- すべてのフィールドが設定されていないか空の場合、SDK はハンドシェイクからクライアント情報を省略し、ランタイムは既定の属性を保持します。