woocommerce/plugins/woocommerce-admin/client/core-profiler/events.tsx

143 lines
3.2 KiB
TypeScript
Raw Normal View History

/**
* External dependencies
*/
import { CountryStateOption } from '@woocommerce/onboarding';
/**
* Internal dependencies
*/
import { IndustryChoice } from './pages/BusinessInfo';
import {
InstallationCompletedResult,
PluginInstallError,
} from './services/installAndActivatePlugins';
import { CoreProfilerStateMachineContext } from '.';
export type InitializationCompleteEvent = {
type: 'INITIALIZATION_COMPLETE';
payload: { optInDataSharing: boolean };
};
blueprint - add php package and cli commands (#49763) * Add blueprint package * Add blueprint to composer * Register blueprint cli commands * Add feature flag * Add changefile(s) from automation for the following project(s): woocommerce * Update packages/php/blueprint/src/Exporters/HasAlias.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/Exporters/ExportInstallThemeSteps.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/UseWPFunctions.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Set destination correctly * Make sure the given path is within wp content dir * Remove debug code * Fix typo * Fix typo * Fix lint errors with README * Move READMD.md from src to the root directory and add development.md * Add run-unit-tests.sh * Setup test env * Create dirs recursively * Remove debug code * Update packages/php/blueprint/src/Util.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update packages/php/blueprint/src/ZipExportedSchema.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Check for steps key * Use if statement * Add hook comment for wooblueprint_exporters and wooblueprint_importers * Fix plugin activation condition * Check for download_link -- it can be empty * Check to make sure a file was written * Plugin must be deactivated before attemping to delete it * Lint fixes * Lint fixes * blueprint - add rest api (#49765) * Add blueprint rest api endpoint * Rename process to import * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove unavailable 2nd argument from get_param -- default values are already set from the rest api def. * blueprint - add builder page (#49774) * Add blueprint builder page * Change to the correct endpoint * Add changefile(s) from automation for the following project(s): woocommerce * Note that the builder intro page is temporary * Remove unused code --------- Co-authored-by: github-actions <github-actions@github.com> * blueprint - add blueprint settings page (#49775) * Add blueprint settings page * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Fix broken test * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update unit test env * Added composer scripts to setup and run tests * Moved tests to Unit dir to make space for Integration tests later * WIP Add tests * Use full if statement * Use the correct step names * Use activate_plugin and wp_get_thmes from wp functions trait * Skip inactive plugins * Use plural for collections * Add a comment for StepExporter * Remove unused construct code * Correct function return types * Update packages/php/blueprint/src/Importers/ImportActivateTheme.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Use full if statement * Make sure plugin is installed * Use functions from trait * Remove unused functions * Pass $force_convert correctly * Correctly assign $this->validator * Fix lint issues * Rename setOptions to setSiteOptions * Do not use die() -- throw an exception instead * Make sure slug is a valid WP plugin slug * Remove hardcoded string with get_step_name() * Fix lint issues * Update json example files * Removed woo-specific examples -- these should be placed in the core * Updated the built-in steps to reflect the recent changes * Update packages/php/blueprint/src/docs/json-examples/deletePlugin.json Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Rename to correct filename * Set version number * Use mime_content_type for checking mime type * Catch all exceptions * Only allow zip and json * Remove unused function * Remove unused functions * Add PHPCS command and ruleset * PHP lint fixes * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Add back removed functions * blueprint - Add woo blueprint exporters and importers (#50057) * Add woo blueprint exporters and importers * Comment fix * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Add a test for ImportSetWCTaxRates * Lint fixes * Lint fixes * Fix setWCShipping schema and data format * Add woocommerce_default_country option * Lint fixes * Fix typo -- it should be decode, not encode * Fix incorrect argument order * Fix typo * Export and import shipping method settings * Lint fixes * Lint fixes * Type functions -- base PR has changed --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Require admin for import and export * Use mime type from $_FILES -- mime_content_type can return incorrect mime type depending on the system configuration * Enable export button when backend errors out * Enable export button when backend errors out * Allow WooCommerce export * Change copy text * Remove redundant check * Fix lint issues * Fix lint issues --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
2024-08-12 23:33:05 +00:00
export type IntroOptInEvent =
| IntroCompletedEvent
| IntroSkippedEvent
| IntroBuilderEvent;
export type IntroCompletedEvent = {
type: 'INTRO_COMPLETED';
payload: { optInDataSharing: boolean };
}; // can be true or false depending on whether the user opted in or not
export type IntroSkippedEvent = {
type: 'INTRO_SKIPPED';
payload: { optInDataSharing: false };
}; // always false for now
export type UserProfileEvent =
| {
type: 'USER_PROFILE_COMPLETED';
payload: {
userProfile: CoreProfilerStateMachineContext[ 'userProfile' ];
};
}
| {
type: 'USER_PROFILE_SKIPPED';
payload: { userProfile: { skipped: true } };
};
export type BusinessInfoEvent =
| {
type: 'BUSINESS_INFO_COMPLETED';
payload: {
storeName?: string;
industry?: IndustryChoice;
storeLocation: CountryStateOption[ 'key' ];
geolocationOverruled: boolean;
isOptInMarketing: boolean;
storeEmailAddress: string;
};
}
| {
type: 'RETRY_PRE_BUSINESS_INFO';
}
| {
type: 'SKIP_BUSINESS_INFO_STEP';
};
export type BusinessLocationEvent = {
type: 'BUSINESS_LOCATION_COMPLETED';
payload: {
storeLocation: CountryStateOption[ 'key' ];
};
};
export type PluginsInstallationRequestedEvent = {
type: 'PLUGINS_INSTALLATION_REQUESTED';
payload: {
pluginsShown: string[];
pluginsSelected: string[];
pluginsUnselected: string[];
};
};
export type PluginsLearnMoreLinkClickedEvent = {
type: 'PLUGINS_LEARN_MORE_LINK_CLICKED';
payload: {
plugin: string;
learnMoreLink: string;
};
};
export type PluginsPageSkippedEvent = {
type: 'PLUGINS_PAGE_SKIPPED';
};
export type PluginInstalledAndActivatedEvent = {
type: 'PLUGIN_INSTALLED_AND_ACTIVATED';
payload: {
progressPercentage: number;
};
};
export type PluginsInstallationCompletedEvent = {
type: 'PLUGINS_INSTALLATION_COMPLETED';
payload: {
installationCompletedResult: InstallationCompletedResult;
};
};
export type PluginsInstallationCompletedWithErrorsEvent = {
type: 'PLUGINS_INSTALLATION_COMPLETED_WITH_ERRORS';
payload: {
errors: PluginInstallError[];
};
};
export type ExternalUrlUpdateEvent = {
type: 'EXTERNAL_URL_UPDATE';
};
export type RedirectToWooHomeEvent = {
type: 'REDIRECT_TO_WOO_HOME';
};
blueprint - add php package and cli commands (#49763) * Add blueprint package * Add blueprint to composer * Register blueprint cli commands * Add feature flag * Add changefile(s) from automation for the following project(s): woocommerce * Update packages/php/blueprint/src/Exporters/HasAlias.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/Exporters/ExportInstallThemeSteps.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/UseWPFunctions.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Set destination correctly * Make sure the given path is within wp content dir * Remove debug code * Fix typo * Fix typo * Fix lint errors with README * Move READMD.md from src to the root directory and add development.md * Add run-unit-tests.sh * Setup test env * Create dirs recursively * Remove debug code * Update packages/php/blueprint/src/Util.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update packages/php/blueprint/src/ZipExportedSchema.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Check for steps key * Use if statement * Add hook comment for wooblueprint_exporters and wooblueprint_importers * Fix plugin activation condition * Check for download_link -- it can be empty * Check to make sure a file was written * Plugin must be deactivated before attemping to delete it * Lint fixes * Lint fixes * blueprint - add rest api (#49765) * Add blueprint rest api endpoint * Rename process to import * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove unavailable 2nd argument from get_param -- default values are already set from the rest api def. * blueprint - add builder page (#49774) * Add blueprint builder page * Change to the correct endpoint * Add changefile(s) from automation for the following project(s): woocommerce * Note that the builder intro page is temporary * Remove unused code --------- Co-authored-by: github-actions <github-actions@github.com> * blueprint - add blueprint settings page (#49775) * Add blueprint settings page * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Fix broken test * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update unit test env * Added composer scripts to setup and run tests * Moved tests to Unit dir to make space for Integration tests later * WIP Add tests * Use full if statement * Use the correct step names * Use activate_plugin and wp_get_thmes from wp functions trait * Skip inactive plugins * Use plural for collections * Add a comment for StepExporter * Remove unused construct code * Correct function return types * Update packages/php/blueprint/src/Importers/ImportActivateTheme.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Use full if statement * Make sure plugin is installed * Use functions from trait * Remove unused functions * Pass $force_convert correctly * Correctly assign $this->validator * Fix lint issues * Rename setOptions to setSiteOptions * Do not use die() -- throw an exception instead * Make sure slug is a valid WP plugin slug * Remove hardcoded string with get_step_name() * Fix lint issues * Update json example files * Removed woo-specific examples -- these should be placed in the core * Updated the built-in steps to reflect the recent changes * Update packages/php/blueprint/src/docs/json-examples/deletePlugin.json Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Rename to correct filename * Set version number * Use mime_content_type for checking mime type * Catch all exceptions * Only allow zip and json * Remove unused function * Remove unused functions * Add PHPCS command and ruleset * PHP lint fixes * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Add back removed functions * blueprint - Add woo blueprint exporters and importers (#50057) * Add woo blueprint exporters and importers * Comment fix * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Add a test for ImportSetWCTaxRates * Lint fixes * Lint fixes * Fix setWCShipping schema and data format * Add woocommerce_default_country option * Lint fixes * Fix typo -- it should be decode, not encode * Fix incorrect argument order * Fix typo * Export and import shipping method settings * Lint fixes * Lint fixes * Type functions -- base PR has changed --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Require admin for import and export * Use mime type from $_FILES -- mime_content_type can return incorrect mime type depending on the system configuration * Enable export button when backend errors out * Enable export button when backend errors out * Allow WooCommerce export * Change copy text * Remove redundant check * Fix lint issues * Fix lint issues --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
2024-08-12 23:33:05 +00:00
export type IntroBuilderEvent = {
type: 'INTRO_BUILDER';
payload: { optInDataSharing: false };
}; // always false for now
export type CoreProfilerEvents =
| InitializationCompleteEvent
| IntroOptInEvent
| UserProfileEvent
| BusinessInfoEvent
| BusinessLocationEvent
| PluginsInstallationRequestedEvent
| PluginsLearnMoreLinkClickedEvent
| PluginsPageSkippedEvent
| PluginInstalledAndActivatedEvent
| PluginsInstallationCompletedEvent
| PluginsInstallationCompletedWithErrorsEvent
| ExternalUrlUpdateEvent
blueprint - add php package and cli commands (#49763) * Add blueprint package * Add blueprint to composer * Register blueprint cli commands * Add feature flag * Add changefile(s) from automation for the following project(s): woocommerce * Update packages/php/blueprint/src/Exporters/HasAlias.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/Exporters/ExportInstallThemeSteps.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update packages/php/blueprint/src/UseWPFunctions.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Set destination correctly * Make sure the given path is within wp content dir * Remove debug code * Fix typo * Fix typo * Fix lint errors with README * Move READMD.md from src to the root directory and add development.md * Add run-unit-tests.sh * Setup test env * Create dirs recursively * Remove debug code * Update packages/php/blueprint/src/Util.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update packages/php/blueprint/src/ZipExportedSchema.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Check for steps key * Use if statement * Add hook comment for wooblueprint_exporters and wooblueprint_importers * Fix plugin activation condition * Check for download_link -- it can be empty * Check to make sure a file was written * Plugin must be deactivated before attemping to delete it * Lint fixes * Lint fixes * blueprint - add rest api (#49765) * Add blueprint rest api endpoint * Rename process to import * Add changefile(s) from automation for the following project(s): woocommerce * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Remove unavailable 2nd argument from get_param -- default values are already set from the rest api def. * blueprint - add builder page (#49774) * Add blueprint builder page * Change to the correct endpoint * Add changefile(s) from automation for the following project(s): woocommerce * Note that the builder intro page is temporary * Remove unused code --------- Co-authored-by: github-actions <github-actions@github.com> * blueprint - add blueprint settings page (#49775) * Add blueprint settings page * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Fix broken test * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update unit test env * Added composer scripts to setup and run tests * Moved tests to Unit dir to make space for Integration tests later * WIP Add tests * Use full if statement * Use the correct step names * Use activate_plugin and wp_get_thmes from wp functions trait * Skip inactive plugins * Use plural for collections * Add a comment for StepExporter * Remove unused construct code * Correct function return types * Update packages/php/blueprint/src/Importers/ImportActivateTheme.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Use full if statement * Make sure plugin is installed * Use functions from trait * Remove unused functions * Pass $force_convert correctly * Correctly assign $this->validator * Fix lint issues * Rename setOptions to setSiteOptions * Do not use die() -- throw an exception instead * Make sure slug is a valid WP plugin slug * Remove hardcoded string with get_step_name() * Fix lint issues * Update json example files * Removed woo-specific examples -- these should be placed in the core * Updated the built-in steps to reflect the recent changes * Update packages/php/blueprint/src/docs/json-examples/deletePlugin.json Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/RestApi.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Rename to correct filename * Set version number * Use mime_content_type for checking mime type * Catch all exceptions * Only allow zip and json * Remove unused function * Remove unused functions * Add PHPCS command and ruleset * PHP lint fixes * Update plugins/woocommerce/src/Admin/Features/Blueprint/Init.php Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> * Add back removed functions * blueprint - Add woo blueprint exporters and importers (#50057) * Add woo blueprint exporters and importers * Comment fix * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Update plugins/woocommerce/src/Admin/Features/Blueprint/Exporters/ExportWCSettings.php Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Add a test for ImportSetWCTaxRates * Lint fixes * Lint fixes * Fix setWCShipping schema and data format * Add woocommerce_default_country option * Lint fixes * Fix typo -- it should be decode, not encode * Fix incorrect argument order * Fix typo * Export and import shipping method settings * Lint fixes * Lint fixes * Type functions -- base PR has changed --------- Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com> * Require admin for import and export * Use mime type from $_FILES -- mime_content_type can return incorrect mime type depending on the system configuration * Enable export button when backend errors out * Enable export button when backend errors out * Allow WooCommerce export * Change copy text * Remove redundant check * Fix lint issues * Fix lint issues --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com> Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
2024-08-12 23:33:05 +00:00
| RedirectToWooHomeEvent
| IntroBuilderEvent;