Update Telemtry
This commit is contained in:
parent
c85d3345c6
commit
8493d67a62
6 changed files with 121 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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("/");
|
||||
---
|
||||
<style is:global>body {background: black}</style>
|
||||
<API Title="MinPluto" Description=""></API>
|
|
@ -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("/");
|
||||
---
|
||||
<style is:global>body {background: black}</style>
|
||||
<API Title="MinPluto" Description=""></API>
|
24
src/pages/api/telemtry/disable.astro
Normal file
24
src/pages/api/telemtry/disable.astro
Normal file
|
@ -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
|
||||
}
|
||||
---
|
||||
<API Title="MinPluto" Description=""></API>
|
36
src/pages/api/telemtry/enable.astro
Normal file
36
src/pages/api/telemtry/enable.astro
Normal file
|
@ -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");
|
||||
---
|
||||
<API Title="MinPluto" Description=""></API>
|
|
@ -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
|
||||
}
|
||||
---
|
||||
|
||||
<Base Title="MinPluto Telemtry" Description="">
|
||||
|
@ -13,14 +20,13 @@ import Base from "@layouts/Default.astro";
|
|||
<hr/>
|
||||
<p>If you decide to opt-in, the following is tracked:</p>
|
||||
<ul style="text-align: left; max-width: 300px;">
|
||||
<li>All pages navigated to</li>
|
||||
<li>Language</li>
|
||||
<li>Browser Useragent</li>
|
||||
<li>Operating System</li>
|
||||
<li>Screen Size</li>
|
||||
<li>Errors</li>
|
||||
<li>Location</li>
|
||||
<li>All settings, except for some</li>
|
||||
<li>Platforms you've imported from</li>
|
||||
</ul>
|
||||
<p>The following will not be tracked:</p>
|
||||
<ul style="text-align: left; max-width: 300px;">
|
||||
|
@ -31,13 +37,16 @@ import Base from "@layouts/Default.astro";
|
|||
<li>Shares</li>
|
||||
<li>Embeds</li>
|
||||
<li>Personal Information in your account, such as name and email</li>
|
||||
<li>CSS/JS Customization</li>
|
||||
<li>Themes</li>
|
||||
</ul>
|
||||
<p style="font-size: 14px; opacity: 0.4;">Note that this can change at anytime.</p>
|
||||
<hr/>
|
||||
<a style="cursor: not-allowed; filter: brightness(0.3) ;color: white;text-decoration: none;margin-bottom: 6px;border-radius: 6px;padding: 8px 24px;background: #1a1a1a;font-size: 14px;border: 2px rgba(255, 255, 255, 0.25) solid;" href="#">Opt-In</a>
|
||||
<br/>
|
||||
<br/>
|
||||
<p style="font-size: 14px; opacity: 0.4;">Not yet implemented</p>
|
||||
{UserIsOptedIn ?
|
||||
<a style="color: white;text-decoration: none;margin-bottom: 6px;border-radius: 6px;padding: 8px 24px;background: #1a1a1a;font-size: 14px;border: 2px rgba(255, 255, 255, 0.25) solid;" href="/api/telemtry/disable">Opt-Out</a>
|
||||
:
|
||||
<a style="color: white;text-decoration: none;margin-bottom: 6px;border-radius: 6px;padding: 8px 24px;background: #1a1a1a;font-size: 14px;border: 2px rgba(255, 255, 255, 0.25) solid;" href="/api/telemtry/enable">Opt-In</a>
|
||||
}
|
||||
</center>
|
||||
</div>
|
||||
</Base>
|
||||
|
|
Reference in a new issue