How to use the obj-case.find function in obj-case

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 / criteo / lib / index.js View on Github external
each(function(value, key) {
    var trait = objCase.find(traits, key);

    if (trait) extraData[value] = trait;
  }, supportingUserData);
github segmentio / analytics.js-integrations / integrations / criteo / lib / index.js View on Github external
Criteo.prototype.orderCompleted = function(track) {
  var orderId = objCase.find(track.properties(), 'orderId');
  var products = getProductMetadata(track);
  var event = [
    {
      event: 'trackTransaction',
      id: orderId || '',
      item: products
    }
  ];
  var payload = [];

  payload = event.concat(this.setExtraData());

  window.criteo_q.push.apply(window.criteo_q, payload);
};
github segmentio / analytics.js-integrations / integrations / criteo / lib / index.js View on Github external
each(function(product) {
    var id = objCase.find(product, 'productId');
    if (id) productIds.push(id);
  }, products);
github segmentio / analytics.js-integrations / integrations / doubleclick-floodlight / lib / index.js View on Github external
each(function(variable) {
        var floodlightProp = variable.value;
        var segmentProp = variable.key.match(/{{(.*)}}/) || variable.key;
        var segmentPropValue;

        if (Array.isArray(segmentProp)) {
          segmentProp = segmentProp.pop();
          segmentPropValue = find(track.json(), segmentProp);
        } else {
          segmentPropValue = properties[segmentProp];
        }

        if (segmentPropValue) {
          matchedVariables[floodlightProp] = segmentPropValue;
        }
      }, tag.customVariable);
github segmentio / analytics.js-integrations / integrations / criteo / lib / index.js View on Github external
products = products.map(function(product) {
    var id = objCase.find(product, 'productId') || '';
    var price = product.price || '';
    var quantity = product.quantity || '';

    return { id: id, price: price, quantity: quantity };
  });

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