Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
feat: change analytics lib + minor fixes
VladSez141df9fd4b3f
diff --git a/README.md b/README.mdindex 5bcd3c6..f69c40f 100644--- a/README.md+++ b/README.md@@ -1,3 +1,7 @@+## Tools we use++- https://www.loglib.io/s/pdf-invoice-editor for analytics+## TODO- [ ] Test with big values/numbers on the invoice, e.g. 1 000 000 (check if pdf is displayed correctly)diff --git a/package.json b/package.jsonindex 33c68ba..aaae835 100644--- a/package.json+++ b/package.json@@ -10,9 +10,9 @@},"dependencies": {"@hookform/resolvers": "3.9.0",+ "@loglib/tracker": "0.8.0","@react-pdf/layout": "4.0.1","@react-pdf/renderer": "4.0.1",- "@vercel/analytics": "1.4.1","dayjs": "1.11.13","lucide-react": "0.460.0","lz-string": "1.5.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 68fc029..7c576e7 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -11,15 +11,15 @@ importers:'@hookform/resolvers':specifier: 3.9.0version: 3.9.0([email protected]([email protected]))+ '@loglib/tracker':+ specifier: 0.8.0+ version: 0.8.0([email protected])'@react-pdf/layout':specifier: 4.0.1version: 4.0.1'@react-pdf/renderer':specifier: 4.0.1version: 4.0.1([email protected])- '@vercel/analytics':- specifier: 1.4.1- version: 1.4.1([email protected]([email protected]([email protected]))([email protected]))([email protected])dayjs:specifier: 1.11.13version: 1.11.13@@ -147,6 +147,11 @@ packages:'@jridgewell/[email protected]':resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}+ '@loglib/[email protected]':+ resolution: {integrity: sha512-WShEN7s4fcmWaWgBNmx4sDNaoLPudvfmopHxeJpWTAb4SEpypRsk4Kx143UQQEvFHE+jPQi/P3m8ennpVqFWAg==}+ peerDependencies:+ react: ^16.8||^17||^18+'@next/[email protected]':resolution: {integrity: sha512-S1qaj25Wru2dUpcIZMjxeMVSwkt8BK4dmWHHiBuRstcIyOsMapqT4A4jSB6onvqeygkSSmOkyny9VVx8JIGamQ==}@@ -355,32 +360,6 @@ packages:'@ungap/[email protected]':resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}- '@vercel/[email protected]':- resolution: {integrity: sha512-ekpL4ReX2TH3LnrRZTUKjHHNpNy9S1I7QmS+g/RQXoSUQ8ienzosuX7T9djZ/s8zPhBx1mpHP/Rw5875N+zQIQ==}- peerDependencies:- '@remix-run/react': ^2- '@sveltejs/kit': ^1 || ^2- next: '>= 13'- react: ^18 || ^19 || ^19.0.0-rc- svelte: '>= 4'- vue: ^3- vue-router: ^4- peerDependenciesMeta:- '@remix-run/react':- optional: true- '@sveltejs/kit':- optional: true- next:- optional: true- react:- optional: true- svelte:- optional: true- vue:- optional: true- vue-router:- optional: true-resolution: {integrity: sha512-d8XPSGjfyzlXC3Xx891DJRyZfqk5JU0BJrDQcsWomFIV1/BIzPW5HDH5iDdWpqWaav0YVIEzT1RHTwWr0FFshA==}@@ -1778,6 +1757,9 @@ packages:resolution: {integrity: sha512-t20zYkrSf868+j/p31cRIGN28Phrjm3nRSLR2fyc2tiWi4cZGVdv68yNlwnIINTkMTmPoMiSlc0OadaO7DXZaQ==}engines: {node: '>= 6'}+ resolution: {integrity: sha512-c0rhqNcHXRkY/ogGDJQxZ9Im9D19hDihbzSQJrsioex+KnFgmMzBiy57Z1EjkhX/+OjyBpclDCzz2ITtjokFmg==}+resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}@@ -1907,6 +1889,11 @@ snapshots:'@jridgewell/resolve-uri': 3.1.2'@jridgewell/sourcemap-codec': 1.5.0+ '@loglib/[email protected]([email protected])':+ dependencies:+ react: 18.3.1+ web-vitals: 3.5.2+'@next/[email protected]': {}'@next/[email protected]':@@ -2179,11 +2166,6 @@ snapshots:'@ungap/[email protected]': {}- '@vercel/[email protected]([email protected]([email protected]([email protected]))([email protected]))([email protected])':- optionalDependencies:- react: 18.3.1-@@ -3819,6 +3801,8 @@ snapshots:string_decoder: 1.3.0util-deprecate: 1.0.2+ [email protected]: {}+diff --git a/src/app/components/invoice-form.tsx b/src/app/components/invoice-form.tsxindex 73bb3bc..98095a5 100644--- a/src/app/components/invoice-form.tsx+++ b/src/app/components/invoice-form.tsx@@ -12,6 +12,7 @@ import {import { useDebouncedCallback } from "use-debounce";import { Plus, Trash2 } from "lucide-react";import { z } from "zod";+import { loglib } from "@loglib/tracker";export const PDF_DATA_LOCAL_STORAGE_KEY = "invoicePdfData";@@ -158,6 +159,10 @@ export function InvoiceForm({const handleRemoveItem = useCallback((index: number) => {remove(index);++ // analytics track event+ loglib.track("remove_invoice_item");+// Manually trigger form submission after removalconst currentFormData = watch();debouncedRegeneratePdfOnFormChange(currentFormData);@@ -828,7 +833,8 @@ export function InvoiceForm({htmlFor={`itemVatAmount${index}`}className="block text-sm font-medium text-gray-700 mb-1">- VAT Amount+ VAT Amount (calculated automatically based on Net Amount and+ VAT)</label><Controllername={`items.${index}.vatAmount`}@@ -890,6 +896,9 @@ export function InvoiceForm({<buttontype="button"onClick={() => {+ // analytics track event+ loglib.track("add_invoice_item");+append({name: "",amount: 1,@@ -914,8 +923,8 @@ export function InvoiceForm({htmlFor="total"className="block text-sm font-medium text-gray-700 mb-1">- Total in {currency} (this is calculated automatically based on Amount- and Net Price)+ Total in {currency} (calculated automatically based on Amount and Net+ Price)</label><div className="relative mt-1 rounded-md shadow-sm"><div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">diff --git a/src/app/components/invoice-pdf-download-link.tsx b/src/app/components/invoice-pdf-download-link.tsxindex 868dc7a..28616a1 100644--- a/src/app/components/invoice-pdf-download-link.tsx+++ b/src/app/components/invoice-pdf-download-link.tsx@@ -2,6 +2,7 @@ import { PDFDownloadLink } from "@react-pdf/renderer";import type { InvoiceData } from "@/app/schema";import dayjs from "dayjs";import { InvoicePdfTemplate } from "./invoice-pdf-template";+import { loglib } from "@loglib/tracker";export function InvoicePDFDownloadLink({invoiceData,@@ -15,6 +16,9 @@ export function InvoicePDFDownloadLink({document={<InvoicePdfTemplate invoiceData={invoiceData} />}fileName={`invoice-${invoiceDate}.pdf`}className="mb-4 lg:mb-0 w-full lg:w-[180px] text-center px-4 py-2 text-white bg-blue-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"+ onClick={() => {+ loglib.track("download_invoice");+ }}>{/* @ts-expect-error PR with fix: https://github.com/diegomura/react-pdf/pull/2888 */}{({ loading }) => (loading ? "Loading document..." : "Download PDF")}diff --git a/src/app/components/invoice-pdf-viewer.tsx b/src/app/components/invoice-pdf-viewer.tsxindex cbaddb9..fb83e0e 100644--- a/src/app/components/invoice-pdf-viewer.tsx+++ b/src/app/components/invoice-pdf-viewer.tsx@@ -2,7 +2,11 @@ import { PDFViewer } from "@react-pdf/renderer";export function InvoicePDFViewer({ children }: { children: React.ReactNode }) {return (- <PDFViewer width="100%" className="mb-4 h-[600px] lg:h-[650px] w-full">+ <PDFViewer+ width="100%"+ className="mb-4 h-[600px] lg:h-[650px] w-full"+ title="Invoice PDF Viewer"+ >{/* @ts-expect-error PR with fix?: https://github.com/diegomura/react-pdf/pull/2888 */}{children}</PDFViewer>diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex 2128d22..625e28a 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -1,6 +1,6 @@import type { Metadata } from "next";import { NuqsAdapter } from "nuqs/adapters/next/app";-import { Analytics } from "@vercel/analytics/next";+import Loglib from "@loglib/tracker/react";import "./globals.css";@@ -66,7 +66,11 @@ export default function RootLayout({<html lang="en"><body className={`antialiased`}><NuqsAdapter>{children}</NuqsAdapter>- <Analytics />+ <Loglib+ config={{+ id: "pdf-invoice-editor",+ }}+ /></body></html>);diff --git a/src/app/page.tsx b/src/app/page.tsxindex 2924620..4b8f535 100644--- a/src/app/page.tsx+++ b/src/app/page.tsx@@ -19,6 +19,7 @@ import {compressToEncodedURIComponent,decompressFromEncodedURIComponent,} from "lz-string";+import { loglib } from "@loglib/tracker";const InvoicePDFDownloadLink = dynamic(() =>@@ -179,7 +180,15 @@ export default function Home() {<div className="bg-white p-6 rounded-lg shadow-lg w-full max-w-7xl"><div className="flex flex-row flex-wrap lg:flex-nowrap items-center justify-between w-full"><h1 className="text-2xl font-bold mb-4 w-full text-center lg:text-left">- Free Invoice PDF Generator • Open Source+ Free Invoice PDF Generator •{" "}+ <a+ href="https://github.com/VladSez/pdf-invoice-generator"+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-2 hover:underline"+ >+ Open Source <GithubIcon />+ </a></h1><div className="w-full flex justify-center flex-wrap lg:flex-nowrap lg:justify-end gap-3 mb-1">@@ -194,6 +203,8 @@ export default function Home() {console.error("Failed to copy URL:", err);alert("Failed to copy URL to clipboard");});++ loglib.track("copy_link_to_invoice");}}className="inline-flex w-full lg:w-auto justify-center items-center px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-800 rounded-md">@@ -211,16 +222,7 @@ export default function Home() {onInvoiceDataChange={handleInvoiceDataChange}/></div>- <div className="flex justify-center mt-4">- <a- href="https://github.com/VladSez/pdf-invoice-generator"- target="_blank"- rel="noopener noreferrer"- className="inline-flex items-center gap-2 text-gray-600 hover:text-gray-900"- >- <GithubIcon />- </a>- </div>+ <hr className="my-4 block w-full lg:hidden" /></div><div className="lg:col-span-8 h-[600px] lg:h-[630px] w-full max-w-full"><InvoicePDFViewer>