@aptabase/electron

中文文档
0.3.1发布于 2023/11/05MITTypeScriptESM + CJS零依赖近 30 天下载 9137

Electron SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps

原始使用文档

Aptabase

Electron SDK for Aptabase

Instrument your Electron apps with Aptabase, an Open Source, Privacy-First, and Simple Analytics for Mobile, Desktop, and Web Apps.

Install

Install the SDK using your preferred JavaScript package manager

npm add @aptabase/electron

Usage

First, you need to get your App Key from Aptabase, you can find it in the Instructions menu on the left side menu.

On your Electron main's process, initialize the SDK before the app is ready:

import { initialize } from "@aptabase/electron/main";

initialize("<YOUR_APP_KEY>"); // 👈 this is where you enter your App Key

app.whenReady().then(() => {
  // ... the rest of your app initialization code
});

Afterward, you can start tracking events with trackEvent:

import { trackEvent } from "@aptabase/electron/renderer";

trackEvent("app_started"); // An event with no properties
trackEvent("screen_view", { name: "Settings" }); // An event with a custom property

NOTE: The trackEvent function is available under separate import paths, depending on where you want to track the event from.

  • import from @aptabase/electron/renderer to track events from the renderer process
  • import from @aptabase/electron/main to track events from the main process

The instruction above is recommended for modern setups of Electron. For older versions of Electron, please refer to the alternative instructions.

A few important notes:

  1. The SDK will automatically enhance the event with some useful information, like the OS, the app version, and other things.
  2. You're in control of what gets sent to Aptabase. This SDK does not automatically track any events, you need to call trackEvent manually.
    • Because of this, it's generally recommended to at least track an event at startup
  3. You do not need to await for the trackEvent function, it'll run in the background.
  4. Only strings and numbers values are allowed on custom properties

版本与发布记录

@aptabase/electron 共发布 11 个版本,首次发布于 2023/05/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.3.1latest2023/11/053 年前
0.3.02023/10/303 年前
0.2.32023/10/273 年前
0.2.22023/05/283 年前
0.2.12023/05/253 年前
0.2.02023/05/253 年前

关于 @aptabase/electron 的常见问题

@aptabase/electron 是什么?

Electron SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps

如何安装 @aptabase/electron?

在项目目录运行 npm install @aptabase/electron,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:electron(>= 3.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aptabase/electron 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aptabase/electron 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@aptabase/electron 可以商用吗?

@aptabase/electron 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aptabase/electron 的下载量有多少?

根据 npm 官方下载统计,@aptabase/electron 在 2026/10/07 – 2026/11/05 这 30 天内被下载 9,137 次,日均约 305 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aptabase/electron 还在维护吗?

最新版本 0.3.1 发布于 2023/11/05(3 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/05/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。