Skip to content

Commit

Permalink
Merge pull request #4 from ACCT-global/fix-event-firing
Browse files Browse the repository at this point in the history
Fixes events not firing
  • Loading branch information
saviofelixmuniz authored Sep 27, 2019
2 parents db84829 + 55473ae commit 720aaab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Function returning void;

## [0.0.2] - 2019-09-19
### Added
- Move app's readme to /docs folder;

## [0.0.1] - 2019-08-06
### Added
- Main pixel app;

15 changes: 6 additions & 9 deletions react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { fetchEmail, getSiteType } from './helpers'
function impression(event: PixelMessage) {
switch (event.data.eventName) {
case 'vtex:pageInfo':
return event.data.eventType === "homeView" ? { event: 'viewHome' } : { event: event.data.eventType }
return event.data.eventType === 'homeView'
? { event: 'viewHome' }
: { event: event.data.eventType }
case 'vtex:categoryView':
return {
event: 'viewList',
Expand Down Expand Up @@ -63,19 +65,14 @@ async function handleEvents(event: PixelMessage) {
case 'vtex:pageInfo':
case 'vtex:categoryView':
case 'vtex:productView': {
impression(event)
break
return impression(event)
}
case 'vtex:orderPlaced': {
purchase(event)
break
return purchase(event)
}
case 'vtex:addToCart': {
cart(event)
break
return cart(event)
}
default:
break
}
}

Expand Down

0 comments on commit 720aaab

Please sign in to comment.