Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openuidev/devtools",
"version": "0.1.0",
"version": "0.1.1",
"description": "Development-only UI widget for OpenUI apps: surfaces errors captured by @openuidev/observability",
"license": "MIT",
"type": "module",
Expand Down
16 changes: 14 additions & 2 deletions packages/devtools/src/inspect/QuotaErrorRow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type ObservabilityEvent } from "@openuidev/observability";
import { CreditCard, KeyRound } from "lucide-react";
import { useState, type CSSProperties } from "react";
import { withDevtoolsAttribution } from "../lib/links";
import { FONT, useStyles, type ThemeTokens } from "../theme";
import { LevelIcon } from "./LevelIcon";

Expand Down Expand Up @@ -61,7 +62,14 @@ export function QuotaErrorRow({ info }: { info: QuotaErrorInfo }) {
onMouseEnter={() => setHoveredCta("purchase")}
onMouseLeave={() => setHoveredCta(null)}
onClick={() =>
window.open("https://console.thesys.dev/billing", "_blank", "noopener,noreferrer")
window.open(
withDevtoolsAttribution(
"https://console.thesys.dev/billing",
"quota_error_purchase_credits",
),
"_blank",
"noopener,noreferrer",
)
}
>
<CreditCard size={13} />
Expand All @@ -79,7 +87,11 @@ export function QuotaErrorRow({ info }: { info: QuotaErrorInfo }) {
onMouseEnter={() => setHoveredCta("byok")}
onMouseLeave={() => setHoveredCta(null)}
onClick={() =>
window.open("https://console.thesys.dev/byok", "_blank", "noopener,noreferrer")
window.open(
withDevtoolsAttribution("https://console.thesys.dev/byok", "quota_error_byok"),
"_blank",
"noopener,noreferrer",
)
}
>
<KeyRound size={13} />
Expand Down
1 change: 1 addition & 0 deletions packages/devtools/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export {
type LibraryLike,
type RegisteredLibrary,
} from "./libraryRegistry";
export { withDevtoolsAttribution } from "./links";
export { useDevtoolsSingleton } from "./singleton";
export { useDevtoolsConfig, type DevtoolsConfig } from "./useDevtoolsConfig";
24 changes: 24 additions & 0 deletions packages/devtools/src/lib/links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const UTM_PARAMS = {
utm_source: "openui",
utm_medium: "referral",
utm_campaign: "openui_devtools",
} as const;

/** Tags an outbound devtools link so referrals are attributable, keeping existing params. */
export function withDevtoolsAttribution(href: string, content: string) {
let url: URL;

try {
url = new URL(href);
} catch {
return href;
}

for (const [key, value] of Object.entries(UTM_PARAMS)) {
if (!url.searchParams.has(key)) url.searchParams.set(key, value);
}

if (!url.searchParams.has("utm_content")) url.searchParams.set("utm_content", content);

return url.toString();
}
6 changes: 5 additions & 1 deletion packages/devtools/src/ui/ReliabilityBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CSSProperties, useState } from "react";
import { withDevtoolsAttribution } from "../lib/links";
import { ColorMode, FONT, theme, ThemeTokens } from "../theme";

export default function ReliabilityBanner({ themeMode }: { themeMode: ColorMode }) {
Expand All @@ -10,7 +11,10 @@ export default function ReliabilityBanner({ themeMode }: { themeMode: ColorMode
<span style={styles.fade} aria-hidden />
<a
style={styles.banner}
href="https://www.openui.com/docs/openui-lang/reliability"
href={withDevtoolsAttribution(
"https://www.openui.com/docs/openui-lang/reliability",
"reliability_banner_learn_more",
)}
target="_blank"
rel="noreferrer"
title="Learn how to track and fix errors in production"
Expand Down
Loading