From b4b890f9a598d2ef7d19bd562bf1ba2446ecd264 Mon Sep 17 00:00:00 2001 From: scastineyras <162158563+scastineyras@users.noreply.github.com> Date: Wed, 21 Aug 2024 11:22:37 -0300 Subject: [PATCH] added group call to segment (#80) * added group call to segment * bug fix --------- Co-authored-by: Sergio Castineyras --- ckanext/opendata_theme/base/helpers.py | 4 ++++ .../opendata_theme/opengov_custom_theme/plugin.py | 3 ++- .../opengov_custom_theme/templates/base.html | 12 ++++++++++-- .../templates/user/dashboard.html | 10 ---------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ckanext/opendata_theme/base/helpers.py b/ckanext/opendata_theme/base/helpers.py index 5c49e7c..5536c4c 100644 --- a/ckanext/opendata_theme/base/helpers.py +++ b/ckanext/opendata_theme/base/helpers.py @@ -143,6 +143,10 @@ def get_segment_writekey(): return str(config.get('ckan.segment_writekey', '')) +def get_entity_id(): + return str(config.get('ckanext.opengov.datastore.entity_id', 'controlpanel')) + + def get_group_alias(): return str(config.get('ckan.group_alias', 'Group')) diff --git a/ckanext/opendata_theme/opengov_custom_theme/plugin.py b/ckanext/opendata_theme/opengov_custom_theme/plugin.py index 22f47cd..ccb1d6d 100644 --- a/ckanext/opendata_theme/opengov_custom_theme/plugin.py +++ b/ckanext/opendata_theme/opengov_custom_theme/plugin.py @@ -35,7 +35,8 @@ def get_helpers(self): 'opendata_theme_is_data_dict_active': helper.is_data_dict_active, 'version': helper.version_builder, 'opendata_theme_segment_writekey': helper.get_segment_writekey, - 'opendata_theme_platform_uuid': helper.get_user_uuid + 'opendata_theme_platform_uuid': helper.get_user_uuid, + 'opendata_theme_entity': helper.get_entity_id } # IBlueprint diff --git a/ckanext/opendata_theme/opengov_custom_theme/templates/base.html b/ckanext/opendata_theme/opengov_custom_theme/templates/base.html index c580bd0..ae4f45b 100644 --- a/ckanext/opendata_theme/opengov_custom_theme/templates/base.html +++ b/ckanext/opendata_theme/opengov_custom_theme/templates/base.html @@ -6,8 +6,16 @@ var writeKey = "{{ h.opendata_theme_segment_writekey() }}"; if(writeKey !== ""){ !function(){var i="analytics",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","screen","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware","register"];analytics.factory=function(e){return function(){if(window[i].initialized)return window[i][e].apply(window[i],arguments);var n=Array.prototype.slice.call(arguments);if(["track","screen","alias","group","page","identify"].indexOf(e)>-1){var c=document.querySelector("link[rel='canonical']");n.push({__t:"bpc",c:c&&c.getAttribute("href")||void 0,p:location.pathname,u:location.href,s:location.search,t:document.title,r:document.referrer})}n.unshift(e);analytics.push(n);return analytics}};for(var n=0;n diff --git a/ckanext/opendata_theme/opengov_custom_theme/templates/user/dashboard.html b/ckanext/opendata_theme/opengov_custom_theme/templates/user/dashboard.html index 9f2bec5..a961c35 100644 --- a/ckanext/opendata_theme/opengov_custom_theme/templates/user/dashboard.html +++ b/ckanext/opendata_theme/opengov_custom_theme/templates/user/dashboard.html @@ -31,14 +31,4 @@ {{ h.build_nav_icon(dashboard_groups_route, _('My {Groups}'.format(Groups=group_alias_pural))) }} - {% endblock %}