コード例 #1
0
ファイル: helpers.js プロジェクト: bengott/Telescope
export const requestAnalyticsAsync = (hook, document, user) => {
  
  // get the segment write key from the settings
  const useSegment = getSetting('useSegment');
  const writeKey = getSetting('segmentWriteKey');

  // the settings obviously tells to use segment
  // and segment write key is defined & isn't the placeholder from sample_settings.json
  if (useSegment && writeKey && writeKey !== '456bar') {
    
    const analytics = new Analytics(writeKey);
    
    if (hook.includes('users')) {
      // if the mutation is related to users, use analytics.identify
      // see https://segment.com/docs/sources/server/node/#identify
      
      // note: on users.new.async, user is undefined
      const userId = user ? user._id : document._id;
      
      if (document.services) {
        if(document.services.password) {
          delete document.services.password;
        }
        
        if (document.services.resume) {
          delete document.services.resume;
        }
      }
      
      
      const data = {
        userId,
        traits: document,
      };
      
      // uncomment for debug
      // console.log(`// dispatching identify on "${hook}" (user ${userId})`);
      // console.log(data);
      
      analytics.identify(data);
      
    } else {
      // else use analytics.track
      // see https://segment.com/docs/sources/server/node/#track
      
      const data = {
        userId: user._id,
        event: hook,
        properties: document,
      };
      
      // uncomment for debug
      // console.log(`// dispatching track on "${hook}"`);
      // console.log(data);
      
      analytics.track(data);  
    }
  }
}
コード例 #2
0
ファイル: index.js プロジェクト: Brandlyst/landing-page
function identify(data) {
    analytics.identify({
        userId: data.user_id,
        traits: {
            email: data.user_email
        }
    });
}
コード例 #3
0
ファイル: server.js プロジェクト: notjrbauer/nodejs-analytics
app.post('/identify', function (req, res, next) {

  // already sanitized
  var body = req.body
  body.timestamp = new Date(body.timestamp)

  try {
    analytics.identify(body, function (err, response, data) {
      debug('Identify', err, response)
      debug('Data', data)

      res.send({
        event: 'identify',
        message: 'success'
      })
    })
  } catch (err) {
    return res.send(err)
  }
})
コード例 #4
0
ファイル: logEvent.js プロジェクト: DustinEMiller/wfh-api
module.exports = function(employee) {

  if (!config.segment || !config.segment.writeKey || !config.segment.writeKey.length) {
    return;
  }

  const analytics = new Analytics(config.segment.writeKey);
  analytics.identify({
    userId: employee.email,
    traits: {
      name: employee.name
    }
  });

  analytics.track({
    userId: employee.email,
    event: 'status',
    properties: {
      status: employee.status
    }
  });

};
コード例 #5
0
ファイル: language-options.js プロジェクト: kenokabe/packages
  beautify: function (text, grammar, allOptions, beautifyCompleted) {
    var self = this;
    // Beautify!
    var unsupportedGrammar = false;
    var options;
    switch (grammar) {
    case 'JSON':
      // Treat JSON as JavaScript, because it will support comments.
      // And Glavin001 has tested JSON beauifying with beautifyJS.
    case 'JavaScript':
      text = beautifyJS(text, self.getOptions('js', allOptions));
      beautifyCompleted(text);
      break;
    case 'CoffeeScript':
      beautifyCoffeeScript(text, self.getOptions('js', allOptions),
        beautifyCompleted);
      break;
    case 'Handlebars':
      // jshint ignore: start
      allOptions.push({
        indent_handlebars: true // Force jsbeautify to indent_handlebars
      });
      // jshint ignore: end
    case 'HTML (Liquid)':
    case 'HTML':
    case 'XML':
      text = beautifyHTML(text, self.getOptions('html', allOptions));
      beautifyCompleted(text);
      break;
    case 'CSS':
      text = beautifyCSS(text, self.getOptions('css', allOptions));
      beautifyCompleted(text);
      break;
    case 'Sass':
    case 'SCSS':
    case 'LESS':
      beautifyLESS(text, self.getOptions('css', allOptions), beautifyCompleted);
      break;
    case 'SQL (Rails)':
    case 'SQL':
      text = beautifySQL(text, self.getOptions('sql', allOptions));
      beautifyCompleted(text);
      break;
    case 'PHP':
      beautifyPHP(text, self.getOptions('php', allOptions), beautifyCompleted);
      break;
    case 'Python':
      beautifyPython(text, self.getOptions('python', allOptions),
        beautifyCompleted);
      break;
    case 'Ruby':
      beautifyRuby(text, self.getOptions('ruby', allOptions), beautifyCompleted);
      break;
    case 'C':
      options = self.getOptions('c', allOptions);
      options.languageOverride = 'C';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'C++':
      options = self.getOptions('cpp', allOptions);
      options.languageOverride = 'CPP';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'C#':
      options = self.getOptions('cs', allOptions);
      options.languageOverride = 'CS';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'Objective-C':
    case 'Objective-C++':
      options = self.getOptions('objectivec', allOptions);
      options.languageOverride = 'OC+';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'D':
      options = self.getOptions('d', allOptions);
      options.languageOverride = 'D';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'Pawn':
      options = self.getOptions('pawn', allOptions);
      options.languageOverride = 'PAWN';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'Vala':
      options = self.getOptions('vala', allOptions);
      options.languageOverride = 'VALA';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    case 'Java':
      options = self.getOptions('java', allOptions);
      options.languageOverride = 'JAVA';
      uncrustifyBeautifier(text, options,
        beautifyCompleted);
      break;
    default:
      unsupportedGrammar = true;
    }

    // Check if Analytics is enabled
    if (atom.config.get('atom-beautify.analytics')) {
      // Setup Analytics
      var analytics = new Analytics(analyticsWriteKey);
      if (!atom.config.get('atom-beautify._analyticsUserId')) {
        var uuid = require('node-uuid');
        atom.config.set('atom-beautify._analyticsUserId', uuid.v4());
      }
      // Setup Analytics User Id
      var userId = atom.config.get('atom-beautify._analyticsUserId');
      analytics.identify({
        userId: userId
      });
      var version = pkg.version;
      analytics.track({
        userId: atom.config.get('atom-beautify._analyticsUserId'),
        event: 'Beautify',
        properties: {
          grammar: grammar,
          version: version,
          options: allOptions,
          label: grammar,
          category: version
        }
      });
    }

  },