Skip to content

Commit

Permalink
PROD (#12)
Browse files Browse the repository at this point in the history
* Updating for voxa3

* Adding generic

* Moving to typescript

* Updating tests

* Updated dependencies

* Changing cobertura for report and installing nyc.

* Adding tslint-no-unused-expression-chai package for tslint to work.

* Setting 3.0.0-alpha38 as minimum

* Moving to yarn

* Changing package version.

* Updated dependencies

* Support for facebook property

* Added printErrors to config interface

* Changed to v2.0.0-alpha4

* Removed facebook property

* Changes to v2.0.0

* Updates dependencies

* Updates run-ci.sh

* Replaces nyc with istanbul

* Changes to v2.0.1

* Removes ignored lib folder

* Changes to v2.0.2
  • Loading branch information
omenocal authored May 15, 2019
1 parent 4b7fb88 commit 089184a
Show file tree
Hide file tree
Showing 16 changed files with 2,353 additions and 1,488 deletions.
32 changes: 0 additions & 32 deletions .eslintrc.json

This file was deleted.

8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Sphinx documentation
# compiled typescript

lib/

## Sphinx documentation
docs/_build/
#### Vim
# swap
Expand Down Expand Up @@ -108,4 +112,4 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
junit.xml
junit.xml
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.10
v8.10
10 changes: 0 additions & 10 deletions index.js

This file was deleted.

55 changes: 0 additions & 55 deletions lib/Voxa-Dashbot.js

This file was deleted.

53 changes: 30 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "voxa-dashbot",
"version": "0.1.8",
"version": "2.0.2",
"description": "Integrate Dashbot analytics into your Alexa apps using the voxa framework",
"main": "index.js",
"main": "lib/Voxa-Dashbot.js",
"scripts": {
"test": "istanbul cover _mocha -- --recursive tests",
"test-ci": "JUNIT_REPORT_PATH=junit.xml istanbul cover _mocha -- --recursive --colors --reporter mocha-jenkins-reporter tests",
"cobertura": "istanbul report cobertura --root coverage",
"lint": "eslint lib/ tests/",
"lint-fix": "eslint --fix lib/ tests/"
"test": "istanbul cover _mocha -- --recursive test",
"test-ci": "JUNIT_REPORT_PATH=junit.xml istanbul cover _mocha -- --recursive --colors --reporter mocha-jenkins-reporter test",
"lint": "tslint --project tsconfig.json --config tslint.json",
"clean": "rimraf lib/",
"prepare": "npm run clean && tsc",
"cobertura": "istanbul report cobertura --root coverage"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mediarain/voxa-dashbot.git"
"url": "git+https://github.com/VoxaAI/voxa-dashbot.git"
},
"keywords": [
"alexa",
Expand All @@ -27,28 +28,34 @@
],
"author": "Rain Agency <npm@rain.agency> (http://rain.agency)",
"engines": {
"node": ">=4.3"
"node": ">=8.10"
},
"license": "MIT",
"dependencies": {
"dashbot": "^9.9.1",
"lambda-log": "^1.4.0",
"lodash": "^4.17.10"
"@types/lodash": "^4.14.126",
"dashbot": "^10.4.0",
"lodash": "^4.17.11"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "3.15.0",
"eslint-config-airbnb-base": "11.1.0",
"eslint-plugin-import": "2.2.0",
"chai": "^4.2.0",
"istanbul": "^0.4.5",
"mocha": "3.2.0",
"mocha-jenkins-reporter": "0.3.7",
"nock": "^9.2.3",
"simple-mock": "^0.7.3",
"voxa": "^2.2.1"
"mocha": "6.1.4",
"mocha-jenkins-reporter": "0.4.1",
"nock": "^10.0.6",
"rimraf": "^2.6.3",
"simple-mock": "^0.8.0",
"source-map-support": "^0.5.12",
"ts-node": "^8.1.0",
"tslint": "^5.16.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^3.4.5",
"voxa": "^3.1.0"
},
"peerDependencies": {
"voxa": "^3.1.0"
},
"bugs": {
"url": "https://github.com/mediarain/voxa-dashbot/issues"
"url": "https://github.com/VoxaAI/voxa-dashbot/issues"
},
"homepage": "https://github.com/mediarain/voxa-dashbot#readme"
"homepage": "https://github.com/VoxaAI/voxa-dashbot#readme"
}
2 changes: 1 addition & 1 deletion run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ npm run lint
if [ "${CI}" = "true" ]; then
npm install coveralls
cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
fi
fi
97 changes: 97 additions & 0 deletions src/Voxa-Dashbot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2018 Rain Agency <contact@rain.agency>
* Author: Rain Agency <contact@rain.agency>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import * as _ from "lodash";
import { IVoxaEvent, IVoxaReply, VoxaApp } from "voxa";
/* tslint:disable-next-line */
const DashbotAnalytics = require("dashbot");

const defaultConfig = {
ignoreUsers: [],
};

const dashbotIntegrations: any = {
alexa: "alexa",
botframework: "generic",
dialogflow: "google", // DEPRECATED
google: "google",
};

export interface IVoxaDashbotConfig {
alexa?: string;
api_key?: string;
botframework?: string;
debug?: boolean;
dialogflow?: string;
printErrors?: boolean;
redact?: boolean;
suppressSending?: boolean;
timeout?: number;
}

export function register(skill: VoxaApp, config: IVoxaDashbotConfig) {
const pluginConfig = _.merge({}, defaultConfig, config);

const dashbotConfig = {
debug: pluginConfig.debug,
printErrors: pluginConfig.printErrors,
redact: pluginConfig.redact,
timeout: pluginConfig.timeout,
};

skill.onRequestStarted(trackIncoming);
skill.onBeforeReplySent(trackOutgoing);

function trackIncoming(voxaEvent: IVoxaEvent) {
if (_.includes(pluginConfig.ignoreUsers, voxaEvent.user.userId)) {
return Promise.resolve(null);
}
if (pluginConfig.suppressSending) {
return Promise.resolve(null);
}
const { rawEvent, platform } = voxaEvent;
const apiKey = _.get(pluginConfig, platform.name) || pluginConfig.api_key;

const Dashbot = DashbotAnalytics(apiKey, dashbotConfig)[
dashbotIntegrations[platform.name]
];
// PROCESSING INCOMING RESPONSE
return Dashbot.logIncoming(rawEvent);
}

function trackOutgoing(voxaEvent: IVoxaEvent, reply: IVoxaReply) {
if (_.includes(pluginConfig.ignoreUsers, voxaEvent.user.userId)) {
return Promise.resolve(null);
}
if (pluginConfig.suppressSending) {
return Promise.resolve(null);
}
const { rawEvent, platform } = voxaEvent;
const apiKey = _.get(pluginConfig, platform.name) || pluginConfig.api_key;

const Dashbot = DashbotAnalytics(apiKey, dashbotConfig)[
dashbotIntegrations[platform.name]
];
// PROCESSING INCOMING RESPONSE
return Dashbot.logOutgoing(rawEvent, reply);
}
}
4 changes: 4 additions & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--require ts-node/register
--watch-extensions ts
--recursive

31 changes: 31 additions & 0 deletions test/views.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

/**
* Views for tests
*
* Copyright (c) 2016 Rain Agency.
* Licensed under the MIT license.
*/

const views = (function views() {
return {
en: {
translation: {
LaunchIntent: {
OpenResponse: "Hello! How are you?"
},
Question: {
Ask: "What time is it?"
},
ExitIntent: {
GeneralExit: "Ok. Goodbye."
},
BadInput: {
RepeatLastAskReprompt: "I'm sorry. I didn't understand."
}
}
}
};
})();

module.exports = views;
Loading

0 comments on commit 089184a

Please sign in to comment.