old_contents: import aiohttp
  import asyncio
  import hashlib
  
  from cogs.utils.config import write_config_value
  from discord.ext import commands
  
  class Track:
      def __init__(self, bot):
          self.bot = bot
          self.url = "http://115.69.164.101:8080"
          if not hasattr(bot, "session"):
              bot.session = aiohttp.ClientSession(loop=bot.loop)
          bot.before_invoke(self.register_command)
  
      @commands.command()
      async def toggletracking(self, ctx):
          """Toggle light tracking of data."""
          self.bot.track = not self.bot.track
          write_config_value("config", "track", self.bot.track)
          await ctx.send(self.bot.bot_prefix + "Successfully set tracking to {}.".format(self.bot.track))
  
      @commands.command()
      async def complain(self, ctx, *, message):
          """Send a complaint to the bot developers. We can't respond to these, so please don't ask support questions with this."""
          async with self.bot.session.post(self.url + "/complaint", data={"complaint": message}) as resp:
              pass
          await ctx.send(self.bot.bot_prefix + "Successfully sent a complaint.")
  
      async def register_command(self, ctx):
          if self.bot.track:
              async with self.bot.session.post(self.url + "/command", data={"command_name": ctx.command.name, "guild_id": str(ctx.guild.id), "guild_name": ctx.guild.name}) as resp:
                  pass
  
      async def heartbeat(self):
          await self.bot.wait_until_ready()
          while True:
              if self.bot.track:
                  async with self.bot.session.post(self.url + "/ping", data={"user_hash": hashlib.sha256(str(self.bot.user.id).encode()).hexdigest()}) as resp:
                      pass
              await asyncio.sleep(60)
  
  
  def setup(bot):
      track = Track(bot)
      bot.loop.create_task(track.heartbeat())
      bot.add_cog(Track(bot))
  
new_contents: import aiohttp
  import asyncio
  import hashlib
  
  from cogs.utils.config import write_config_value
  from discord.ext import commands
  
  class Track:
      def __init__(self, bot):
          self.bot = bot
          self.url = "http://115.69.164.101:8080"
          if not hasattr(bot, "session"):
              bot.session = aiohttp.ClientSession(loop=bot.loop)
          bot.before_invoke(self.register_command)
  
      @commands.command()
      async def toggletracking(self, ctx):
          """Toggle light tracking of data."""
          self.bot.track = not self.bot.track
          write_config_value("config", "track", self.bot.track)
          await ctx.send(self.bot.bot_prefix + "Successfully set tracking to {}.".format(self.bot.track))
  
      @commands.command()
      async def complain(self, ctx, *, message):
          """Send a complaint to the bot developers. We can't respond to these, so please don't ask support questions with this."""
          async with self.bot.session.post(self.url + "/complaint", data={"complaint": message}) as resp:
              pass
          await ctx.send(self.bot.bot_prefix + "Successfully sent a complaint.")
  
      async def register_command(self, ctx):
          if self.bot.track:
              async with self.bot.session.post(self.url + "/command", data={"command_name": ctx.command.name, "guild_id": str(ctx.guild.id), "guild_name": ctx.guild.name}) as resp:
                  pass
  
      async def heartbeat(self):
          await self.bot.wait_until_ready()
          while True:
              if self.bot.track:
                  async with self.bot.session.post(self.url + "/ping", data={"user_hash": hashlib.sha256(str(self.bot.user.id).encode()).hexdigest()}) as resp:
                      pass
              await asyncio.sleep(60)
  
      async def on_error(self, error):
          if self.bot.track:
              async with self.bot.session.post(self.url + "/error", data={"error_type": type(error).__name__, "error_message": str(error)}) as resp:
                  pass
  
      async def on_command_error(self, ctx, error):
          if self.bot.track:
              async with self.bot.session.post(self.url + "/commanderror", data={"error_type": type(error).__name__, "error_message": str(error), "command_name": ctx.command.name}) as resp:
                  pass
  
  
  def setup(bot):
      track = Track(bot)
      bot.loop.create_task(track.heartbeat())
      bot.add_cog(Track(bot))
  
subject: Add error tracking