V
Size: a a a
V
V
R
R
V

R

V
const fireEventFxInternal = appDomain.createEffect<
{ env: Environment } & (
| {
type: string;
category: string;
tool: 'ga';
}
| {
type: string;
tool: 'ym';
options?: CommonOptions;
}
),
void
>(async (req) => {
switch (req.tool) {
case 'ga': {
ReactGa.event({
category: req.category,
action: req.type,
});
break;
}
case 'ym': {
((<any>window)[
`yaCounter${req.env.metrikaID}`
] as YandexMetrika).reachGoal(req.type, req?.options);
}
}
});
export const fireEventFx = attach<
| {
type: string;
category: string;
tool: 'ga';
}
| {
type: string;
tool: 'ym';
options?: CommonOptions;
},
Store<Environment>,
typeof fireEventFxInternal
>({
effect: fireEventFxInternal,
source: $envStore,
mapParams: (params, data) => {
return {
...params,
env: data,
};
},
});
sample({
source: $envStore,
clock: loginEffect.doneData,
fn: (source, clock) => ({
type: 'reachGoal',
tool: 'ym',
options: {
params: {
UserID: clock.user_id,
},
},
}),
target: fireEventFx,
});
V
Type 'string' is not assignable to type '"ga" | "ym"'.
V
V
V
V
V
🦜
🦜
🦜
DS
V
V
V