惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
宝玉的分享
宝玉的分享
V
V2EX
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
IT之家
IT之家
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
Recent Announcements
Recent Announcements
人人都是产品经理
人人都是产品经理
博客园 - 司徒正美
美团技术团队
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
B
Blog RSS Feed

Deno

Deno 2.8 | Deno Claw Patrol: an open-source security firewall for agents | Deno Fresh 2.3: Zero JS by default, View Transitions, and Temporal support | Deno Deno 2.7: Temporal API, Windows ARM, and npm overrides | Deno Build a dinosaur runner game with Deno, pt. 6 | Deno Build a dinosaur runner game with Deno, pt. 5 | Deno Deno Deploy is Generally Available | Deno Introducing Deno Sandbox | Deno Build a dinosaur runner game with Deno, pt. 4 | Deno Build a dinosaur runner game with Deno, pt. 3 | Deno Build a dinosaur runner game with Deno, pt. 2 | Deno React / Next.js Denial-of-Service Vulnerability: Deno Deploy users protected | Deno Deno 2.6: dx is the new npx | Deno Build a dinosaur runner game with Deno, pt. 1 | Deno React Server Functions / Next.js Vulnerability: Deno Deploy users protected | Deno My highlights from the new Deno Deploy | Deno Deno's Other Open Source Projects | Deno How Deno protects against npm exploits | Deno Help Us Raise $200k to Free JavaScript from Oracle | Deno Deno 2.5: Permissions in the config file | Deno Fresh 2.0 Graduates to Beta, Adds Vite Support | Deno Deno 2.4: deno bundle is back | Deno JavaScript™ Trademark Update | Deno What's coming to JavaScript | Deno A brief history of JavaScript | Deno Reports of Deno's Demise Have Been Greatly Exaggerated | Deno An Update on Fresh | Deno How Plaid migrated 100 services to a new database platform 5x faster with Deno | Deno Deno 2.3: Improved deno compile, local npm packages, and more | Deno Add JSR packages with pnpm and Yarn | Deno
Announcing Growthbook on JSR | Deno
Andy Jiang · 2024-11-04 · via Deno

Users today are savvier than ever with more sites and apps to choose from. Leveraging product data and analytics is now table stakes for businesses, who are keen to understand and engage their users. But setting up and maintaining a data ingestion pipeline and experiment platform is not realistic for most teams.

We’re thrilled to announce that GrowthBook’s JavaScript SDK is now available on JSR.

GrowthBook, a leading open source Feature Flagging and Experimentation platform, lets you evaluate feature flags and run experiments in your JavaScript application. Their JavaScript SDK is lightweight, fast, does not require any external dependencies, and plugs into your existing event tracking tools (e.g. GA, Segment, etc.). It can also be used across any JavaScript environment, such as browsers and various JavaScript runtimes.

JSR is a modern open source JavaScript registry that simplifies publishing and importing JavaScript and TypeScript modules. JSR supports publishing TypeScript source code, auto-generating documentation and type definition files, provenance attestation for more security, and can be used with npm-like package managers. JSR has seen continued growth since launch, with over 400 new packages published weekly.

Using GrowthBook’s SDK via JSR offers an unparalleled developer experience, with first class TypeScript support, auto-generated documentation right in your code editor, and more.

Installing Growthbook

You can get started with Growthbook using the deno add command:

deno add jsr:@growthbook/growthbook

Or using npm:

npx jsr add @growthbook/growthbook

The above commands will generate a deno.json file, listing all your project dependencies.



{
  "imports": {
    "@growthbook/growthbook": "jsr:@growthbook/growthbook@0.1.2"
  }
}

Let’s use GrowthBook with an Express server.

In our main.ts file, we can write:

import express from "npm:express";
import { GrowthBook } from "@growthbook/growthbook";

const app = express();


app.use(function (req, res, next) {
  
  req.growthbook = new GrowthBook({
    apiHost: "https://cdn.growthbook.io",
    clientKey: "sdk-qtIKLlwNVKxdMIA5",
  });

  
  req.growthbook.setAttributes({
    id: req.user?.id,
  });

  
  res.on("close", () => req.growthbook.destroy());

  
  req.growthbook.init({ timeout: 1000 }).then(() => next());
});

app.get("/", (req, res) => {
  const gb = req.growthbook;

  
  if (gb.isOn("my-boolean-feature")) {
    res.send("Hello, boolean-feature!");
  }

  
  const value = gb.getFeatureValue("my-string-feature", "fallback");

  res.send(`Hello, ${value}!`);
});

console.log("Listening on port 8000");
app.listen(8000);

⚠️️ Note that you can import express via npm: specifier. When this is executed the first time, express is installed to a global cache. No node_modules folder needed.

Finally, you can run the following command to execute:

​​deno -A main.ts

Depending on how you’ve set your feature flags in the GrowthBook app (you can sign up for free), the response will be different:

Running the app shows fallback response

Check out the GrowthBook documentation to learn more about creating and running experiments, analyzing results, and various rollout processes for feature flags.

What’s next?

With GrowthBook’s JS SDK now on JSR, it’s even easier to bring the power of feature flags and A/B testing to any JavaScript environment.

Interested in modernizing your JS/TS module and making it easier for your users to use? Check out how to publish to JSR from these docs or this video demo.

🚨️ Read more about JSR 🚨️