diff --git a/src/with-tracker/with-tracker.ts b/src/with-tracker/with-tracker.ts index 369f18b..0f4f545 100644 --- a/src/with-tracker/with-tracker.ts +++ b/src/with-tracker/with-tracker.ts @@ -1,6 +1,6 @@ import { dataLayer, EventProperties } from '../data-layer' +import { logEvent } from './with-tracker-logs' import type { TrackerContext } from '../tracker-context' - import type { TrackModule, SubtractEventProperties } from './with-tracker-types' /** @@ -29,8 +29,11 @@ export function withTrackerContext({ context, }: TrackerContext): TrackModule { function trackEvent(eventProps: Properties) { + const eventProperties = { ...context.value, ...eventProps } + dataLayer.assertIsAvailable() - dataLayer.addEvent({ ...context.value, ...eventProps }) + dataLayer.addEvent(eventProperties) + logEvent(eventProperties) } function setRepeatedProps>(defaultProps: T) {