File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ extraHosts:
100100# Overrides for production
101101production :
102102 replicas : 5
103+ env :
104+ - name : ANALYTICS_ENDPOINT
105+ value : https://marketplace-analytics.canonical.com/k8s-prod-marketplace-analytics-marketplace-analytics/analytics/events
106+
103107 nginxConfigurationSnippet : |
104108 if ($host = 'docs.snapcraft.io' ) {
105109 rewrite ^ https://snapcraft.io/docs$request_uri? permanent;
@@ -153,3 +157,8 @@ staging:
153157 replicas : 2
154158 memoryLimit : 256Mi
155159 env : *env
160+
161+ demo :
162+ env :
163+ - name : ANALYTICS_ENDPOINT
164+ value : https://marketplace-analytics.staging.canonical.com/k8s-stg-marketplace-marketplace-analytics-marketplace-analytics/analytics/events
Original file line number Diff line number Diff line change 2525 "@babel/preset-env" : " 7.29.0" ,
2626 "@babel/preset-react" : " 7.28.5" ,
2727 "@babel/preset-typescript" : " 7.28.5" ,
28+ "@canonical/analytics-events" : " 1.0.4" ,
2829 "@canonical/cookie-policy" : " 3.8.4" ,
2930 "@canonical/global-nav" : " 3.8.0" ,
3031 "@canonical/react-components" : " 3.12.1" ,
Original file line number Diff line number Diff line change 11import "./ga" ;
22import "./contactForm" ;
33import "./sentry" ;
4+ import { initAnalytics } from "@canonical/analytics-events" ;
5+
6+ declare global {
7+ interface Window {
8+ ANALYTICS_ENDPOINT : string ;
9+ }
10+ }
11+
12+ if ( window . ANALYTICS_ENDPOINT ) {
13+ initAnalytics ( {
14+ appName : "snapcraft" ,
15+ endpoint : window . ANALYTICS_ENDPOINT ,
16+ } ) ;
17+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ import initEmbeddedCardModal from "./snap-details/embeddedCard";
77import { snapDetailsPosts } from "./snap-details/blog-posts" ;
88import initExpandableArea from "./expandable-area" ;
99import declareGlobal from "../libs/declare" ;
10+ import { trackPageView } from "@canonical/analytics-events" ;
11+
12+ if ( window . ANALYTICS_ENDPOINT ) {
13+ trackPageView ( "snap_details_page" ) ;
14+ }
1015
1116declareGlobal ( "snapcraft.public.storeDetails" , {
1217 map,
Original file line number Diff line number Diff line change 8585 window . COMMIT_ID = "{{ COMMIT_ID }}" ;
8686 window . ENVIRONMENT = "{{ ENVIRONMENT }}" ;
8787 window . SENTRY_DSN = "{{ SENTRY_DSN }}" ;
88+ window . ANALYTICS_ENDPOINT = "{{ ANALYTICS_ENDPOINT }}" ;
8889 </ script >
8990
9091 < script type ="application/ld+json " nonce ="{{ CSP_NONCE }} ">
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ <h2>Where people are using {{ snap_title }}</h2>
189189 </ div >
190190 < div class ="grid-row {% if normalized_os %}u-equal-height{% endif %} ">
191191 {% if countries %}
192- < div class ="{% if normalized_os %}grid-col-4{% else %}grid-col-6{% endif %} grid-col-start-large-3 js-snap-map-holder " data-live ="installed_base_by_country_percent ">
192+ < div class ="{% if normalized_os %}grid-col-4{% else %}grid-col-6{% endif %} grid-col-start-large-3 js-snap-map-holder " data-live ="installed_base_by_country_percent " data-analytics-view data-analytics-hover data-analytics-target =" snap_details_map_installed_base_by_country_percent " >
193193 < div id ="js-snap-map " class ="snapcraft-territories "> </ div >
194194 </ div >
195195 {% endif %}
@@ -231,7 +231,7 @@ <h3 class="p-muted-heading">Users by distribution (log)</h3>
231231 </ div >
232232 < div class ="p-show-more__fade ">
233233 < div class ="p-show-more__link-container ">
234- < button class ="p-button--link p-show-more__link is-small u-no-padding " aria-expanded ="false "> Show more</ button >
234+ < button class ="p-button--link p-show-more__link is-small u-no-padding " aria-expanded ="false " data-analytics-click data-analytics-target =" snap_details_map_show_more_distributions " > Show more</ button >
235235 </ div >
236236 </ div >
237237 </ div >
Original file line number Diff line number Diff line change @@ -49,5 +49,6 @@ class ConfigurationError(Exception):
4949SEARCH_CUSTOM_ID = "009048213575199080868:i3zoqdwqk8o"
5050
5151APP_NAME = "snapcraft"
52+ ANALYTICS_ENDPOINT = os .getenv ("ANALYTICS_ENDPOINT" , "" ).strip ()
5253
5354REPORT_SHEET_URL = os .getenv ("REPORT_SHEET_URL" , "" ).strip ()
Original file line number Diff line number Diff line change 2424 DNS_VERIFICATION_SALT ,
2525 IS_DEVELOPMENT ,
2626 VITE_PORT ,
27+ ANALYTICS_ENDPOINT ,
2728)
2829
2930from canonicalwebteam .exceptions import (
9091 "px.ads.linkedin.com" ,
9192 "*.snapcraft.io" ,
9293 "*.snapcraftcontent.com" ,
94+ "marketplace-analytics.staging.canonical.com" ,
9395 "www.google.com" ,
9496 ],
9597 "frame-src" : [
@@ -192,6 +194,7 @@ def snapcraft_utility_processor():
192194 "stores" : stores ,
193195 "format_link" : template_utils .format_link ,
194196 "DNS_VERIFICATION_SALT" : DNS_VERIFICATION_SALT ,
197+ "ANALYTICS_ENDPOINT" : ANALYTICS_ENDPOINT ,
195198 }
196199
197200
Original file line number Diff line number Diff line change 924924 hashery "^1.5.0"
925925 keyv "^5.6.0"
926926
927+ " @canonical/analytics-events@1.0.4 " :
928+ version "1.0.4"
929+ resolved "https://registry.yarnpkg.com/@canonical/analytics-events/-/analytics-events-1.0.4.tgz#27440161a7970f2f2a990dd0597e70685706c3b4"
930+ integrity sha512-+ChQJHpwpBQxuSdVwNv1YSGSzX6z6QeCmfxKqo8K02Hk2nJGuIdwEfi4yIa/KxVOhxaFLO7fy7ACSsBkTGeGRA==
931+
927932" @canonical/cookie-policy@3.8.4 " :
928933 version "3.8.4"
929934 resolved "https://registry.yarnpkg.com/@canonical/cookie-policy/-/cookie-policy-3.8.4.tgz#38fd82f35d98ab0476bc106b0d813a2719bae26c"
You can’t perform that action at this time.
0 commit comments