Skip to main content

Official analytics SDK for Discord bots using Cordia

Reason this release was yanked:

Contains circular import issues and lacks startup handshake. Upgrade to 1.1.4.

Project description

Cordia

The official Python analytics SDK for Discord bots.

Async-first design built on aiohttp. Tracks commands, users, server count, and uptime with automatic batching and background heartbeat.

PyPI License: MIT

Install

pip install cordia

Requires Python 3.8+.

Quick Start

import cordia
import os

client = cordia.CordiaClient(
    api_key=os.getenv("CORDIA_API_KEY"),
    bot_id=os.getenv("CORDIA_BOT_ID"),
)

Discord.py Example

import discord
from discord.ext import commands
import cordia
import os

intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)

cordia_client = cordia.CordiaClient(
    api_key=os.getenv("CORDIA_API_KEY"),
    bot_id=os.getenv("CORDIA_BOT_ID"),
)

@bot.event
async def on_ready():
    print(f"Logged in as {bot.user}")
    await cordia_client.post_guild_count(len(bot.guilds))
    cordia_client.start(bot.loop)

@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")
    await cordia_client.track_command(
        command="ping",
        user_id=str(ctx.author.id),
        guild_id=str(ctx.guild.id) if ctx.guild else None,
    )

bot.run(os.getenv("DISCORD_TOKEN"))

Configuration

Parameter Type Default Description
api_key str required API key from the Cordia dashboard
bot_id str required Your bot's unique ID
base_url str https://api.cordialane.com/api/v1 API endpoint
heartbeat_interval int 30000 Heartbeat interval (ms)
auto_heartbeat bool True Start heartbeat on start()
batch_size int 10 Events before auto-flush
flush_interval int 5000 Auto-flush interval (ms)
debug bool False Enable debug logging

API

Method Description
start(loop) Start background tasks (flush + heartbeat)
track_command(...) Queue a command event
track_user(...) Queue a user activity event
post_guild_count(count) Report server count (immediate)
start_heartbeat(loop) Start heartbeat manually
stop_heartbeat() Stop heartbeat
get_uptime() Returns uptime in ms
flush() Force-flush queued events
close() Stop tasks, flush, and close session

Documentation

Full guides and API reference at docs.cordialane.com.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cordia-1.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cordia-1.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file cordia-1.1.1.tar.gz.

File metadata

  • Download URL: cordia-1.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cordia-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9f483377865aea11a1ee4539bd4b423e93c087b64edea3f31244f496a3f24fda
MD5 b45bd3e723f9d694de615642d04f9e4d
BLAKE2b-256 4f18af48364a504af46386f2f72d6d747455fcc281c6cb1531fbdce099ffcd82

See more details on using hashes here.

File details

Details for the file cordia-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: cordia-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cordia-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc47e1d10b607fd277d4729586d96a6dda15987f3d0f1db7a780aefc28c7a46
MD5 4ebc753308e455275be884b05341e136
BLAKE2b-256 9232c2d99c7b23a175876d5d777b88109fea438ce1c89212b8f3cd3a9b6a80c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page