Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@segment/analytics.js-core

Package Overview
Dependencies
Maintainers
138
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/analytics.js-core - npm Package Compare versions

Comparing version 4.1.4 to 4.1.5

39

build/analytics.js
'use strict';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -255,4 +266,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = __assign(__assign({}, this.options.integrations), msg.integrations);
}

@@ -302,4 +315,6 @@ this._invoke('identify', new Identify(msg));

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = __assign(__assign({}, this.options.integrations), msg.integrations);
}

@@ -358,3 +373,5 @@ this._invoke('group', new Group(msg));

// Add the initialize integrations so the server-side ones can be disabled too
defaults(msg.integrations, this._mergeInitializeAndPlanIntegrations(planIntegrationOptions));
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
msg.integrations = __assign(__assign({}, this._mergeInitializeAndPlanIntegrations(planIntegrationOptions)), msg.integrations);
this._invoke('track', new Track(msg));

@@ -490,4 +507,8 @@ this.emit('track', event, properties, options);

// TODO: Eventually move these entirely to `options.context.page`
// FIXME: This is purposely not overriding `defs`. There was a bug in the logic implemented by `@ndhoule/defaults`.
// This bug made it so we only would overwrite values in `defs` that were set to `undefined`.
// In some cases, though, pageDefaults will return defaults with values set to "" (such as `window.location.search` defaulting to "").
// The decision to not fix this bus was made to preserve backwards compatibility.
var defs = pageDefaults();
defaults(properties, defs);
properties = __assign(__assign({}, properties), defs);
// Mirror user overrides to `options.context.page` (but exclude custom properties)

@@ -509,4 +530,6 @@ // (Any page defaults get applied in `this.normalize` for consistency.)

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = __assign(__assign({}, this.options.integrations), msg.integrations);
}

@@ -554,4 +577,6 @@ this._invoke('page', new Page(msg));

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = __assign(__assign({}, this.options.integrations), msg.integrations);
}

@@ -787,3 +812,3 @@ this._invoke('alias', new Alias(msg));

// Ensure all outgoing requests include page data in their contexts.
msg.context.page = defaults(msg.context.page || {}, pageDefaults());
msg.context.page = __assign(__assign({}, pageDefaults()), msg.context.page);
return msg;

@@ -790,0 +815,0 @@ };

23

build/cookie.js
'use strict';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -13,4 +24,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var debug = require('debug')('analytics.js:cookie');
var defaults = require('@ndhoule/defaults');
var topDomain = require('@segment/top-domain');
var MAX_AGE_ONE_YEAR = 31536000000;
/**

@@ -34,9 +45,9 @@ * Initialize a new `Cookie` with `options`.

domain = null;
this._options = defaults(options, {
// default to a year
maxage: 31536000000,
var defaults = {
maxage: MAX_AGE_ONE_YEAR,
domain: domain,
path: '/',
domain: domain,
sameSite: 'Lax'
});
};
this._options = __assign(__assign({}, defaults), options);
// http://curl.haxx.se/rfc/cookie_spec.html

@@ -43,0 +54,0 @@ // https://publicsuffix.org/list/effective_tld_names.dat

'use strict';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -13,3 +24,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var debug = require('debug')('analytics:entity');
var defaults = require('@ndhoule/defaults');
var memory = require('./memory');

@@ -64,3 +74,3 @@ var store = require('./store');

return this._options;
this._options = defaults(options || {}, this.defaults || {});
this._options = __assign(__assign({}, this.defaults), options);
};

@@ -67,0 +77,0 @@ /**

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -11,3 +22,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

var debug = require('debug')('analytics.js:normalize');
var defaults = require('@ndhoule/defaults');
var type = require('component-type');

@@ -73,3 +83,3 @@ var uuid = require('uuid/v4');

ret.context = context;
ret = defaults(ret, msg);
ret = __assign(__assign({}, msg), ret);
debug('->', ret);

@@ -76,0 +86,0 @@ return ret;

@@ -1,11 +0,1 @@

declare var bindAll: any;
declare var defaults: any;
declare var store: any;
/**
* Initialize a new `Store` with `options`.
*
* @param {Object} options
*/
declare function Store(options?: {
enabled: boolean;
}): void;
export {};
'use strict';
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
/*

@@ -6,3 +18,2 @@ * Module dependencies.

var bindAll = require('bind-all');
var defaults = require('@ndhoule/defaults');
var store = require('@segment/store');

@@ -24,3 +35,3 @@ /**

options = options || {};
defaults(options, { enabled: true });
options = __assign({ enabled: true }, options);
this.enabled = options.enabled && store.enabled;

@@ -27,0 +38,0 @@ this._options = options;

@@ -29,2 +29,3 @@ export interface SegmentAnalytics {

secure?: boolean;
sameSite?: string;
}

@@ -37,3 +38,3 @@ export interface MetricsOptions {

}
interface StoreOptions {
export interface StoreOptions {
enabled?: boolean;

@@ -96,2 +97,1 @@ }

}
export {};

@@ -0,1 +1,5 @@

# 4.1.5 / 2020-09-17
- Replace @ndhoule/defaults with merging via ES6 spread syntax
# 4.1.4 / 2020-09-16

@@ -2,0 +6,0 @@

@@ -8,3 +8,4 @@ 'use strict';

SegmentOpts,
SegmentIntegration
SegmentIntegration,
PageDefaults, Message
} from './types';

@@ -327,4 +328,9 @@

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = {
...this.options.integrations,
...msg.integrations
}
}

@@ -384,4 +390,9 @@

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = {
...this.options.integrations,
...msg.integrations
}
}

@@ -450,6 +461,8 @@

// Add the initialize integrations so the server-side ones can be disabled too
defaults(
msg.integrations,
this._mergeInitializeAndPlanIntegrations(planIntegrationOptions)
);
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
msg.integrations = {
...this._mergeInitializeAndPlanIntegrations(planIntegrationOptions),
...msg.integrations
}

@@ -607,4 +620,11 @@ this._invoke('track', new Track(msg));

// TODO: Eventually move these entirely to `options.context.page`
const defs = pageDefaults();
defaults(properties, defs);
// FIXME: This is purposely not overriding `defs`. There was a bug in the logic implemented by `@ndhoule/defaults`.
// This bug made it so we only would overwrite values in `defs` that were set to `undefined`.
// In some cases, though, pageDefaults will return defaults with values set to "" (such as `window.location.search` defaulting to "").
// The decision to not fix this bus was made to preserve backwards compatibility.
const defs = pageDefaults()
properties = {
...properties,
...defs
}

@@ -629,4 +649,9 @@ // Mirror user overrides to `options.context.page` (but exclude custom properties)

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = {
...this.options.integrations,
...msg.integrations
}
}

@@ -683,4 +708,9 @@

// Add the initialize integrations so the server-side ones can be disabled too
// NOTE: We need to merge integrations, not override them with assign
// since it is possible to change the initialized integrations at runtime.
if (this.options.integrations) {
defaults(msg.integrations, this.options.integrations);
msg.integrations = {
...this.options.integrations,
...msg.integrations
}
}

@@ -977,3 +1007,4 @@

Analytics.prototype.normalize = function(msg: {
context: { page };
options: { [key: string]: unknown }
context: { page: Partial<PageDefaults> };
anonymousId: string;

@@ -986,3 +1017,6 @@ }): object {

// Ensure all outgoing requests include page data in their contexts.
msg.context.page = defaults(msg.context.page || {}, pageDefaults());
msg.context.page = {
...pageDefaults(),
...msg.context.page
};

@@ -989,0 +1023,0 @@ return msg;

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

var debug = require('debug')('analytics.js:cookie');
var defaults = require('@ndhoule/defaults');
var topDomain = require('@segment/top-domain');
const MAX_AGE_ONE_YEAR = 31536000000
/**

@@ -36,13 +37,17 @@ * Initialize a new `Cookie` with `options`.

var domain = '.' + topDomain(window.location.href);
let domain = '.' + topDomain(window.location.href);
if (domain === '.') domain = null;
this._options = defaults(options, {
// default to a year
maxage: 31536000000,
const defaults: CookieOptions = {
maxage: MAX_AGE_ONE_YEAR,
domain: domain,
path: '/',
domain: domain,
sameSite: 'Lax'
});
}
this._options = {
...defaults,
...options
};
// http://curl.haxx.se/rfc/cookie_spec.html

@@ -49,0 +54,0 @@ // https://publicsuffix.org/list/effective_tld_names.dat

@@ -13,3 +13,2 @@ 'use strict';

var debug = require('debug')('analytics:entity');
var defaults = require('@ndhoule/defaults');
var memory = require('./memory');

@@ -78,3 +77,6 @@ var store = require('./store');

if (arguments.length === 0) return this._options;
this._options = defaults(options || {}, this.defaults || {});
this._options = {
...this.defaults,
...options
}
};

@@ -81,0 +83,0 @@

@@ -9,3 +9,2 @@ import { Message } from './types';

var debug = require('debug')('analytics.js:normalize');
var defaults = require('@ndhoule/defaults');
var type = require('component-type');

@@ -15,2 +14,3 @@ var uuid = require('uuid/v4');

/**

@@ -93,3 +93,7 @@ * HOP.

ret.context = context;
ret = defaults(ret, msg);
ret = {
...msg,
...ret
}
debug('->', ret);

@@ -96,0 +100,0 @@ return ret;

'use strict';
import { StoreOptions } from './types';
/*

@@ -8,3 +10,2 @@ * Module dependencies.

var bindAll = require('bind-all');
var defaults = require('@ndhoule/defaults');
var store = require('@segment/store');

@@ -26,7 +27,10 @@

Store.prototype.options = function(options?: { enabled?: boolean }) {
Store.prototype.options = function(options?: StoreOptions) {
if (arguments.length === 0) return this._options;
options = options || {};
defaults(options, { enabled: true });
options = {
enabled: true,
...options
};

@@ -33,0 +37,0 @@ this.enabled = options.enabled && store.enabled;

@@ -40,2 +40,3 @@ export interface SegmentAnalytics {

secure?: boolean;
sameSite?: string
}

@@ -50,3 +51,3 @@

interface StoreOptions {
export interface StoreOptions {
enabled?: boolean;

@@ -53,0 +54,0 @@ }

{
"name": "@segment/analytics.js-core",
"author": "Segment <friends@segment.com>",
"version": "4.1.4",
"version": "4.1.5",
"description": "The hassle-free way to integrate analytics into any web application.",

@@ -33,3 +33,2 @@ "types": "lib/index.d.ts",

"dependencies": {
"@ndhoule/defaults": "^2.0.1",
"@segment/canonical": "^1.0.0",

@@ -36,0 +35,0 @@ "@segment/cookie": "^1.1.5",

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