from .models import Session


class Tracking(object):
    """The default tracking middleware logs all successful responses as a 'visit' variable with
    the URL path as its value."""

    def process_response(self, request, response):
        if response.status_code == 200:
            session = Session.objects.for_request(request)
            session.record("visit", request.path)
        return response

from .models import Session


class Tracking(object):
    """The default tracking middleware logs all successful responses as a 'visit' variable with
    the URL path as its value."""

    def process_response(self, request, response):
        if request.path.startswith('/heartbeat/'):
            return response

        if response.status_code == 200:
            session = Session.objects.for_request(request)
            session.record("visit", request.path)
        return response

Disable use tracking of all heartbeat app urls.
Disable use tracking of all heartbeat app urls.

  from .models import Session
  
  
  class Tracking(object):
      """The default tracking middleware logs all successful responses as a 'visit' variable with
      the URL path as its value."""
  
      def process_response(self, request, response):
+         if request.path.startswith('/heartbeat/'):
+             return response
+ 
          if response.status_code == 200:
              session = Session.objects.for_request(request)
              session.record("visit", request.path)
          return response
  
Disable use tracking of all heartbeat app urls.
## Code Before:
from .models import Session


class Tracking(object):
    """The default tracking middleware logs all successful responses as a 'visit' variable with
    the URL path as its value."""

    def process_response(self, request, response):
        if response.status_code == 200:
            session = Session.objects.for_request(request)
            session.record("visit", request.path)
        return response

## Instruction:
Disable use tracking of all heartbeat app urls.
## Code After:
from .models import Session


class Tracking(object):
    """The default tracking middleware logs all successful responses as a 'visit' variable with
    the URL path as its value."""

    def process_response(self, request, response):
        if request.path.startswith('/heartbeat/'):
            return response

        if response.status_code == 200:
            session = Session.objects.for_request(request)
            session.record("visit", request.path)
        return response
