Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
Removed botanalytics integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtomczyk committed Dec 11, 2018
1 parent 475f756 commit 910b1e6
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 418 deletions.
3 changes: 0 additions & 3 deletions models/Sender.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const axios = require('axios')
const Botanalytics = require('botanalytics');
const logger = require('../modules/winston')
const MessageFrame = require('./MessageFrame.js')
const MessageBase = require('./MessageBase.js')
Expand All @@ -19,15 +18,13 @@ class Sender {
this.natural_typing = config.natural_typing || true
this.natural_typing_speed = config.natural_typing_speed || 50
this.typing = new Typer(config)
this.botanalytics = (this.config.botanalytics) ? Botanalytics.FacebookMessenger(this.config.botanalytics.token) : false
}

async raw(message) {
if (message.message.text && this.natural_typing) await this.typing.on(message.recipient.id, this.calculateTypingTime(message.message.text))
return new Promise((resolve, reject) => {
axios.post(this.api_url, message)
.then(res => {
if (this.botanalytics) this.botanalytics.logOutgoingMessage(message.message, message.recipient.id, this.access_token)
resolve(res)
})
.catch(err => {
Expand Down
3 changes: 0 additions & 3 deletions models/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const randomstring = require('randomstring')
const express = require('express')
const bodyParser = require('body-parser')
const EventEmitter = require('events')
const Botanalytics = require('botanalytics')
class Emitter extends EventEmitter {}
const emitter = new Emitter()
const logger = require('../modules/winston')
Expand All @@ -20,7 +19,6 @@ class Server {
constructor(config) {
this.config = config
this.verify_token = randomstring.generate(10)
this.botanalytics = (this.config.botanalytics) ? Botanalytics.FacebookMessenger(this.config.botanalytics.token) : false
that = this
}

Expand All @@ -43,7 +41,6 @@ class Server {

app.post('/webhook', (req, res) => {
let body = req.body
if(this.botanalytics) this.botanalytics.logIncomingMessage(body);
emitter.emit('request', body, req)
if (body.object === 'page') {
body.entry.forEach(function(entry) {
Expand Down
13 changes: 0 additions & 13 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const axios = require('axios')
const Botanalytics = require('botanalytics');

const logger = require('../modules/winston')

Expand All @@ -10,7 +9,6 @@ class User {
this.messenger_id = messenger_id
this.api_url = `https://graph.facebook.com/${config.api_version}/${this.messenger_id}`
this.send = sender
this.botanalytics = (this.config.botanalytics) ? Botanalytics.FacebookMessenger(this.config.botanalytics.token) : false
}

async getData(...fields) {
Expand All @@ -19,17 +17,6 @@ class User {
let url = `${this.api_url}?fields=${fields.toString().replace(' ', '')}&access_token=${this.config.access_token}`
let data = await axios.get(url)

if (this.botanalytics) {
let analyticsData = Object.assign({}, data.data)
analyticsData.user_id = analyticsData.id

delete analyticsData.last_ad_referral
delete analyticsData.is_payment_enabled
delete analyticsData.id

this.botanalytics.logUserProfile(analyticsData)
}

return data.data
} catch (e) {
logger.error(e)
Expand Down
Loading

0 comments on commit 910b1e6

Please sign in to comment.