How to use the mixpanel.init function in mixpanel

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 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) {
github freedomexio / rocketx-condenser / src / server / api / general.js View on Github external
import config from 'config';
import recordWebEvent from 'server/record_web_event';
import { esc, escAttrs } from 'db/models';
import {
    emailRegex,
    getRemoteIp,
    rateLimitReq,
    checkCSRF,
} from 'server/utils/misc';
import coBody from 'co-body';
import Mixpanel from 'mixpanel';
import { PublicKey, Signature, hash } from '@steemit/steem-js/lib/auth/ecc';
import { api, broadcast } from '@steemit/steem-js';

const mixpanel = config.get('mixpanel')
    ? Mixpanel.init(config.get('mixpanel'))
    : null;

const _stringval = v => (typeof v === 'string' ? v : JSON.stringify(v));
function logRequest(path, ctx, extra) {
    let d = { ip: getRemoteIp(ctx.req) };
    if (ctx.session) {
        if (ctx.session.user) {
            d.user = ctx.session.user;
        }
        if (ctx.session.uid) {
            d.uid = ctx.session.uid;
        }
        if (ctx.session.a) {
            d.account = ctx.session.a;
        }
    }
github backstrokeapp / server / src / routes / webhook / handler.js View on Github external
import {paginateRequest} from '../helpers';
import Debug from 'debug';
const debug = Debug('backstroke:webhook');

import Mixpanel from 'mixpanel';
let mixpanel;
if (process.env.USE_MIXPANEL) {
  mixpanel = Mixpanel.init(process.env.USE_MIXPANEL);
}

function trackWebhook(link) {
  process.env.USE_MIXPANEL && mixpanel.track('Webhook', {
    "Link Id": link._id,
    "From Repo Name": link.upstream ? link.upstream.name : null,
    "From Repo Provider": link.upstream ? link.upstream.provider : null,
    "To Repo Name": link.fork ? (link.fork.name || link.fork.type) : null,
    "To Repo Provider": link.fork ? link.fork.provider : null,
  });
}


function createPullRequest(req, upstream, fork) {
  debug('CREATING PULL REQUEST FROM UPSTREAM %o TO FORK %o', upstream, fork);
  return didRepoOptOut(req, fork).then(didOptOut => {

mixpanel

A simple server-side API for mixpanel

MIT
Latest version published 8 months ago

Package Health Score

70 / 100
Full package analysis