Api reference
components.growth.public.api ¶
Growth component public API.
This module consolidates all public exports from the growth component. External code should import from this module rather than internal modules.
Accountant
dataclass
¶
CustomerIOEmailCaptureEventName ¶
DocumentReviewIndividualParams
dataclass
¶
DocumentReviewParams
dataclass
¶
DocumentReviewParams(
proposal_id,
ccn_code,
company_siren,
company_name,
plan_id,
health_start_date,
participation,
contract_cover_option,
legacy_health_contract,
choose_prevoyance,
legacy_prevoyance_contract,
)
EmailCaptureData
dataclass
¶
GrowthIntercomHandlerService ¶
Service to handle Intercom webhook events for Growth tracking. Only handles user_replied and admin_replied topics.
handle_topic
staticmethod
¶
Handle Intercom topics for Growth tracking.
Source code in components/growth/internal/services/growth_intercom_handler_service.py
GrowthUser
dataclass
¶
InboundSalesTeam
dataclass
¶
Bases: DataClassJsonMixin
Represents an inbound sales team / crew for a specific country
IndividualDocumentReviewEvent
dataclass
¶
IndividualDocumentReviewEvent(
proposal_id,
health_start_date_timestamp,
primary_price,
primary_age,
has_legacy_health_contract,
document_review_version="1",
)
Bases: DataClassJsonMixin
MarketingEventParameters
dataclass
¶
MarketingEventParameters(
utms,
all_utms,
clids,
facebook,
alan_partner_code,
referring_user_token,
referring_partner,
cookie_status,
version,
landing_referrer_url,
landing_page_url,
device_type=None,
)
Bases: DataClassJsonMixin, DataClassJsonAlanMixin
__post_init__ ¶
Truncate all string fields to appropriate max lengths.
Source code in components/growth/internal/entities/prospect.py
PersonaType ¶
Bases: AlanBaseEnum
Marketing persona types (mirrors frontend PersonaType).
ProspectEventContractSignedProperties
dataclass
¶
Bases: DataClassJsonMixin
Properties for contract signed events.
ProspectEventManager ¶
Static class for creating prospect events in the database.
create_prospect_event
staticmethod
¶
create_prospect_event(
email,
event_name,
country_code,
persona_type,
marketing_parameters,
event_properties,
create_prospect_if_not_exists=True,
commit=False,
)
Create a prospect event in the database.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_account_creation
staticmethod
¶
Dispatch account creation event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_call_hungup
staticmethod
¶
Dispatch sales inbound call hung up event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_contact_sales
staticmethod
¶
on_contact_sales(
email,
country_code,
persona_type,
properties,
marketing_parameters,
commit=True,
)
Dispatch meeting request event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_contract_signed
staticmethod
¶
Dispatch contract signed event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_flow_capture_screen
staticmethod
¶
Dispatch flow capture contact event (email capture).
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_intercom_admin_replied
staticmethod
¶
Dispatch sales inbound mail/chat replied event based on tags.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_intercom_user_replied
staticmethod
¶
Dispatch sales inbound mail/chat sent event based on tags.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_meeting_request_attribution_survey
staticmethod
¶
on_meeting_request_attribution_survey(
email,
country_code,
persona_type,
properties,
marketing_parameters=None,
commit=True,
)
Dispatch attribution survey filled event for meeting requests.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_nurturing_mail_clicked
staticmethod
¶
Dispatch nurturing mail clicked event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_nurturing_mail_read
staticmethod
¶
Dispatch nurturing mail read event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_nurturing_mail_sent
staticmethod
¶
Dispatch nurturing mail sent event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_page_view
staticmethod
¶
Dispatch page view event for known prospects only.
Marketing parameters are only stored if different from the last recorded parameters for this prospect (across any event type).
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_quote_request
staticmethod
¶
Dispatch quote request event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
on_website_capture_form
staticmethod
¶
on_website_capture_form(
email,
country_code,
persona_type,
marketing_parameters,
properties=None,
commit=True,
)
Dispatch website capture form event.
Source code in components/growth/internal/business_logic/prospect/prospect_event_manager.py
ProspectFactory ¶
ProspectRequestType
module-attribute
¶
ProspectRequestType = Literal[
"meeting_request",
"callback",
"email",
"chat",
"account_creation_stuck",
"quote_request",
"email_capture",
"contract_comparison",
]
QuoteRequestData
dataclass
¶
QuoteRequestData(
*,
customer_io_event_name,
customer_io_event_attributes,
should_be_sent_to_crm,
quote_details,
self_serve_flow_id
)
Bases: DataClassJsonMixin
ReferralActions ¶
Actions for the referral lifecycle.
add_contract_to_referral
staticmethod
¶
Add a contract reference to be rewarded for the referral.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
consume_referral
staticmethod
¶
Consume a referral for the rewarded contract.
Creates a discount from the referral for a given month if the conditions are met.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
create_referral
staticmethod
¶
Create a referral.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
delete_referral
staticmethod
¶
Delete a GlobalReferral and its associated country-specific discount.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
delete_referral_profile
staticmethod
¶
Delete a referral profile and all associated GlobalReferrals for a user.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
merge_referral_profiles
staticmethod
¶
Merge global referral profile of a duplicated user into an existing user's profile.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
reassign_referral_profile
staticmethod
¶
Reassign all global referrals from one user's profile to another, then delete the source profile.
Source code in components/growth/internal/business_logic/referral/actions/referral_actions.py
ReferralEntity
dataclass
¶
Bases: DataClassJsonMixin
Entity for a referral.
Source code in components/growth/internal/entities/referral.py
referrer_name
property
¶
Get the referrer display name: user full name or partner name.
ReferralProfileFactory ¶
ReferralQueries ¶
Queries for the referral.
get_by_id
staticmethod
¶
Get a referral by its ID.
Source code in components/growth/internal/business_logic/referral/queries/referral_queries.py
get_received_referral_for_profile
staticmethod
¶
Get the received referral for a profile.
Source code in components/growth/internal/business_logic/referral/queries/referral_queries.py
get_referral_by_contract_ref
staticmethod
¶
Find a referral by its referred contract reference.
Source code in components/growth/internal/business_logic/referral/queries/referral_queries.py
get_referral_link
staticmethod
¶
Get the referral link for a user, creating a profile if needed.
Source code in components/growth/internal/business_logic/referral/queries/referral_queries.py
get_unrewarded_referrals_with_contract
staticmethod
¶
Get referrals that have a contract but haven't been rewarded yet.
Also filters out referrals that already have a country-specific discount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_code
|
CountryCode
|
Country to filter referrals for. |
required |
contract_refs
|
list[str] | None
|
If provided, only return referrals matching these contract refs. |
None
|
Source code in components/growth/internal/business_logic/referral/queries/referral_queries.py
ReferralRewardTargetType ¶
ReferralType
module-attribute
¶
SELF_SERVE_PROPOSAL_EXPIRES_AFTER_IN_DAYS
module-attribute
¶
clean_phone_number ¶
Clean a phone number by removing all non-digit characters and keeping the country code if it exists. Returns null if cleaned number is too short.
Source code in components/growth/internal/business_logic/crm/utils/phone_number.py
create_attribution_signature_success ¶
Source code in components/growth/internal/business_logic/crm/fr/attribution.py
create_or_retrieve_self_serve_health_plan ¶
create_or_retrieve_self_serve_health_plan(
coverage_level, siren, ccn_code, target_population="all"
)
Create a Plan from the top builder product for a given company and coverage level
Retrieve the existing Plan if it has already been created Raise an error if the builder product were not created
Returns the Plan id
Source code in components/growth/internal/business_logic/self_serve/fr/actions/company_health.py
extract_marketing_parameters_from_params ¶
Extract marketing parameters from params dict if present.
Source code in components/growth/internal/entities/prospect.py
get_accountant_by_email ¶
Source code in components/growth/internal/business_logic/accountant/fr/get_accountant.py
get_accounting_firm_landing_page_link ¶
get_livestorm_replay_url ¶
Get the replay URL for a given Livestorm session ID from Public API.
Source code in components/growth/internal/business_logic/crm/lead_generation_resources.py
get_referral_reward_amount ¶
Returns the reward amount for the most recent reward active on or before the given date.
- If multiple entries share the same start_date, returns the largest amount.
- Returns 0 if no matching reward entry exists.
Source code in components/growth/internal/business_logic/referral/queries/reward_queries.py
individual_paid_acquisition_contract_conversion_value ¶
Source code in components/growth/internal/business_logic/crm/fr/attribution.py
is_alaner_inbound_sales ¶
Source code in components/growth/internal/business_logic/crm/user_and_roles.py
is_assigned_to_inbound_sales ¶
Returns True if the inbox_id parameter is one of the Inbound Sales inbox for the selected country
Source code in components/growth/internal/business_logic/crm/intercom.py
is_conversation_recently_closed ¶
Check if a conversation is closed and was updated within the last 30 days.
Source code in components/growth/internal/business_logic/crm/intercom.py
load_global_referral_rewards ¶
Seed GlobalReferralReward with initial FR/BE values.
Idempotent: skips if any rows already exist.
Source code in components/growth/internal/helpers/load_global_referral_rewards.py
load_growth_settings ¶
Load all growth settings to the database, used for flask data init
Source code in components/growth/internal/helpers/data_init.py
notify_company_document_review ¶
Source code in components/growth/internal/business_logic/crm/fr/notify_document_review.py
notify_individual_document_review ¶
Source code in components/growth/internal/business_logic/crm/fr/notify_document_review.py
notify_intercom_on_contract_signature ¶
Source code in components/growth/internal/business_logic/crm/actions/notify_intercom_on_contract_signature.py
notify_nurturing_company_contract_signature ¶
notify_nurturing_company_contract_signature(
user_id,
approver_email,
company_id,
products,
contract_id=None,
)
Source code in components/growth/internal/business_logic/crm/fr/notify_contract_signature.py
notify_nurturing_individual_contract_signature ¶
notify_nurturing_individual_contract_signature(
user_id,
approver_email,
segment_for_slack_message,
persona_type,
siren_or_siret=None,
contract_id=None,
)
Source code in components/growth/internal/business_logic/crm/fr/notify_contract_signature.py
paid_acquisition_contract_conversion_value ¶
paid_acquisition_contract_conversion_value(
coverage_level=None, ccn_code=None, has_prevoyance=False
)
Source code in components/growth/internal/business_logic/crm/fr/attribution.py
prospect_conversation_detect_duplicates ¶
This function will try to detect if Lead/Prospect have started several conversation, it will rely on both the fact that we have a Prospect object, but also if the conversation are owned by a Inbound Sales alaner or if the conversation was in the Lead Inbox.
We will also try to detect when a conversation is open via multiple prospect for the SIREN, it actually happens quite a lot, we can have the HR that come ask some questions, but then when the CEO is ready to sign they might ask new questions.
Source code in components/growth/internal/business_logic/crm/fr/conversation_detect_duplicates.py
register_new_prospect ¶
Register a new prospect in the database. If the prospect already exists, it will update the phone number and attribution survey if provided.
Source code in components/growth/internal/business_logic/prospect/register_new_prospect.py
reopen_inbound_sales_conversation_if_possible ¶
Reopen a closed conversation if assigned to inbound sales and the admin is available.
Source code in components/growth/internal/business_logic/crm/intercom.py
retrieve_eligible_prevoyance_offers_from_account_id ¶
Source code in components/growth/internal/business_logic/self_serve/fr/queries/company_prevoyance.py
retrieve_eligible_prevoyance_offers_from_company_id ¶
Conditions to meet: - Active Health Contract - No Active Prevoyance Contract - No suspended Prevoyance contract - No Tailored offer in the account
Return only self-serve prevoyance offers (if there are some for the CCN)
Source code in components/growth/internal/business_logic/self_serve/fr/queries/company_prevoyance.py
submit_contact_form ¶
Source code in components/growth/internal/business_logic/crm/fr/push_sales_contact.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
submit_form_to_hubspot ¶
submit_form_to_hubspot(
portal_id,
form_id,
fields,
ip_address,
page=None,
marketing_parameters=None,
)
Submit form to hubspot API
Source code in components/growth/internal/business_logic/crm/hubspot.py
unsubscribe_email ¶
Unsubscribe user or prospect from commercial emails.
Return success. Note that in the failure case, it's important that we return the same value (False) whether it's the email that does not exist or the token which is incorrect. This is because we don't want a snooper to be able to deduce the email addresses in our system by brute forcing this function.
Source code in components/growth/internal/business_logic/prospect/fr/commercial_emails_unsubscription.py
unsubscribe_email_without_token ¶
Unsubscribe user or prospect from commercial emails.
WARNING: This doesn't require a token, and should only be called in a context where we're sure the request is legit. (eg webhook)
Source code in components/growth/internal/business_logic/prospect/fr/commercial_emails_unsubscription.py
components.growth.public.dependencies ¶
GrowthDependency ¶
Bases: ABC
create_conversation_context
abstractmethod
¶
Implement create_conversation_context
Source code in components/growth/internal/business_logic/dependencies/growth_dependency.py
get_company_quote_request_data
abstractmethod
¶
get_company_quote_request_data(
language,
phone_number,
firstname,
lastname,
company_name,
number_of_employees,
qualification,
)
Implement get_company_quote_request_event
Source code in components/growth/internal/business_logic/dependencies/growth_dependency.py
get_email_capture_event_data
abstractmethod
¶
Implement get_company_email_capture_event_data
get_extra_tags_for_country
abstractmethod
¶
Implement get_extra_tags_for_country
get_inbound_sales_team
abstractmethod
¶
get_intercom_admin_id_from_user_id
abstractmethod
¶
get_persona_type_via_flow_id
abstractmethod
¶
get_prospects_emails_from_phone_number
abstractmethod
¶
Implement get_prospects_emails_from_phone_number
get_self_serve_flow_id_from_qualification
abstractmethod
¶
Implement get_self_serve_flow_id_from_qualification
get_user
abstractmethod
¶
get_user_from_email
abstractmethod
¶
get_user_from_intercom_admin_id
abstractmethod
¶
Implement get_user_from_intercom_admin_id
is_admin_sales
abstractmethod
¶
is_request_likely_for_care
abstractmethod
¶
Implement is_request_likely_for_care it should return a tuple with: - a bool if the request is likely for care - a str with the reason if the request is likely for care
Source code in components/growth/internal/business_logic/dependencies/growth_dependency.py
register_prospect
abstractmethod
¶
register_prospect(
email,
phone=None,
attribution_survey_source=None,
qualification_raw_company=None,
qualification_raw_individual=None,
qualification_raw_website=None,
)
Implement register_prospect
Source code in components/growth/internal/business_logic/dependencies/growth_dependency.py
send_unauthenticated_user_async_message_to_intercom
abstractmethod
¶
Implement send_unauthenticated_user_async_message_to_intercom
Source code in components/growth/internal/business_logic/dependencies/growth_dependency.py
set_app_growth_dependency ¶
Set the growth dependency in the current app context