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.

Self-hosting Improvements

Steven Tey04e75a5da540
diff --git a/.gitignore b/.gitignore
index 46b1d3a090..b5cee4ed5f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,7 +26,7 @@ dist/
.vercel
# tinybird
-venv
+.venv
.tinyb
# turbo
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 77a053af75..3dc3351d96 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -2,6 +2,9 @@
###### REQUIRED ENV VARS ######
###############################
+NEXT_PUBLIC_APP_DOMAIN=dub.co
+NEXT_PUBLIC_APP_SHORT_DOMAIN=dub.sh
+
# Tinybird – required for analytics
# Get your Tinybird Auth Token here: https://www.tinybird.co/docs/concepts/auth-tokens.html
TINYBIRD_API_KEY=
@@ -79,3 +82,16 @@ NEXT_PUBLIC_BITLY_REDIRECT_URI=http://localhost:8888/api/callback/bitly
# You can remove this by removing `DUB_SLACK_HOOK_CRON` and `DUB_SLACK_HOOK_LINKS` from the codebase
DUB_SLACK_HOOK_CRON=
DUB_SLACK_HOOK_LINKS=
+
+######################################
+###### DUB.CO INTERNAL USE ONLY ######
+######################################
+
+# For the official Dub.co app
+NEXT_PUBLIC_IS_DUB=true
+
+# For cron jobs
+CRON_SECRET=
+
+# For marketing emails
+RESEND_AUDIENCE_ID=
\ No newline at end of file
diff --git a/apps/web/app/robots.ts b/apps/web/app/robots.ts
index a32e5ac2e9..4a91797b51 100644
--- a/apps/web/app/robots.ts
+++ b/apps/web/app/robots.ts
@@ -3,7 +3,7 @@ import { headers } from "next/headers";
export default function robots(): MetadataRoute.Robots {
const headersList = headers();
- let domain = headersList.get("host") as string;
+ const domain = headersList.get("host") as string;
return {
rules: {
@@ -11,6 +11,6 @@ export default function robots(): MetadataRoute.Robots {
disallow: "/api/",
allow: "/api/og/",
},
- sitemap: `https://dub.co/sitemap.xml`,
+ sitemap: `https://${domain}/sitemap.xml`,
};
}
diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts
index 92f83c87d4..0b1c1f77ce 100644
--- a/apps/web/middleware.ts
+++ b/apps/web/middleware.ts
@@ -47,6 +47,7 @@ export default async function middleware(req: NextRequest, ev: NextFetchEvent) {
return NextResponse.rewrite(new URL(`/${domain}${path}`, req.url));
}
+ // default redirects for dub.sh
if (domain === "dub.sh" && DEFAULT_REDIRECTS[key]) {
return NextResponse.redirect(DEFAULT_REDIRECTS[key]);
}
diff --git a/apps/web/ui/modals/add-edit-domain-modal.tsx b/apps/web/ui/modals/add-edit-domain-modal.tsx
index 5a0c95c390..eea9cdc89a 100644
--- a/apps/web/ui/modals/add-edit-domain-modal.tsx
+++ b/apps/web/ui/modals/add-edit-domain-modal.tsx
@@ -226,7 +226,7 @@ function AddEditDomainModal({
? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
: "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
} block w-full rounded-md focus:outline-none sm:text-sm`}
- placeholder="dub.sh"
+ placeholder={process.env.NEXT_PUBLIC_APP_SHORT_DOMAIN}
value={domain}
onChange={(e) => {
setDomainError(null);
diff --git a/apps/web/ui/modals/add-project-modal.tsx b/apps/web/ui/modals/add-project-modal.tsx
index 77920a4626..513a8f8b1c 100644
--- a/apps/web/ui/modals/add-project-modal.tsx
+++ b/apps/web/ui/modals/add-project-modal.tsx
@@ -177,7 +177,7 @@ function AddProjectModalHelper({
</label>
<div className="relative mt-1 flex rounded-md shadow-sm">
<span className="inline-flex items-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 px-5 text-gray-500 sm:text-sm">
- app.dub.co
+ app.{process.env.NEXT_PUBLIC_APP_DOMAIN}
</span>
<input
name="slug"
@@ -235,7 +235,7 @@ function AddProjectModalHelper({
? "border-red-300 pr-10 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
: "border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:ring-gray-500"
} block w-full rounded-md focus:outline-none sm:text-sm`}
- placeholder="dub.sh"
+ placeholder={process.env.NEXT_PUBLIC_APP_SHORT_DOMAIN}
value={domain}
onChange={(e) => {
setDomainError(null);
diff --git a/packages/tinybird/README.md b/packages/tinybird/README.md
new file mode 100644
index 0000000000..65ff79f219
--- /dev/null
+++ b/packages/tinybird/README.md
@@ -0,0 +1,16 @@
+# Dub.co Tinybird Setup
+
+```bash
+├── datasources
+│ └── click_events.datasource
+├── endpoints
+│ ├── browser.pipe
+│ ├── city.pipe
+│ ├── clicks.pipe
+│ ├── country.pipe
+│ ├── device.pipe
+│ ├── os.pipe
+│ └── referer.pipe
+│ └── timeseries.pipe
+│ └── top_links.pipe
+```
diff --git a/packages/tinybird/datasources/click_events.datasource b/packages/tinybird/datasources/click_events.datasource
new file mode 100644
index 0000000000..d526bae1db
--- /dev/null
+++ b/packages/tinybird/datasources/click_events.datasource
@@ -0,0 +1,28 @@
+
+SCHEMA >
+ `timestamp` DateTime64(3) `json:$.timestamp`,
+ `domain` String `json:$.domain`,
+ `key` String `json:$.key`,
+ `country` LowCardinality(String) `json:$.country`,
+ `city` String `json:$.city`,
+ `device` LowCardinality(String) `json:$.device`,
+ `browser` LowCardinality(String) `json:$.browser`,
+ `os` LowCardinality(String) `json:$.os`,
+ `bot` UInt8 `json:$.bot`,
+ `referer` String `json:$.referer`,
+ `browser_version` String `json:$.browser_version`,
+ `engine` LowCardinality(String) `json:$.engine`,
+ `engine_version` String `json:$.engine_version`,
+ `latitude` String `json:$.latitude`,
+ `longitude` String `json:$.longitude`,
+ `os_version` String `json:$.os_version`,
+ `region` String `json:$.region`,
+ `ua` String `json:$.ua`,
+ `device_model` LowCardinality(String) `json:$.device_model`,
+ `device_vendor` LowCardinality(String) `json:$.device_vendor`,
+ `cpu_architecture` LowCardinality(String) `json:$.cpu_architecture`,
+ `referer_url` String `json:$.referer_url`
+
+ENGINE "MergeTree"
+ENGINE_PARTITION_KEY "toYYYYMM(timestamp)"
+ENGINE_SORTING_KEY "domain, key, timestamp"
\ No newline at end of file
diff --git a/packages/tinybird/endpoints/browser.pipe b/packages/tinybird/endpoints/browser.pipe
new file mode 100644
index 0000000000..bc19bc6be2
--- /dev/null
+++ b/packages/tinybird/endpoints/browser.pipe
@@ -0,0 +1,29 @@
+TOKEN "browser_endpoint_read_5885" READ
+
+NODE browser_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT browser, COUNT(browser) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ AND browser != 'Unknown'
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY browser
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/city.pipe b/packages/tinybird/endpoints/city.pipe
new file mode 100644
index 0000000000..c50b8bb3d9
--- /dev/null
+++ b/packages/tinybird/endpoints/city.pipe
@@ -0,0 +1,29 @@
+TOKEN "city_endpoint_read_5276" READ
+
+NODE city_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT city, country, COUNT(city) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ AND city != 'Unknown'
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY city, country
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/clicks.pipe b/packages/tinybird/endpoints/clicks.pipe
new file mode 100644
index 0000000000..0832a08c8e
--- /dev/null
+++ b/packages/tinybird/endpoints/clicks.pipe
@@ -0,0 +1,24 @@
+TOKEN "clicks_endpoint_read_1555" READ
+
+NODE clicks_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT COUNT(*)
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me,steven.yt,steven.blue') }}
+ {% if defined(key) %} AND key IN {{ Array(key, 'String', default='twitter') }} {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{city}} {% end %}
+ {% if defined(device) %} AND device = {{device}} {% end %}
+ {% if defined(browser) %} AND browser = {{browser}} {% end %}
+ {% if defined(os) %} AND os = {{os}} {% end %}
+ {% if defined(referer) %} AND referer = {{referer}} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+
+
diff --git a/packages/tinybird/endpoints/country.pipe b/packages/tinybird/endpoints/country.pipe
new file mode 100644
index 0000000000..39fdb473f5
--- /dev/null
+++ b/packages/tinybird/endpoints/country.pipe
@@ -0,0 +1,29 @@
+TOKEN "country_endpoint_read_3116" READ
+
+NODE country_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT country, COUNT(country) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ AND country != 'Unknown'
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY country
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/device.pipe b/packages/tinybird/endpoints/device.pipe
new file mode 100644
index 0000000000..a3008a9e22
--- /dev/null
+++ b/packages/tinybird/endpoints/device.pipe
@@ -0,0 +1,28 @@
+TOKEN "device_endpoint_read_8888" READ
+
+NODE device_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT device, COUNT(device) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY device
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/os.pipe b/packages/tinybird/endpoints/os.pipe
new file mode 100644
index 0000000000..7fa056a3dd
--- /dev/null
+++ b/packages/tinybird/endpoints/os.pipe
@@ -0,0 +1,29 @@
+TOKEN "os_endpoint_read_7161" READ
+
+NODE os_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT os, COUNT(os) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ AND os != 'Unknown'
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY os
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/referer.pipe b/packages/tinybird/endpoints/referer.pipe
new file mode 100644
index 0000000000..e07fcfd824
--- /dev/null
+++ b/packages/tinybird/endpoints/referer.pipe
@@ -0,0 +1,28 @@
+TOKEN "referer_endpoint_read_8276" READ
+
+NODE referer_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT referer, COUNT(referer) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY referer
+ ORDER BY clicks DESC
+
+
diff --git a/packages/tinybird/endpoints/timeseries.pipe b/packages/tinybird/endpoints/timeseries.pipe
new file mode 100644
index 0000000000..6bf2631144
--- /dev/null
+++ b/packages/tinybird/endpoints/timeseries.pipe
@@ -0,0 +1,96 @@
+NODE day_intervals
+SQL >
+
+ %
+ WITH
+ toStartOfDay(toDateTime64({{ DateTime64(start, '2022-09-25 00:00:00.000') }}, 3)) AS start,
+ toStartOfDay(toDateTime64({{ DateTime64(end, '2022-12-20 00:00:00.000') }}, 3)) AS end
+ SELECT arrayJoin(arrayMap(x -> toDateTime64(x, 3), range(toUInt32(start + 86400), toUInt32(end + 86400), 86400))) as interval
+
+
+
+NODE hour_intervals
+SQL >
+
+ %
+ WITH
+ toStartOfHour(toDateTime64({{ DateTime64(start, '2022-12-19 00:00:00.000') }}, 3)) AS start,
+ toStartOfHour(toDateTime64({{ DateTime64(end, '2022-12-20 00:00:00.000') }}, 3)) AS end
+ SELECT arrayJoin(arrayMap(x -> toDateTime64(x, 3), range(toUInt32(start + 3600), toUInt32(end + 3600), 3600))) as interval
+
+
+
+NODE minute_intervals
+SQL >
+
+ %
+ WITH
+ toStartOfMinute(toDateTime64({{ DateTime64(start, '2022-12-20 15:08:57.000') }}, 3)) AS start,
+ toStartOfMinute(toDateTime64({{ DateTime64(end, '2022-12-20 16:08:57.000') }}, 3)) AS end
+ SELECT arrayJoin(arrayMap(x -> toDateTime64(x, 3), range(toUInt32(start + 60), toUInt32(end + 60), 60))) as interval
+
+
+
+NODE timeseries_data
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT
+ {% if granularity == "minute" %} toStartOfMinute(timestamp)
+ {% elif granularity == "hour" %} toStartOfHour(timestamp)
+ {% elif granularity == "month" %} toDateTime(toStartOfMonth(timestamp))
+ {% else %} toDateTime(toStartOfDay(timestamp))
+ {% end %} AS interval,
+ uniq(*) as clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me,steven.yt') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ AND timestamp >= {{ DateTime64(start, '2023-06-25 00:00:00.000') }}
+ AND timestamp < {{ DateTime64(end, '2023-10-20 00:00:00.000') }}
+ GROUP BY interval
+ ORDER BY interval
+
+
+
+NODE timeseries_node
+SQL >
+
+ %
+ SELECT formatDateTime(interval, '%FT%T.000Z') as start, clicks
+ FROM
+ {% if granularity == "minute" %} minute_intervals
+ {% elif granularity == "hour" %} hour_intervals
+ {% elif granularity == "month" %} month_intervals
+ {% else %} day_intervals
+ {% end %}
+ LEFT JOIN timeseries_data USING interval
+
+
+
+NODE month_intervals
+SQL >
+
+ %
+ SELECT
+ toStartOfMonth(toDateTime64({{ DateTime64(start, '2023-02-23 20:45:02.959') }}, 3)) as interval
+ ORDER BY interval ASC
+ WITH FILL
+ FROM
+ toStartOfMonth(toDateTime64({{ DateTime64(start, '2023-02-23 20:45:02.959') }}, 3))
+ TO
+ toStartOfMonth(addMonths(toDateTime64({{ DateTime64(end, '2023-06-06 20:45:02.959') }}, 3), 1))
+ STEP interval 1 month
+
+
diff --git a/packages/tinybird/endpoints/top_links.pipe b/packages/tinybird/endpoints/top_links.pipe
new file mode 100644
index 0000000000..0ca1e54893
--- /dev/null
+++ b/packages/tinybird/endpoints/top_links.pipe
@@ -0,0 +1,32 @@
+DESCRIPTION >
+ This is used for the 30-day summary email
+
+
+TOKEN "usage_endpoint_read_8241" READ
+
+NODE top_links_node
+DESCRIPTION >
+ undefined
+
+SQL >
+
+ %
+ SELECT domain, key, COUNT(*) AS clicks
+ FROM click_events
+ WHERE
+ domain IN {{ Array(domain, 'String', default='stey.me') }}
+ {% if defined(key) %}
+ AND key IN {{ Array(key, 'String', default='twitter') }}
+ {% end %}
+ {% if defined(country) %} AND country = {{ country }} {% end %}
+ {% if defined(city) %} AND city = {{ city }} {% end %}
+ {% if defined(device) %} AND device = {{ device }} {% end %}
+ {% if defined(browser) %} AND browser = {{ browser }} {% end %}
+ {% if defined(os) %} AND os = {{ os }} {% end %}
+ {% if defined(referer) %} AND referer = {{ referer }} {% end %}
+ {% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}
+ {% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}
+ GROUP BY domain, key
+ ORDER BY clicks DESC
+
+
diff --git a/packages/utils/src/constants/index.ts b/packages/utils/src/constants/index.ts
index 9c4847c4ba..ebcbe9d28b 100644
--- a/packages/utils/src/constants/index.ts
+++ b/packages/utils/src/constants/index.ts
@@ -33,44 +33,43 @@ export const FADE_IN_ANIMATION_SETTINGS = {
export const PAGINATION_LIMIT = 100;
-export const HOME_DOMAIN = "https://dub.co";
+export const HOME_DOMAIN = `https://${process.env.NEXT_PUBLIC_APP_DOMAIN}`;
export const APP_HOSTNAMES = new Set([
- "app.dub.co",
- "preview.dub.co",
+ `app.${process.env.NEXT_PUBLIC_APP_DOMAIN}`,
+ `preview.${process.env.NEXT_PUBLIC_APP_DOMAIN}`,
"localhost:8888",
"localhost",
]);
export const APP_DOMAIN =
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "https://app.dub.co"
+ ? `https://app.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: process.env.NEXT_PUBLIC_VERCEL_ENV === "preview"
- ? "https://preview.dub.co"
+ ? `https://preview.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: "http://localhost:8888";
export const APP_DOMAIN_WITH_NGROK =
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "https://app.dub.co"
+ ? `https://app.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: process.env.NEXT_PUBLIC_VERCEL_ENV === "preview"
- ? "https://preview.dub.co"
+ ? `https://preview.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: process.env.NGROK_URL;
export const API_HOSTNAMES = new Set([
- "api.dub.co",
- "api.dub.sh",
+ `api.${process.env.NEXT_PUBLIC_APP_DOMAIN}`,
"api.localhost:8888",
]);
export const API_DOMAIN =
process.env.NEXT_PUBLIC_VERCEL_ENV === "production"
- ? "https://api.dub.co"
+ ? `https://api.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: process.env.NEXT_PUBLIC_VERCEL_ENV === "preview"
- ? "https://api.dub.sh"
+ ? `https://api.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
: "http://api.localhost:8888";
export const ADMIN_HOSTNAMES = new Set([
- "admin.dub.co",
+ `admin.${process.env.NEXT_PUBLIC_APP_DOMAIN}`,
"admin.localhost:8888",
]);
@@ -119,45 +118,49 @@ export const SHOW_BACKGROUND_SEGMENTS = [
export const DUB_DOMAINS = [
{
- slug: "dub.sh",
+ slug: process.env.NEXT_PUBLIC_APP_SHORT_DOMAIN,
verified: true,
primary: true,
- target: "https://dub.co",
+ target: `https://${process.env.NEXT_PUBLIC_APP_DOMAIN}`,
type: "redirect",
placeholder: "https://dub.co/help/article/what-is-dub",
clicks: 0,
allowedHostnames: [],
},
- {
- slug: "chatg.pt",
- verified: true,
- primary: false,
- target: "https://dub.co/tools/chatgpt-link-shortener",
- type: "redirect",
- placeholder: "https://chat.openai.com/g/g-UGjKKONEe-domainsgpt",
- clicks: 0,
- allowedHostnames: ["chat.openai.com"],
- },
- {
- slug: "amzn.id",
- verified: true,
- primary: false,
- target: "https://dub.co/tools/amazon-link-shortener",
- type: "redirect",
- placeholder: "https://www.amazon.com/dp/B0BW4SWNC8",
- clicks: 0,
- allowedHostnames: ["amazon.com", "amazon.co.uk", "amazon.ca"],
- },
- {
- slug: "spti.fi",
- verified: true,
- primary: false,
- target: "https://dub.co/tools/spotify-link-shortener",
- type: "redirect",
- placeholder: "https://open.spotify.com/album/1SCyi9a5pOasikidToUY5y",
- clicks: 0,
- allowedHostnames: ["open.spotify.com"],
- },
+ ...(process.env.NEXT_PUBLIC_IS_DUB
+ ? [
+ {
+ slug: "chatg.pt",
+ verified: true,
+ primary: false,
+ target: "https://dub.co/tools/chatgpt-link-shortener",
+ type: "redirect",
+ placeholder: "https://chat.openai.com/g/g-UGjKKONEe-domainsgpt",
+ clicks: 0,
+ allowedHostnames: ["chat.openai.com"],
+ },
+ {
+ slug: "amzn.id",
+ verified: true,
+ primary: false,
+ target: "https://dub.co/tools/amazon-link-shortener",
+ type: "redirect",
+ placeholder: "https://www.amazon.com/dp/B0BW4SWNC8",
+ clicks: 0,
+ allowedHostnames: ["amazon.com", "amazon.co.uk", "amazon.ca"],
+ },
+ {
+ slug: "spti.fi",
+ verified: true,
+ primary: false,
+ target: "https://dub.co/tools/spotify-link-shortener",
+ type: "redirect",
+ placeholder: "https://open.spotify.com/album/1SCyi9a5pOasikidToUY5y",
+ clicks: 0,
+ allowedHostnames: ["open.spotify.com"],
+ },
+ ]
+ : []),
];
export const ALL_TOOLS = [