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.

chore: Update Dub SDK usage in quickstart guides

Kiran K5ab5774ec2ca
diff --git a/apps/docs/quickstart/django.mdx b/apps/docs/quickstart/django.mdx
index 37a699607c..ddd38704f2 100644
--- a/apps/docs/quickstart/django.mdx
+++ b/apps/docs/quickstart/django.mdx
@@ -119,9 +119,9 @@ Dub allows you to retrieve analytics for a link using the Dub Python SDK.
# Retrieve the timeseries analytics for the last 7 days for a link
def analytics(request):
res = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- link_id="clx1gvi9o0005hf5momm6f7hj",
- interval="7d",
- group_by="timeseries",
+ link_id='clx1gvi9o0005hf5momm6f7hj',
+ interval='7d',
+ group_by='timeseries',
))
return JsonResponse(res)
@@ -133,9 +133,9 @@ Simliarly, you can retrieve analytics for a link using the `externalId` field.
# Retrieve the timeseries analytics for the last 7 days for a link
def analytics(request):
res = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- external_id="ext_12345",
- interval="7d",
- group_by="timeseries",
+ external_id='ext_12345',
+ interval='7d',
+ group_by='timeseries',
))
return JsonResponse(res)
diff --git a/apps/docs/quickstart/express.mdx b/apps/docs/quickstart/express.mdx
index 9e88f40563..f5a0fdbb4f 100644
--- a/apps/docs/quickstart/express.mdx
+++ b/apps/docs/quickstart/express.mdx
@@ -16,9 +16,6 @@ import LinkArguments from "/snippets/link-arguments.mdx";
Let's create a short link using the Dub Node.js SDK.
```typescript index.ts
-import express, { Request, Response } from "express";
-import { dub } from "./dub";
-
app.get("/create-link", async (req: Request, res: Response) => {
try {
const result = await dub.links.create({
@@ -41,9 +38,6 @@ app.get("/create-link", async (req: Request, res: Response) => {
Optionally, you can also pass an `externalId` field which is a unique identifier for the link in your own database to associate it with the link in Dub's system.
```typescript index.ts
-import express, { Request, Response } from "express";
-import { dub } from "./dub";
-
app.get("/create-link", async (req: Request, res: Response) => {
try {
const result = await dub.links.create({
diff --git a/apps/docs/quickstart/flask.mdx b/apps/docs/quickstart/flask.mdx
index d965f6e9bc..82bc9110b5 100644
--- a/apps/docs/quickstart/flask.mdx
+++ b/apps/docs/quickstart/flask.mdx
@@ -104,7 +104,6 @@ You can do that in two ways:
- Using the link's `externalId` in your own database (prefixed with `ext_`).
```python app.py
-# Update a link by its linkId
@app.route('/update-link')
def update():
res = None
@@ -132,9 +131,9 @@ def analytics():
try:
# Retrieve the timeseries analytics for the last 7 days for a link
res = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- link_id="clx1gvi9o0005hf5momm6f7hj",
- interval="7d",
- group_by="timeseries",
+ link_id='clx1gvi9o0005hf5momm6f7hj',
+ interval='7d',
+ group_by='timeseries',
))
except Exception as e:
return str(e)
@@ -148,9 +147,9 @@ Simliarly, you can retrieve analytics for a link using the `externalId` field.
```python app.py
# Retrieve the timeseries analytics for the last 7 days for a link
result = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- external_id: 'ext_12345',
- interval="7d",
- group_by="timeseries",
+ external_id='ext_12345',
+ interval='7d',
+ group_by='timeseries',
))
```
diff --git a/apps/docs/quickstart/nuxt.mdx b/apps/docs/quickstart/nuxt.mdx
index 183e946282..a71a197609 100644
--- a/apps/docs/quickstart/nuxt.mdx
+++ b/apps/docs/quickstart/nuxt.mdx
@@ -15,8 +15,6 @@ import InstallNode from "/snippets/sdk-install-nodejs.mdx";
Let's create a short link using the Dub Node.js SDK.
```typescript server/api/links.post.ts
-import { dub } from "../utils/dub";
-
export default defineEventHandler(async () => {
try {
const result = await dub.links.create({
@@ -36,8 +34,6 @@ export default defineEventHandler(async () => {
Optionally, you can also pass an `externalId` field which is a unique identifier for the link in your own database to associate it with the link in Dub's system.
```typescript server/api/links.post.ts
-import { dub } from "../utils/dub";
-
export default defineEventHandler(async () => {
try {
const result = await dub.links.create({
@@ -58,8 +54,6 @@ export default defineEventHandler(async () => {
Dub Node.js SDK provides a method to create or update a link so you don't have to worry about checking if the link already exists.
```typescript server/api/links.put.ts
-import { dub } from "../utils/dub";
-
export default defineEventHandler(async () => {
try {
const result = await dub.links.upsert({
@@ -84,8 +78,6 @@ You can do that in two ways:
- Using the link's `externalId` in your own database (prefixed with `ext_`).
```typescript server/api/links.patch.ts
-import { dub } from "../utils/dub";
-
export default defineEventHandler(async () => {
try {
// Update a link by its linkId
@@ -111,7 +103,6 @@ export default defineEventHandler(async () => {
Dub allows you to retrieve analytics for a link using the Dub Node.js SDK.
```typescript server/api/analytics.get.ts
-import { dub } from "../utils/dub";
import { ClicksTimeseries } from "dub/models/components";
export default defineEventHandler(async () => {
diff --git a/apps/docs/quickstart/python.mdx b/apps/docs/quickstart/python.mdx
index a09f71d111..0bf114c1b5 100644
--- a/apps/docs/quickstart/python.mdx
+++ b/apps/docs/quickstart/python.mdx
@@ -100,9 +100,9 @@ Dub allows you to retrieve analytics for a link using the Dub Python SDK.
```python index.py
# Retrieve the timeseries analytics for the last 7 days for a link
result = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- link_id="clx1gvi9o0005hf5momm6f7hj",
- interval="7d",
- group_by="timeseries",
+ link_id='clx1gvi9o0005hf5momm6f7hj',
+ interval='7d',
+ group_by='timeseries',
))
print(result)
@@ -113,9 +113,9 @@ Simliarly, you can retrieve analytics for a link using the `externalId` field.
```python index.py
# Retrieve the timeseries analytics for the last 7 days for a link
result = d.analytics.retrieve(request=operations.RetrieveAnalyticsRequest(
- external_id: 'ext_12345',
- interval="7d",
- group_by="timeseries",
+ external_id='ext_12345',
+ interval='7d',
+ group_by='timeseries',
))
```
diff --git a/apps/docs/quickstart/remix.mdx b/apps/docs/quickstart/remix.mdx
index a3f6058521..7220c95fca 100644
--- a/apps/docs/quickstart/remix.mdx
+++ b/apps/docs/quickstart/remix.mdx
@@ -16,9 +16,6 @@ import LinkArguments from "/snippets/link-arguments.mdx";
Let's create a short link using the Dub Node.js SDK.
```typescript app/routes/create-link.ts
-import { json } from "@remix-run/node";
-import { dub } from "~/dub";
-
export const loader = async () => {
try {
const result = await dub.links.create({
@@ -42,9 +39,6 @@ export const loader = async () => {
Optionally, you can also pass an `externalId` field which is a unique identifier for the link in your own database to associate it with the link in Dub's system.
```typescript app/routes/create-link.ts
-import { json } from "@remix-run/node";
-import { dub } from "~/dub";
-
export const loader = async () => {
try {
const result = await dub.links.create({
@@ -67,9 +61,6 @@ This will let you easily [update the link](#5-update-link) later on using the `e
Dub Node.js SDK provides a method to create or update a link so you don't have to worry about checking if the link already exists.
```typescript app/routes/upsert-link.ts
-import { json } from "@remix-run/node";
-import { dub } from "~/dub";
-
export const loader = async () => {
try {
const result = await dub.links.upsert({
@@ -94,9 +85,6 @@ You can do that in two ways:
- Using the link's `externalId` in your own database (prefixed with `ext_`).
```typescript app/routes/update-link.ts
-import { json } from "@remix-run/node";
-import { dub } from "~/dub";
-
export const loader = async () => {
try {
// Update a link by its linkId
@@ -122,9 +110,6 @@ export const loader = async () => {
Dub allows you to retrieve analytics for a link using the Dub Node.js SDK.
```typescript app/routes/analytics.ts
-import { json } from "@remix-run/node";
-import { dub } from "~/dub";
-
export const loader = async () => {
try {
// Retrieve the timeseries analytics for the last 7 days for a link