All Customers

How Midday integrated link-sharing with analytics in a few lines of code with Dub.co

Learn how Midday was able to leverage Dub.co's link infrastructure to programmatically generate short links at scale, with features like real-time analytics, auto-expiration, and link cloaking.

How Midday integrated link-sharing with analytics in a few lines of code with Dub.co
Midday

Midday

midday.ai

About

Midday provides you with greater insight into your business and automates the boring tasks, allowing you to focus on what you love to do instead.

Industry

FinTech, SaaS

Company Size

1-10

Founded

2023

Dub Plan

Pro

Midday is an all-in-one financial management platform that focuses on making business operations smarter by providing insights into a business' financials and streamlining activities like time-tracking and invoice management.

When Midday launched their time tracker view on X (formerly Twitter), they received a lot of great feedback from users – one of which that stood out was the ability to share tracked hours with their customers in real-time.

With this report, business owners can focus on what they do best instead of manually keeping their customers up to date with time reports.

To build this feature, Midday needed a solution that would allow them to:

After evaluating different solutions, they decided to use Dub.co for their link-sharing needs.

Dub's TypeScript SDK allowed Midday to programmatically create beautiful short links with just a few lines of code.

Since Midday was already using Next.js and Supabase for their tech stack, they were able to quickly implement this by adding a new create-report-action.ts function:

create-report-action.ts
"use server";
 
import { action } from "@/actions/safe-action";
import { createReportSchema } from "@/actions/schema";
import { createClient } from "@midday/supabase/server";
import { Dub } from "dub";
 
const dub = new Dub();
 
export const createReportAction = action(
  createReportSchema,
  async (payload) => {
    const supabase = createClient();
 
    const { data } = await supabase
      .from("reports")
      .insert(payload)
      .select("*")
      .single();
 
    const link = await dub.links.create({
      url: `${params.baseUrl}/report/${data.id}`,
      rewrite: true,
      expiresAt: params.expiresAt,
    });
 
    return link;
  },
);

In this code snippet, Midday uses Next.js' Server Actions to:

  1. Create a new report in their Supabase database
  2. Generate a short link for that report using Dub's SDK
  3. The short link is then returned to the user, who can share it with their customers

Optionally, Midday would also set an expiration date for the link to ensure that the report is only accessible for a certain period. This is done by setting the expiresAt parameter in the dub.links.create method.

For a better brand experience, Midday also uses the rewrite parameter to cloak the actual destination URL. This way, the short link will look like go.midday.ai/abc123 instead of app.midday.ai/report/project/random-uuid-123456.

You can learn more about the different parameters you can set in the dub.links.create method in the Dub API documentation.

Because of how easy the implementation was, Midday was able to quickly roll out this feature on two more reports – Profit and Revenue reports:

To find more examples of how Midday use Dub, you can check out their GitHub repository below:

Midday has a lot of features where files, activity reports, and other resources can be shared.

Previously, these links were secured by JWT tokens and were not very user-friendly to share with customers given how long they were.

With Dub's link infrastructure, not only were they able to generate beautiful short links at scale, but they also got access to real-time click analytics, which their users greatly appreciate.

Midday also uses a go.midday.ai short link for their desktop app download command, which allows them to track the number of downloads and the source of the traffic:

Pontus Abrahamsson

I highly recommend using Dub for all your public-facing links – whether it's your email signature or social profiles. Putting aside the argument of aesthetics, Dub gives you valuable click analytics that can help you understand your audience better – not to mention that you can easily update the destination URL for your links whenever you need.

Midday.ai

Pontus Abrahamsson

Founder

The future of Midday x Dub

Midday has experienced a shift in their approach to links after implementing Dub. They now treat links as assets and utilize Dub to generate visual charts based on financial data. These charts can be easily shared with others, thanks to Dub's link infrastructure.

For example, their upcoming Midday AI feature will allow users to share financial insights with their customers in a visual format – easily shareable via a Dub-powered short link:

Pontus Abrahamsson

We are super happy customers of Dub and recommend them to everyone that have links that they want to share. Also, the customer support is truly one of the best you can get.

Midday.ai

Pontus Abrahamsson

Founder

Want to build your own link-sharing features with Dub's TypeScript SDK? We created a simple template – affectionately dubbed dublet – to help you get started:

Have any questions? Feel free to send us an email or tweet at us – we'd love to help!

Supercharge your marketing efforts

See why Dub is the link management infrastructure of choice for modern marketing teams.