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

WSTEAM1-827: Add EMP core work. #11347

Merged
merged 62 commits into from
Mar 4, 2024
Merged

WSTEAM1-827: Add EMP core work. #11347

merged 62 commits into from
Mar 4, 2024

Conversation

shayneahchoon
Copy link
Contributor

Resolves WSTEAM1-827

Overall changes

Adds a dynamic Media Player component that loads the correct embedded media player for a user device.
Article Page:
Screenshot 2023-12-22 at 11 51 17

Live Page:
Screenshot 2023-12-28 at 16 14 04

Code changes

  • An EMP loader has been added here src/app/components/MediaPlayer/index.tsx
  • A BUMP settings builder has been added here /src/app/components/MediaPlayer/utils/buildSettings.ts
  • Parameter extractor functions have been modified to fit BUMP requirements here src/app/legacy/containers/MediaPlayer/helpers/propsInference/default/index.js
  • Added the EMP loader to LivePage

Testing

  1. For localhost:
  2. In your terminal, run sudo -- sh -c -e "echo '127.0.0.1 localhost.bbc.com' >> /etc/hosts";.
  3. For the Express app: Go to http://localhost.bbc.com:7080/afaanoromoo/articles/c4g19kgl85ko and check that the video loads.
  4. For the NextJS app: Go to http://localhost.bbc.com:7081/pidgin/live/c7p765ynk9qt?renderer_env=test and check that the video loads.

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@shayneahchoon shayneahchoon changed the title WSTEAM1-827 WSTEAM1-827: Add EMP core work. Feb 26, 2024
Copy link
Contributor

@amoore108 amoore108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great start, thanks for all the hard work!

Comment on lines 5 to 14
const isTestURL = () => {
let isTestRender = false;

if (onClient()) {
const queryParams = new URLSearchParams(window.location.search);
isTestRender = queryParams.get('renderer_env') === 'test';
}

return isTestRender;
};
Copy link
Contributor

@amoore108 amoore108 Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking, do we need to use the Test mediator if we're on the Test environment in general? We tend to not use the renderer_env flag on Test, as the environment variables should determine what to use behind the scenes.

I'm not 100% sure the videos will work when this is deployed to Test if we aren't using the Test mediator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this one in to apply this setting: { mediator: { host: 'open.test.bbc.co.uk' } }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that way, we could easily switch between live and test assets when doing development on our localhost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could switch it the other way round so that { mediator: { host: 'open.test.bbc.co.uk' } } is applied by default, but removed if it's on live?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its ok for localhost, I'm just thinking when its deployed to Test, will we need to remember to add in renderer_env=test to get the video player to work correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling is that the mediator value should default to the environment its on and then we override it with the renderer_env query param.

So on local/test it defaults to { mediator: { host: 'open.test.bbc.co.uk' } } and we use renderer_env flags to override it if needed.
On Live mediator is removed entirely and cannot be overridden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coolio

Copy link
Contributor

@amoore108 amoore108 Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something along these lines may work:

switch (true) {
  // Conditions to use Test Mediator
  case queryParams.get('renderer_env') === 'test':
  case isLocal():
  case isTest():
    return true;
  // Conditions to use Live Mediator
  case queryParams.get('renderer_env') === 'live' && !isLive():
    return false;
  default:
    return false;
}

The ordering of the cases is important, so the above may not work and require a bit of testing to get it just right. if statements maybe clearer for this.

Copy link
Contributor

@Isabella-Mitchell Isabella-Mitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks for going through it! A few notes from our call

  • Will need to check that this doesn't break if editorial try to upload audio before we support it.
  • Will need to update the NextJS threat model with BUMP/ our Runbook before it goes to production.

@shayneahchoon shayneahchoon merged commit 78f6f93 into latest Mar 4, 2024
11 checks passed
@shayneahchoon shayneahchoon deleted the WSTEAM1-827 branch March 4, 2024 15:09
shayneahchoon added a commit that referenced this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants