Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f9c5d54
feat: Add new error codes and implement AnalyticsBase class for track…
ValDesign22 Apr 23, 2025
e5b3cd2
feat: Enhance documentation for events and trackGuilds methods in Ana…
ValDesign22 Apr 23, 2025
e26a091
feat: Refactor AnalyticsBase and DiscordAnalytics classes for improve…
ValDesign22 Apr 23, 2025
b578178
feat: Add documentation for trackInteractions method in DiscordAnalyt…
ValDesign22 Apr 23, 2025
9a294fe
feat: Add updateOrInsert method and refactor interaction tracking in …
ValDesign22 Apr 24, 2025
05da160
fix: Correct locale type handling in calculateGuildMembersRepartition…
ValDesign22 Apr 24, 2025
b434099
feat: Add calculateGuildMembers method and refactor guild members han…
ValDesign22 Apr 24, 2025
c7dc161
refactor: Simplify initialization and tracking methods in DiscordAnal…
ValDesign22 Apr 24, 2025
2708d5c
fix: Update documentation links in README for consistency
ValDesign22 Apr 24, 2025
0eb6793
feat: Initialize analytics before tracking events in usage examples
ValDesign22 Apr 24, 2025
d4af7e5
chore: Bump version to 3.5.0 in package.json
ValDesign22 Apr 24, 2025
381a4ae
refactor: Update import statements and improve debug logging in Disco…
ValDesign22 Apr 24, 2025
34022c8
feat: Add client_id property and improve error handling in AnalyticsB…
ValDesign22 Apr 24, 2025
84366d5
feat: Add ensure method call in CustomEvent constructor for validation
ValDesign22 Apr 24, 2025
1a8b1e8
feat: Enhance user type tracking in trackInteractions method (eris)
ValDesign22 Apr 24, 2025
f05acc3
refactor: Remove redundant ensure method calls in CustomEvent class
ValDesign22 Apr 25, 2025
29a978a
feat: add Discord Analytics packages for various libraries (discord.j…
ValDesign22 Apr 25, 2025
2362984
refactor: Refactor code structure for improved readability and mainta…
ValDesign22 Apr 25, 2025
dd035ba
chore: Update GitHub Actions workflow to use pnpm and latest action v…
ValDesign22 Apr 25, 2025
00bfda9
chore: Update Node.js version matrix in GitHub Actions workflow
ValDesign22 Apr 25, 2025
388fcee
refactor: Remove commented-out steps from TypeScript test workflow fo…
ValDesign22 Apr 25, 2025
041755a
chore: Update GitHub Actions workflow to use latest action versions a…
ValDesign22 Apr 25, 2025
a9ad012
refactor: Change API call method from POST to GET for event tracking …
ValDesign22 Apr 25, 2025
6b3fac0
feat: Add tests for AnalyticsBase and example implementations for Dis…
ValDesign22 Apr 27, 2025
b1e5a1f
refactor: Remove redundant comment from DiscordAnalytics initialization
ValDesign22 Apr 27, 2025
1cd73db
feat: Add sharding example using ShardingManager
ValDesign22 Apr 27, 2025
f54fe30
feat: Add example for DiscordAnalytics (discordjs-light) with interac…
ValDesign22 Apr 27, 2025
32ec1a9
feat(eris): Add example implementation for DiscordAnalytics with inte…
ValDesign22 Apr 27, 2025
6d0f58d
feat(oceanic): Implement DiscordAnalytics example with interaction ha…
ValDesign22 Apr 27, 2025
4d38ded
fix: Update package installation and import paths for DiscordAnalytic…
ValDesign22 Apr 27, 2025
7eb6827
fix: Fixed some typos and bugs
ValDesign22 Apr 30, 2025
c00f17a
fix: Fixed a problem in increment function
ValDesign22 Apr 30, 2025
1749133
refactor: Removed unecessary condition
ValDesign22 Apr 30, 2025
bf83ff9
chore: Remove obsolete test workflow and add new CI workflow with bui…
ValDesign22 Apr 30, 2025
c8ac478
fix: Corrected string escaping in error messages and labels
ValDesign22 Apr 30, 2025
895c68a
test: Add test for updating event value in AnalyticsBase
ValDesign22 Apr 30, 2025
d079fa4
feat: Add coverage configuration to Vitest for package source files
ValDesign22 Apr 30, 2025
9da565a
feat: Added README for every package
ValDesign22 May 18, 2025
f9bdb57
fix: Replace error throwing with console error logging for better err…
ValDesign22 Jul 23, 2025
2a998fc
feat!: skip Discord Analytics initialization if NODE_ENV is not "prod…
Nonolanlan1007 Dec 6, 2025
ddd4af0
refactor!: --dev argument renamed to --fast to enhance comprehension
Nonolanlan1007 Dec 6, 2025
5ff785c
fix: custom events
Nonolanlan1007 Dec 7, 2025
273a459
Merge branch 'master' into feat/custom-events
Nonolanlan1007 Dec 17, 2025
6821ceb
refactor: removed useless file but required to merge
Nonolanlan1007 Dec 17, 2025
a636b53
fix(tests): fixed test error on core package
ValDesign22 Dec 17, 2025
5902a0b
chore: fix README file name
Nonolanlan1007 Dec 17, 2025
f1fe949
refactor: removed useless import
Nonolanlan1007 Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 19.x, 20.x, 21.x, 22.x]
fail-fast: true

name: Test TypeScript build
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build the package
run: pnpm build
- name: Run tests
run: pnpm run coverage
20 changes: 9 additions & 11 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v3
version: 10
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
Expand All @@ -29,12 +30,13 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v3
version: 10
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
Expand All @@ -43,11 +45,7 @@ jobs:
run: pnpm install --frozen-lock
- name: Build the package
run: pnpm build
- name: Move files
run: rm -r ./src && mv ./dist/src/* ./ && rm -r ./dist
- name: Edit package.json imports
run: sed -i 's#../../package.json#../package.json#' discordjs/index.js && sed -i 's#../../package.json#../package.json#' discordjs-light/index.js && sed -i 's#../../package.json#../package.json#' eris/index.js && sed -i 's#../../package.json#../package.json#' oceanic/index.js
- name: Publish to NPM
run: pnpm publish --no-git-checks
run: pnpm publish --recursive --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
26 changes: 0 additions & 26 deletions .github/workflows/test-ts.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

node_modules
dist
coverage
.idea

# Files
Expand Down
9 changes: 6 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
node_modules
src
dist/test
test
examples
coverage
tsconfig.json
*.ts
.idea
.github
test
.github
114 changes: 13 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,110 +1,22 @@
# Discord Analytics

## Installing the package
## Overview
Discord Analytics is a powerful tool that allows you to track and analyze your Discord bot's performance and user engagement. This repository contains packages for different Discord libraries, including Discord.js, Eris, Oceanic.js, and Discord.js-light.
These packages provide a simple and efficient way to integrate Discord Analytics into your bot, enabling you to gather valuable insights and improve your bot's functionality.

## Installing the packages
> **Note:** Use the package manager of your choice (npm, yarn, pnpm) to install the packages.

```bash
npm install discord-analytics
npm install @discordanalytics/core # Core package
npm install @discordanalytics/discordjs # For Discord.js
npm install @discordanalytics/discordjs-light # For Discord.js-light
npm install @discordanalytics/eris # For Eris
npm install @discordanalytics/oceanic # For Oceanic.js
```

## Usage

> **Note:** To use Discord Analytics, you need to have an API token. Check the docs for more informations : https://docs.discordanalytics.xyz/get-started/bot-registration

**With Discord.js:**

```js
// Import Discord.js's client and intents
const { Client, IntentsBitField } = require("discord.js")
// import discord-analytics
const { default: DiscordAnalytics } = require("discord-analytics/discordjs")

// Create Discord client
const client = new Client({
intents: [IntentsBitField.Flags.Guilds] // This intent is required
});

// Create Discord Analytics instance
// Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
const analytics = new DiscordAnalytics({
client: client,
apiToken: 'YOUR_API_TOKEN',
sharded: false // Set it to true if your bot use shards
});

// start tracking selected events
analytics.trackEvents();

// When Discord client is ready
client.on('ready', () => {
console.log("Bot is ready!");
});

// Login to Discord
// Don't forget to replace token by your Discord bot token !
client.login('token');
```

**With Eris:**

```js
const {Client} = require("eris");
const {default: DiscordAnalytics} = require("discord-analytics/eris");

// Create Eris client.
// Don't forget to replace token by your Discord bot token !
const bot = new Client("token");

bot.on("ready", () => {
// Create Discord Analytics instance
// Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
const analytics = new DiscordAnalytics({
client: client,
apiToken: 'YOUR_API_TOKEN'
});

// start tracking selected events
analytics.trackEvents();

console.log("Ready!");
});

// Login to Discord
bot.connect();
```

**With Oceanic.js:**
```js
// Import Discord.js's client and intents
const { Client } = require("oceanic.js")
// import discord-analytics
const { default: DiscordAnalytics } = require("discord-analytics/oceanic")

// Create Discord client
const client = new Client({
auth: "Bot <YOUR_BOT_TOKEN>",
gateway: {
intents: ["GUILDS"] // This intent is required
}
})

// Create Discord Analytics instance
// Don't forget to replace YOUR_API_TOKEN by your Discord Analytics token !
const analytics = new DiscordAnalytics({
client: client,
apiToken: 'YOUR_API_TOKEN'
});

// start tracking selected events
analytics.trackEvents();

// When Discord client is ready
client.on('ready', () => {
console.log("Bot is ready!");
});

// Login to Discord
// Don't forget to replace token by your Discord bot token !
client.login('token');
```
[Discord.js](./packages/discordjs/README.md) | [Discord.js-light](./packages/discordjs-light/README.md) | [Eris](./packages/eris/README.md) | [Oceanic.js](./packages/oceanic/README.md)

> For advanced usages and updated docs, please check https://docs.discordanalytics.xyz/get-started/installation
> For advanced usages and updated docs, please check https://discordanalytics.xyz/docs/main/get-started/advanced-usage
57 changes: 16 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,30 @@
{
"name": "discord-analytics",
"version": "2.5.0",
"description": "A discord bot analytics to send your bot data",
"main": "dist/index.js",
"version": "0.0.0",
"author": "Discord Analytics",
"homepage": "https://discordanalytics.xyz",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"init": "tsc --init",
"test:djs": "nodemon src/test/discordjs/index.ts --dev",
"test:eris": "nodemon src/test/eris/index.ts --dev",
"test:oceanic": "nodemon src/test/oceanic/index.ts --dev",
"build": "tsc"
"build": "pnpm -r run build",
"test": "vitest",
"coverage": "vitest run --coverage"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DiscordAnalytics/node-package.git"
},
"keywords": [
"Javascript",
"Discord",
"Discord.js",
"Discord.js-Light",
"Eris",
"API",
"Analytics",
"Oceanic"
],
"author": "Discord Analytics",
"license": "MIT",
"bugs": {
"url": "https://github.com/DiscordAnalytics/node-package/issues"
},
"homepage": "https://discordanalytics.xyz",
"devDependencies": {
"@types/node": "^20.17.11",
"@types/node-fetch": "^2.6.12",
"discord.js": "^14.17.2",
"discord.js-light": "^4.10.0",
"dotenv": "^16.4.7",
"eris": "^0.17.2",
"nodemon": "^3.1.9",
"oceanic.js": "^1.11.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
},
"dependencies": {
"node-fetch": "^2.7.0"
},
"peerDependencies": {
"discord.js": "14.x",
"discord.js-light": "4.10.0",
"eris": ">=0.17.2",
"oceanic.js": ">= 1.11.0 < 1.12.0"
"@types/node": "^22.15.2",
"@vitest/coverage-v8": "3.1.2",
"dotenv": "^16.5.0",
"typescript": "^5.8.3",
"vitest": "^3.1.2"
}
}
24 changes: 24 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Discord Analytics

## Overview
This package is a wrapper for the Discord Analytics API. It allows you to track events and send them to the Discord Analytics API.

## Installation
You can install the package using npm:

```bash
npm install @discordanalytics/core
# or
yarn add @discordanalytics/core
# or
pnpm add @discordanalytics/core
```

### Usage
Discord Analytics core package is used by other packages like `@discordanalytics/discordjs`, `@discordanalytics/discordjs-light`, `@discordanalytics/eris`, and `@discordanalytics/oceanic`. You don't need to use this package directly unless you want to use the core features without any wrapper.

## API
### `AnalyticsBase`
The main class of the package. It is used to track events and send them to the Discord Analytics API.
### `CustomEvent`
A class that represents a custom event. It is used to track custom events and send them to the Discord Analytics API.
27 changes: 27 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@discordanalytics/core",
"version": "3.5.0",
"description": "Core package to work with Discord Analytics",
"main": "dist/index.js",
"author": "Discord Analytics",
"homepage": "https://discordanalytics.xyz",
"readme": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/DiscordAnalytics/node-package.git"
},
"bugs": {
"url": "https://github.com/DiscordAnalytics/node-package/issues"
},
"scripts": {
"build": "tsc"
},
"dependencies": {
"node-fetch": "^2.7.0"
},
"devDependencies": {
"@types/node": "*",
"@types/node-fetch": "2.6.12",
"typescript": "*"
}
}
Loading
Loading