Analytics.Keys
Overview
Create and revoke project keys for sending events.
Available Operations
- create - Create a capture key and return its secret once
- list - List capture key metadata
- revoke - Revoke a capture key
create
Create a key that can send events to this project. Save the key from this response; its secret is only returned once. Capture keys cannot read analytics or manage projects.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.analytics.keys.create({
id: "<id>",
analyticsKeyCreate: {
name: "<value>",
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { analyticsKeysCreate } from "@meetkai/mka1/funcs/analyticsKeysCreate.js";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await analyticsKeysCreate(sdk, {
id: "<id>",
analyticsKeyCreate: {
name: "<value>",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("analyticsKeysCreate failed:", res.error);
}
}
run();React hooks and utilities
This method can be used in React components through the following hooks and associated utilities.
Check out this guide for information about each of the utilities below and how to get started using React hooks.
import {
// Mutation hook for triggering the API call.
useAnalyticsKeysCreateMutation
} from "@meetkai/mka1/react-query/analyticsKeysCreate.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.AnalyticsKeysCreateRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<components.AnalyticsCreatedCaptureKey>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.AnalyticsError | 400, 401, 403, 404, 409, 413, 415, 429 | application/json |
| errors.AnalyticsError | 500, 503 | application/json |
| errors.APIError | 4XX, 5XX | */* |
list
List capture key metadata
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.analytics.keys.list({
id: "<id>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { analyticsKeysList } from "@meetkai/mka1/funcs/analyticsKeysList.js";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await analyticsKeysList(sdk, {
id: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("analyticsKeysList failed:", res.error);
}
}
run();React hooks and utilities
This method can be used in React components through the following hooks and associated utilities.
Check out this guide for information about each of the utilities below and how to get started using React hooks.
import {
// Query hooks for fetching data.
useAnalyticsKeysList,
useAnalyticsKeysListSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchAnalyticsKeysList,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateAnalyticsKeysList,
invalidateAllAnalyticsKeysList,
} from "@meetkai/mka1/react-query/analyticsKeysList.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.AnalyticsKeysListRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<components.AnalyticsKeyList>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.AnalyticsError | 400, 401, 403, 404, 409, 413, 415, 429 | application/json |
| errors.AnalyticsError | 500, 503 | application/json |
| errors.APIError | 4XX, 5XX | */* |
revoke
Revoke a capture key
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.analytics.keys.revoke({
id: "<id>",
keyId: "<id>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { analyticsKeysRevoke } from "@meetkai/mka1/funcs/analyticsKeysRevoke.js";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await analyticsKeysRevoke(sdk, {
id: "<id>",
keyId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("analyticsKeysRevoke failed:", res.error);
}
}
run();React hooks and utilities
This method can be used in React components through the following hooks and associated utilities.
Check out this guide for information about each of the utilities below and how to get started using React hooks.
import {
// Mutation hook for triggering the API call.
useAnalyticsKeysRevokeMutation
} from "@meetkai/mka1/react-query/analyticsKeysRevoke.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.AnalyticsKeysRevokeRequest | ✔️ | The request object to use for the request. |
options | RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions | RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries | RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Response
Promise<components.AnalyticsCaptureKey>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.AnalyticsError | 400, 401, 403, 404, 409, 413, 415, 429 | application/json |
| errors.AnalyticsError | 500, 503 | application/json |
| errors.APIError | 4XX, 5XX | */* |