Skip to content

Commit

Permalink
Merge pull request #15 from luizgamabh/develop
Browse files Browse the repository at this point in the history
Add interface declaration for new pixel event vtex:newsletterSubscription
  • Loading branch information
victorhmp authored Mar 22, 2021
2 parents 038f8fe + 9900889 commit 29e0b05
Show file tree
Hide file tree
Showing 4 changed files with 901 additions and 811 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add interface for newsletter subscription event
3 changes: 2 additions & 1 deletion react/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { canUseDOM } from 'vtex.render-runtime'

import { PixelMessage } from './typings/events'
import type { PixelMessage } from './typings/events'

export function handleEvents(e: PixelMessage) {
switch (e.data.eventName) {
case 'vtex:pageView': {
break
}

default: {
break
}
Expand Down
9 changes: 9 additions & 0 deletions react/typings/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PixelMessage extends MessageEvent {
| CartIdData
| PromoViewData
| PromotionClickData
| NewsletterSubscriptionData
}

export interface EventData {
Expand Down Expand Up @@ -161,6 +162,14 @@ export interface PromotionClickData extends EventData {
promotions: Promotion[]
}

export interface NewsletterSubscriptionData extends EventData {
event: 'newsletterSubscription'
eventName: 'vtex:newsletterSubscription'
name: string
email: string
phone: string
}

interface Promotion {
id?: string
name?: string
Expand Down
Loading

0 comments on commit 29e0b05

Please sign in to comment.