: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
import { MessageType, PluginMessages } from '../iframe/integratedMessages';
fetchDisableInternalTracking,
} from '../api/wordpressApiClient';
import { removeQueryParamFromLocation } from '../utils/queryParams';
import { startActivation, startInstall } from '../utils/contentEmbedInstaller';
export type Message = { key: MessageType; payload?: any };
const messageMapper: Map<MessageType, Function> = new Map([
PluginMessages.TrackConsent,
trackConsent(message.payload);
PluginMessages.InternalTrackingChangeRequest,
(message: Message, embedder: any) => {
disableInternalTracking(message.payload)
key: PluginMessages.InternalTrackingFetchResponse,
payload: message.payload,
key: PluginMessages.InternalTrackingChangeError,
PluginMessages.InternalTrackingFetchRequest,
(__message: Message, embedder: any) => {
fetchDisableInternalTracking()
.then(({ message: payload }) => {
key: PluginMessages.InternalTrackingFetchResponse,
key: PluginMessages.InternalTrackingFetchError,
PluginMessages.BusinessUnitFetchRequest,
(__message: Message, embedder: any) => {
key: PluginMessages.BusinessUnitFetchResponse,
key: PluginMessages.BusinessUnitFetchError,
PluginMessages.BusinessUnitChangeRequest,
(message: Message, embedder: any) => {
setBusinessUnitId(message.payload)
key: PluginMessages.BusinessUnitFetchResponse,
key: PluginMessages.BusinessUnitChangeError,
PluginMessages.SkipReviewRequest,
(__message: Message, embedder: any) => {
key: PluginMessages.SkipReviewResponse,
key: PluginMessages.SkipReviewError,
PluginMessages.RemoveParentQueryParam,
removeQueryParamFromLocation(message.payload);
PluginMessages.ContentEmbedInstallRequest,
(message: Message, embedder: any) => {
startInstall(message.payload.nonce)
key: PluginMessages.ContentEmbedInstallResponse,
key: PluginMessages.ContentEmbedInstallError,
PluginMessages.ContentEmbedActivationRequest,
(message: Message, embedder: any) => {
startActivation(message.payload.activateAjaxUrl)
key: PluginMessages.ContentEmbedActivationResponse,
key: PluginMessages.ContentEmbedActivationError,
export const messageMiddleware = (embedder: any) => (message: Message) => {
const next = messageMapper.get(message.key);