How to use ember-metrics - 10 common examples

To help you get started, we’ve selected a few ember-metrics 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 hummingbird-me / hummingbird-client / app / metrics-adapters / twitter-pixel.js View on Github external
import BaseAdapter from 'ember-metrics/metrics-adapters/base';
import { get } from '@ember/object';

export default BaseAdapter.extend({
  toStringExtension() {
    return 'TwitterPixel';
  },

  init() {
    const { id } = get(this, 'config');
    /* eslint-disable */
    !function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
    },s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',
    a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');
    /* eslint-enable */
    window.twq('init', id);
  },

  trackPage(options = {}) {
    window.twq('track', 'PageView', options);
github hummingbird-me / hummingbird-client / app / metrics-adapters / stream.js View on Github external
import BaseAdapter from 'ember-metrics/metrics-adapters/base';
import { get, set } from '@ember/object';
import jQuery from 'jquery';
import Config from 'client/config/environment';
import canUseDOM from 'client/utils/can-use-dom';

export default BaseAdapter.extend({
  toStringExtension() {
    return 'Stream';
  },

  init() {
    const environment = Config.kitsu.isStaging ? 'staging' : Config.environment;
    const config = get(this, `config.${environment}`);
    if (canUseDOM) {
      // eslint-disable-next-line
      !function(t,e){t("StreamAnalytics","https://d2j1fszo1axgmp.cloudfront.net/2.6.0/stream-analytics.min.js",e)}(function(t,e,n){var s,i,r;n["_"+t]={},n[t]=function(e){n["_"+t].clients=n["_"+t].clients||{},n["_"+t].clients[e.apiKey]=this,this._config=e};var c=function(t){return function(){return this["_"+t]=this["_"+t]||[],this["_"+t].push(arguments),this}};s=["setUser","trackImpression","trackEngagement"];for(var a=0;a
github hummingbird-me / hummingbird-client / app / metrics-adapters / go-squared.js View on Github external
import BaseAdapter from 'ember-metrics/metrics-adapters/base';
import { get } from '@ember/object';
import { compact, without } from 'ember-metrics/utils/object-transforms';

export default BaseAdapter.extend({
  toStringExtension() {
    return 'GoSquared';
  },

  init() {
    const { id } = get(this, 'config');
    /* eslint-disable */
    !function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
    arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
    d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
    insertBefore(d,q)}(window,document,'script','_gs');
    /* eslint-enable */
    if (window._gs && id) {
      window._gs(id, false);
    }
  },
github hummingbird-me / hummingbird-client / app / metrics-adapters / heap.js View on Github external
import BaseAdapter from 'ember-metrics/metrics-adapters/base';
import { compact, without } from 'ember-metrics/utils/object-transforms';
import get from 'ember-metal/get';
import canUseDOM from 'client/utils/can-use-dom';
import jQuery from 'jquery';

export default BaseAdapter.extend({
  toStringExtension() {
    return 'Heap';
  },

  init() {
    const { appId } = get(this, 'config');
    if (canUseDOM) {
      /* eslint-disable */
      window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c
github hummingbird-me / hummingbird-client / app / metrics-adapters / intercom.js View on Github external
import IntercomAdapter from 'ember-metrics/metrics-adapters/intercom';
import { compact, without } from 'ember-metrics/utils/object-transforms';
import canUseDOM from 'ember-metrics/utils/can-use-dom';
import get from 'ember-metal/get';
import { assert } from 'ember-metal/utils';

/**
 * Override the ember-metrics Intercom adapter to support guest users.
 *
 * This can be turned into a Pull Request later on.
 */
export default IntercomAdapter.extend({
  init() {
    const { appId } = get(this, 'config');

    assert(`[ember-metrics] You must pass a valid \`appId\` to the ${this.toString()} adapter`, appId);

    if (canUseDOM) {
      /* eslint-disable */
      (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',{});}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;
      s.src=`https://widget.intercom.io/widget/${appId}`;
      var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);} l(); }})()
      /* eslint-enable */
    }
  },

  identify(options = {}) {
    const { appId } = get(this, 'config');
github poteto / ember-metrics / tests / dummy / app / metrics-adapters / local-dummy-adapter.js View on Github external
import { inject } from '@ember/service';
import BaseAdapter from 'ember-metrics/metrics-adapters/base';

export default BaseAdapter.extend({
  application: inject(),

  toStringExtension() {
    return 'LocalDummy';
  },

  init() {
    this.set('application.foo', 'bar');
  },

  trackEvent({ controller }) {
    if (controller) {
      controller.set('foo', 'bar');
    }
  },
github CenterForOpenScience / ember-osf / addon / metrics-adapters / keen.js View on Github external
import Ember from 'ember';
import md5 from 'npm:js-md5';
import _get from 'npm:lodash/get';
import Cookie from 'npm:js-cookie';
import config from 'ember-get-config';
import keenTracking from 'npm:keen-tracking';
import BaseAdapter from 'ember-metrics/metrics-adapters/base';

export default BaseAdapter.extend({
    session: Ember.inject.service(),

    toStringExtension() {
        return 'Keen';
    },

    init() {},

    trackEvent(properties, node) {
        window.contextVars = {};
        window.contextVars.currentUser = this.userContextVars();
        window.contextVars.node = this.nodeContextVars(node);
        return this.KeenTracker().getInstance().trackPrivateEvent('front-end-events', { interaction: properties });
    },

    trackPage(properties) {
github hummingbird-me / hummingbird-client / app / metrics-adapters / heap.js View on Github external
identify(options = {}) {
    const compactedOptions = compact(options);
    const { distinctId } = compactedOptions;
    const props = without(compactedOptions, ['distinctId', 'alias']);
    if (canUseDOM && distinctId) {
      window.heap.identify(distinctId);
      window.heap.addUserProperties(props);
    }
  },
github hummingbird-me / hummingbird-client / app / metrics-adapters / go-squared.js View on Github external
trackEvent(options = {}) {
    const compactedOptions = compact(options);
    const { eventName } = compactedOptions;
    if (!eventName) { return; }

    if (window._gs) {
      window._gs('event', eventName, without(compactedOptions, 'eventName') || {});
    }
  },
github hummingbird-me / hummingbird-client / app / metrics-adapters / intercom.js View on Github external
identify(options = {}) {
    const { appId } = get(this, 'config');
    const compactedOptions = compact(options);
    const { distinctId } = compactedOptions;
    const props = without(compactedOptions, 'distinctId');

    props.app_id = appId;
    if (distinctId) {
      props.user_id = distinctId;
    }

    const method = this.booted ? 'update' : 'boot';
    if (canUseDOM) {
      window.Intercom(method, props);
      this.booted = true;
    }
  },

ember-metrics

Send data to multiple analytics integrations without re-implementing new API

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis