How to use insight - 10 common examples

To help you get started, we’ve selected a few insight 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 d4rkr00t / aik / src / analytics.js View on Github external
/* @flow */

import querystring from "querystring";
import Insight from "insight";
import pkg from "../package.json";

const trackingCode = "UA-88006586-1";
const trackingProvider = "google";
const insight = new Insight({ trackingCode, trackingProvider, pkg });

export function askPermission(cb: Function) {
  // eslint-disable-next-line
  if (insight.optOut === undefined) {
    return insight.askPermission(null, cb);
  }
  cb();
}

export function track(path: string[], input: string[], flags: CLIFlags) {
  if (insight.optOut) return;

  const filteredFlags = Object.keys(flags).reduce((acc, flag) => {
    if (flag.length > 1) {
      acc[flag] = flags[flag];
    }
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / insight.js View on Github external
return new Promise(resolve => {
		try {
			const projectPkgJson = readJsonSync(
				path.join(process.cwd(), 'package.json')
			);

			PROJECT_NAME = projectPkgJson.name;
			PROJECT_VERSION = projectPkgJson.version;

			insight = new Insight({
				trackingCode: GA_TOKEN,
				pkg: require('../package.json'),
			});
		} catch (err) {
			// ignore
		}

		if (insight && insight.optOut === undefined) {
			insight.askPermission(undefined, resolve);
		} else {
			resolve();
		}
	});
}
github lightingbeetle / generator-lb / app / generator.js View on Github external
return function() {
      this.pkg = require('../package.json');
      this.version = this.pkg.version;
      
      this.insight = new Insight({
        // Google Analytics tracking code
        trackingCode: 'UA-27851629-19',
        pkg: this.pkg,
        version: this.version
      });
    };
  }
github slackapi / steno / src / analytics.ts View on Github external
export function prompt(): Promise {
  // instantiate a dummy insight in order to use its instance method
  const dummy = new Insight({
    pkg,
    trackingCode: pkg.analytics.googleTrackingId,
  });
  if (dummy.optOut === undefined) {
    return new Promise((resolve, reject) => {
      dummy.askPermission(undefined, (error: Error, optIn: boolean) => {
        if (error) return reject(error);
        resolve(optIn);
      });
    });
  }
  return Promise.resolve(!dummy.optOut);
}
github apache / cordova-cli / spec / cli.spec.js View on Github external
beforeEach(() => {
            // Allow testing if we _really_ would send tracking requests
            telemetry.track.and.callThrough();
            telemetry.turnOn.and.callThrough();
            telemetry.turnOff.and.callThrough();
            spyOn(Insight.prototype, 'track').and.callThrough();
            spyOn(Insight.prototype, '_save');
            spyOnProperty(Insight.prototype, 'optOut', 'get')
                .and.callFake(() => isOptedOut);
            spyOnProperty(Insight.prototype, 'optOut', 'set')
                .and.callFake(x => { isOptedOut = x; });

            // Set a normal opted-in user as default
            spyOn(telemetry, 'isCI').and.returnValue(false);
            isOptedOut = false;
        });
github apache / cordova-cli / spec / telemetry.spec.js View on Github external
beforeEach(() => {
        telemetry = rewire('../src/telemetry');
        insight = telemetry.__get__('insight');

        // Prevent any settings from being persisted during testing
        insight.config = {
            get (key) { return this[key]; },
            set (key, val) { this[key] = val; }
        };
        for (const key in insight.config) {
            spyOn(insight.config, key).and.callThrough();
        }

        // Prevent tracking anything during testing
        spyOn(Insight.prototype, '_save');

        // Prevent prompts during testing
        spyOn(Insight.prototype, 'askPermission');
    });
github wulkano / kap / app / src / main / analytics.js View on Github external
import firstRun from 'first-run';
import Insight from 'insight';
import {parse} from 'semver';
import pkg from '../../package';
import {get as getSetting} from '../common/settings-manager';

const trackingCode = 'UA-84705099-2';
const insight = new Insight({trackingCode, pkg});
const version = parse(pkg.version);

export const init = () => {
  if (firstRun()) {
    insight.track('install');
  }

  if (firstRun({name: `${pkg.name}-${pkg.version}`})) {
    insight.track(`v${version.major}.${version.minor}/install`);
  }
};

export const track = (...paths) => {
  console.log(getSetting('allowAnalytics'));

  if (getSetting('allowAnalytics') === true) {
github slackapi / steno / src / analytics.ts View on Github external
constructor(private name: string, trackingId: string) {
    this.insight = new Insight({
      pkg,
      trackingCode: trackingId,
    });
  }
github terkelg / ramme / app / src / main / analytics.js View on Github external
import firstRun from 'first-run'
import Insight from 'insight'

const pkg = require('../../package')

const trackingCode = 'UA-87371303-1'

const insight = new Insight({trackingCode, pkg})

function init () {
  if (firstRun()) {
    insight.track('install')
  }

  if (firstRun({name: `${pkg.name}-${pkg.version}`})) {
  }
}

function track (...paths) {
  insight.track(...paths)
}

export {init, track}

insight

Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics or Yandex.Metrica

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular insight functions