(form_id, webuser, hubspot_cookie, meta, extra_fields=None, email=False)
This sends hubspot the user's first and last names and tracks everything they did
    up until the point they signed up.
This sends hubspot the user's first and last names and tracks everything they did
    up until the point they signed up.
This sends hubspot the user s first and last names and tracks everything they did up until the point they signed up .
def _send_form_to_hubspot(form_id, webuser, hubspot_cookie, meta, extra_fields=None, email=False):
    """
    This sends hubspot the user's first and last names and tracks everything they did
    up until the point they signed up.
    """
    if ((webuser and not hubspot_enabled_for_user(webuser))
            or (not webuser and not hubspot_enabled_for_email(email))):
        # This user has analytics disabled
        metrics_counter(
            'commcare.hubspot.sent_form.rejected'
        )
        return

    hubspot_id = settings.ANALYTICS_IDS.get('HUBSPOT_API_ID')
    if hubspot_id and hubspot_cookie:
        data = {
            'email': email if email else webuser.username,
            'hs_context': json.dumps({"hutk": hubspot_cookie, "ipAddress": _get_client_ip(meta)}),
        }
        if webuser:
            data.update({
                'firstname': webuser.first_name,
                'lastname': webuser.last_name,
            })
        if extra_fields:
            data.update(extra_fields)

        response = _send_hubspot_form_request(hubspot_id, form_id, data)
        _log_response('HS', data, response)
        response.raise_for_status()
def _send_form_to_hubspot ( form_id , webuser , hubspot_cookie , meta , extra_fields = None , email = False ) : if ( ( webuser and not hubspot_enabled_for_user ( webuser ) ) or ( not webuser and not hubspot_enabled_for_email ( email ) ) ) : # This user has analytics disabled metrics_counter ( 'commcare.hubspot.sent_form.rejected' ) return hubspot_id = settings . ANALYTICS_IDS . get ( 'HUBSPOT_API_ID' ) if hubspot_id and hubspot_cookie : data = { 'email' : email if email else webuser . username , 'hs_context' : json . dumps ( { "hutk" : hubspot_cookie , "ipAddress" : _get_client_ip ( meta ) } ) , } if webuser : data . update ( { 'firstname' : webuser . first_name , 'lastname' : webuser . last_name , } ) if extra_fields : data . update ( extra_fields ) response = _send_hubspot_form_request ( hubspot_id , form_id , data ) _log_response ( 'HS' , data , response ) response . raise_for_status ( )