Launching of Experimentation on Portal.
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.
Problem statement:
Sunbird should support experimenting with the portal, which allows customers to load the different portal app/module with new features. This should follow the below principle
- Experiment feature should be isolated from the main app.
- Deployment of the experiment should not affect the main app.
- Loading of the experiment app should be configurable and loading logic should reside in the server.
- Determine experiment Id and fetch experiment details before the app loads .
- It should not have any impact on the load times for the users who are not part of an experiment.
- All telemetry generated from the portal thereafter should contain the experiment id (in tags section)
Prerequisites :-
- APP_INITIALIZER :- The
"APP_INITIALIZER"
is an instance ofInjectionToken
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 :-
Workflow for Anonymous users : -
- Anonymous user opens the sunbird portal by entering the url .
- before the portal loads in browser a middleware is called in portal backend that determines which app to load
- if expID is set in the express session load the experiment app
- else load the default portal app .
- App_initializer factory method is called before the angular bootstrap process.
- generate the Did and uaspec from browser.
- makes an device register api call from portal backend (did and uaspec are passed as parameters)
- From portal backend make a device register call passing "url and did"as extra parameters to fetch the experiment details .
- If any experimentation details is present then
- check for experiment build in blob
- if exists set the experiment id in express session.
- return the api response.
- check for experiment build in blob
- If no experimentation details present
- return the api response.
- If any experimentation details is present then
- From portal backend make a device register call passing "url and did"as extra parameters to fetch the experiment details .
- API response from device register is received
- if experimentation details present then
- check whether expId is set
- continue with the portal bootstrap process.
- if expId is not set
- reload the app.
- process continues from step 2.
- check whether expId is set
- if experimentation details not present then
- continue with the portal bootstrap process.
- if experimentation details present then
Workflow for Logged in users : -
- Anonymous user opens the sunbird portal by entering the url .
- before the portal loads in browser a middleware is called in portal backend that determines which app to load
- if expID is set in the express session load the experiment app
- else load the default portal app .
- App_initializer factory method is called before the angular bootstrap process.
- generate the Did and uaspec from browser.
- makes an device register api call from portal backend (did and uaspec are passed as parameters)
- From portal backend make a device register call passing "url and did and uid"as extra parameters to fetch the experiment details .
- If any experimentation details is present then
- check for experiment build in blob
- if exists set the experiment id in express session.
- return the api response.
- check for experiment build in blob
- If no experimentation details present
- return the api response.
- If any experimentation details is present then
- From portal backend make a device register call passing "url and did and uid"as extra parameters to fetch the experiment details .
- API response from device register is received
- if experimentation details present then
- check whether expId is set
- continue with the portal bootstrap process.
- if expId is not set
- reload the app.
- process continues from step 2.
- check whether expId is set
- if experimentation details not present then
- continue with the portal bootstrap process.
- if experimentation details present then