-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
integration with angularjs #54
Comments
Hello Eka, no it's not possible for now, but there are some initiatives to build module that can interact with a front end: https://github.com/pm2-hive/pm2-fronterr |
@Unitech hai thanks for your response ! .. actually I've been thinking to build another instance of Restful api application using expressjs.. but now that you mention it.. could you explain it to me a little bit on how to use the pm2 fronterr ? |
Hey, |
hi @alavit-d could your component be use for event logging management ? so for example if I'm loggin I would like to store on who is logged in to keymetrics.. |
Not designed for this at the moment unfortunately, mainly for client-side errors. I feel like you would have more luck trying to create a Keymetrics custom Probe that retrieves the number of clients in back-end. |
Hi @alavit-d & @Unitech, so I create a workaround by creating a simple logging restful api app using express js.. so whenever the frontend (which is angularjs) is logged in.. I simply made an http call to the expressjs api and from expressjs api, it will emit an event using pmx api.. this is the codes // server.js
// BASE SETUP
// =============================================================================
// call the packages we need
var express = require('express'); // call express
var bodyParser = require('body-parser');
var app = express(); // define our app using express
var pmx = require('pmx');
var url = require('url');
var https = require('https');
var fs = require('fs');
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, JSESSIONID");
next();
});
var port = process.env.PORT || 8080; // set our port
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router(); // get an instance of the express Router
// test route to make sure everything is working (accessed at GET http://localhost:8080/pmx)
router.post('/', function(req, res) {
var urlParts = url.parse(req.url, true);
var urlQuery = urlParts.query;
if (urlQuery.JSESSIONID && urlQuery.activity) {
pmx.emit(urlQuery.activity, JSON.stringify(req.body));
res.json({message: "JSESSIONID provided", urlQuery: urlQuery, req: req.body});
console.info("pmx event has been emited !");
console.info("activity : " + urlQuery.activity);
console.info("payload : " + req.body);
console.info("stringify payload : " + JSON.stringify(req.body));
} else if (!urlQuery.JSESSIONID && !urlQuery.activity) {
console.error("There's no activity and JSESSIONID provided !");
res.json({message: "There's no activity and JSESSIONID provided !"});
} else if (!urlQuery.activity) {
console.error("There's no activity provided !");
res.json({message: "There's no activity provided !"});
} else if (!urlQuery.JSESSIONID) {
console.error("There's no JSESSIONID provided !");
res.json({message: "There's no JSESSIONID provided !"});
}
});
var privateKey = fs.readFileSync('https.key', 'utf-8');
var certificate = fs.readFileSync('https.crt', 'utf-8');
var credentials = {key: privateKey, cert: certificate};
app.use('/pmx', router);
//app.listen(port);
https.createServer(credentials, app).listen(port);
console.log('pmx api integration has start on port : ' + port); all is well untill I do a test.. the rest api worked but when I go to the keymetrics dashboard.. There's no event logged there on the events menu, meanwhile on the more menu -> realtime event, the logged are there in realtime. am I missing something ? |
Hi, |
Hi @alavit-d, the api name is yes I am using |
I've been using pm2 for management processing tool of my angularjs project it's a great tool !.. the question is really simple.. could I integrate this component on my angularjs project ? so basically I want to include this component when I do a login for example
could I do this ?
The text was updated successfully, but these errors were encountered: