# Track (*track*) ## Overview ### Available Operations * [lead](#lead) - Track a lead * [sale](#sale) - Track a sale * [customer](#customer) - Track a customer ## lead Track a lead for a short link. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.track.lead(); // Handle the result console.log(result) } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { trackLead } from "dub/funcs/trackLead.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await trackLead(dub); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.TrackLeadRequestBody](../../models/operations/trackleadrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.TrackLeadResponseBody](../../models/operations/trackleadresponsebody.md)\>** ### Errors | Error Object | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4xx-5xx | */* | ## sale Track a sale for a short link. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.track.sale(); // Handle the result console.log(result) } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { trackSale } from "dub/funcs/trackSale.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await trackSale(dub); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.TrackSaleRequestBody](../../models/operations/tracksalerequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.TrackSaleResponseBody](../../models/operations/tracksaleresponsebody.md)\>** ### Errors | Error Object | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4xx-5xx | */* | ## customer Track a customer for an authenticated workspace. ### Example Usage ```typescript import { Dub } from "dub"; const dub = new Dub({ token: "DUB_API_KEY", }); async function run() { const result = await dub.track.customer(); // Handle the result console.log(result) } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { DubCore } from "dub/core.js"; import { trackCustomer } from "dub/funcs/trackCustomer.js"; // Use `DubCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const dub = new DubCore({ token: "DUB_API_KEY", }); async function run() { const res = await trackCustomer(dub); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result) } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.TrackCustomerRequestBody](../../models/operations/trackcustomerrequestbody.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | 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](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[operations.TrackCustomerResponseBody](../../models/operations/trackcustomerresponsebody.md)\>** ### Errors | Error Object | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | | errors.BadRequest | 400 | application/json | | errors.Unauthorized | 401 | application/json | | errors.Forbidden | 403 | application/json | | errors.NotFound | 404 | application/json | | errors.Conflict | 409 | application/json | | errors.InviteExpired | 410 | application/json | | errors.UnprocessableEntity | 422 | application/json | | errors.RateLimitExceeded | 429 | application/json | | errors.InternalServerError | 500 | application/json | | errors.SDKError | 4xx-5xx | */* |