Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Extra logging for Dub track

Richie McIlroy5365e94945bf
diff --git a/apps/web/package.json b/apps/web/package.json
index 0ca79cd2b..d530584cc 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -61,7 +61,7 @@
"dompurify": "^3.2.6",
"dotenv": "^16.3.1",
"drizzle-orm": "0.43.1",
- "dub": "^0.33.1",
+ "dub": "^0.36.1",
"file-saver": "^2.0.5",
"framer-motion": "^11.13.1",
"geist": "^1.3.1",
diff --git a/packages/database/auth/auth-options.tsx b/packages/database/auth/auth-options.tsx
index 404572020..e1f42cbd6 100644
--- a/packages/database/auth/auth-options.tsx
+++ b/packages/database/auth/auth-options.tsx
@@ -105,13 +105,13 @@ export const authOptions = (): NextAuthOptions => {
events: {
async signIn({ user, account, isNewUser }) {
if (isNewUser) {
- // Check if dub_id cookie is present
const dubId = cookies().get("dub_id")?.value;
+ const dubPartnerData = cookies().get("dub_partner_data")?.value;
if (dubId) {
try {
- // Send lead event to Dub
- await dub().track.lead({
+ console.log("Attempting to track lead with Dub...");
+ const trackResult = await dub().track.lead({
clickId: dubId,
eventName: "Sign Up",
externalId: user.id,
@@ -120,13 +120,21 @@ export const authOptions = (): NextAuthOptions => {
customerAvatar: user.image || undefined,
});
- // Delete the dub_id cookie
- cookies().set("dub_id", "", {
- expires: new Date(0),
- });
+ console.log("Dub tracking successful:", trackResult);
+
+ // Properly delete the dub_id cookie
+ cookies().delete("dub_id");
+
+ // Also delete dub_partner_data if it exists
+ if (dubPartnerData) {
+ cookies().delete("dub_partner_data");
+ }
} catch (error) {
console.error("Failed to track lead with Dub:", error);
+ console.error("Error details:", JSON.stringify(error, null, 2));
}
+ } else {
+ console.log("No dub_id cookie found - referral tracking skipped");
}
const organizationId = nanoId();
diff --git a/packages/database/package.json b/packages/database/package.json
index 9cef7b718..2342b3fe5 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -22,7 +22,7 @@
"@react-email/render": "1.1.2",
"@react-email/tailwind": "^1.0.5",
"drizzle-orm": "0.43.1",
- "dub": "^0.33.1",
+ "dub": "^0.64.0",
"nanoid": "^5.0.4",
"next": "14.2.9",
"next-auth": "^4.24.5",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index cec0ff421..90c5a365d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7,6 +7,16 @@ settings:
importers:
.:
+ dependencies:
+ date-fns:
+ specifier: ^3.6.0
+ version: 3.6.0
+ dub:
+ specifier: ^0.36.1
+ version: 0.36.6([email protected])
+ eslint:
+ specifier: ^8.57.0
+ version: 8.57.1
devDependencies:
'@clack/prompts':
specifier: ^0.10.0
@@ -553,8 +563,8 @@ importers:
specifier: 0.43.1
version: 0.43.1(@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected])
dub:
- specifier: ^0.33.1
- version: 0.33.1([email protected])
+ specifier: ^0.36.1
+ version: 0.36.6([email protected])
file-saver:
specifier: ^2.0.5
version: 2.0.5
@@ -808,8 +818,11 @@ importers:
specifier: 0.43.1
version: 0.43.1(@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected])
dub:
- specifier: ^0.33.1
- version: 0.33.1([email protected])
+ specifier: ^0.64.0
+ version: 0.64.0(@modelcontextprotocol/[email protected])([email protected])
+ joi:
+ specifier: ^17.13.3
+ version: 17.13.3
nanoid:
specifier: ^5.0.4
version: 5.1.5
@@ -2701,6 +2714,12 @@ packages:
engines: {node: '>=6'}
hasBin: true
+ resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==}
+
+ resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==}
+
'@headlessui/[email protected]':
resolution: {integrity: sha512-Ll+8q3OlMJfJbAKM/+/Y2q6PPYbryqNTXDbryx7SXLIDamkF6iQFbriYHga0dY44PvDhvvBWCx1Xj4U5+G4hOw==}
engines: {node: '>=10'}
@@ -4889,6 +4908,15 @@ packages:
'@shikijs/[email protected]':
resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
+ '@sideway/[email protected]':
+ resolution: {integrity: sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==}
+
+ '@sideway/[email protected]':
+ resolution: {integrity: sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==}
+
+ '@sideway/[email protected]':
+ resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==}
+
'@sigstore/[email protected]':
resolution: {integrity: sha512-wueKWDk70QixNLB363yHc2D2ItTgYiMTdPwK8D9dKQMR3ZQ0c35IxP5xnwQ8cNLoCgCRcHf14kE+CLIvNX1zmA==}
engines: {node: ^16.14.0 || >=18.0.0}
@@ -7758,10 +7786,20 @@ packages:
sqlite3:
optional: true
- resolution: {integrity: sha512-R0X0z9+nPCLs7J62kH2K3tX5L6fNigsPsw/Ch6zvfMy3hgSuSrA6idGQ474e/kJQdXXSi8T4hZsAPy1UzTZHAA==}
+ resolution: {integrity: sha512-MgdFsHiQr/3jVRcld8dhm58bsAGo4PABhEBymF6aJRapavUl9vfHqF/sbhnAlYrixTIweBjB3ofrOXSeaa10nQ==}
+ peerDependencies:
+ zod: '>= 3'
+
+ resolution: {integrity: sha512-HJ/nYSinJpoqU94+wXwpZWS8S/QddkKFTPKQEPY7N3YYXQLk2t9TVDArKBfIdcjFpvmCltJ+awa8Ogjq0DOv7w==}
+ hasBin: true
peerDependencies:
+ '@modelcontextprotocol/sdk': '>=1.5.0 <1.10.0'
zod: '>= 3'
+ peerDependenciesMeta:
+ '@modelcontextprotocol/sdk':
+ optional: true
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
@@ -9449,6 +9487,9 @@ packages:
resolution: {integrity: sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==}
engines: {node: '>= 0.6.0'}
+ resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==}
+
resolution: {integrity: sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==}
@@ -15040,7 +15081,7 @@ snapshots:
'@eslint/[email protected]':
dependencies:
ajv: 6.12.6
- debug: 4.4.0([email protected])
+ debug: 4.4.1
espree: 9.6.1
globals: 13.24.0
ignore: 5.3.2
@@ -15110,6 +15151,12 @@ snapshots:
protobufjs: 7.4.0
yargs: 17.7.2
+ '@hapi/[email protected]': {}
+
+ dependencies:
+ '@hapi/hoek': 9.3.0
+
dependencies:
'@tanstack/react-virtual': 3.13.8([email protected]([email protected]))([email protected])
@@ -15134,7 +15181,7 @@ snapshots:
'@humanwhocodes/[email protected]':
dependencies:
'@humanwhocodes/object-schema': 2.0.3
- debug: 4.4.0([email protected])
+ debug: 4.4.1
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -17626,6 +17673,14 @@ snapshots:
'@shikijs/[email protected]': {}
+ '@sideway/[email protected]':
+ dependencies:
+ '@hapi/hoek': 9.3.0
+
+ '@sideway/[email protected]': {}
+
+ '@sideway/[email protected]': {}
+
'@sigstore/[email protected]':
dependencies:
'@sigstore/protobuf-specs': 0.3.3
@@ -20869,14 +20924,20 @@ snapshots:
'@planetscale/database': 1.19.0
mysql2: 3.14.1
dependencies:
zod: 3.25.20
dependencies:
zod: 3.25.67
+ dependencies:
+ zod: 3.25.67
+ optionalDependencies:
+ '@modelcontextprotocol/sdk': 1.6.1
+
dependencies:
call-bind-apply-helpers: 1.0.2
@@ -21326,7 +21387,7 @@ snapshots:
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]))([email protected])
eslint-plugin-jsx-a11y: 6.10.2([email protected])
eslint-plugin-react: 7.37.5([email protected])
eslint-plugin-react-hooks: 4.6.2([email protected])
@@ -21365,7 +21426,7 @@ snapshots:
tinyglobby: 0.2.13
unrs-resolver: 1.7.2
optionalDependencies:
transitivePeerDependencies:
- supports-color
@@ -21384,6 +21445,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ debug: 3.2.7
+ optionalDependencies:
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ eslint: 8.57.1
+ eslint-import-resolver-node: 0.3.9
+ eslint-import-resolver-typescript: 3.10.1([email protected]([email protected]))([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
debug: 3.2.7
@@ -21406,6 +21478,35 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ '@rtsao/scc': 1.1.0
+ array-includes: 3.1.8
+ array.prototype.findlastindex: 1.2.6
+ array.prototype.flat: 1.3.3
+ array.prototype.flatmap: 1.3.3
+ debug: 3.2.7
+ doctrine: 2.1.0
+ eslint: 8.57.1
+ eslint-import-resolver-node: 0.3.9
+ hasown: 2.0.2
+ is-core-module: 2.16.1
+ is-glob: 4.0.3
+ minimatch: 3.1.2
+ object.fromentries: 2.0.8
+ object.groupby: 1.0.3
+ object.values: 1.2.1
+ semver: 6.3.1
+ string.prototype.trimend: 1.0.9
+ tsconfig-paths: 3.15.0
+ optionalDependencies:
+ '@typescript-eslint/parser': 5.62.0([email protected])([email protected])
+ transitivePeerDependencies:
+ - eslint-import-resolver-typescript
+ - eslint-import-resolver-webpack
+ - supports-color
+
dependencies:
'@rtsao/scc': 1.1.0
@@ -21611,7 +21712,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.6
- debug: 4.4.0([email protected])
+ debug: 4.4.1
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -23278,6 +23379,14 @@ snapshots:
+ dependencies:
+ '@hapi/hoek': 9.3.0
+ '@hapi/topo': 5.1.0
+ '@sideway/address': 4.1.5
+ '@sideway/formula': 3.0.1
+ '@sideway/pinpoint': 2.0.0
+