Versions Compared

Key

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

Background: 

Currently, Sunbird has one portal instance that has all the modules and has multiple tenant support. If a tenant request any changes to an existing feature or a new feature, all tenants will get these changes as well.

...

  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 by entering the url .
  2. before the portal loads in browser a middleware is called in portal backend that determines which app to load
    1. if expID is set in the express session load the experiment app
    2. else load the default portal app .
  3. App_initializer factory method is called before the app loadsangular bootstrap process.
    1. generate the Did and uaspec 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 makes an device register api call from portal backend (did and uaspec are passed as parameters)
      1. From portal backend 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.If any experiment
    6. 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
        1. any experimentation details 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.
      App is reloaded with experiment Id set 
            1. check for experiment build in blob
              1. if exists set the experiment id in express session.
              2. return the api response.
          1. If no experimentation details present 
            1. return the api response.
      1. API response from device register is received
        1. if experimentation details present then
          1. check whether expId is set
            1. continue with the portal bootstrap process.
          2. if expId is not set 
            1. reload the app.
            2. process continues from step 2.
        2. if experimentation details not present then
          1. continue with the portal bootstrap process.


    Workflow for Logged in users  : -

    1. Logged in User Anonymous user opens the sunbird portal by entering the url .
    2. before the portal loads in browser a middleware is called in portal backend that determines which app to load
      1. if expID is set in the express session load the experiment app
      2. else load the default portal app .
    3. App_initializer factory method is called before the app loads.
    4. Check whether any experiment is set for this user instance (inside locals).
    5. If no experiment is set then , check whether he/she is a logged in user.
    6. By this time we will have the url , uid and did info.
    7. we will angular bootstrap process.
      1. generate the Did and uaspec from browser. 
      2. makes an device register api call from portal backend (did and uaspec are passed as parameters)
        1. From portal backend make a device register call passing "url
        ,
        1. and did and
        userId
        1. uid"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 .
          1. If any
          experiment
      3. 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
          1. experimentation details is present then
            1. Reload the app passing experiment details in encoded form .
            2. There will be a middleware for the logged in 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.
        App is reloaded with experiment Id set 
              1. check for experiment build in blob
                1. if exists set the experiment id in express session.
                2. return the api response.
            1. If no experimentation details present 
              1. return the api response.
        1. API response from device register is received
          1. if experimentation details present then
            1. check whether expId is set
              1. continue with the portal bootstrap process.
            2. if expId is not set 
              1. reload the app.
              2. process continues from step 2.
          2. if experimentation details not present then
            1. continue with the portal bootstrap process.