-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from liam-hq/feat/custom-log
📈 : add GTM utility functions and types for click logging
- Loading branch information
Showing
5 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@liam-hq/erd-core": patch | ||
"@liam-hq/cli": patch | ||
--- | ||
|
||
📈 : add click logging for CopyLinkButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
frontend/packages/erd-core/src/features/gtm/utils/clickLogEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { pushToDataLayer } from './pushToDataLayer' | ||
|
||
type ClickLogEvent = { | ||
element: string | ||
} | ||
|
||
export const clickLogEvent = ({ element }: ClickLogEvent) => { | ||
pushToDataLayer({ | ||
event: 'click', | ||
element, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './clickLogEvent' |
10 changes: 10 additions & 0 deletions
10
frontend/packages/erd-core/src/features/gtm/utils/pushToDataLayer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
type WindowWithDataLayer = Window & { | ||
dataLayer: Record<string, unknown>[] | ||
} | ||
|
||
declare const window: WindowWithDataLayer | ||
|
||
export const pushToDataLayer = (obj: Record<string, unknown>) => { | ||
window.dataLayer = window.dataLayer || [] | ||
window.dataLayer.push(obj) | ||
} |