Skip to main content

Add your description here

Project description

django-trackmate

django-trackmate is a lightweight and customizable Django package for tracking API requests, login/logout activities, and user-defined actions within your application. This package is designed to simplify activity tracking and help you gain actionable insights into user behavior.


🚀 Features

  • Request Logging: Automatically log incoming API requests with detailed metadata.
  • Login/Logout Tracking: Monitor user authentication events seamlessly.
  • Custom Action Logs: Track user actions across your application.
  • Django Admin Integration: View, filter, and manage activity logs in the admin panel.
  • GenericForeignKey Support: Log actions related to various models effortlessly.
  • Highly Configurable: Exclude paths, customize log details, and more.

📦 Installation

  1. Using pip:

    pip install django-trackmate
    

    or using uv:

    uv add django-trackmate
    
  2. Add trackmate to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        'django_trackmate',
    ]
    
  3. Run migrations to set up the necessary database tables:

    python manage.py makemigrations django_trackmate
    python manage.py migrate
    

🛠 Usage

Logging Custom Actions

Use the tracker decorator to log custom actions:

from django_trackmate import tracker

@tracker()
def my_api_view(request):
    ...

Extending Functionality

Directly create activity logs using the ActivityLog model:

from django_trackmate.models import ActivityLog

    ActivityLog.objects.create(
        actor=None,
        action_type=LOGIN_FAILED,
        action_time=datetime.now(),
        remarks=message
    )

Parameters

  • content_object: An instance of a Django model to link to the activity log.
  • actor: The user who performed the action.
  • action_type: The type of action being logged. Choices: "Create", "Read", "Update", "Delete", "Login", "Logout", "Login Failed".
  • action_time: The timestamp of the action.
  • remarks: Additional details about the action.
  • ip_address: The IP address of the user's request.
  • status: The status of the action. Choices: "Success", "Failed".
  • status_code: The HTTP status code associated with the action.
  • response: The response data associated with the action.
  • data: The request data associated with the action.

📊 Viewing Logs

  • View logs in the Django Admin under the Activity Logs section.
  • Use filters to sort by user, action type, timestamp, or related object.

🧪 Running Tests

Run the test suite to ensure everything is functioning correctly:

python manage.py test trackmate

💡 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Submit a pull request with a detailed description of the changes.

📄 License

This project is licensed under the MIT License. See the LICENSE file for more details.


📧 Support

If you encounter any issues or have questions, feel free to open an issue on GitHub or email us at aime.degbey@kodesio.com.


🏗 Built With

  • Django: The web framework for perfectionists with deadlines.
  • Python: Simplicity and flexibility for building scalable software.

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

django_trackmate-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

django_trackmate-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file django_trackmate-0.1.0.tar.gz.

File metadata

  • Download URL: django_trackmate-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for django_trackmate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12954c6ad493d52d412f6802c235f9e05930991b551c5da8e8bc3472186e8667
MD5 b79f636393917d5fd321867ab9464526
BLAKE2b-256 06ce6987e31141bd5c77e783512d56927432c0133b24a133593cedefec794542

See more details on using hashes here.

File details

Details for the file django_trackmate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_trackmate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2beba72da08ce6022cd3c8b995b36ab18fe3dbed1a032abc0d2c11b3d96f0867
MD5 5577bc82964aeee3a600750472186f83
BLAKE2b-256 69b8c8ddd90de5cd6d0254eed41e552f39e5f20236b061dcb2dff03441b9407f

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