How to use obj-case - 10 common examples

To help you get started, we’ve selected a few obj-case 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-integrations / integrations / nielsen-dcr / lib / index.js View on Github external
function formatLoadType(integrationOpts, loadTypeProperty) {
  var loadType = find(integrationOpts, 'ad_load_type') || loadTypeProperty;
  // linear or dynamic
  // linear means original ads that were broadcasted with tv airing. much less common use case
  loadType = loadType === 'dynamic' ? '2' : '1';
  return loadType;
}
github segmentio / analytics.js-integrations / integrations / nielsen-dcr / lib / index.js View on Github external
var integrationOpts = track.options(this.name);
  var contentMetadata = {
    type: 'content',
    assetid: assetId,
    program: track.proxy(propertiesPath + 'program'),
    title: track.proxy(propertiesPath + 'title'),
    isfullepisode: track.proxy(propertiesPath + 'full_episode') ? 'y' : 'n',
    mediaURL: track.proxy('context.page.url'),
    airdate: formatAirdate(track.proxy(propertiesPath + 'airdate')),
    // `adLoadType` may be set in int opts, falling back to `load_type` property per our video spec
    adloadtype: formatLoadType(
      integrationOpts,
      track.proxy(propertiesPath + 'load_type')
    ),
    // below metadata fields must all be set in event's integrations opts object
    crossId1: find(integrationOpts, 'crossId1'),
    crossId2: find(integrationOpts, 'crossId2'),
    hasAds: find(integrationOpts, 'hasAds') === true ? '1' : '0'
  };

  if (this.options.contentLengthPropertyName !== 'total_length') {
    var contentLengthKey = this.options.contentLengthPropertyName;
    contentMetadata.length = track.proxy(propertiesPath + contentLengthKey);
  } else {
    contentMetadata.length = track.proxy(propertiesPath + 'total_length');
  }
  // if length is any falsy value after the above checks, default to 0 length per Nielsen
  contentMetadata.length = contentMetadata.length || 0;

  if (this.options.subbrandPropertyName) {
    var subbrandProp = this.options.subbrandPropertyName;
    contentMetadata.subbrand = track.proxy(propertiesPath + subbrandProp);
github segmentio / analytics.js-integrations / integrations / friendbuy / lib / index.js View on Github external
FriendBuy.prototype.orderCompleted = function(track) {
  if (!track.orderId()) return; // required

  var options = track.options(this.name);
  var orderDetail = reject({
    id: track.orderId(),
    email: track.email(),
    amount: track.revenue(),
    coupon_code: track.proxy('properties.coupon'),
    new_customer: find(options, 'new_customer')
  });

  window.friendbuy.push(['track', 'order', orderDetail]);

  var orderList = [];
  each(function(item) {
    var i = new Facade({ properties: item });

    if (i.sku()) {
      orderList.push(
        reject({
          sku: i.sku(),
          price: i.price(),
          quantity: i.quantity()
        })
      );
github segmentio / analytics.js-integrations / integrations / friendbuy / lib / index.js View on Github external
FriendBuy.prototype.identify = function(identify) {
  if (!identify.userId()) return; // required

  var options = identify.options(this.name);
  var customerDetail = reject({
    id: identify.userId(),
    email: identify.email(),
    first_name: identify.firstName(),
    last_name: identify.lastName(),
    stripe_customer_id: find(options, 'stripe_customer_id'),
    chargebee_customer_id: find(options, 'chargebee_customer_id')
  });

  window.friendbuy.push(['track', 'customer', customerDetail]);
};
github segmentio / analytics.js-integrations / integrations / appboy / lib / index.js View on Github external
Appboy.prototype.orderCompleted = function(track) {
  var userId = track.userId();
  var products = track.products();
  var currencyCode = track.currency();
  var purchaseProperties = track.properties();

  if (userId) {
    window.appboy.changeUser(userId);
  }

  // remove reduntant properties
  del(purchaseProperties, 'products');
  del(purchaseProperties, 'currency');

  // we have to make a separate call to appboy for each product
  for (var i = 0; i < products.length; i++) {
    logProduct(products[i], currencyCode, purchaseProperties);
  }
};
github segmentio / analytics.js-integrations / integrations / kenshoo-infinity / lib / index.js View on Github external
KenshooInfinity.prototype.track = function(track) {
  var conversionType = this.events(track.event()); // returns an array
  if (!conversionType.length) return;

  var subdomain = this.options.subdomain;
  var cid = this.options.cid;
  var revenue = track.revenue() || '0';
  var orderId = track.orderId();
  var promoCode = track.options(this.name).promoCode;
  var currency = track.currency();

  // Get custom properties only after removing semantic properties
  var customProperties = track.properties();
  remove(customProperties, 'conversionType');
  remove(customProperties, 'revenue');
  remove(customProperties, 'currency');
  remove(customProperties, 'orderId');
  remove(customProperties, 'promoCode');
  // flatten all compound objects with underscores and then format
  customProperties = format(trample(customProperties, { delimiter: '_' }));

  var params = reject({
    conversionType: limitChars(conversionType, 100) || 'conv',
    revenue: revenue,
    currency: currency, // defaults to 'USD'
    orderId: limitChars(orderId, 64),
    promoCode: limitChars(promoCode, 1024)
  });

  params = extend(params, customProperties);
github segmentio / analytics.js-integrations / integrations / kenshoo-infinity / lib / index.js View on Github external
KenshooInfinity.prototype.track = function(track) {
  var conversionType = this.events(track.event()); // returns an array
  if (!conversionType.length) return;

  var subdomain = this.options.subdomain;
  var cid = this.options.cid;
  var revenue = track.revenue() || '0';
  var orderId = track.orderId();
  var promoCode = track.options(this.name).promoCode;
  var currency = track.currency();

  // Get custom properties only after removing semantic properties
  var customProperties = track.properties();
  remove(customProperties, 'conversionType');
  remove(customProperties, 'revenue');
  remove(customProperties, 'currency');
  remove(customProperties, 'orderId');
  remove(customProperties, 'promoCode');
  // flatten all compound objects with underscores and then format
  customProperties = format(trample(customProperties, { delimiter: '_' }));

  var params = reject({
    conversionType: limitChars(conversionType, 100) || 'conv',
    revenue: revenue,
    currency: currency, // defaults to 'USD'
    orderId: limitChars(orderId, 64),
    promoCode: limitChars(promoCode, 1024)
  });

  params = extend(params, customProperties);
  // All string values must be encoded
  var encodedParams = {};
github segmentio / analytics.js-integrations / integrations / appboy / lib / index.js View on Github external
Appboy.prototype.orderCompleted = function(track) {
  var userId = track.userId();
  var products = track.products();
  var currencyCode = track.currency();
  var purchaseProperties = track.properties();

  if (userId) {
    window.appboy.changeUser(userId);
  }

  // remove reduntant properties
  del(purchaseProperties, 'products');
  del(purchaseProperties, 'currency');

  // we have to make a separate call to appboy for each product
  for (var i = 0; i < products.length; i++) {
    logProduct(products[i], currencyCode, purchaseProperties);
  }
};
github segmentio / analytics.js-integrations / integrations / mixpanel / lib / index.js View on Github external
var email = identify.email();
  var id = identify.userId();
  var setAllTraitsByDefault = this.options.setAllTraitsByDefault;
  var people = this.options.people;
  var peopleProperties = extendTraits(this.options.peopleProperties);
  var superProperties = this.options.superProperties;

  // id
  if (id) window.mixpanel.identify(id);

  // name tag
  var nametag = email || username || id;
  if (nametag) window.mixpanel.name_tag(nametag);

  var traits = identify.traits(traitAliases);
  if (traits.$created) del(traits, 'createdAt');
  traits = dates(traits, iso);

  // determine which traits to union to existing properties and which to set as new properties
  var traitsToUnion = {};
  var traitsToSet = {};
  for (var key in traits) {
    if (!traits.hasOwnProperty(key)) continue;

    var trait = traits[key];
    if (Array.isArray(trait) && trait.length > 0) {
      traitsToUnion[key] = trait;
      // since mixpanel doesn't offer a union method for super properties we have to do it manually by retrieving the existing list super property
      // from mixpanel and manually unioning to it ourselves
      var existingTrait = window.mixpanel.get_property(key);
      if (existingTrait && Array.isArray(existingTrait)) {
        traits[key] = unionArrays(existingTrait, trait);
github segmentio / analytics.js-integrations / integrations / criteo / lib / index.js View on Github external
each(function(value, key) {
    var trait = objCase.find(traits, key);

    if (trait) extraData[value] = trait;
  }, supportingUserData);

obj-case

Work with objects of different cased keys

MIT
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis

Popular obj-case functions