Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/lib/services/connect/services/connect.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { supabaseProfile } from "./supabaseProfile.svelte";
/** Global anonymous mode flag, controlled by environment variable */
let anonMode = false;

/** Global flag to disable analytics in case of database issues*/
export let analyticsEnabled = false;

if (PUBLIC_ANON_MODE === "TRUE") {
anonMode = true;
}
Expand Down Expand Up @@ -98,8 +101,10 @@ export const tutorsConnectService: TutorsConnectService = {
*/
courseVisit(course: Course) {
if (anonMode) return;
updateCourseList(course);
this.profile.logCourseVisit(course);
if (analyticsEnabled) {
updateCourseList(course);
this.profile.logCourseVisit(course);
}
presenceService.startPresenceListener(course.courseId);
if (course.authLevel! > 0 && !tutorsId.value?.login) {
localStorage.loginCourse = course.courseId;
Expand Down Expand Up @@ -146,7 +151,7 @@ export const tutorsConnectService: TutorsConnectService = {
learningEvent(params: Record<string, string>): void {
if (anonMode) return;
if (currentCourse.value && currentLo.value && tutorsId.value) {
analyticsService.learningEvent(currentCourse.value, params, currentLo.value, tutorsId.value);
if (analyticsEnabled) analyticsService.learningEvent(currentCourse.value, params, currentLo.value, tutorsId.value);
if (tutorsId.value.share === "true" && !currentCourse.value.isPrivate) {
presenceService.sendLoEvent(currentCourse.value, currentLo.value, tutorsId.value);
}
Expand All @@ -161,7 +166,7 @@ export const tutorsConnectService: TutorsConnectService = {
if (anonMode) return;
this.intervalId = setInterval(() => {
if (!document.hidden && currentCourse.value && currentLo.value && tutorsId.value) {
analyticsService.updatePageCount(currentCourse.value, currentLo.value, tutorsId.value);
if (analyticsEnabled) analyticsService.updatePageCount(currentCourse.value, currentLo.value, tutorsId.value);
}
}, 30 * 1000);
},
Expand Down
7 changes: 5 additions & 2 deletions src/lib/ui/navigators/tutors-connect/ConnectedProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import OnlineButton from "../buttons/OnlineButton.svelte";
import Icon from "$lib/ui/components/Icon.svelte";
import { currentCourse, tutorsId } from "$lib/runes.svelte";
import { analyticsEnabled } from "$lib/services/connect/services/connect.svelte";

function logout() {
tutorsConnectService.disconnect("/");
Expand All @@ -19,7 +20,7 @@
{#snippet menuSelector()}
<div class="relative">
{#if presenceService.studentsOnline.value.length && tutorsId.value?.share}
<span class="variant-filled-error badge-icon text-error-500 font-bold absolute -top-1 -right-2 z-10">
<span class="variant-filled-error badge-icon text-error-500 absolute -top-1 -right-2 z-10 font-bold">
{presenceService.studentsOnline.value.length}
</span>
{/if}
Expand All @@ -45,7 +46,9 @@
<MenuItem text="Share Presence" type="offline" onClick={shareStatusChange} />
{/if}
{#if tutorsId.value?.share === "true"}
<MenuItem link="https://time.tutors.dev/{currentCourse.value?.courseId}" text="Tutors Time" type="tutorsTime" targetStr="_blank" />
{#if analyticsEnabled}
<MenuItem link="https://time.tutors.dev/{currentCourse.value?.courseId}" text="Tutors Time" type="tutorsTime" targetStr="_blank" />
{/if}
<MenuItem link="/live/{currentCourse.value?.courseId}" text="Tutors Live" type="live" targetStr="_blank" />

<li class="option hover:preset-tonal p-0!">
Expand Down
Loading