@@ -38,6 +38,8 @@ interface Consent {
3838 */
3939@Component
4040class TrackingConsent extends Vue {
41+ private static _instances: Set <TrackingConsent > = new Set ();
42+
4143 @Prop ({
4244 type: Object ,
4345 default : () => ({
@@ -76,12 +78,13 @@ class TrackingConsent extends Vue {
7678 @Prop ({
7779 type: Object ,
7880 default : () => ({
81+ setSiteId: 1 ,
7982 setTrackerUrl: TrackingConsent .DEFAULT_TRACKER_URL ,
8083 }),
8184 })
8285 public options: {
83- setSiteId: number , /* 3 for safe.nimiq.com ? */
84- setTrackerUrl: string
86+ setSiteId: number ,
87+ setTrackerUrl? : string
8588 addDownloadExtensions? : string ,
8689 trackPageView? : boolean ,
8790 enableLinkTracking? : boolean ,
@@ -123,11 +126,9 @@ class TrackingConsent extends Vue {
123126 type: String ,
124127 default: ' https://geoip.nimiq-network.com:8443/v1/locate' ,
125128 })
126- private geoIpServer: string ;
129+ public geoIpServer: string ;
127130
128- private static _instances: Set <TrackingConsent > = new Set ();
129131 private uiRequired: boolean = false ;
130- private safariFix: string = ' ' ;
131132
132133 public static get _paq() {
133134 if (! window ._paq || ! Array .isArray (window ._paq )) {
@@ -143,23 +144,33 @@ class TrackingConsent extends Vue {
143144 return window ._mtm ;
144145 }
145146
147+ /**
148+ * consent getter - return the parsed content of the consent cookie that store the user's choice about data sharing
149+ * @return {Consent} An object containing two boolean properties: allowsBrowserData & allowsUsageData
150+ */
146151 public static get consent(): Consent {
147152 const cookie = TrackingConsent ._getCookie (TrackingConsent .COOKIE_STORAGE_KEY );
153+
148154 if (cookie ) {
149155 return JSON .parse (cookie );
150156 }
151157
152158 return {};
153159 }
154160
155- public static get allowsUsageData() {
161+ public static get allowsUsageData(): boolean {
156162 return TrackingConsent .consent .allowsUsageData ;
157163 }
158164
159- public static get allowsBrowserData() {
165+ public static get allowsBrowserData(): boolean {
160166 return TrackingConsent .consent .allowsBrowserData ;
161167 }
162168
169+ /**
170+ * trackEvent - allow you to track custom interaction on the website/webapp.
171+ *
172+ * Docs: https://matomo.org/docs/event-tracking/
173+ */
163174 public static trackEvent(
164175 category : string ,
165176 action : string ,
@@ -208,17 +219,20 @@ class TrackingConsent extends Vue {
208219 return match && match [2 ];
209220 }
210221
222+ /** denyConsent - deny sharing usage & browser data and opt out of matomo tracking */
211223 public denyConsent() {
212224 TrackingConsent ._paq .push ([' optUserOut' ]);
213225 this ._setConsent ({ allowsUsageData: false , allowsBrowserData: false });
214226 }
215227
228+ /** allowUsageData - allow sharing usage & browser data */
216229 public allowUsageData() {
217230 TrackingConsent ._paq .push ([' forgetUserOptOut' ]);
218231 this ._setConsent ({ allowsUsageData: true , allowsBrowserData: true });
219232 this ._initMatomo ();
220233 }
221234
235+ /** allowBrowserData - allow sharing browser data, but not usage data */
222236 public allowBrowserData() {
223237 TrackingConsent ._paq .push ([' forgetUserOptOut' ]);
224238 this ._setConsent ({ allowsBrowserData: true , allowsUsageData: false });
0 commit comments