New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

adonisjs-mixpanel

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonisjs-mixpanel

An addon/plugin package to provide Mixpanel data collection and tracking services in AdonisJS 4.0+

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

adonis-mixpanel

An addon/plugin package to provide Mixpanel data collection and tracking services in AdonisJS 4.0+

NPM Version Build Status Coveralls

Getting Started

Install from the NPM Registry - (Please read the instructions.md file to learn how to setup this package properly).


   $ adonis install adonisjs-mixpanel

Usage

Import and use in controllers or the standard AdonisJS Event Bus


const mixpanel = use('MixPanel')
const User = use('App/Models/User')

class UserController {

    async fetch({ request, response }){

        let allUsers = await User.all()

        return response.status(200).json({
            users:allUsers
        });
    }

    async register({ request, response }) {

        let user_details = request.only([
            'dob',
            'email',
            'phone',
            'first_name',
            'last_name'
        ])

        let newUser = await User.create(user_details)

        // track a new user registered to the web OR mobile app
        mixpanel.trackUserBasicAttributes(
            newUser.toJSON()
        );

        return response.status(201).json({
            message:'User Created!',
            user: newUSer.toJSON()
        });
    }
}

module.exports = UserController

More examples


const mixpanel = use('MixPanel')
const User = use('App/Models/User')

class BillingController {

    async payment({ request, response }){

        let user = await User.findBy('id', 1)

        // track the charge made on a user for using the web OR mobile app
        // which ties to revenue from the user for the app
        mixpanel.trackUserBillingCharge(
            user,
            40000 // Naira
        )
    }
}

module.exports = BillingController

This library can also be used to track events using the mixtrack named middleware.


const Route = use('Route')

Route.group(() => {
  Route.get('/all', 'UserController.fetch')
  Route.put('/update/email', function({ auth, request, response }) {
    const user = await auth.getUser()
    user.merge({
      email: request.input('email', null)
    })

    await user.save() // send to database
    await user.reload() // refresh with new email

    request.user = user.toJSON()
    return response.status(200).send('User Updated Email!')
  }).middleware (
    ['auth', 'mixtrack:set;email']
  ) // track updated data for user via 'email'
})
.prefix('user')

License

MIT

Running Tests


    npm i


    npm run lint

    npm run test

Credits

Contributing

See the CONTRIBUTING.md file for info

Support

Coolcodes is a non-profit software foundation (collective) created by Oparand - parent company of StitchNG, Synergixe based in Abuja, Nigeria. You'll find an overview of all our work and supported open source projects on our Facebook Page.

Follow us on facebook if you can to get the latest open source software/freeware news and infomation.

Does your business depend on our open projects? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Keywords

FAQs

Package last updated on 10 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc