Skip to content

Commit 3b70bc8

Browse files
authored
track installs on distro page (#5621)
* track installs on distro page
1 parent 298262d commit 3b70bc8

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

static/js/public/distro-install.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import screenshots from "./snap-details/screenshots";
22
import videos from "./snap-details/videos";
33
import initExpandableArea from "./expandable-area";
44
import triggerEventWhenVisible from "./ga-scroll-event";
5+
import initCopyCommand from "./snap-details/copyCommand";
56
import declareGlobal from "../libs/declare";
7+
import { trackPageView } from "@canonical/analytics-events";
8+
9+
if (window.ANALYTICS_ENDPOINT) {
10+
trackPageView("snap_distro_install_page");
11+
}
12+
13+
initCopyCommand();
614

715
declareGlobal("snapcraft.public.distroInstall", {
816
screenshots,
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
<div class="p-code-snippet">
1+
<div class="p-code-snippet" style="position: relative;">
22
<pre class="p-code-snippet__block--icon is-wrapped"><code {% if snippet_id %}id="snippet-{{ snippet_id }}"{% endif %}>{{ snippet_value }}</code></pre>
3+
{% if snippet_id %}
4+
<button
5+
class="p-button--base is-dense has-icon u-no-margin--bottom"
6+
title="Copy to clipboard"
7+
data-js="copy-install-command"
8+
data-copy-target="snippet-{{ snippet_id }}"
9+
{% if snippet_analytics_target %}
10+
data-analytics-click
11+
data-analytics-target="{{ snippet_analytics_target }}"
12+
{% endif %}
13+
style="position: absolute; top: 0.5rem; right: 0.5rem;"
14+
>
15+
<i class="p-icon--copy">Copy to clipboard</i>
16+
</button>
17+
{% endif %}
318
</div>

templates/store/snap-distro-install.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ <h3>Install {{ snap_title }}</h3>
188188
lowest_risk_available,
189189
confinement) %}
190190
{% set snippet_id = "snap-install-stable" %}
191+
{% set snippet_analytics_target = "snap_distro_install_copy_install_command" %}
191192
{% include "/partials/_code-snippet.html" %}
192193
</div>
193194
</div>

0 commit comments

Comments
 (0)