|
| 1 | +--- |
| 2 | +title: Client info |
| 3 | +shortTitle: Client info |
| 4 | +intro: >- |
| 5 | + Client info identifies the application using the Copilot SDK and, when |
| 6 | + applicable, a specific integration within it. An integration is an |
| 7 | + identifiable sub-part of the application through which the SDK is used, such |
| 8 | + as an extension or plugin. Set the optional `clientInfo` client option to |
| 9 | + attribute runtime telemetry for that connection to your application instead of |
| 10 | + the runtime's own build. |
| 11 | +versions: |
| 12 | + fpt: '*' |
| 13 | + ghec: '*' |
| 14 | +contentType: how-tos |
| 15 | +--- |
| 16 | + |
| 17 | +<!-- markdownlint-disable GHD046 GHD005 --> |
| 18 | +<!-- Suppressed: GHD046 (outdated release terminology), GHD005 (hardcoded data variable) --> |
| 19 | + |
| 20 | +## When to set client info |
| 21 | + |
| 22 | +Set client info when your SDK application represents a distinct product, service, or integration whose runtime activity should be attributed consistently. |
| 23 | + |
| 24 | +Leave client info unset for scripts, one-off tools, and jobs that do not represent a distinct application. The runtime then keeps its default attribution. |
| 25 | + |
| 26 | +Client info has four optional string fields. Set the fields you know and omit the rest. The SDK includes client info in the `server.connect` handshake only when at least one field has a non-empty value. |
| 27 | + |
| 28 | +| Field | Example | Meaning | |
| 29 | +|---|---|---| |
| 30 | +| `applicationName` | `"vscode"` | Name of the application using the SDK | |
| 31 | +| `applicationVersion` | `"1.124.2"` | Version of the application using the SDK | |
| 32 | +| `integrationName` | `"copilot-chat"` | Name of the extension, plugin, or other application sub-part using the SDK | |
| 33 | +| `integrationVersion` | `"0.54.0"` | Version of that extension, plugin, or application sub-part | |
| 34 | + |
| 35 | +For a standalone application without a distinct integration, set only the application fields. For example, a developer portal could set `applicationName` to `"acme-developer-portal"` and `applicationVersion` to `"2.4.0"`, leaving both integration fields unset. |
| 36 | + |
| 37 | +The SDK sends client info once when it establishes the connection. The identity applies for the lifetime of that connection. |
| 38 | + |
| 39 | +## Configure client info |
| 40 | + |
| 41 | +Pass client info when you create the client: |
| 42 | + |
| 43 | +{% codetabs %} |
| 44 | +{% codetab typescript %} |
| 45 | + |
| 46 | +```typescript |
| 47 | +import { CopilotClient } from "@github/copilot-sdk"; |
| 48 | + |
| 49 | +const client = new CopilotClient({ |
| 50 | + clientInfo: { |
| 51 | + applicationName: "vscode", |
| 52 | + applicationVersion: "1.124.2", |
| 53 | + integrationName: "copilot-chat", |
| 54 | + integrationVersion: "0.54.0", |
| 55 | + }, |
| 56 | +}); |
| 57 | + |
| 58 | +await client.start(); |
| 59 | +``` |
| 60 | + |
| 61 | +{% endcodetab %} |
| 62 | +{% codetab python %} |
| 63 | + |
| 64 | +<!-- docs-validate: wrap-async --> |
| 65 | + |
| 66 | +```python |
| 67 | +from copilot import CopilotClient |
| 68 | + |
| 69 | +client = CopilotClient( |
| 70 | + client_info={ |
| 71 | + "application_name": "vscode", |
| 72 | + "application_version": "1.124.2", |
| 73 | + "integration_name": "copilot-chat", |
| 74 | + "integration_version": "0.54.0", |
| 75 | + }, |
| 76 | +) |
| 77 | +await client.start() |
| 78 | +``` |
| 79 | + |
| 80 | +{% endcodetab %} |
| 81 | +{% codetab go %} |
| 82 | + |
| 83 | +```golang |
| 84 | +client := copilot.NewClient(&copilot.ClientOptions{ |
| 85 | + ClientInfo: &copilot.ClientInfo{ |
| 86 | + ApplicationName: "vscode", |
| 87 | + ApplicationVersion: "1.124.2", |
| 88 | + IntegrationName: "copilot-chat", |
| 89 | + IntegrationVersion: "0.54.0", |
| 90 | + }, |
| 91 | +}) |
| 92 | +if err := client.Start(ctx); err != nil { |
| 93 | + return err |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +{% endcodetab %} |
| 98 | +{% codetab dotnet %} |
| 99 | + |
| 100 | +```csharp |
| 101 | +using GitHub.Copilot; |
| 102 | + |
| 103 | +await using var client = new CopilotClient(new CopilotClientOptions |
| 104 | +{ |
| 105 | + ClientInfo = new CopilotClientInfo |
| 106 | + { |
| 107 | + ApplicationName = "vscode", |
| 108 | + ApplicationVersion = "1.124.2", |
| 109 | + IntegrationName = "copilot-chat", |
| 110 | + IntegrationVersion = "0.54.0", |
| 111 | + }, |
| 112 | +}); |
| 113 | + |
| 114 | +await client.StartAsync(); |
| 115 | +``` |
| 116 | + |
| 117 | +{% endcodetab %} |
| 118 | +{% codetab java %} |
| 119 | + |
| 120 | +```java |
| 121 | +var options = new CopilotClientOptions() |
| 122 | + .setClientInfo(new ClientInfo() |
| 123 | + .setApplicationName("vscode") |
| 124 | + .setApplicationVersion("1.124.2") |
| 125 | + .setIntegrationName("copilot-chat") |
| 126 | + .setIntegrationVersion("0.54.0")); |
| 127 | + |
| 128 | +var client = new CopilotClient(options); |
| 129 | +client.start().get(); |
| 130 | +``` |
| 131 | + |
| 132 | +{% endcodetab %} |
| 133 | +{% codetab rust %} |
| 134 | + |
| 135 | +```rust |
| 136 | +use github_copilot_sdk::{Client, ClientInfo, ClientOptions}; |
| 137 | + |
| 138 | +let client = Client::start( |
| 139 | + ClientOptions::new().with_client_info( |
| 140 | + ClientInfo::new() |
| 141 | + .with_application_name("vscode") |
| 142 | + .with_application_version("1.124.2") |
| 143 | + .with_integration_name("copilot-chat") |
| 144 | + .with_integration_version("0.54.0"), |
| 145 | + ), |
| 146 | +) |
| 147 | +.await?; |
| 148 | +``` |
| 149 | + |
| 150 | +{% endcodetab %} |
| 151 | +{% endcodetabs %} |
| 152 | + |
| 153 | +## Notes |
| 154 | + |
| 155 | +* Client info is advisory. The runtime can ignore values that do not match the expected format, such as an invalid version string. |
| 156 | +* Setting client info changes how the runtime attributes its telemetry. It does not change what the runtime records. |
| 157 | +* If every field is unset or empty, the SDK omits client info from the handshake and the runtime keeps its default attribution. |
0 commit comments