Skip to content

Commit

Permalink
liveDestination vars
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Mar 7, 2025
1 parent bd2f8d9 commit b53a95f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions website/src/components/organisms/liveDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const DestinationInit: React.FC<DestinationInitProps> = ({
interface DestinationPushProps {
event: WalkerOS.PartialEvent;
mapping?: Mapping.EventConfig | string;
children?: React.ReactNode;
height?: number;
smallText?: boolean;
className?: string;
Expand All @@ -112,7 +111,6 @@ interface DestinationPushProps {
export const DestinationPush: React.FC<DestinationPushProps> = ({
event,
mapping = {},
children,
height,
smallText,
className,
Expand All @@ -122,25 +120,24 @@ export const DestinationPush: React.FC<DestinationPushProps> = ({
eventConfig = true,
}) => {
const { customConfig, destination, fnName } = useDestinationContext();
const middleValue = children ?? mapping;
const inputValue = formatValue(event);
const mappingValue = formatValue(mapping);

const mappingFn = useCallback(
(
left: unknown,
middle: unknown,
input: unknown,
config: unknown,
log: (...args: unknown[]) => void,
options: WalkerOS.AnyObject,
) => {
try {
const leftValue = parseInput(left);
const middleValue = parseInput(middle);
const event = createEvent(leftValue);
const inputValue = parseInput(input);
const configValue = parseInput(config);
const event = createEvent(inputValue);
const [entity, action] = event.event.split(' ');
const finalMapping = eventConfig
? {
[entity]: { [action]: middleValue },
}
: middleValue;
? { [entity]: { [action]: configValue } }
: configValue;

destinationPush(
{ hooks: {}, consent: event.consent } as never, // Fake instance
Expand All @@ -164,8 +161,8 @@ export const DestinationPush: React.FC<DestinationPushProps> = ({
return (
<LiveCode
fnName={fnName}
input={formatValue(event)}
config={formatValue(middleValue)}
input={inputValue}
config={mappingValue}
fn={mappingFn}
options={customConfig}
height={height}
Expand Down

0 comments on commit b53a95f

Please sign in to comment.