diff --git a/app/app/context.py b/app/app/context.py index 362ae7d8988..40af025d743 100644 --- a/app/app/context.py +++ b/app/app/context.py @@ -95,6 +95,7 @@ def preprocess(request): except Exception as e: logger.exception(e) metadata = { + 'visitorId': request.COOKIES.get("visitorId", None), 'useragent': request.META['HTTP_USER_AGENT'], 'referrer': request.META.get('HTTP_REFERER', None), 'path': request.META.get('PATH_INFO', None), diff --git a/app/assets/v2/js/base.js b/app/assets/v2/js/base.js index b8f9da15e80..012c7c2d70e 100644 --- a/app/assets/v2/js/base.js +++ b/app/assets/v2/js/base.js @@ -103,8 +103,12 @@ $(document).ready(function() { }); }; + if (document.visitorId) { + Cookies.set('visitorId', document.visitorId); + } record_campaign_to_cookie(); + if (!$('.header > .minihero').length && $('.header > .navbar').length) { $('.header').css('overflow', 'visible'); } diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index a8831ae2ae1..7b11e30cd03 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1032,6 +1032,7 @@ Vue.component('grants-cart', { signature: 'onetime', splitter_contract_address: contractAddress, subscription_hash: 'onetime', + visitorId: document.visitorId, // Values that vary by donation 'gitcoin-grant-input-amount': [], admin_address: [], diff --git a/app/grants/admin.py b/app/grants/admin.py index ef6a54b9229..a5ae7e23e8a 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -271,8 +271,6 @@ class SubscriptionAdmin(GeneralAdmin): raw_id_fields = ['grant', 'contributor_profile'] readonly_fields = [ 'contributions_links', - 'error_email_copy_insufficient_balance', - 'error_email_copy_not_active', ] def contributions_links(self, instance): diff --git a/app/grants/migrations/0117_subscription_visitorid.py b/app/grants/migrations/0117_subscription_visitorid.py new file mode 100644 index 00000000000..b35595e920a --- /dev/null +++ b/app/grants/migrations/0117_subscription_visitorid.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.4 on 2021-03-21 19:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0116_auto_20210316_2021'), + ] + + operations = [ + migrations.AddField( + model_name='subscription', + name='visitorId', + field=models.CharField(blank=True, default='', help_text='The visitorID of the contributor', max_length=255), + ), + ] diff --git a/app/grants/models.py b/app/grants/models.py index 2108c68f76f..0e6dcbcb565 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -1133,6 +1133,12 @@ class Subscription(SuperModel): help_text=_('The amount per contribution period in USDT'), ) tenant = models.CharField(max_length=10, null=True, blank=True, default="ETH", choices=TENANT, help_text="specific tenant in which contribution is made") + visitorId = models.CharField( + default='', + max_length=255, + help_text=_('The visitorID of the contributor'), + blank=True, + ) @property def negative(self): diff --git a/app/grants/tasks.py b/app/grants/tasks.py index 00a86da3c0a..adde6debf87 100644 --- a/app/grants/tasks.py +++ b/app/grants/tasks.py @@ -195,6 +195,7 @@ def process_grant_contribution(self, grant_id, grant_slug, profile_id, package, subscription.split_tx_id = package.get('split_tx_id', '0x0') subscription.num_tx_approved = package.get('num_tx_approved', 1) subscription.network = package.get('network', '') + subscription.visitorId = package.get('visitorId', '') if subscription.network == 'undefined': # we unfortunately cannot trust the frontend to give us a valid network name # so this handles that case. more details are available at diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 2345ba93cbb..a9b64644c95 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -125,6 +125,7 @@