-
Notifications
You must be signed in to change notification settings - Fork 15
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 #332 from nossas/feature-analytics-events
Improvements to send event to Google Analytics when key actions occurs
- Loading branch information
Showing
12 changed files
with
119 additions
and
3 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
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
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
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
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
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
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
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
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,52 @@ | ||
import ReactGA from 'react-ga' | ||
|
||
class AnalyticsEvents { | ||
constructor () { | ||
this.FORM_FILLED = { category: 'Formulário', action: 'Preenchimento Iniciado' } | ||
this.FORM_SAVED = { category: 'Formulário', action: 'Dados Salvos com Sucesso' } | ||
|
||
this.DONATION_STARTED = { category: 'Doação', action: 'Escolheu Valor' } | ||
this.DONATION_FINISHED = { category: 'Doação', action: 'Servidor Recebeu Dados' } | ||
|
||
this.PRESSURE_FILLED = { category: 'Pressão', action: 'Preenchimento Iniciado' } | ||
this.PRESSURE_SAVED = { category: 'Pressão', action: 'Dados Salvos com Sucesso' } | ||
|
||
this.SOCIAL_SHARED = { category: 'Redes Sociais', action: 'Compartilhou no ' } | ||
} | ||
sendEvent (event) { | ||
return ReactGA.event(event) | ||
} | ||
|
||
formIsFilled () { | ||
return this.sendEvent(this.FORM_FILLED) | ||
} | ||
|
||
formSavedData () { | ||
return this.sendEvent(this.FORM_SAVED) | ||
} | ||
|
||
donationSetValue () { | ||
return this.sendEvent(this.DONATION_STARTED) | ||
} | ||
|
||
donationFinishRequest (value) { | ||
return this.sendEvent({...this.DONATION_FINISHED, label: value}) | ||
} | ||
|
||
pressureIsFilled () { | ||
return this.sendEvent(this.PRESSURE_FILLED) | ||
} | ||
|
||
pressureSavedData () { | ||
return this.sendEvent(this.PRESSURE_SAVED) | ||
} | ||
|
||
socialShared (source, text) { | ||
let evt = { ...this.SOCIAL_SHARED } | ||
evt.action = evt.action + source | ||
evt.label = text | ||
return this.sendEvent(evt) | ||
} | ||
} | ||
|
||
export default new AnalyticsEvents() |
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,31 @@ | ||
import sinon from 'sinon' | ||
import { expect } from 'chai' | ||
|
||
import AnalyticsEvents from '../../../modules/widgets/utils/analytics-events' | ||
|
||
describe.skip('app/modules/widgets/utils/analytics-events', () => { | ||
let sandbox | ||
|
||
before(() => { | ||
sandbox = sinon.sandbox.create() | ||
sandbox.spy(AnalyticsEvents, 'sendEvent') | ||
}) | ||
|
||
context('#formIsFilled', () => { | ||
console.log(AnalyticsEvents) | ||
it('should return true when form is filled', () => { | ||
expect(AnalyticsEvents.formIsFilled()).to.be.true | ||
}) | ||
|
||
expect(AnalyticsEvents.sendEvent).to.be.called | ||
}) | ||
|
||
// formSavedData, | ||
// formSocialShare, | ||
// donationSetValue, | ||
// donationFinishRequest, | ||
// donationSocialShare, | ||
// pressureIsFilled, | ||
// pressureSavedData, | ||
// pressureSocialShare | ||
}) |
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
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