From 7c57f5d4fb137dd6d7e0dc9ef257de1e21a1dee7 Mon Sep 17 00:00:00 2001 From: Mark Hall Date: Fri, 29 Sep 2023 15:37:18 +0100 Subject: [PATCH] Added tracking consent UI --- museum_map/server/frontend/src/App.svelte | 2 + .../src/components/TrackingConfig.svelte | 196 ++++++++++++++++++ .../server/frontend/src/store/consent.ts | 12 ++ museum_map/server/frontend/src/store/index.ts | 5 + 4 files changed, 215 insertions(+) create mode 100644 museum_map/server/frontend/src/components/TrackingConfig.svelte create mode 100644 museum_map/server/frontend/src/store/consent.ts diff --git a/museum_map/server/frontend/src/App.svelte b/museum_map/server/frontend/src/App.svelte index 05dd06e..194e881 100644 --- a/museum_map/server/frontend/src/App.svelte +++ b/museum_map/server/frontend/src/App.svelte @@ -5,6 +5,7 @@ import Lobby from "./routes/Lobby.svelte"; import Room from "./routes/Room.svelte"; + import TrackingConfig from "./components/TrackingConfig.svelte"; import { isBusy, isUpdatable } from "./store"; import { @@ -138,4 +139,5 @@ {/if} + diff --git a/museum_map/server/frontend/src/components/TrackingConfig.svelte b/museum_map/server/frontend/src/components/TrackingConfig.svelte new file mode 100644 index 0000000..350df9d --- /dev/null +++ b/museum_map/server/frontend/src/components/TrackingConfig.svelte @@ -0,0 +1,196 @@ + + +
+ +
+ +{#if dialogVisible} +
+

+ Participate in our Research +

+ {#if $trackingAllowed} +

+ Thank you for contributing to the Museum Map project. Your input is much + appreciated! +

+ {/if} +
+
+

+ The Museum Map system is developed as part of an ongoing research + project collaboration between researchers at the Open University and + Edge Hill University. We are investigating how large digital cultural + heritage collections can be made available to the general public. As + part of this we are also interested in understanding how users explore + such a digital collection and for this we would like to ask you for + your consent to track your interactions on the Museum Map. If you are + prepared to help us, then please use the consent button on the right + to give your consent to collecting your data as outlined. +

+
+
+

+ If you consent to participate, the following data will be collected: +

+
    +
  • Your browser version and operating system.
  • +
  • All your interactions with the Museum Map system.
  • +
  • Basic demographics data.
  • +
+

Your data will be used for the following purposes:

+
    +
  • + Anonymised and cleaned data will be made available to the research + community for future studies. +
  • +
  • + Anonymised and cleaned data will be used in research publications. +
  • +
+

+ You can withdraw your consent at any point using the research icon in + the bottom-left corner of the page. +

+
+
+ + {#if $consent} + + {/if} +
+
+ +
+
+
+
+ +
+{/if} diff --git a/museum_map/server/frontend/src/store/consent.ts b/museum_map/server/frontend/src/store/consent.ts new file mode 100644 index 0000000..f708ce3 --- /dev/null +++ b/museum_map/server/frontend/src/store/consent.ts @@ -0,0 +1,12 @@ +import { writable, derived, get } from "svelte/store"; +import { localPreferences, type NestedStorage } from "./preferences"; + +const prefs = get(localPreferences); + +export const consent = writable(prefs.tracking && (prefs.tracking as NestedStorage).consent === true); + +export const ageBand = writable(prefs.tracking && (prefs.tracking as NestedStorage).ageBand as string || "0"); + +export const trackingAllowed = derived([consent, ageBand], ([consent, ageBand]) => { + return consent && Number.parseInt(ageBand) > 0; +}); diff --git a/museum_map/server/frontend/src/store/index.ts b/museum_map/server/frontend/src/store/index.ts index 2935864..dfb2207 100644 --- a/museum_map/server/frontend/src/store/index.ts +++ b/museum_map/server/frontend/src/store/index.ts @@ -7,6 +7,7 @@ import { config, fetchConfig, status, fetchStatus, isUpdatable } from './config' import { cachedTopics, loadTopics } from './topics'; import { localPreferences } from './preferences'; import { searchTerm, searchRoom, matchingFloors, matchingRooms, matchingItems } from './search'; +import { consent, ageBand, trackingAllowed } from './consent'; export { busyCounter, @@ -45,4 +46,8 @@ export { matchingFloors, matchingRooms, matchingItems, + + consent, + ageBand, + trackingAllowed, };