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

Report to Raven when a component does not support the requested brand. #188

Merged
merged 7 commits into from Jan 23, 2019

Conversation

notlee
Copy link
Contributor

@notlee notlee commented Jan 22, 2019

goal

SCSS compilation fails for o-layout@v3.0.0-beta-1 and the master brand. We don't intent to fix it, as o-layout only supports the internal brand.

Instead of a random SCSS compilation error:

cannot complete build due to compilation error from build tools: .../bower_components/o-typography/src/scss/_functions.scss Error: Invalid null operation: "null times 0.87". on line 21 of [...]

OBS should throw a more helpful error:

o-layout does not support the master brand. Please set a supported brand (internal) using the "brand" query parameter, otherwise contact the Origami team to propose adding master brand support to o-layout.

gotchas

  1. o-layout < v3 mistakenly set the brand SCSS variable itself, therefore some users have not have set their brand parameter in the OBS request. No error should be thrown in this case.
  2. Brand support has been added to components incrementally, therefore any components which are not branded have to assume support for any brand.
  3. Some components like o-colors have added support for different brands at different times. It's possible that a branded component has been used for an unsupported brand.

approach

Throwing an error when a component does not support the requested brand is technically a breaking due to gotcha 3. I think it's a reasonable error to throw though if we can confirm it won't break our users builds. This PR will report to Sentry any builds which would fail. If none are reported, we may assume we can safely throw an error for real (I suggest at least a month, to allow the max-age of builds to expire; a month will also allow for sites with little traffic to make a request, as branding is quite recent this concerns me less). 👈 Feedback on whether this is a dreadful idea appreciated.

@notlee notlee requested a review from a team as a code owner January 22, 2019 15:26
// Therefore projects may have included it without setting the brand.
let oLayoutException = false;
if (allComponents.hasOwnProperty('o-layout')) {
oLayoutException = parseFloat(allComponents['o-layout'].version) < 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would parseFloat work with a SemVer version such as 2.2.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would to confirm it's less than 3.

@JakeChampion
Copy link
Contributor

Is it possible to have some tests to cover this feature?

@notlee
Copy link
Contributor Author

notlee commented Jan 22, 2019

Is it possible to have some tests to cover this feature?

@JakeChampion My intention is to add an integration test if we keep it (I'll create an issue with details).

@notlee notlee merged commit abba03b into master Jan 23, 2019
@notlee notlee deleted the fail-when-brand-unsupported branch January 23, 2019 11:07
notlee added a commit that referenced this pull request Mar 14, 2019
* Error when building a component for an unsupported brand.

This is more helpful than broken CSS or a general Sass build failure.

Relates to: #188
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.

None yet

2 participants