Write our users to Marketo as leads.
This commit is contained in:
parent
013e27f7d5
commit
f04b018805
11 changed files with 250 additions and 6 deletions
|
@ -10,7 +10,7 @@ from peewee import IntegrityError
|
|||
|
||||
import features
|
||||
|
||||
from app import app, billing as stripe, authentication, avatar
|
||||
from app import app, billing as stripe, authentication, avatar, user_analytics
|
||||
from auth import scopes
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from auth.permissions import (AdministerOrganizationPermission, CreateRepositoryPermission,
|
||||
|
@ -119,6 +119,14 @@ def user_view(user):
|
|||
'tag_expiration': user.removed_tag_expiration_s,
|
||||
})
|
||||
|
||||
analytics_metadata = user_analytics.get_user_analytics_metadata(user)
|
||||
|
||||
# This is a sync call, but goes through the async wrapper interface and
|
||||
# returns a Future. By calling with timeout 0 immediately after the method
|
||||
# call, we ensure that if it ever accidentally becomes async it will raise
|
||||
# a TimeoutError.
|
||||
user_response.update(analytics_metadata.result(timeout=0))
|
||||
|
||||
user_view_perm = UserReadPermission(user.username)
|
||||
if user_view_perm.can():
|
||||
user_response.update({
|
||||
|
|
|
@ -16,7 +16,7 @@ from flask_principal import identity_changed
|
|||
import endpoints.decorated # Register the various exceptions via decorators.
|
||||
import features
|
||||
|
||||
from app import app, oauth_apps, LoginWrappedDBUser
|
||||
from app import app, oauth_apps, LoginWrappedDBUser, user_analytics
|
||||
from auth import scopes
|
||||
from auth.permissions import QuayDeferredPermissionUser
|
||||
from config import frontend_visible_config
|
||||
|
@ -114,6 +114,10 @@ def common_login(db_user):
|
|||
new_identity = QuayDeferredPermissionUser.for_user(db_user)
|
||||
identity_changed.send(app, identity=new_identity)
|
||||
session['login_time'] = datetime.datetime.now()
|
||||
|
||||
# Inform our user analytics that we have a new "lead"
|
||||
user_analytics.create_lead(db_user.email, db_user.username)
|
||||
|
||||
return True
|
||||
else:
|
||||
logger.debug('User could not be logged in, inactive?.')
|
||||
|
@ -209,7 +213,7 @@ def render_page_template(name, route_data=None, **kwargs):
|
|||
vuln_priority_set=json.dumps(PRIORITY_LEVELS),
|
||||
enterprise_logo=app.config.get('ENTERPRISE_LOGO_URL', ''),
|
||||
mixpanel_key=app.config.get('MIXPANEL_KEY', ''),
|
||||
munchkin_key=app.config.get('MUNCHKIN_KEY', ''),
|
||||
munchkin_key=app.config.get('MARKETO_MUNCHKIN_ID', ''),
|
||||
google_tagmanager_key=app.config.get('GOOGLE_TAGMANAGER_KEY', ''),
|
||||
google_anaytics_key=app.config.get('GOOGLE_ANALYTICS_KEY', ''),
|
||||
sentry_public_dsn=app.config.get('SENTRY_PUBLIC_DSN', ''),
|
||||
|
|
|
@ -11,7 +11,7 @@ from flask_login import current_user
|
|||
import features
|
||||
|
||||
from app import (app, billing as stripe, build_logs, avatar, signer, log_archive, config_provider,
|
||||
get_app_url, instance_keys)
|
||||
get_app_url, instance_keys, user_analytics)
|
||||
from auth import scopes
|
||||
from auth.auth_context import get_authenticated_user
|
||||
from auth.permissions import (AdministerOrganizationPermission, ReadRepositoryPermission,
|
||||
|
@ -390,6 +390,7 @@ def confirm_email():
|
|||
|
||||
if new_email:
|
||||
send_email_changed(user.username, old_email, new_email)
|
||||
user_analytics.change_email(old_email, new_email)
|
||||
|
||||
common_login(user)
|
||||
|
||||
|
|
Reference in a new issue