Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Background: 

...

  1. Experiment feature should be isolated from the main app.
  2. Deployment of the experiment should not affect the main app.
  3. Loading of the experiment app should be configurable and loading logic should reside in the server.
  4. Determine experiment Id  and fetch experiment details before the app loads .
  5. It should not have any impact on the load times for the users who are not part of an experiment.
  6. All telemetry generated from the portal thereafter should contain the experiment id (in tags section)

Prerequisites :- 

  • APP_INITIALIZER :- The "APP_INITIALIZER" is an instance of InjectionToken in angular that  will be executed when an application is initialized. We will make use of it and perform our device register call and get the experiment details at this step.
  • Currently device register call is done after the app is initialized.

Loading Experiment specific app:

Solution :- 


Image RemovedImage Added


Workflow for Anonymous users  : -

  1. Anonymous user opens the sunbird portal .
  2. App_initializer factory method is called before the app loads.
    1. generate the Did from browser. 
    2. Check whether any experiment is set for this user instance (inside locals).
    3. If no experiment is set then , check whether he/she is a non logged in user.
    4. By this time we will have the url and  did info.
    5. we will make a device register call passing "url and did"as extra parameters to fetch the experiment details .
      1. If no experiment is present then we will continue with the normal portal flow and load the default app . This will have no impact on the page load time.
      2. If any experiment is present then
        1. Reload the app passing experiment details in encoded form .
        2. There will be a middleware for the anonymous routes that will look for experiment details .
        3. Fetch the experiment build.
          1. Set the experiment Id and render the experiment app
        4. If no experiment dist found reload the app with normal app.
  3. App is reloaded with experiment Id set 
    1. Again App_initializer factory method is called before the app loads.
      1. this time experiment id is set so all steps are skipped and it loads the experiment app.
      2. initialise the telemetry with experiment id set in tags .

...