import sentry_heroku

from sentry.plugins import ReleaseHook, ReleaseTrackingPlugin


class HerokuReleaseHook(ReleaseHook):
    def handle(self, request):
        self.finish_release(
            version=request.POST['head_long'],
        )


class HerokuPlugin(ReleaseTrackingPlugin):
    author = 'Sentry Team'
    author_url = 'https://github.com/getsentry'
    resource_links = (
        ('Bug Tracker', 'https://github.com/getsentry/sentry-heroku/issues'),
        ('Source', 'https://github.com/getsentry/sentry-heroku'),
    )

    title = 'Heroku'
    slug = 'heroku'
    description = 'Integrate Heroku release tracking.'
    version = sentry_heroku.VERSION

    def get_release_doc_html(self, hook_url):
        return """
        <p>Add Sentry as a deploy hook to automatically track new releases.</p>
        <pre class="clippy">heroku addons:create deployhooks:http --url={hook_url}</pre>
        """.format(hook_url=hook_url)

    def get_release_hook(self):
        return HerokuReleaseHook

import sentry_heroku

from sentry.plugins import ReleaseHook, ReleaseTrackingPlugin


class HerokuReleaseHook(ReleaseHook):
    def handle(self, request):
        self.finish_release(
            version=request.POST['head_long'],
            url=request.POST['url'],
            environment=request.POST['app'],
        )


class HerokuPlugin(ReleaseTrackingPlugin):
    author = 'Sentry Team'
    author_url = 'https://github.com/getsentry'
    resource_links = (
        ('Bug Tracker', 'https://github.com/getsentry/sentry-heroku/issues'),
        ('Source', 'https://github.com/getsentry/sentry-heroku'),
    )

    title = 'Heroku'
    slug = 'heroku'
    description = 'Integrate Heroku release tracking.'
    version = sentry_heroku.VERSION

    def get_release_doc_html(self, hook_url):
        return """
        <p>Add Sentry as a deploy hook to automatically track new releases.</p>
        <pre class="clippy">heroku addons:create deployhooks:http --url={hook_url}</pre>
        """.format(hook_url=hook_url)

    def get_release_hook(self):
        return HerokuReleaseHook

Add url and environment to payload
Add url and environment to payload

  import sentry_heroku
  
  from sentry.plugins import ReleaseHook, ReleaseTrackingPlugin
  
  
  class HerokuReleaseHook(ReleaseHook):
      def handle(self, request):
          self.finish_release(
              version=request.POST['head_long'],
+             url=request.POST['url'],
+             environment=request.POST['app'],
          )
  
  
  class HerokuPlugin(ReleaseTrackingPlugin):
      author = 'Sentry Team'
      author_url = 'https://github.com/getsentry'
      resource_links = (
          ('Bug Tracker', 'https://github.com/getsentry/sentry-heroku/issues'),
          ('Source', 'https://github.com/getsentry/sentry-heroku'),
      )
  
      title = 'Heroku'
      slug = 'heroku'
      description = 'Integrate Heroku release tracking.'
      version = sentry_heroku.VERSION
  
      def get_release_doc_html(self, hook_url):
          return """
          <p>Add Sentry as a deploy hook to automatically track new releases.</p>
          <pre class="clippy">heroku addons:create deployhooks:http --url={hook_url}</pre>
          """.format(hook_url=hook_url)
  
      def get_release_hook(self):
          return HerokuReleaseHook
  
Add url and environment to payload
## Code Before:
import sentry_heroku

from sentry.plugins import ReleaseHook, ReleaseTrackingPlugin


class HerokuReleaseHook(ReleaseHook):
    def handle(self, request):
        self.finish_release(
            version=request.POST['head_long'],
        )


class HerokuPlugin(ReleaseTrackingPlugin):
    author = 'Sentry Team'
    author_url = 'https://github.com/getsentry'
    resource_links = (
        ('Bug Tracker', 'https://github.com/getsentry/sentry-heroku/issues'),
        ('Source', 'https://github.com/getsentry/sentry-heroku'),
    )

    title = 'Heroku'
    slug = 'heroku'
    description = 'Integrate Heroku release tracking.'
    version = sentry_heroku.VERSION

    def get_release_doc_html(self, hook_url):
        return """
        <p>Add Sentry as a deploy hook to automatically track new releases.</p>
        <pre class="clippy">heroku addons:create deployhooks:http --url={hook_url}</pre>
        """.format(hook_url=hook_url)

    def get_release_hook(self):
        return HerokuReleaseHook

## Instruction:
Add url and environment to payload
## Code After:
import sentry_heroku

from sentry.plugins import ReleaseHook, ReleaseTrackingPlugin


class HerokuReleaseHook(ReleaseHook):
    def handle(self, request):
        self.finish_release(
            version=request.POST['head_long'],
            url=request.POST['url'],
            environment=request.POST['app'],
        )


class HerokuPlugin(ReleaseTrackingPlugin):
    author = 'Sentry Team'
    author_url = 'https://github.com/getsentry'
    resource_links = (
        ('Bug Tracker', 'https://github.com/getsentry/sentry-heroku/issues'),
        ('Source', 'https://github.com/getsentry/sentry-heroku'),
    )

    title = 'Heroku'
    slug = 'heroku'
    description = 'Integrate Heroku release tracking.'
    version = sentry_heroku.VERSION

    def get_release_doc_html(self, hook_url):
        return """
        <p>Add Sentry as a deploy hook to automatically track new releases.</p>
        <pre class="clippy">heroku addons:create deployhooks:http --url={hook_url}</pre>
        """.format(hook_url=hook_url)

    def get_release_hook(self):
        return HerokuReleaseHook
