Skip to content

Commit d5853e0

Browse files
committed
Use class based tracking, no async methods.
1 parent 42123ff commit d5853e0

4 files changed

Lines changed: 18 additions & 92 deletions

File tree

_scripts/page.js

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -38,84 +38,3 @@ export function url () {
3838

3939
return basePath
4040
}
41-
42-
/**
43-
* detectedOS
44-
* Returns the OS of the user
45-
*
46-
* @return {String} - OS of the user
47-
*/
48-
export function detectedOS () {
49-
const ua = window.navigator.userAgent
50-
if (ua == null || ua === false) return 'Other'
51-
if (ua.indexOf('Android') >= 0) {
52-
return 'Android'
53-
}
54-
if (ua.indexOf('Mac OS X') >= 0 && ua.indexOf('Mobile') >= 0) {
55-
return 'iOS'
56-
}
57-
if (ua.indexOf('Windows') >= 0) {
58-
return 'Windows'
59-
}
60-
if (ua.indexOf('Mac_PowerPC') >= 0 || ua.indexOf('Macintosh') >= 0) {
61-
return 'macOS'
62-
}
63-
if (ua.indexOf('Linux') >= 0) {
64-
return 'Linux'
65-
}
66-
return 'Unknown'
67-
}
68-
69-
/**
70-
* detectedArchitecture
71-
* Returns the architecture of the user's device using User-Agent Client Hints API
72-
*
73-
* @return {Promise<String>} - Architecture of the user (ARM or x86)
74-
*/
75-
export async function detectedArchitecture () {
76-
// Try to use the modern User-Agent Client Hints API first
77-
if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
78-
try {
79-
const values = await navigator.userAgentData.getHighEntropyValues(['architecture'])
80-
81-
if (values.architecture) {
82-
const arch = values.architecture.toLowerCase()
83-
if (arch.indexOf('arm') >= 0) {
84-
return 'ARM'
85-
}
86-
if (arch.indexOf('x86') >= 0) {
87-
return 'x86'
88-
}
89-
}
90-
} catch (e) {
91-
// Fall through to legacy detection
92-
}
93-
}
94-
95-
// Fallback to legacy user agent parsing
96-
const ua = window.navigator.userAgent
97-
if (ua == null || ua === false) return 'Unknown'
98-
99-
// Check for ARM indicators in user agent
100-
if (ua.indexOf('ARM') >= 0 || ua.indexOf('aarch64') >= 0 || ua.indexOf('arm64') >= 0) {
101-
return 'ARM'
102-
}
103-
104-
// Check for x86/x64 indicators
105-
if (ua.indexOf('x86') >= 0 || ua.indexOf('x64') >= 0 || ua.indexOf('WOW64') >= 0 || ua.indexOf('Win64') >= 0 || ua.indexOf('Intel Mac') >= 0) {
106-
return 'x86'
107-
}
108-
109-
// Additional platform checks
110-
if (navigator.platform) {
111-
const platform = navigator.platform.toLowerCase()
112-
if (platform.indexOf('arm') >= 0 || platform.indexOf('aarch') >= 0) {
113-
return 'ARM'
114-
}
115-
if (platform.indexOf('x86') >= 0 || platform.indexOf('win') >= 0 || platform.indexOf('mac') >= 0 || platform.indexOf('linux') >= 0) {
116-
return 'x86'
117-
}
118-
}
119-
120-
return 'Unknown'
121-
}

_scripts/pages/download.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import jQuery from '~/lib/jquery'
99

10-
import { detectedArchitecture } from '~/page'
1110
import config from '~/config'
1211

1312
import { openDownloadOverlay } from '~/widgets/download-modal'
@@ -132,19 +131,27 @@ Promise.all([config, jQuery, openDownloadOverlay]).then(([config, $, openDownloa
132131
})
133132

134133
// ACTION: .download-http.click: Track downloads
135-
$('.download-link').click(async function () {
134+
$('.download-link').click(function () {
135+
const $this = $(this)
136136
let downloadMethod = 'Unknown'
137-
if ($(this).hasClass('magnet')) {
137+
if ($this.hasClass('magnet')) {
138138
downloadMethod = 'Magnet'
139139
}
140-
if ($(this).hasClass('http')) {
140+
if ($this.hasClass('http')) {
141141
downloadMethod = 'HTTP'
142142
}
143+
let downloadArchitecture = 'Unknown'
144+
if ($this.hasClass('arm')) {
145+
downloadArchitecture = 'ARM'
146+
}
147+
if ($this.hasClass('x86')) {
148+
downloadArchitecture = 'x86'
149+
}
143150
plausible('Download', {
144151
props: {
145152
Region: config.user.region,
146153
Method: downloadMethod,
147-
Architecture: await detectedArchitecture(),
154+
Architecture: downloadArchitecture,
148155
Version: config.release.version
149156
}
150157
})

index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,16 +481,16 @@
481481
<h3 class="dialog-option-title">ARM® 64-bit</h3>
482482
<p class="dialog-option-subtitle">Apple Silicon, Raspberry Pi, etc</p>
483483
</div>
484-
<a class="button download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_arm_magnet'].'&dn='.$config['release_arm_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_arm_filename']); ?>"><i class="fa fa-magnet"></i></a>
485-
<a class="button download-link http" href="<?php echo $download_link.$config['release_arm_filename']; ?>">Download</a>
484+
<a class="button download-link magnet arm" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_arm_magnet'].'&dn='.$config['release_arm_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_arm_filename']); ?>"><i class="fa fa-magnet"></i></a>
485+
<a class="button download-link http arm" href="<?php echo $download_link.$config['release_arm_filename']; ?>">Download</a>
486486
</div>
487487
<div class="dialog-option">
488488
<div class="dialog-option-description">
489489
<h3 class="dialog-option-title">Intel or AMD 64-bit</h3>
490490
<p class="dialog-option-subtitle">Most PCs and older Macs</p>
491491
</div>
492-
<a class="button download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_magnet'].'&dn='.$config['release_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_filename']); ?>"><i class="fa fa-magnet"></i></a>
493-
<a autofocus class="button download-link http" href="<?php echo $download_link.$config['release_filename']; ?>">Download</a>
492+
<a class="button download-link magnet x86" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['release_magnet'].'&dn='.$config['release_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http%3A<?php echo urlencode($download_link.$config['release_filename']); ?>"><i class="fa fa-magnet"></i></a>
493+
<a autofocus class="button download-link http x86" href="<?php echo $download_link.$config['release_filename']; ?>">Download</a>
494494
</div>
495495
</div>
496496
</dialog>

previous.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
<h1>Thank You for Downloading elementary OS</h1>
3838
<div class="action-area">
3939
<div class="linked">
40-
<a class="button suggested-action download-link http" href="<?php echo $download_link.$config['previous_filename']; ?>">Download</a>
41-
<a class="button suggested-action download-link magnet" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['previous_magnet'].'&dn='.$config['previous_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http:<?php echo $download_link.$config['previous_filename']; ?>"><i class="fa fa-magnet"></i></a>
40+
<a class="button suggested-action download-link http x86" href="<?php echo $download_link.$config['previous_filename']; ?>">Download</a>
41+
<a class="button suggested-action download-link magnet x86" title="Torrent Magnet Link" href="<?php echo 'magnet:?xt=urn:btih:'.$config['previous_magnet'].'&dn='.$config['previous_filename']; ?>&tr=https%3A%2F%2Fashrise.com%3A443%2Fphoenix%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&ws=http:<?php echo $download_link.$config['previous_filename']; ?>"><i class="fa fa-magnet"></i></a>
4242
</div>
4343
</div>
4444
<p>For help and more info, read the <a href="<?php echo $page['lang-root'];?>/docs/installation#installation">installation guide</a>. If you purchased elementary OS, check your email for a receipt that includes your link to download elementary OS again for free.</p>

0 commit comments

Comments
 (0)