Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add /track/* endpoints to openapi spec

Kiran Kb54fa1e5fe90
diff --git a/apps/web/lib/openapi/index.ts b/apps/web/lib/openapi/index.ts
index ad584bf4e5..b8f1be2381 100644
--- a/apps/web/lib/openapi/index.ts
+++ b/apps/web/lib/openapi/index.ts
@@ -13,6 +13,7 @@ import { linksPaths } from "./links";
import { metatagsPath } from "./metatags";
import { qrCodePaths } from "./qr";
import { tagsPaths } from "./tags";
+import { trackPaths } from "./track";
import { workspacesPaths } from "./workspaces";
export const document = createDocument({
@@ -45,6 +46,7 @@ export const document = createDocument({
...workspacesPaths,
...tagsPaths,
...domainsPaths,
+ ...trackPaths,
...metatagsPath,
},
components: {
diff --git a/apps/web/lib/openapi/track/customer.ts b/apps/web/lib/openapi/track/customer.ts
new file mode 100644
index 0000000000..849d73235e
--- /dev/null
+++ b/apps/web/lib/openapi/track/customer.ts
@@ -0,0 +1,33 @@
+import { openApiErrorResponses } from "@/lib/openapi/responses";
+import z from "@/lib/zod";
+import { trackCustomerRequestSchema } from "@/lib/zod/schemas";
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+export const trackCustomer: ZodOpenApiOperationObject = {
+ operationId: "trackCustomer",
+ "x-speakeasy-name-override": "customer",
+ summary: "Track a customer.",
+ description: "Track a customer for an authenticated workspace.",
+ requestBody: {
+ content: {
+ "application/json": {
+ schema: trackCustomerRequestSchema,
+ },
+ },
+ },
+ responses: {
+ "200": {
+ description: "A customer was tracked.",
+ content: {
+ "application/json": {
+ schema: z.object({
+ success: z.literal(true),
+ }),
+ },
+ },
+ },
+ ...openApiErrorResponses,
+ },
+ tags: ["Track"],
+ security: [{ token: [] }],
+};
diff --git a/apps/web/lib/openapi/track/index.ts b/apps/web/lib/openapi/track/index.ts
new file mode 100644
index 0000000000..b344a46000
--- /dev/null
+++ b/apps/web/lib/openapi/track/index.ts
@@ -0,0 +1,16 @@
+import { ZodOpenApiPathsObject } from "zod-openapi";
+import { trackCustomer } from "./customer";
+import { trackLead } from "./lead";
+import { trackSale } from "./sale";
+
+export const trackPaths: ZodOpenApiPathsObject = {
+ "/track/lead": {
+ post: trackLead,
+ },
+ "/track/sale": {
+ post: trackSale,
+ },
+ "/track/customer": {
+ post: trackCustomer,
+ },
+};
diff --git a/apps/web/lib/openapi/track/lead.ts b/apps/web/lib/openapi/track/lead.ts
new file mode 100644
index 0000000000..ca4ee97c1c
--- /dev/null
+++ b/apps/web/lib/openapi/track/lead.ts
@@ -0,0 +1,33 @@
+import { openApiErrorResponses } from "@/lib/openapi/responses";
+import z from "@/lib/zod";
+import { trackLeadRequestSchema } from "@/lib/zod/schemas";
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+export const trackLead: ZodOpenApiOperationObject = {
+ operationId: "trackLead",
+ "x-speakeasy-name-override": "lead",
+ summary: "Track a lead.",
+ description: "Track a lead for a short link.",
+ requestBody: {
+ content: {
+ "application/json": {
+ schema: trackLeadRequestSchema,
+ },
+ },
+ },
+ responses: {
+ "200": {
+ description: "A lead was tracked.",
+ content: {
+ "application/json": {
+ schema: z.object({
+ success: z.literal(true),
+ }),
+ },
+ },
+ },
+ ...openApiErrorResponses,
+ },
+ tags: ["Track"],
+ security: [{ token: [] }],
+};
diff --git a/apps/web/lib/openapi/track/sale.ts b/apps/web/lib/openapi/track/sale.ts
new file mode 100644
index 0000000000..ff78c5716a
--- /dev/null
+++ b/apps/web/lib/openapi/track/sale.ts
@@ -0,0 +1,33 @@
+import { openApiErrorResponses } from "@/lib/openapi/responses";
+import z from "@/lib/zod";
+import { trackSaleRequestSchema } from "@/lib/zod/schemas";
+import { ZodOpenApiOperationObject } from "zod-openapi";
+
+export const trackSale: ZodOpenApiOperationObject = {
+ operationId: "trackSale",
+ "x-speakeasy-name-override": "sale",
+ summary: "Track a sale.",
+ description: "Track a sale for a short link.",
+ requestBody: {
+ content: {
+ "application/json": {
+ schema: trackSaleRequestSchema,
+ },
+ },
+ },
+ responses: {
+ "200": {
+ description: "A sale was tracked.",
+ content: {
+ "application/json": {
+ schema: z.object({
+ success: z.literal(true),
+ }),
+ },
+ },
+ },
+ ...openApiErrorResponses,
+ },
+ tags: ["Track"],
+ security: [{ token: [] }],
+};