SDK guide
One file, no dependencies, typed. Everything your extension needs to sign people in, check their plan, sell it, and hear what breaks.
Install
Download extensiongrowth.js and extensiongrowth.d.ts from your project's Install page and put them in your extension's source. Add identity and storage to the manifest's permissions. The Install page writes every snippet below with your own endpoint, feature keys and plans.
Create the client
Create it once, in a module the background script, popup and options page all import. Each part of the extension gets its own client; they share one session.
import { createClient } from "./extensiongrowth.js";
export const eg = createClient({ endpoint: "https://…/v1/projects/prj…" });Read the plan
ready() reads the saved session at once, without waiting for the network, then checks the plan in the background when it is more than a minute old or after a checkout. can() answers from what was read, so it is safe in a click handler. onChange hears every sign-in, sign-out and plan change, in every part of the extension.
const { user, access } = await eg.ready();
if (eg.can("no-limit")) runWithoutLimit();
const stop = eg.onChange(({ user, access }) => render(user, access));Sign in
signIn() opens your website's sign-in page in a small window. People sign in there with any way you have turned on under Sign-in, and the window closes with your extension signed in. There is no sign-in form inside an extension and nothing to set up in Google for it: the same page works in every Chromium browser, for every way of signing in.
Sell a plan
openCheckout({ plan, interval }) opens the checkout page of your website in a new tab, already signed in. openAccount() opens the account page, where the customer changes or cancels their plan and gets their invoices. Paddle confirms each payment and the plan changes at once; a popup opened afterwards shows it, and refresh() reads it straight away.
Sell where the feature is asked for: when can() says no, say what the plan adds and open checkout from there. Each no is counted on Analytics, once a day for each feature, so you see which paid feature people reach for most.
Count what people do
The SDK counts how your extension is used, for Analytics in the console: installs and updates, the people using it each day, week and month, and how many come back in each week after they install it. track() adds your own events, such as a note saved: how often, how many people a day, and how many did it for the first time. Choose the one that says the extension proved useful on Analytics, and it becomes the step to lead people to.
Nothing sent names the person. Each copy of the extension keeps the days it was used in its own storage and says only whether a report is its first of the day, the week or the month, with the weeks since it was installed, its version and the browser's time zone, read for a country and kept as nothing else. Create the client at the top of your service worker, so it hears the install. createClient({ endpoint, analytics: false }) counts nothing.
// Something that went well: count it, then maybe ask for a review.
eg.track("note-saved");
if (await eg.reviewMoment()) showReviewPrompt(() => eg.openReview());
// A paid feature asked for: can() says no, and the ask is counted.
if (!eg.can("search-all")) showUpgrade(() => eg.openCheckout({ plan: "pro" }));Ask for a review
Ratings and recent reviews move a listing up its store's results, and the people to ask are those it already helps. reviewMoment() says yes once a copy was installed a week ago or more and used on five days or more, and not again for 90 days after a review page opened. Ask right after something went well, never on install. openReview() opens the review page in the store that copy came from.
Crashes and errors
The SDK reports what breaks in your extension as it happens, for Errors in the console: every error a part of it did not catch and every promise it left refused, in the service worker, the popup, the options page, a side panel and your content scripts. Create the client in each part, as above. A content script hands its errors to the rest of your extension, so nothing is sent as the page it runs on. Report the errors your code catches with reportError().
// Every part that creates the client reports what it did not catch, on its own.
export const eg = createClient({ endpoint: "https://…/v1/projects/prj…" });
// One your code caught and handled: report it, with a few details of your own.
try {
await syncNotes();
} catch (error) {
eg.reportError(error, { step: "sync", notes: notes.length });
showRetry();
}Each report carries the error's stack, the part of the extension and the version it ran in, and the last steps before it: the events you track, a paid feature asked for, sign-in and checkout. Before anything leaves the browser, addresses, emails, tokens and long numbers are taken out of messages and details, and of a page your content script ran on only its site is kept. A copy sends a new error at once and adds up its repeats, so an error in a loop is one report. createClient({ endpoint, errors: false }) reports nothing.
Read your own source
A bundled extension's stack names one long line of its bundle. Build with source maps, and send each build's maps with the ExtensionGrowth CLI before you zip it: an error's stack then shows your own files, lines and the code around them, for the version that reported it. --remove takes the maps out of the folder once they are sent, so the store's zip has none.
# After each build, before you zip it for the store
npx -y @extensiongrowth/cli sourcemaps dist --removeAlerts, and a fix
Errors emails you when an error is new, when one you marked fixed comes back in that version or later, and when one spikes; it can post the same to Slack, Discord or any webhook. Mark an error fixed in the version that ships the fix: copies not updated yet may still report it, and only a report from that version on says it came back. Each error's page also reads in a terminal, whole, with npx -y @extensiongrowth/cli errors show and its number.
Help people
People write to you from your website's support page, which each store takes as the extension's support link: its address is under Support in the console, where you answer. Your answer reaches them by email and on the page, so nobody has to wait with the extension open.
openSupport() opens that page in a tab, signed in, and puts this extension and its version on a new case, with the browser it runs in: you never have to ask. eg.support does the same in screens of your own: list(), open(), read(), reply() and close() the signed-in person's cases, and unread() counts their cases with a reply they have not read, for a badge. Everything else they send is what they type.
// The quickest: your website's support page, signed in, with this extension and its version on a new case.
helpButton.onclick = () => eg.openSupport();
// Or screens of your own: a badge for replies not read yet, the person's cases, a new one, a reply.
const unread = await eg.support.unread();
const cases = await eg.support.list();
const item = await eg.support.open({ subject: "Sync stops", message: "What happened, step by step…" });
await eg.support.reply(item.id, "One more thing…");Open your community
Your community is a page of your website where the people who use your extension ask questions, share ideas and report problems, and you answer. You open it on Community in the console. openCommunity() opens it in a tab, signed in when someone is, and anyone can read it. With start it opens the form a topic is started with, as a question, an idea or a problem, and the topic says which of your extensions and which version it came from.
communityUnread() counts the topics the signed-in person started, replied in or said Me too on that have something new since they last read them, so your button can say so. People write under a name they choose there; their email address is never shown to others.
// A Community button in the popup or the options page.
communityButton.onclick = () => eg.openCommunity();
// "Report a problem" opens the form, and the topic says its version.
reportButton.onclick = () => eg.openCommunity({ start: "problem" });
// A mark beside the button while a topic they follow has something new.
const unread = await eg.communityUnread();
communityBadge.hidden = unread === 0;Check it works
The Install page of the console has a check beside its steps, and your extension ticks it as you use it: the SDK running, the permissions in your manifest, a customer signing in, the features it checks and the checkout it opens. A feature key with a typo, which would lock that feature for everyone, shows there the moment the extension asks for it. Only your extension itself can tick a sign-in.
While you build, create the client with the endpoint for a development build, also on the Install page. It takes any extension ID, so an unpacked copy signs in as it is, with any email and one code, and nobody pays. Ship with your project's own endpoint.
To fill the check, the SDK sends your extension's name and version, its own version, where it runs, which permissions it has, and the feature and plan keys it asks for: each once per run of the extension, and nothing about the person using it. createClient({ endpoint, report: false }) sends none of it.
Your own server
getToken() returns a signed token that lasts an hour and renews itself. Verify it against your project's keys, with your project id as its audience. Its sub is the customer, and it carries their email, plan, features and status.
The token tells your server who is calling and nothing more. ExtensionGrowth never accepts it, so your server, its logs and anyone who reads them can't act for the customer: not change their plan, not delete their account, not sign in as them.
// In the extension
const token = await eg.getToken();
await fetch("https://api.yourextension.com/convert", { headers: { authorization: `Bearer ${token}` } });
// On your server, with any JOSE library
const jwks = createRemoteJWKSet(new URL(`${endpoint}/jwks.json`));
const { payload } = await jwtVerify(token, jwks, { issuer: endpoint, audience: projectId });
payload.features.includes("no-limit");Reference
createClient({ endpoint, uninstallPage?, report?, analytics?, errors? })- The client for one project. The endpoint is on the Install page. uninstallPage: false leaves the uninstall address to you; report: false keeps the Install page's check from hearing how your extension uses the SDK; analytics: false counts nothing for Analytics; errors: false reports no crash or error.
ready()- Reads the saved session; resolves with { user, access }. Also sets your uninstall page as the address the browser opens when the extension is removed.
state- The last state read: { user, access }, both null when signed out.
can(feature)- Whether the signed-in person may use a feature. False when signed out. A no is counted for Analytics, once a day for each feature, as someone asking for it without the plan.
onChange(listener)- Runs on every change in any part of the extension. Returns a function that stops it.
signIn()- Opens your website's sign-in page in a small window, and resolves with the person once they are back.
signOut()- Signs out everywhere in the extension.
refresh()- Reads the plan again now.
getToken()- A signed, hour-long token for your own server, which ExtensionGrowth never accepts; null when signed out.
plans()- The plans on sale, with prices and features, to show in your own UI.
openCheckout({ plan, interval })- Opens checkout for a plan on your website, signed in.
openAccount()- Opens the account page on your website, signed in.
track(event)- Counts something people do, such as "note-saved": how often, how many people a day, and how many for the first time. Lower-case letters, digits and _ . : -, up to 48.
reviewMoment()- Whether now is a good moment to ask for a review: installed a week or more, used on five days or more, and not asked in the last 90 days.
openReview()- Opens the extension's review page in the store it came from.
reportError(error, details?)- Reports an error your code caught, for Errors in the console, with up to ten details of your own: a name and a short text, number or yes/no each. The errors you did not catch are reported on their own.
openSupport({ caseId? })- Opens your website's support page in a tab, signed in when someone is, with this extension, its version and the browser on a new case. caseId opens that case.
support.list()- The signed-in person's support cases, newest first: subject, number, status (open, answered, closed), the newest words, and unread when you replied since they last read it.
support.unread()- How many cases have a reply the person has not read: for a badge. 0 when signed out.
support.open({ subject, message })- Opens a case from the extension, naming it, its version and the browser. The person gets a copy by email, and you a notice.
support.read(caseId)- One case with its whole thread, oldest first; reading it marks your replies read.
support.reply(caseId, message, { close }) · support.close(caseId)- Writes in a case, which opens it again when closed, or with close: true closes it with the person's last word; or closes one the person no longer needs.
openCommunity({ start? })- Opens your community on your website, signed in when someone is. start: "question", "idea" or "problem" opens the form a topic is started with, which says the extension and version it came from.
communityUnread()- How many topics the signed-in person follows in your community have something new. 0 when signed out or while no community is open.
Your website
Your extension opens one website for sign-in, checkout and the customer's account. You write it on your project's Website page and we host it: there is nothing to build, upload or deploy.
Writing it
A page is a list of sections: an opening with your headline and a picture, features, screenshots, how it works, text, questions, what people say, pricing, and a closing install button. Click a section on the page to change it, or type straight onto the page. A theme, your accent colour and your logo give every page your look. To start, paste the description from your store listing: its words fill your home page. Sell several extensions under one name? They share one website: home speaks for the brand, and each extension can have a page of its own.
The pages that come with it
Sign-in, the customer's account, checkout and, if you ask why people leave, the uninstall page are ours, in your look, at /sign-in, /account, /checkout and /uninstall. You write your terms of service, privacy policy and refund policy, or start from our drafts; Paddle's review looks for them, and the Website page says what it would still miss.
What it counts
Each visit to your website, each page opened and each press on its install button is counted. Your Overview shows them day by day beside your new customers and what they paid, and Analytics shows which pages people begin on and press install from, which of your launch links brought them, and their kind of device, browser and country. A count keeps nothing about the visitor. No cookie is set, nothing is kept in their browser, and of the page they came from only the kind of place is added up: a search engine, an AI assistant, a store or another website. Their country is read from their time zone, and crawlers are not counted.
An install button tells the Chrome Web Store and Firefox Add-ons which website, and which launch link, sent the press, so their own statistics name you as the source. Connect Google Search Console or Bing Webmaster Tools on Analytics to see the searches that show your website.
Publishing
Nothing changes for customers until you publish. Preview first puts your draft at an address of its own, where sign-in and checkout run on your sandbox and nobody pays. Every publish is kept, so an earlier one can go back online in a click. Once your website is online, add your own domain.
A link to your sign-in page from another site of yours can say where to come back to. List that site under Sign-in.
<a href="https://www.yourextension.com/sign-in?return=%2Fpricing">Sign in</a>Errors
Every failure is an ExtensionGrowthError with a stable code and a message written for the person using your extension, so you can show it as it is.
bad_endpoint- The endpoint is not the one from the Install page.
identity_missing- The manifest lacks the identity permission.
sign_in_closed- The person closed the sign-in window. Nothing to show.
sign_in_failed- Sign-in did not finish. Offer to try again.
signed_out- The action needs someone signed in.
no_website- Checkout, sign-in and openSupport() need your website, which is not online yet.
offline- No connection. The saved plan still answers can().
no_store- openReview() has nowhere to go: the extension is in no store yet.
too_many_cases- support.open() while ten of the person's cases are still open: add to one, or close one.
rate_limited- support.open() past five new cases in an hour, or reply() past thirty messages: show the message, and let them try later.
case_full- support.reply() on a case of 200 messages: open a new case to go on.
no_community- openCommunity() has nowhere to go: you have no community open.