GDPR, Cookie consent, delay loading aurelia

Hi,

I’m currently implementing cookie consent in my application for the GDPR region (using some free solution that implements the TCF API v2).

My code uses local storage and few cookies. Some third-party vendor do it too. According to GDPR you must ask the user for consent before storing non-mandatory data on the device (that includes local storage). My code became a little messy because I had to add a lot of promises everywhere to wait for the user consent.

I though that a more elegant solution would be load aurelia but not start it until the cookie consent is finished.

Also some plugins (like google analytics or i18n) would have to be delay loaded to wait for the cookie consent.

My first idea is to change the main.ts and call (some) plugin loads and the aurelia.start() inside of a promise (see example below).

  1. Do you believe this will work? Are there any risks that Aurelia won’t load at all?
  2. Has anybody done something similar in the past? Would you have a more elegant solution?

Example:

getCookieConsent().then((consent: boolean) => {
  // load the remaining plugins

  // start aurelia
  aurelia.start().then(() => aurelia.setRoot());
}.catch(() => {
  // assume no cookie consent but start aurelia
  consent = false;
  // load the remaining plugins

  // start aurelia
  aurelia.start().then(() => aurelia.setRoot());
});

Perfectly fine approach. I do something similar in order to load initialData which the User selects before the App starts. As long as you delay aurelias start all is fine