Version: next
This documentation is for an unreleased version of Taquito. Features and APIs may change before the final release. View the latest stable version .
RPC Analytics Headers
Written by Maxwell Ward
When creating a TezosToolkit, you can optionally pass in a clientInfo parameter to send analytics headers with your RPC requests. These headers help RPC providers understand how their infrastructure is being used and can improve their services.
Overview
The clientInfo configuration allows you to send the following optional HTTP headers with each RPC request:
| Header | Description |
|---|---|
X-Tezos-SDK | The Taquito version (e.g., taquito/23.1.0) |
X-Tezos-App-Name | Your application’s name |
X-Tezos-App-Url | Your application’s URL |
This feature is opt-in only. No analytics headers are sent unless you explicitly configure clientInfo.
Basic Usage
The simplest way to enable analytics headers is in the TezosToolkit constructor:
import { TezosToolkit } from '@taquito/taquito';
const Tezos = new TezosToolkit('https://mainnet.tezos.ecadinfra.com', {
clientInfo: {
appName: 'MyDapp',
sendSdkVersion: true,
},
});
Configuration Options
The clientInfo object supports the following properties:
interface ClientInfo {
/** Custom application name to send in X-Tezos-App-Name header */
appName?: string;
/** Application URL to send in X-Tezos-App-Url header.
* In browsers, auto-detected from window.location.origin if not specified */
appUrl?: string;
/** Whether to send the SDK version in X-Tezos-SDK header */
sendSdkVersion?: boolean;
/** Callback for warnings about unsupported headers (e.g., CORS issues) */
onCorsWarning?: (warning: CorsWarning) => void;
}
Full Example
import { TezosToolkit, CorsWarning } from '@taquito/taquito';
const Tezos = new TezosToolkit('https://mainnet.tezos.ecadinfra.com', {
clientInfo: {
appName: 'MyDapp',
appUrl: 'https://mydapp.com',
sendSdkVersion: true,
onCorsWarning: (warning: CorsWarning) => {
console.warn(`Header ${warning.header} not supported by ${warning.url}`);
},
},
});
Browser Auto-Detection
In browser environments, if you don’t specify appUrl, Taquito will automatically detect it from window.location.origin. This means in most browser dapps, you only need to specify appName:
const Tezos = new TezosToolkit('https://mainnet.tezos.ecadinfra.com', {
clientInfo: {
appName: 'MyDapp',
sendSdkVersion: true,
// appUrl is auto-detected in browsers
},
});
CORS Handling
Not all RPC providers support custom headers due to CORS (Cross-Origin Resource Sharing) restrictions. Taquito handles this automatically:
- Automatic verification: On the first request to each RPC origin, Taquito verifies which headers are supported
- Only sends supported headers: Headers that aren’t allowed by the server’s CORS policy are silently omitted
- Warning callbacks: If you provide an
onCorsWarningcallback, you’ll be notified about unsupported headers
const Tezos = new TezosToolkit('https://mainnet.tezos.ecadinfra.com', {
clientInfo: {
appName: 'MyDapp',
sendSdkVersion: true,
onCorsWarning: (warning) => {
// warning.header - the header that isn't supported
// warning.url - the RPC server URL
// warning.message - human-readable explanation
console.warn(warning.message);
},
},
});
Manual CORS Verification
You can also manually verify CORS support before making requests:
const corsSupport = await Tezos.rpc.verifyCorsSupport();
console.log('SDK header supported:', corsSupport.sdkHeader);
console.log('App name header supported:', corsSupport.appNameHeader);
console.log('App URL header supported:', corsSupport.appUrlHeader);
console.log('All allowed headers:', corsSupport.allowedHeaders);
Changing RPC Providers
When you change RPC providers using setRpcProvider, the clientInfo from the constructor is preserved:
const Tezos = new TezosToolkit('https://mainnet.tezos.ecadinfra.com', {
clientInfo: { appName: 'MyDapp', sendSdkVersion: true },
});
// Later, switch to a different RPC - clientInfo is preserved
Tezos.setRpcProvider('https://other-rpc.example.com');
// Or override clientInfo for the new RPC
Tezos.setRpcProvider('https://other-rpc.example.com', {
clientInfo: { appName: 'DifferentName' },
});
Privacy Considerations
The analytics headers you configure will be sent to the RPC provider with every request. Only include information you’re comfortable sharing.
appName: Consider using a generic name if you don’t want to identify your specific applicationappUrl: In browsers, this may be auto-detected. Set it explicitly toundefinedinclientInfoif you want to prevent sending itsendSdkVersion: Reveals that you’re using Taquito and which version