mock-event 961 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. from sentry.runner import configure
  3. configure()
  4. import argparse
  5. import sys
  6. from django.utils import timezone
  7. from sentry.models import Project
  8. from sentry.utils.samples import create_sample_event
  9. def main(project, sample_type):
  10. org_slug, project_slug = project.split("/", 1)
  11. project = Project.objects.get(organization__slug=org_slug, slug=project_slug)
  12. event = create_sample_event(project=project, platform=sample_type)
  13. if not event:
  14. sys.stderr.write("ERR: No event created. Was the sample type valid?\n")
  15. sys.exit(1)
  16. if not project.first_event:
  17. project.update(first_event=timezone.now())
  18. sys.stdout.write(f"> Created event {event.event_id}\n")
  19. if __name__ == "__main__":
  20. parser = argparse.ArgumentParser()
  21. parser.add_argument("project")
  22. parser.add_argument("sample_type")
  23. args = parser.parse_args()
  24. main(project=args.project, sample_type=args.sample_type)