Skip to content

Commit

Permalink
feat: Add Hubspot cookie logging (#4854)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan authored Nov 21, 2024
1 parent 86ba762 commit 8fe4d41
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api/integrations/lead_tracking/hubspot/services.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import logging

from rest_framework.request import Request

from integrations.lead_tracking.hubspot.constants import HUBSPOT_COOKIE_NAME
from users.models import HubspotTracker

logger = logging.getLogger(__name__)


def register_hubspot_tracker(request: Request) -> None:
hubspot_cookie = request.COOKIES.get(HUBSPOT_COOKIE_NAME)

# TODO: Remove this temporary debugging logger statement.
logger.info(f"Request cookies for user {request.user.email}: {request.COOKIES}")

if hubspot_cookie:
logger.info(
f"Creating HubspotTracker instance for user {request.user.email} with cookie {hubspot_cookie}"
)

HubspotTracker.objects.update_or_create(
user=request.user,
defaults={
"hubspot_cookie": hubspot_cookie,
},
)
else:
logger.info(
f"Could not create HubspotTracker instance for user {request.user.email} since no cookie"
)

0 comments on commit 8fe4d41

Please sign in to comment.