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

chore: add runtime component deprecation warnings #9821

Merged
merged 12 commits into from
Jul 23, 2024

Conversation

jcfranco
Copy link
Member

@jcfranco jcfranco commented Jul 20, 2024

Related Issue: #9295

Summary

This adds deprecation warning messages to components marked for deprecation at v3 and v4.

Screenshot 2024-07-19 at 4 22 03 PM

Notes

  • Adds logger util to:
    • facilitate deprecation of component and their members (this PR)
    • help ensure consistent log messages across components and utils (follow-up PR)
    • display a 'badge' for calcite-related messages (similar to Stencil)
  • Fixes typo in variable for global test log spy
  • Adds logLevel to the config for users to specify a different log level
  • There is a known limitation for composite components where the host and supporting components are also deprecated. For these cases, a deprecation message will be displayed per component.

Questions

  1. Badge 👍👎?
  2. Assuming 👍 on the badge, should we keep calcite in component names used in messaging? The badge already provides context
  3. Do we want to keep logLevel in the config or should we do something similar to Maps SDK's config for future log-related features? I don't see a use case for interceptors at the moment.

@jcfranco jcfranco added the skip visual snapshots Pull requests that do not need visual regression testing. label Jul 20, 2024
@github-actions github-actions bot added the chore Issues with changes that don't modify src or test files. label Jul 20, 2024
@driskull
Copy link
Member

  1. I do like the badge
  2. I don't think we need the calcite prefix as it is redundant with the badge.
  3. I think its probably fine in the config for now. What do you think?

Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

This will be awesome! 💯

import { CSS, SLOTS } from "./resources";

logger.deprecated("component", {
Copy link
Member

Choose a reason for hiding this comment

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

this is super cool!

}

const badgeTemplate = "%ccalcite";
const badgeStyle = "background: #007AC2; color: #fff; border-radius: 4px;padding: 2px 4px;";
Copy link
Member

Choose a reason for hiding this comment

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

Should design approve the styling :)

Wondering if we could use CSS vars here instead of styles. I guess it doesn't really matter since its just a log badge but still.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did test this, but no dice. Custom CSS props don't appear to be available for console styling. 😞

listFormatter = new Intl.ListFormat("en", { style: "long", type: "disjunction" });
}

const message = `[${name}] ${context} is deprecated and will be removed in ${removalVersion === "future" ? `a future version` : `v${removalVersion}`}.${suggested ? ` Use ${multiSuggestions ? listFormatter.format(suggested.map((suggestion) => `"${suggestion}"`)) : `"${suggested}"`} instead.` : ""}`;
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to translate this right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. Dev messaging is not translated.

@DitwanP
Copy link
Contributor

DitwanP commented Jul 22, 2024

This is great! 💪 👏

I'm with Matt on points 1, 2, and 3 from his first comment above.

@geospatialem geospatialem self-requested a review July 22, 2024 19:30
Copy link
Member

@geospatialem geospatialem left a comment

Choose a reason for hiding this comment

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

Awesome!! 💪🏻

As far as the version, should we also mention a timeframe for folks to plan, or keep it vague with the version? Something like:

calcite [tip-group] component is deprecated and will be removed in v4 (2025 Q4). Use "carousel" or "carousel item" instead.

  1. Badge 👍👎?

Badge it up! 🦡📛

  1. Assuming 👍 on the badge, should we keep calcite in component names used in messaging? The badge already provides context

For consistency with our documentation, its okay to omit since its mentioned already in the badge. If we remove the badge, we should leave it in though.

The only hesitation would be if omitting it creates confusion for developers to use the recommended component(s).

It looks like the messaging also adds " to the recommended components, should the symbol be around each of the recommendations, like:

Use "carousel" or "carousel-item" instead.

  1. Do we want to keep logLevel in the config or should we do something similar to Maps SDK's config for future log-related features? I don't see a use case for interceptors at the moment.

Flexible on whichever approach is best as long as it is clear to developers working with both Maps SDK and Calcite.

Copy link
Member

@benelan benelan left a comment

Choose a reason for hiding this comment

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

I like this idea as well! One suggestion that hasn't been mentioned, maybe add a "none" or "disabled" option to logLevels? That way teams can completely turn it off in prod and set it to something verbose in dev.

@jcfranco
Copy link
Member Author

As far as the version, should we also mention a timeframe for folks to plan, or keep it vague with the version? Something like:

I like the idea of adding the timeframe, but this would be tricky to maintain and enforce via TypeScript.

The only hesitation would be if omitting it creates confusion for developers to use the recommended component(s).

I hear ya. We should be good on this front since we do have the badge giving context and often omit calcite in the doc when referring to components. This also makes the message less noisy.

It looks like the messaging also adds " to the recommended components, should the symbol be around each of the recommendations, like:

My bad. 😅 I used an outdated screenshot. Each component should be quoted in the latest version (covered by a test too).

@jcfranco
Copy link
Member Author

Thanks for the feedback, y'all! 🚀 Made the following changes:

  • dropped namespace from component messaging to simplify (this is enforced by TS)
  • added an off level to mute all logs

@jcfranco jcfranco merged commit 574ac9a into dev Jul 23, 2024
9 checks passed
@jcfranco jcfranco deleted the jcfranco/9295-add-deprecation-messaging branch July 23, 2024 03:33
@github-actions github-actions bot added this to the 2024-07-30 - Jul Release milestone Jul 23, 2024
@eriklharper
Copy link
Contributor

+1 for badge, +1 for keeping calcite in the name of the component message. I think that's clearer for folks outside the core team since that's how they interact with the components. Keeping log level in the config sounds like a good first step, we can always add more to that down the road.

benelan added a commit that referenced this pull request Jul 23, 2024
…-to-monorepo

* origin/dev:
  chore: release next
  fix(tabs): handle tab close events that remove the associated tab-title and tab elements from the DOM (#9768)
  chore: add runtime component deprecation warnings (#9821)
  build(deps): drop unnecessary @types/prettier dep (#9833)
  build: update browserslist db (#9822)
  build(deps): update dependency dayjs to v1.11.12 (#9824)
  build(deps): update dependency semver to v7.6.3 (#9825)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issues with changes that don't modify src or test files. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants