Skip to content

[internal] Change how we initialise plugins #151

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

Merged
merged 3 commits into from
Mar 28, 2025

Conversation

yoannmoinet
Copy link
Member

@yoannmoinet yoannmoinet commented Mar 26, 2025

What and why?

In preparation of [feat] Add synthetics plugin we need to offload the enabling capability onto the plugins instead of on the factory.

So the plugins have more control over when to be enabled or not instead of only relying on the disabled: true configuration.

How?

  • Simplify the plugins initialisation in the factory.
  • Move the enabling logic onto each product plugin.
  • Add more tests, into the plugins, to confirm each plugin is enabled when it needs to.
  • Update the boilerplates to follow this new way of enabling plugins.

@yoannmoinet yoannmoinet mentioned this pull request Mar 27, 2025
1 task
@yoannmoinet yoannmoinet marked this pull request as ready for review March 27, 2025 09:59
@yoannmoinet yoannmoinet requested a review from a team as a code owner March 27, 2025 09:59
@yoannmoinet yoannmoinet requested review from nchapma2 and elbywan and removed request for a team and nchapma2 March 27, 2025 09:59
@yoannmoinet yoannmoinet requested a review from Copilot March 27, 2025 10:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the plugin initialization by shifting the enabling logic into individual product plugins and simplifying the factory’s initialization. Key changes include updating type signatures for plugin functions, removing legacy conditional checks from the factory and integrity commands, and adding tests to verify that plugins only initialize when explicitly enabled.

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/tools/src/helpers.ts Updates the generic use for getSupportedBundlers.
packages/tools/src/commands/integrity/files.ts Removes test path checks from the CODEOWNERS update logic.
packages/tools/src/commands/create-plugin/templates.ts Adjusts import types and plugin option validation logic.
packages/tools/src/commands/create-plugin/index.ts Removes test path insertion in the CODEOWNERS file.
packages/tools/src/commands/create-plugin/index.test.ts Updates tests to match the new CODEOWNERS file content.
packages/tests/src/_jest/helpers/mocks.ts Revises the logger mock implementation.
packages/plugins/telemetry/* Updates function signature and adds early returns when disabled.
packages/plugins/rum/* Updates type definitions and configuration validation.
packages/plugins/error-tracking/* Changes plugin option types and adds early returns when disabled.
packages/factory/src/* Refactors the plugin factory to iterate through product plugins.
packages/core/src/types.ts Removes the generic type for GetPlugins.
Files not reviewed (1)
  • .github/CODEOWNERS: Language not supported
Comments suppressed due to low confidence (1)

packages/tests/src/_jest/helpers/mocks.ts:145

  • The variable 'mockLogger' is referenced but not defined in this file. Consider defining or importing 'mockLogger' to ensure the logger mock works as expected.
getLogger: jest.fn(() => mockLogger),

Copy link
Member Author

Choose a reason for hiding this comment

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

This was forgotten from when I moved test files closer to what they test.

global.d.ts Outdated
Copy link
Member Author

Choose a reason for hiding this comment

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

Just alpha sort of the keys.

Copy link
Member Author

Choose a reason for hiding this comment

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

The responsibility has moved, no need to test for this in the factory anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

Missed from the test files move's PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Missed from the test files move's PR.

Comment on lines -243 to -251
const testsPath = `packages/tests/src/plugins/${plugin.slug}`;
const pluginPath = `${plugin.location}`;

if (!codeowners.includes(testsPath)) {
errors.push(
`[${error}] Missing ${title}'s tests (${dim(testsPath)}) in ${green(codeownersPath)}.`,
);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Missed from the test files move's PR.

@yoannmoinet yoannmoinet merged commit f4e9a44 into master Mar 28, 2025
4 checks passed
@yoannmoinet yoannmoinet deleted the yoann/change-plugin-init branch March 28, 2025 15:46
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.

3 participants