Skip to content

Commit

Permalink
feat(with-tracker): trigger log on event
Browse files Browse the repository at this point in the history
  • Loading branch information
emkis committed May 7, 2022
1 parent a82b58d commit 43e44bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/with-tracker/with-tracker.ts
Original file line number Diff line number Diff line change
@@ -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'

/**
Expand Down Expand Up @@ -29,8 +29,11 @@ export function withTrackerContext<Properties extends EventProperties>({
context,
}: TrackerContext): TrackModule<Properties> {
function trackEvent(eventProps: Properties) {
const eventProperties = { ...context.value, ...eventProps }

dataLayer.assertIsAvailable()
dataLayer.addEvent({ ...context.value, ...eventProps })
dataLayer.addEvent(eventProperties)
logEvent(eventProperties)
}

function setRepeatedProps<T extends Partial<Properties>>(defaultProps: T) {
Expand Down

0 comments on commit 43e44bf

Please sign in to comment.