Skip to content

Commit

Permalink
add google analytic support
Browse files Browse the repository at this point in the history
  • Loading branch information
apemon committed Sep 28, 2019
1 parent 44cb8cc commit 4708dcb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"qrcode.vue": "^1.6.2",
"store": "^2.0.12",
"vue": "^2.6.10",
"vue-analytics": "^5.17.2",
"vue-clipboard2": "^0.3.0",
"vue-element-loading": "^1.1.1",
"vue-i18n": "^8.14.1",
Expand Down
5 changes: 5 additions & 0 deletions src/components/Transfer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ export default {
const mnemonic = this.mnemonic.split(';')[0]
const toAddress = this.address
await this.libra.transfer(mnemonic, toAddress, this.amount)
// Fire event to Google Analytic
this.$ga.event({
eventCategory: 'Transaction',
eventAction: 'Transfer'
})
// For peer to peer transfer
if (this.labelHead === '') {
this.$router.push({ name: 'Wallet' })
Expand Down
21 changes: 20 additions & 1 deletion src/components/Wallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default {
} catch (error) {
console.log(error)
}
// Creating a new wallet
// Creating a new wallet
} else {
const data = await this.createNewWallet()
await this.updatePersistance(data.address, data.balance, data.mnemonic)
Expand Down Expand Up @@ -210,6 +210,13 @@ export default {
mnemonic: createdResult.mnemonic + ';1',
balance: this.AMOUNT_TO_MINT.toString(10)
}
// Fire event to google analytic
this.$ga.event({
eventCategory: 'Wallet',
eventAction: 'Create'
})
return wallet
} catch (error) {
console.log(error)
Expand Down Expand Up @@ -238,12 +245,24 @@ export default {
window.location.href = 'https://github.com/iyawat/M5Stack_libra_hw_wallet'
},
openSend () {
this.$ga.event({
eventCategory: 'Wallet',
eventAction: 'Transfer'
})
this.$router.push({ name: 'ScanQR' })
},
openReceive () {
this.$ga.event({
eventCategory: 'Wallet',
eventAction: 'Receive'
})
this.$router.push({ name: 'Receive', query: { address: this.userAddress } })
},
openTransaction () {
this.$ga.event({
eventCategory: 'Wallet',
eventAction: 'History'
})
this.$router.push({ name: 'Transactions', query: { address: this.userAddress } })
},
async doUpdateBalance () {
Expand Down
5 changes: 5 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Buefy from 'buefy'
import VueLoading from 'vue-loading-template'
import VueClipboard from 'vue-clipboard2'
import SocialSharing from 'vue-social-sharing'
import VueAnalytics from 'vue-analytics'

// Styles
import 'buefy/dist/buefy.css'
Expand All @@ -21,6 +22,10 @@ Vue.use(SocialSharing)
Vue.use(VueLoading)
Vue.use(VueClipboard)
VueClipboard.config.autoSetContainer = true // add this line
Vue.use(VueAnalytics, {
id: 'UA-148960913-1',
router
})

Vue.config.productionTip = false

Expand Down

0 comments on commit 4708dcb

Please sign in to comment.