How to use the ember-metrics/metrics-adapters/intercom.extend function in ember-metrics

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 / 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');

ember-metrics

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

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis