How to use segmentio-facade - 10 common examples

To help you get started, we’ve selected a few segmentio-facade 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 segmentio / analytics.js-core / lib / analytics.js View on Github external
}
  } else {
    var defaultPlan = events.__default || { enabled: true };
    if (!defaultPlan.enabled) {
      // Disabled events should always be sent to Segment.
      planIntegrationOptions = { All: false, 'Segment.io': true };
    }
  }

  // Add the initialize integrations so the server-side ones can be disabled too
  defaults(
    msg.integrations,
    this._mergeInitializeAndPlanIntegrations(planIntegrationOptions)
  );

  this._invoke('track', new Track(msg));

  this.emit('track', event, properties, options);
  this._callback(fn);
  return this;
};
github segmentio / analytics.js-core / lib / analytics.js View on Github external
// clone traits before we manipulate so we don't do anything uncouth, and take
  // from `user` so that we carryover anonymous traits
  user.identify(id, traits);

  var msg = this.normalize({
    options: options,
    traits: user.traits(),
    userId: user.id()
  });

  // Add the initialize integrations so the server-side ones can be disabled too
  if (this.options.integrations) {
    defaults(msg.integrations, this.options.integrations);
  }

  this._invoke('identify', new Identify(msg));

  // emit
  this.emit('identify', id, traits, options);
  this._callback(fn);
  return this;
};
github segmentio / analytics.js-core / lib / analytics.js View on Github external
options.context.page = overrides;
  }

  var msg = this.normalize({
    properties: properties,
    category: category,
    options: options,
    name: name
  });

  // Add the initialize integrations so the server-side ones can be disabled too
  if (this.options.integrations) {
    defaults(msg.integrations, this.options.integrations);
  }

  this._invoke('page', new Page(msg));

  this.emit('page', category, name, properties, options);
  this._callback(fn);
  return this;
};
github segmentio / analytics.js-core / lib / analytics.js View on Github external
if (is.fn(from)) (fn = from), (options = null), (from = null);
  if (is.object(from)) (options = from), (from = null);
  /* eslint-enable no-unused-expressions, no-sequences */

  var msg = this.normalize({
    options: options,
    previousId: from,
    userId: to
  });

  // Add the initialize integrations so the server-side ones can be disabled too
  if (this.options.integrations) {
    defaults(msg.integrations, this.options.integrations);
  }

  this._invoke('alias', new Alias(msg));

  this.emit('alias', to, from, options);
  this._callback(fn);
  return this;
};
github segmentio / analytics.js-core / lib / analytics.js View on Github external
// grab from group again to make sure we're taking from the source
  group.identify(id, traits);

  var msg = this.normalize({
    options: options,
    traits: group.traits(),
    groupId: group.id()
  });

  // Add the initialize integrations so the server-side ones can be disabled too
  if (this.options.integrations) {
    defaults(msg.integrations, this.options.integrations);
  }

  this._invoke('group', new Group(msg));

  this.emit('group', id, traits, options);
  this._callback(fn);
  return this;
};
github segmentio / analytics.js-integrations / integrations / amplitude / lib / index.js View on Github external
var price = product.price;
      var quantity = product.quantity;
      clonedTrack.properties = product;
      clonedTrack.event = 'Product Purchased';
      // Price and quantity are both required by Amplitude:
      // https://amplitude.zendesk.com/hc/en-us/articles/115001361248#tracking-revenue
      // Price could potentially be 0 so handle that edge case.
      if (trackRevenuePerProduct && price != null && quantity) {
        // Add revenueType if exists, to be able to override.
        if (revenueType) {
          clonedTrack.properties.revenueType = revenueType;
        }
        if (revenue) {
          clonedTrack.properties.revenue = revenue;
        }
        this.setRevenue(mapRevenueAttributes(new Track(clonedTrack)));
      }
      logEvent.call(this, new Track(clonedTrack), trackRevenuePerProduct);
    }.bind(this),
    products
github segmentio / analytics.js-integrations / integrations / hubspot / lib / index.js View on Github external
HubSpot.prototype.identify = function(identify) {
  // use newer version of Identify to have access to `companyName`
  var newIdentify = new Identify({
    traits: identify.traits(),
    userId: identify.userId()
  });

  if (!newIdentify.email()) {
    return;
  }

  var traits = newIdentify.traits({
    firstName: 'firstname',
    lastName: 'lastname'
  });
  traits = convertDates(traits);
  traits = formatTraits(traits);

  if (newIdentify.companyName() !== undefined) {
github segmentio / analytics.js-integrations / integrations / totango / lib / index.js View on Github external
Totango.prototype.initialize = function(page) {
  page = page || new Page({});

  /* eslint-disable */
  window.totango = {
    go:function(){return -1;},
    setAccountAttributes:function(){},
    identify:function(){},
    track:function(t,o,n,a){window.totango_tmp_stack.push({activity:t,module:o,org:n,user:a}); return -1;}};
  /* eslint-enable */

  window.totango_options = {
    allow_empty_accounts: false,
    service_id: this.options.serviceId,
    disable_heartbeat: this.options.disableHeartbeat,
    module: page.category()
  };
github segmentio / analytics.js-integrations / integrations / google-analytics / lib / index.js View on Github external
each(products, function(product) {
    var track = new Track({ properties: product });
    push(
      '_addItem',
      orderId,
      track.sku(),
      track.name(),
      track.category(),
      track.price(),
      track.quantity()
    );
  });
github segment-integrations / analytics.js-integration-google-analytics / lib / index.js View on Github external
each(products, function(product) {
    var track = new Track({ properties: product });
    window.ga(self._trackerName + 'ec:addProduct', {
      id: track.productId() || track.id() || track.sku(),
      quantity: track.quantity()
    });
  });

segmentio-facade

Providing common fields for analytics integrations

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages