diff --git a/src/components/global/Head.astro b/src/components/global/Head.astro
index 502df74..495e94e 100644
--- a/src/components/global/Head.astro
+++ b/src/components/global/Head.astro
@@ -1,7 +1,6 @@
---
// i18n
import i18next, { t } from "i18next";
-import { Trans, HeadHrefLangs } from "astro-i18next/components";
// Cookies
/// Language
@@ -10,6 +9,12 @@ if (Astro.cookies.get("Language") === undefined) {
Astro.cookies.set("Language", "EN", {path: "/",sameSite: 'strict'})
}
+/// Telemtry
+//// Users should be opted-out by default
+if (Astro.cookies.get("Telemtry") === undefined) {
+ Astro.cookies.set("Telemtry", "Disabled", {path: "/",sameSite: 'strict'})
+}
+
//// Check what language the user has set it to and switch to it
var UserLanguage = Astro.cookies.get("Language").value
if (UserLanguage === "JP") {i18next.changeLanguage("jp")}
@@ -31,9 +36,6 @@ import Analytics from "@components/global/Analytics.astro";
// Configuration
import {SERVER_DOMAIN} from '@utils/GetConfig'
-// Icons
-import { Donate, Download, ShareIos, ThumbsUp } from '@iconoir/vue'
-
// Embed
const SWV = Astro.url.href.split("embed/").pop();
@@ -46,7 +48,6 @@ if (Astro.url.href.match('watch')) {
}
// Track Events
-
// TODO
// Before re-enabling, create an "opt-in" solution
// first for the end-user, as asking for consent
diff --git a/src/pages/api/language/en.astro b/src/pages/api/language/en.astro
index 40da0c7..af6dd52 100644
--- a/src/pages/api/language/en.astro
+++ b/src/pages/api/language/en.astro
@@ -1,8 +1,27 @@
---
+// Layout
+import API from '@layouts/API.astro'
+
+// API Action
Astro.cookies.set("Language", "EN", {
path: "/",
sameSite: "strict"
});
+
+// Track Event
+import { OpenpanelSdk } from '@openpanel/sdk';
+const op = new OpenpanelSdk({
+ clientId: 'b4c27f56-18f5-4d66-bb62-cbf7f7161812',
+ clientSecret: 'sec_107558407af59a591b50',
+});
+if (Astro.cookies.get("Telemtry").value === "Enabled") {
+ op.event('Language', { Language: 'English' });
+}
+else if (Astro.cookies.get("Telemtry").value === "Disabled") {
+ null
+}
+
+// Return
return Astro.redirect("/");
---
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/pages/api/language/jp.astro b/src/pages/api/language/jp.astro
index 95ea390..2d2210b 100644
--- a/src/pages/api/language/jp.astro
+++ b/src/pages/api/language/jp.astro
@@ -1,8 +1,27 @@
---
+// Layout
+import API from '@layouts/API.astro'
+
+// API Action
Astro.cookies.set("Language", "JP", {
path: "/",
sameSite: "strict"
});
+
+// Track Event
+import { OpenpanelSdk } from '@openpanel/sdk';
+const op = new OpenpanelSdk({
+ clientId: 'b4c27f56-18f5-4d66-bb62-cbf7f7161812',
+ clientSecret: 'sec_107558407af59a591b50',
+});
+if (Astro.cookies.get("Telemtry").value === "Enabled") {
+ op.event('Language', { Language: 'Japanese' });
+}
+else if (Astro.cookies.get("Telemtry").value === "Disabled") {
+ null
+}
+
+// Return
return Astro.redirect("/");
---
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/pages/api/telemtry/disable.astro b/src/pages/api/telemtry/disable.astro
new file mode 100644
index 0000000..d680855
--- /dev/null
+++ b/src/pages/api/telemtry/disable.astro
@@ -0,0 +1,24 @@
+---
+import API from '@layouts/API.astro'
+Astro.cookies.set("Telemtry", "Disabled", {
+ path: "/",
+ sameSite: "strict"
+});
+return Astro.redirect("/telemtry");
+
+// SDK
+import { OpenpanelSdk } from '@openpanel/sdk';
+const op = new OpenpanelSdk({
+ clientId: 'b4c27f56-18f5-4d66-bb62-cbf7f7161812',
+ clientSecret: 'sec_107558407af59a591b50',
+});
+
+// Track Event
+if (Astro.cookies.get("Telemtry").value === "Enabled") {
+ op.event('Language', { Language: 'English' });
+}
+else if (Astro.cookies.get("Telemtry").value === "Disabled") {
+ null
+}
+---
+
\ No newline at end of file
diff --git a/src/pages/api/telemtry/enable.astro b/src/pages/api/telemtry/enable.astro
new file mode 100644
index 0000000..7759fba
--- /dev/null
+++ b/src/pages/api/telemtry/enable.astro
@@ -0,0 +1,36 @@
+---
+// Layout
+import API from '@layouts/API.astro'
+
+// API Action
+Astro.cookies.set("Telemtry", "Enabled", {
+ path: "/",
+ sameSite: "strict"
+});
+
+// SDK
+import { OpenpanelSdk } from '@openpanel/sdk';
+const op = new OpenpanelSdk({
+ clientId: 'b4c27f56-18f5-4d66-bb62-cbf7f7161812',
+ clientSecret: 'sec_107558407af59a591b50',
+});
+
+// Track Event
+import { useUserAgent } from "astro-useragent";
+const uaString = Astro.request.headers.get("user-agent");
+const {
+ os,
+ browser,
+ browserVersion,
+ isDesktop,
+ isMobile
+} = useUserAgent(uaString);
+op.event('Operating System', {OS: os})
+op.event('Browser', {Browser: browser + ' v' + browserVersion})
+op.event('Desktop', {Desktop: isDesktop})
+op.event('Mobile', {Mobile: isMobile})
+
+// Return
+return Astro.redirect("/telemtry");
+---
+
\ No newline at end of file
diff --git a/src/pages/telemtry.astro b/src/pages/telemtry.astro
index c086d0a..de6c768 100644
--- a/src/pages/telemtry.astro
+++ b/src/pages/telemtry.astro
@@ -1,6 +1,13 @@
---
import i18next,{ t, changeLanguage } from "i18next";
import Base from "@layouts/Default.astro";
+
+if (Astro.cookies.get("Telemtry").value === "Enabled") {
+ var UserIsOptedIn = true
+}
+else if (Astro.cookies.get("Telemtry").value === "Disabled") {
+ var UserIsOptedIn = false
+}
---
@@ -13,14 +20,13 @@ import Base from "@layouts/Default.astro";
If you decide to opt-in, the following is tracked:
- - All pages navigated to
- Language
- Browser Useragent
- Operating System
- - Screen Size
- Errors
- Location
- All settings, except for some
+ - Platforms you've imported from
The following will not be tracked:
@@ -31,13 +37,16 @@ import Base from "@layouts/Default.astro";
- Shares
- Embeds
- Personal Information in your account, such as name and email
+ - CSS/JS Customization
+ - Themes
Note that this can change at anytime.
- Opt-In
-
-
- Not yet implemented
+ {UserIsOptedIn ?
+ Opt-Out
+ :
+ Opt-In
+ }