Skip to content

Commit 96233d0

Browse files
authored
Merge branch 'main' into feat/show-package-size-1864
2 parents 5868528 + 684e209 commit 96233d0

9 files changed

Lines changed: 41 additions & 2 deletions

File tree

konf/site.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ extraHosts:
100100
# Overrides for production
101101
production:
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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
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",

static/js/base/base.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
import "./ga";
22
import "./contactForm";
33
import "./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+
}

static/js/public/store-details.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import initEmbeddedCardModal from "./snap-details/embeddedCard";
77
import { snapDetailsPosts } from "./snap-details/blog-posts";
88
import initExpandableArea from "./expandable-area";
99
import declareGlobal from "../libs/declare";
10+
import { trackPageView } from "@canonical/analytics-events";
11+
12+
if (window.ANALYTICS_ENDPOINT) {
13+
trackPageView("snap_details_page");
14+
}
1015

1116
declareGlobal("snapcraft.public.storeDetails", {
1217
map,

templates/_base-layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
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 }}">

templates/store/snap-details.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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>

webapp/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ class ConfigurationError(Exception):
4949
SEARCH_CUSTOM_ID = "009048213575199080868:i3zoqdwqk8o"
5050

5151
APP_NAME = "snapcraft"
52+
ANALYTICS_ENDPOINT = os.getenv("ANALYTICS_ENDPOINT", "").strip()
5253

5354
REPORT_SHEET_URL = os.getenv("REPORT_SHEET_URL", "").strip()

webapp/handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
DNS_VERIFICATION_SALT,
2525
IS_DEVELOPMENT,
2626
VITE_PORT,
27+
ANALYTICS_ENDPOINT,
2728
)
2829

2930
from canonicalwebteam.exceptions import (
@@ -90,6 +91,7 @@
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

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,11 @@
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"

0 commit comments

Comments
 (0)