npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng2-stats

v0.0.5

Published

A statistics tracker for ng2+

Downloads

2

Readme

ng2-stats

A statistics tracker for ng2+

Backend powered by AWS

Want your own?

First crete an acocunt on AWS, then install the python CLI. create two tables on DynamoDB, users and projects. Make sure you create a profile with sufficient permissions.

I recommand using a single profile for running and deploying... Which is what I demo here.

pip install awscli --upgrade --user
aws configure --profile lambda_accessors

aws lambda create-function --region eu-west-2 --function-name ng2-stats --zip-file fileb://ng2-stats.zip --role arn:aws:iam::016857696516:role/lambda_accessors --handler ng2-stats.handler --runtime nodejs6.10 --profile lambda_accessors --timeout 3 --memory-size 128

At that point, the service is up and running but is not accessible via HTTPS. We'll need to: [ http://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https-example.html ] [ http://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https-example-configure-event-source.html ]

aws apigateway create-rest-api --name ng2-stats --region eu-west-2 --profile lambda_accessors
aws apigateway get-rest-apis --region eu-west-2 --profile lambda_accessors

aws apigateway put-method --rest-api-id ilpnvewoa0 --resource-id re86swgq12 --http-method ANY --authorization-type NONE --region eu-west-2 --profile lambda_accessors
aws apigateway put-integration --rest-api-id ilpnvewoa0 --resource-id re86swgq12 --http-method ANY --type AWS_PROXY --uri arn:aws:apigateway:eu-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-2:016857696516:function:ng2-stats/invocations --region eu-west-2 --profile lambda_accessors

aws apigateway put-method-response --rest-api-id ilpnvewoa0 --resource-id re86swgq12 --http-method ANY --status-code 200 --response-models "{\"application/json\": \"Empty\"}" --region eu-west-2 --profile lambda_accessors

aws apigateway create-deployment --rest-api-id ilpnvewoa0 --stage-name prod --region eu-west-2 --profile lambda_accessors

aws lambda add-permission --function-name ng2-stats --statement-id apigateway-test-2 --action lambda:InvokeFunction --principal apigateway.amazonaws.com --source-arn "arn:aws:execute-api:eu-west-2:016857696516:ilpnvewoa0/*/ANY" --region eu-west-2 --profile lambda_accessors
aws lambda add-permission --function-name ng2-stats --statement-id apigateway-prod-2 --action lambda:InvokeFunction --principal apigateway.amazonaws.com --source-arn "arn:aws:execute-api:eu-west-2:016857696516:ilpnvewoa0/prod/ANY" --region eu-west-2 --profile lambda_accessors

This is unfortunately not enough as this would be for a single endpoint. The endpoints are split to allow for payload validation done by Amazon (models incoming into API). The UI is friendly! [ https://eu-west-2.console.aws.amazon.com/apigateway/home?region=eu-west-2 ]

How to use?

npm i --save-dev ng2-stats

Import the module into your main module, then import Ng2StatsService into your main component, and load it with your desired options:

this.ng2statsService.load({
    username: 'MyUsername',
    token: 'API-generated-token',
    by: 'teamMemberA', // Or the user agent
    project: 'A project', // Or the document title
    reloadOnError: false, // Whether to reload page when an error is thrown by ng2, its dump being reshown,
    monitoredHttp: 'api.myapi.com' // A regexp to match for requests whose performance will be monitored
});