How to use mixpanel - 10 common examples

To help you get started, we’ve selected a few mixpanel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github therehq / there-desktop / main / utils / mixpanel.js View on Github external
const os = require('os')
const Mixpanel = require('mixpanel')
const isDev = require('electron-is-dev')
const { app: electronApp } = require('electron')
const { machineId: genMachineId } = require('node-machine-id')

// Utilities
const { mixpanelProjectToken } = require('../../config')
const { getUser } = require('../utils/store')

const mixpanel = Mixpanel.init(mixpanelProjectToken)

const track = async (app = electronApp, event, additionalData, callback) => {
  // I do not ever want to spoil Sentry with useless errors
  try {
    const machineId = await genMachineId()
    const appVersion = app && 'getVersion' in app ? app.getVersion() : ''
    const userId = (getUser() || {}).id

    mixpanel.track(
      event,
      Object.assign(
        {
          distinct_id: machineId,
          process: process.type,
          platform: os.platform(),
          platform_release: os.release(),
github kiteco / plugins / atom / kite / lib / metrics.js View on Github external
var os = require('os');
const mixpanel = require('mixpanel');
const crypto = require('crypto');
const kitePkg = require('../package.json');

const MIXPANEL_TOKEN = '2ab52cc896c9c74a7452d65f00e4f938';

const OS_VERSION = os.type() + ' ' + os.release();

const client = mixpanel.init(MIXPANEL_TOKEN, {
  protocol: 'https',
});

// The list of all possible events
var events = {
  ACTIVATE: "activate",
};

// Generate a unique ID for this user and save it for future use.
function distinctID() {
  var id = atom.config.get('kite.distinctID');
  if (id === undefined) {
    id = crypto.randomBytes(32).toString('hex');
    atom.config.set('kite.distinctID', id);
  }
  return id;
github freedomexio / rocketx-condenser / src / server / sign_up_pages / enter_confirm_email.jsx View on Github external
import sendEmail from "../sendEmail";
import { getRemoteIp, checkCSRF } from "server/utils/misc";
import config from "config";
import MiniHeader from "app/components/modules/MiniHeader";
import secureRandom from "secure-random";
import Mixpanel from "mixpanel";
import Progress from "react-foundation-components/lib/global/progress-bar";
import {api} from 'steem';

const path = require('path');
const ROOT = path.join(__dirname, '../../..');

// FIXME copy paste code, refactor mixpanel out
let mixpanel = null;
if (config.has("mixpanel") && config.get("mixpanel")) {
    mixpanel = Mixpanel.init(config.get("mixpanel"));
}

let assets_file = ROOT + "/tmp/webpack-stats-dev.json";
if (process.env.NODE_ENV === "production") {
    assets_file = ROOT + "/tmp/webpack-stats-prod.json";
}

const assets = Object.assign({}, require(assets_file), { script: [] });

assets.script.push("https://www.google.com/recaptcha/api.js");
assets.script.push("/enter_email/submit_form.js");

function* confirmEmailHandler() {
    const confirmation_code = this.params && this.params.code
        ? this.params.code
        : this.request.body.code;
github ThomasGaubert / zephyr / desktop / app / main.js View on Github external
// Module to control application life.
const app = electron.app

// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow

// Preferences
const Config = require('electron-config')
const conf = new Config()

// Analytics
var mixpanel = require('mixpanel').init('6cae86bf1da092b800b30b27689bd665')
if (!conf.has('uuid')) {
  conf.set('uuid', require('node-uuid').v1())
}
const uuid = conf.get('uuid')

// Networking
var bodyParser = require('body-parser')
var web = require('express')()
web.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*")
  res.header("Access-Control-Allow-Headers", "X-Requested-With")
  res.header("Access-Control-Allow-Headers", "Content-Type")
  res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS")
  next()
})
web.use(bodyParser.urlencoded({ extended: false }))
github mixpanel / mixpanel-node / example / simple.js View on Github external
var mixpanel = require('mixpanel');

var mp_client = new mixpanel.Client('89c4df475859a3323fd9f72237ed7260');

mp_client.track("my event", {
	distinct_id: "1111",
	as: "many",
	properties: "as",
	you: "want"
}, function(err) {
    console.log("sent event");
	if(err) { throw err; }
});

// manual funnel tracking is supported, but not recommended
mp_client.track_funnel("my funnel", 1, "first goal", {
	distinct_id: "1111"
}, function(err) {
    console.log("sent first funnel event");
github Wyliodrin / WyliodrinSTUDIO / source / public / controllers / ToolbarController.js View on Github external
var project_data = null;
								try
								{
									project_data = JSON.parse (value.target.result);
								}
								catch (e)
								{
									debug ('Project format error '+e);
								}
								if (project_data && _.isArray (project_data))
								{
									for (var projectIndex in project_data)
									{
										library.add (project_data[projectIndex]);
									}
									mixpanel.track ('Projects Import', {
										// language: projectimport.language
									});
									$wyapp.emit ('library');
								}
							};
							fileReader.onerror = function (err)
github Wyliodrin / WyliodrinSTUDIO / source / public / controllers / DashboardController.js View on Github external
$mdDialog.show(message).then(function() {
		    	var pos = _.indexOf($scope.project.dashboard, signal);
		    	mixpanel.track ('Dashboard Erase',
				{
					language: $scope.project.language,
					type: $scope.project.dashboard[pos].style
				});
				if (pos >= 0) $scope.project.dashboard.splice (pos, 1);
				$timeout (function ()
				{
					$(window).trigger ('resize');
				}, 500);
		    }, function() {
		    	// 
github DnD-industries / stellar_tipping_bot / src / loggers / tip-analytics.js View on Github external
const AbstractLogger = require('./abstract-logger')
const MixPanel = require('mixpanel')
const Utils = require('../utils')
var mixpanel = process.env.MIXPANEL_TOKEN ? MixPanel.init(process.env.MIXPANEL_TOKEN, {
  protocol: 'https'
}) : null;

class TipAnalytics extends AbstractLogger {

  constructor() {
    super()

    this.MessagingEvents = {
      onTipReceivedMessageSent(tip, userIsRegistered) {

        let data = TipAnalytics.getTipAnalyticsBase(tip)
        data.userIsRegistered = userIsRegistered
        if(mixpanel) mixpanel.track('message sent received tip', data)
      },
github docker / kitematic / src / utils / MetricsUtil.js View on Github external
import os from 'os';
import osxRelease from 'osx-release';
var settings;

try {
  settings = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'settings.json'), 'utf8'));
} catch (err) {
  settings = {};
}

var token = process.env.NODE_ENV === 'development' ? settings['mixpanel-dev'] : settings.mixpanel;
if (!token) {
  token = 'none';
}

var mixpanel = Mixpanel.init(token);

if (localStorage.getItem('metrics.enabled') === null) {
  localStorage.setItem('metrics.enabled', true);
}

var Metrics = {
  enabled: function () {
    return localStorage.getItem('metrics.enabled') === 'true';
  },
  setEnabled: function (enabled) {
    localStorage.setItem('metrics.enabled', !!enabled);
  },
  track: function (name, data) {
    data = data || {};
    if (!name) {
      return;
github datproject / datBase / server / auth / index.js View on Github external
module.exports = function (router, db, config) {
  const townshipDb = level(config.township.db || path.join(__dirname, 'township.db'))
  const ship = township(townshipDb, config.township)
  const mx = Mixpanel.init(config.mixpanel)
  var reset
  if (config.email) reset = createReset(config, townshipDb)

  function onerror (err, res) {
    var data = {statusCode: 400, message: errors.humanize(err).message}
    return response.json(data).status(400).pipe(res)
  }

  router.post('/api/v1/register', function (req, res) {
    if (!req.body) return onerror(new Error('Requires email and username.'), res)
    if (!req.body.email) return onerror(new Error('Email required.'), res)
    if (!req.body.username) return onerror(new Error('Username required.'), res)
    verify(req.body, {whitelist: config.whitelist}, function (err) {
      if (err) return onerror(err, res)
      ship.register(req, res, {body: req.body}, function (err, statusCode, obj) {
        if (err) {

mixpanel

A simple server-side API for mixpanel

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis