Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc explaining the codebase structure #1743

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/code-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Commercial codebase structure

The entry point of the commercial runtime is [commercial.ts](./commercial.ts)

The codebase is structured to align with the [lifecycle](https://github.com/guardian/commercial-playground/blob/main/simple-ad-example/render-ad.html) of displaying an advert

The high level sequence is as follows:

## init

Initialise commercial, decide if we are running consented, consentless (i.e. opt out) and initialise respective modules

In particular initialises Google Publisher Tag (GPT) in [prepare-googletag](./init/consented/prepare-googletag.ts)

## define

Call Google Publisher Tag (GPT) to _define_ an advert, with its size mappings

## display

Call Google Publisher Tag (GPT) to _display_ an advert

Includes logic to control lazy loading and refresh

## events

Ad event handlers

## insert

Code that inserts all dynamic ads i.e. spacefinder inserted ads or inserted ads for specific use cases

## experiments

AB test modules

## lib

Library modules

Exported library utilties are specified in [export.ts](./init/consented/export.ts)
Loading