Skip to content

Instantly share code, notes, and snippets.

View steven-tey's full-sized avatar
👷
building infra for the next trillion links on the web @dubinc

Steven Tey steven-tey

👷
building infra for the next trillion links on the web @dubinc
View GitHub Profile
@steven-tey
steven-tey / youtube-channel.tsx
Last active July 9, 2024 03:41
YoutubeChannel RSC
import { BlurImage, YouTube } from "@dub/ui";
import { nFormatter } from "@dub/utils";
import { Eye, UserCheck, Video } from "lucide-react";
import { Suspense } from "react";
export function YoutubeChannel({ id }: { id: string }) {
return (
<Suspense fallback={<div className="not-prose grid gap-4"></div>}>
<YoutubeChannelRSC id={id} />
</Suspense>
@steven-tey
steven-tey / graphql_controller.rb
Created July 29, 2024 23:00
Retrieving `dclid` cookie in newsletter subscription and tracking a lead event with `dub`
# app/controllers/graphql_controller.rb
class GraphqlController < ApplicationController
def execute
# Reading the `dclid` cookie
dclid = cookies[:dclid]
# Handle the GraphQL query
variables = ensure_hash(params[:variables])
context = {
@steven-tey
steven-tey / main.ts
Created January 28, 2025 17:36
Get links by tenantId and their analytics
const links = await dub.links.list({
tenantId: "xxx"
}).then((res) => res.result)
// if you need all time stats, the links array should have `clicks`, `leads` and `sales`
// for a certain timeframe
const analytics = await Promise.all(links.map(async (link) => {
return await dub.analytics.retrieve({
event: "composite", // to get clicks, leads, sales, and saleAmount