code: def telemetry(fn):
      
  
      @wraps(fn)
      def telemetry_wrapper(*args, **kwargs):
          # By default, do not instantiate a client,
          # and inherit the telemetry settings passed
          client = None
          if len(args) > 0 and isinstance(args[0], click.Context):
              ctx = args[0]
  
              # First try to get off API obj
              if ctx.obj and ctx.obj.get("API") is not None:
                  client = ctx.obj["API"]._raven_client
  
              # Else try to see if telemetry param is set
              elif ctx.params.get("telemetry", False):
                  client = get_raven_client()
  
              # Finally check for the ctx.obj['TELEMETRY'] bool
              elif ctx.obj and ctx.obj.get("TELEMETRY", False):
                  client = get_raven_client()
  
          try:
              return fn(*args, **kwargs)
          except Exception as e:
              if client:
                  client.captureException()
                  client.context.clear()
                  sys.stdout = StringIO()
              raise e
  
      return telemetry_wrapper
docs: Decorator for CLI and other functions that need special Sentry client handling.
      This function is only required for functions that may exit *before* we set up
      the ._raven_client object on the Api instance *or* that specifically catch and re-raise
      exceptions or call sys.exit directly.
  
      Note that this also overwrites verbose Raven logs on exit ("Sentry is waiting to send..."),
      see https://github.com/getsentry/raven-python/issues/904 for more details.