New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mrporter/frontend-monitoring

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mrporter/frontend-monitoring - npm Package Compare versions

Comparing version 3.0.2 to 4.0.0

41

dist/index.js

@@ -6,2 +6,5 @@ 'use strict';

});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.setupMonitoring = setupMonitoring;

@@ -20,11 +23,33 @@ exports.trackEvent = trackEvent;

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var client = void 0;
function setupMonitoring(config) {
var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultProperties;
function setupMonitoring() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (config && config.projectId) {
client = new _keenTracking2.default(config);
client.extendEvents(properties);
var _config$globalPropert = config.globalProperties,
globalProperties = _config$globalPropert === undefined ? {} : _config$globalPropert,
keenConfig = _objectWithoutProperties(config, ['globalProperties']);
var app_name = globalProperties.app_name,
business = globalProperties.business;
if (process && process.env && process.env.NODE_ENV !== 'production') {
if (!app_name) {
console.warn('Warning: No app_name property set');
}
if (!business) {
console.warn('Warning: No business property set');
}
}
if (keenConfig.projectId) {
client = new _keenTracking2.default(keenConfig);
client.extendEvents(function () {
return mergeWithDefaultProperties(globalProperties);
});
}
return client;

@@ -62,4 +87,4 @@ }

function defaultProperties() {
return {
function mergeWithDefaultProperties(properties) {
return _extends({}, properties, {
ip_address: '${keen.ip}',

@@ -96,3 +121,3 @@ user_agent: '${keen.user_agent}',

}
};
});
}

2

package.json
{
"name": "@mrporter/frontend-monitoring",
"version": "3.0.2",
"version": "4.0.0",
"description": "Utils and Events for MRP front end monitoring",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -14,5 +14,12 @@ # MRP Front End Monitoring

projectId: 'abc123',
writeKey: 'def456'
writeKey: 'def456',
properties: {
app_name: 'myaccount',
business: 'mrporter'
}
});
```
The properties object can contain any default properties you want to pass with every event. You can specify an app_name property and business here to easily differentiate when querying keen. If these aren't set, a warning will be logged to the console in dev mode.
If no projectId is passed in, `trackEvent` will log events to the console ('dev mode') rather than attempt to fire off events to keen.

@@ -19,0 +26,0 @@ ### API

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc