Skip to content

Commit

Permalink
Merge pull request #71 from squidit/feature/standardization-of-evetn-…
Browse files Browse the repository at this point in the history
…tracking-for-ga4

✨ feat: Padronização da captura de eventos para o GA4
  • Loading branch information
wandersonsales-dev authored Dec 12, 2024
2 parents 5977a95 + 9954a0d commit 57afdf9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@squidit/react-css",
"version": "1.2.18",
"version": "1.2.19",
"scripts": {
"format": "prettier --write --parser typescript '**/*.{ts,tsx}'",
"lint": "eslint src --ext js,ts,tsx",
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/data-layer/data-layer.helper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { WindowWithDataLayer } from '@interfaces/sq-data-layer.interface'
import { DataLayer, WindowWithDataLayer } from '@interfaces/sq-data-layer.interface'

export default class DataLayerHelper {
private readonly window: WindowWithDataLayer = window

public sendToDataLayer(payload) {
const fullPayload = {
public sendToDataLayer(payload: DataLayer): void {
const fullPayload: DataLayer = {
...payload,
}
this.window?.dataLayer?.push(fullPayload)
Expand Down
26 changes: 24 additions & 2 deletions src/interfaces/sq-data-layer.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
import { SocialNetworksAvailables } from './sq-profile-cache.interface'

export interface WindowWithDataLayer extends Window {
// TODO: Criar uma interface para o objeto dataLayer do Google Tag Manager
dataLayer?: any[]
dataLayer?: DataLayer[]
}

export interface DataLayer {
event: Event
profile?: string
socialNetwork?: SocialNetworksAvailables
context?: string
action?: string
description?: string
location?: string
value?: any
return?: any
user: UserDataLayer
[key: string]: any
}

export type Event = 'hub_user_conversion' | 'hub_user_interaction' | 'hub_user_engagement'

export interface UserDataLayer {
squidId: string | null
[key: string]: any
}

0 comments on commit 57afdf9

Please sign in to comment.