Refactor commercial boot process #1764
Draft
+190
−167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this change?
Splits out the
loadModules
,recordCommercialMetrics
andbootCommercial
functions into a separateinit-utils
file for tidiness. Also splitsconsented.ts
into two files -ad-free.ts
andconsented-advertising.ts
. This (in my opinion) makes the ad free logic easier to find and clearer to read. By doing this, we also get rid of the idea of "base" and "extra" modules, which were confusingly named.Why?
Having explained this code several times over the last few weeks to different people, I have noticed a few parts that don't make immediate sense when you try to explain them (eg the naming of base vs extra modules). I think this little refactor is much more readable, and focuses the different bundle entry point files on the modules that they load.
Also, by having an ad-free specific file, we should be shipping less code to end users who don't see ads. I am also in favour of having the ad free check in the commercial file instead of the consented file, as I think it makes the purpose of each file much clearer to understand.
Would like to hear other people's thoughts on if this is an improvement or not!