Socket
Socket
Sign inDemoInstall

mixpanel-browser

Package Overview
Dependencies
Maintainers
7
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mixpanel-browser - npm Package Compare versions

Comparing version 2.35.0 to 2.36.0

src/request-batcher.js

3

CHANGELOG.md

@@ -0,1 +1,4 @@

**2.36.0** (7 May 2020)
- Add batch/queue/retry support for event-tracking and people/group profile updates
**2.35.0** (17 Mar 2020)

@@ -2,0 +5,0 @@ - Fix cross-subdomain tracking for various edge cases (extra-long TLDs, very short .com/.org domains)

@@ -42,3 +42,3 @@ /**

.replace(/<p>([\S\s]+?)<\/p>/g, (str, match) => match.replace(/\n/g, ` `) + `\n`)
.replace(/<pre><code>([\s\S]+?)<\/code><\/pre>/g, '\n```javascript\n$1\n```')
.replace(/<pre><code>([\s\S]+?)<\/code><\/pre>/g, '\n```javascript\n$1\n```\n')
;

@@ -48,2 +48,6 @@ });

function stripPTags(str) {
return str.replace(/<p>([\S\s]+?)<\/?p>/g, `$1`);
}
// transform the structured data dox parses out of our JSDoc and feed it through

@@ -77,6 +81,12 @@ // the lodash template at template.md

name: trim(arg.name, `[]`),
description: arg.description.replace(/<p>([\S\s]+?)<\/?p>/g, `$1`),
description: stripPTags(arg.description),
required: !arg.name.startsWith(`[`),
types: arg.typesDescription === `<code>*</code>` ? `any` : arg.types.join(` or `),
})),
returns: item.tags
.filter(tag => tag.type === `returns`)
.map(tag => ({
description: stripPTags(tag.description),
types: tag.types.join(` or `),
})),
...parseDescriptionAttrs(item.description.full),

@@ -83,0 +93,0 @@ })),

184

doc/readme.io/javascript-full-api-reference.md

@@ -10,3 +10,3 @@ ---

<hr>
___
## mixpanel.add_group

@@ -23,2 +23,3 @@ Add a new group for this user.

| Argument | Type | Description |

@@ -31,19 +32,40 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.alias
Create an alias, which Mixpanel will use to link two distinct_ids going forward (not retroactively). Multiple aliases can map to the same original ID, but not vice-versa. Aliases can also be chained - the following is a valid scenario:
The alias method creates an alias which Mixpanel will use to remap one id to another. Multiple aliases can point to the same identifier.
The following is a valid use of alias:
```javascript
mixpanel.alias('new_id', 'existing_id');
...
// You can add multiple id aliases to the existing ID
mixpanel.alias('newer_id', 'existing_id');
```
Aliases can also be chained - the following is a valid example:
```javascript
mixpanel.alias('new_id', 'existing_id');
// chain newer_id - new_id - existing_id
mixpanel.alias('newer_id', 'new_id');
```
If the original ID is not passed in, we will use the current distinct_id - probably the auto-generated GUID.
Aliases cannot point to multiple identifiers - the following example will not work:
```javascript
mixpanel.alias('new_id', 'existing_id');
// this is invalid as 'new_id' already points to 'existing_id'
mixpanel.alias('new_id', 'newer_id');
```
### Notes:
The best practice is to call alias() when a unique ID is first created for a user (e.g., when a user first registers for an account and provides an email address). alias() should never be called more than once for a given user, except to chain a newer ID to a previously new ID, as described above.
If your project does not have <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a> enabled, the best practice is to call alias once when a unique ID is first created for a user (e.g., when a user first registers for an account). Do not use alias multiple times for a single user without ID Merge enabled.

@@ -57,3 +79,3 @@

<hr>
___
## mixpanel.clear_opt_in_out_tracking

@@ -78,3 +100,3 @@ Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance

<hr>
___
## mixpanel.disable

@@ -93,3 +115,3 @@ Disable events on the Mixpanel object. If passed no arguments, this function disables tracking of any event. If passed an array of event names, those events will be disabled, but other events will continue to be tracked.

<hr>
___
## mixpanel.get_config

@@ -102,3 +124,3 @@ returns the current config object for the library.

<hr>
___
## mixpanel.get_distinct_id

@@ -123,3 +145,4 @@ Returns the current distinct id of the user. This is either the id automatically generated by the library or the id that has been passed by a call to identify().

<hr>
___
## mixpanel.get_group

@@ -136,2 +159,3 @@ Look up reference to a Mixpanel group

| Argument | Type | Description |

@@ -141,5 +165,9 @@ | ------------- | ------------- | ----- |

| **group_id** | <span class="mp-arg-type">Object</span></br></span><span class="mp-arg-required">required</span> | A valid Mixpanel property type |
#### Returns:
| Type | Description |
| ----- | ------------- |
| <span class="mp-arg-type">Object</span> | A MixpanelGroup identifier |
<hr>
___
## mixpanel.get_property

@@ -163,2 +191,3 @@ Returns the value of the super property named property_name. If no such property is set, get_property() will return the undefined value.

| Argument | Type | Description |

@@ -169,3 +198,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.has_opted_in_tracking

@@ -182,5 +211,9 @@ Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance

| **options.cookie_prefix=__mp_opt_in_out** | <span class="mp-arg-type">string</span></br></span><span class="mp-arg-optional">optional</span> | Custom prefix to be used in the cookie/localstorage name |
#### Returns:
| Type | Description |
| ----- | ------------- |
| <span class="mp-arg-type">boolean</span> | current opt-in status |
<hr>
___
## mixpanel.has_opted_out_tracking

@@ -197,14 +230,20 @@ Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance

| **options.cookie_prefix=__mp_opt_in_out** | <span class="mp-arg-type">string</span></br></span><span class="mp-arg-optional">optional</span> | Custom prefix to be used in the cookie/localstorage name |
#### Returns:
| Type | Description |
| ----- | ------------- |
| <span class="mp-arg-type">boolean</span> | current opt-out status |
<hr>
___
## mixpanel.identify
Identify a user with a unique ID instead of a Mixpanel randomly generated distinct_id. If the method is never called, then unique visitors will be identified by a UUID generated the first time they visit the site.
Identify a user with a unique ID to track user activity across devices, tie a user to their events, and create a user profile. If you never call this method, unique visitors are tracked using a UUID generated the first time they visit the site.
Call identify when you know the identity of the current user, typically after login or signup. We recommend against using identify for anonymous visitors to your site.
### Notes:
You can call this function to overwrite a previously set unique ID for the current user. Mixpanel cannot translate between IDs at this time, so when you change a user's ID they will appear to be a new user.
If your project has <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a> enabled, the identify method will connect pre- and post-authentication events when appropriate.
When used alone, mixpanel.identify will change the user's distinct_id to the unique ID provided. When used in tandem with mixpanel.alias, it will allow you to identify based on unique ID and map that back to the original, anonymous distinct_id given to the user upon her first arrival to your site (thus connecting anonymous pre-signup activity to post-signup activity). Though the two work together, do not call identify() at the same time as alias(). Calling the two at the same time can cause a race condition, so it is best practice to call identify on the original, anonymous ID right after you've aliased it. <a href="https://mixpanel.com/help/questions/articles/how-should-i-handle-my-user-identity-with-the-mixpanel-javascript-library">Learn more about how mixpanel.identify and mixpanel.alias can be used</a>.
If your project does not have ID Merge enabled, identify will change the user's local distinct_id to the unique ID you pass. Events tracked prior to authentication will not be connected to the same user identity. If ID Merge is disabled, alias can be used to connect pre- and post-registration events.

@@ -217,3 +256,3 @@

<hr>
___
## mixpanel.init

@@ -227,2 +266,3 @@ This function initializes a new instance of the Mixpanel tracking object. All new instances are added to the main mixpanel object as sub properties (such as mixpanel.library_name) and also returned by this function. To define a second instance on the page, you would call:

```
and use it like so:

@@ -237,2 +277,3 @@

| Argument | Type | Description |

@@ -245,3 +286,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.opt_in_tracking

@@ -269,3 +310,3 @@ Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance

<hr>
___
## mixpanel.opt_out_tracking

@@ -291,3 +332,3 @@ Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance

<hr>
___
## mixpanel.push

@@ -304,2 +345,3 @@ push() keeps the standard async-array-push behavior around after the lib is loaded. This is only useful for external integrations that do not wish to rely on our convenience methods (created in the snippet).

| Argument | Type | Description |

@@ -310,3 +352,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.register

@@ -330,2 +372,3 @@ Register a set of super properties, which are included with all events. This will overwrite previous super property values.

| Argument | Type | Description |

@@ -337,3 +380,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.register_once

@@ -353,2 +396,3 @@ Register a set of super properties only once. This will not overwrite previous super property values, unlike register().

### Notes:

@@ -365,3 +409,3 @@ If default_value is specified, current super properties with that value will be overwritten.

<hr>
___
## mixpanel.remove_group

@@ -378,2 +422,3 @@ Remove a group from this user.

| Argument | Type | Description |

@@ -386,3 +431,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.reset

@@ -395,3 +440,3 @@ Clears super properties and generates a new random distinct_id for this instance. Useful for clearing data when a user logs out.

<hr>
___
## mixpanel.set_config

@@ -417,2 +462,16 @@ Update the configuration of a mixpanel library instance.

// turn on request-batching/queueing/retry
batch_requests: false,
// maximum number of events/updates to send in a single
// network request
batch_size: 50,
// milliseconds to wait between sending batch requests
batch_flush_interval_ms: 5000,
// milliseconds to wait for network response to batch requests
// before they are considered timed-out and retried
batch_request_timeout_ms: 90000,
// override value for cookie domain, only useful for ensuring

@@ -510,2 +569,3 @@ // correct cross-subdomain cookies on unusual domains like

| Argument | Type | Description |

@@ -516,3 +576,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.set_group

@@ -531,2 +591,3 @@ Register the current user into one/many groups.

| Argument | Type | Description |

@@ -539,3 +600,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.time_event

@@ -553,2 +614,3 @@ Time an event by including the time between this call and a later 'track' call for the same event in the properties sent with the event.

```
When called for a particular event name, the next track call for that event name will include the elapsed time between the 'time_event' and 'track' calls. This value is stored as seconds in the '$duration' property.

@@ -563,3 +625,3 @@

<hr>
___
## mixpanel.track

@@ -579,2 +641,3 @@ Track an event. This is the most important and frequently used Mixpanel function.

```
To track link clicks or form submissions, see track_links() or track_forms().

@@ -590,6 +653,11 @@

| **options.transport** | <span class="mp-arg-type">String</span></br></span><span class="mp-arg-optional">optional</span> | Transport method for network request ('xhr' or 'sendBeacon'). |
| **options.send_immediately** | <span class="mp-arg-type">Boolean</span></br></span><span class="mp-arg-optional">optional</span> | Whether to bypass batching/queueing and send track request immediately. |
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback function will be called after tracking the event. |
#### Returns:
| Type | Description |
| ----- | ------------- |
| <span class="mp-arg-type">Boolean or Object</span> | If the tracking request was successfully initiated/queued, an object with the tracking payload sent to the API server is returned; otherwise false. |
<hr>
___
## mixpanel.track_forms

@@ -607,2 +675,3 @@ Track form submissions. Selector must be a valid query.

### Notes:

@@ -621,3 +690,3 @@ This function will wait up to 300 ms for the mixpanel servers to respond, if they have not responded by that time it will head to the link without ensuring that your event has been tracked. To configure this timeout please see the set_config() documentation below.

<hr>
___
## mixpanel.track_links

@@ -635,2 +704,3 @@ Track clicks on a set of document elements. Selector must be a valid query. Elements must exist on the page at the time track_links is called.

### Notes:

@@ -649,3 +719,3 @@ This function will wait up to 300 ms for the Mixpanel servers to respond. If they have not responded by that time it will head to the link without ensuring that your event has been tracked. To configure this timeout please see the set_config() documentation below.

<hr>
___
## mixpanel.track_with_groups

@@ -662,2 +732,3 @@ Track an event with specific groups.

| Argument | Type | Description |

@@ -671,3 +742,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.unregister

@@ -688,3 +759,3 @@ Delete a super property stored with the current user.

<hr>
___
## mixpanel.people.append

@@ -709,2 +780,3 @@ Append a value to a list-valued people analytics property.

| Argument | Type | Description |

@@ -717,3 +789,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.clear_charges

@@ -730,2 +802,3 @@ Permanently clear all revenue report transactions from the current user's people analytics profile.

| Argument | Type | Description |

@@ -736,3 +809,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.delete_user

@@ -751,3 +824,4 @@ Permanently deletes the current people analytics profile from Mixpanel (using the current distinct_id).

<hr>
___
## mixpanel.people.increment

@@ -778,2 +852,3 @@ Increment/decrement numeric people analytics properties.

| Argument | Type | Description |

@@ -786,3 +861,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.remove

@@ -799,2 +874,3 @@ Remove a value from a list-valued people analytics property.

| Argument | Type | Description |

@@ -807,3 +883,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.set

@@ -828,2 +904,3 @@ Set properties on a user record.

| Argument | Type | Description |

@@ -836,3 +913,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.set_once

@@ -857,2 +934,3 @@ Set properties on a user record, only if they do not yet exist. This will not overwrite previous people property values, unlike people.set().

| Argument | Type | Description |

@@ -865,3 +943,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.track_charge

@@ -884,2 +962,3 @@ Record that you have charged the current user a certain amount of money. Charges recorded with track_charge() will appear in the Mixpanel revenue report.

| Argument | Type | Description |

@@ -892,3 +971,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.union

@@ -919,2 +998,3 @@ Merge a given list with a list-valued people analytics property, excluding duplicate values.

| Argument | Type | Description |

@@ -927,3 +1007,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.people.unset

@@ -943,2 +1023,3 @@ Unset properties on a user record (permanently removes the properties and their values from a profile).

| Argument | Type | Description |

@@ -954,3 +1035,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.group.remove

@@ -967,2 +1048,3 @@ Remove a property from a group. The value will be ignored if doesn't exist.

| Argument | Type | Description |

@@ -975,3 +1057,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.group.set

@@ -995,2 +1077,3 @@ Set properties on a group.

| Argument | Type | Description |

@@ -1003,3 +1086,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.group.set_once

@@ -1023,2 +1106,3 @@ Set properties on a group, only if they do not yet exist. This will not overwrite previous group property values, unlike group.set().

| Argument | Type | Description |

@@ -1031,3 +1115,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.group.union

@@ -1045,2 +1129,3 @@ Merge a given list with a list-valued group property, excluding duplicate values.

| Argument | Type | Description |

@@ -1053,3 +1138,3 @@ | ------------- | ------------- | ----- |

<hr>
___
## mixpanel.group.unset

@@ -1066,2 +1151,3 @@ Unset properties on a group permanently.

| Argument | Type | Description |

@@ -1068,0 +1154,0 @@ | ------------- | ------------- | ----- |

@@ -10,3 +10,3 @@ ---

<% for (const item of namespace.items) { %>
<hr>
___
## <%= item.name %>

@@ -23,5 +23,9 @@ <%= item.description %>

| ------------- | ------------- | ----- |<% for (const arg of item.arguments) { %>
| **<%= arg.name %>** | <span class="mp-arg-type"><%= arg.types %></span></br></span><% if (arg.required) { %><span class="mp-arg-required">required</span><% } else { %><span class="mp-arg-optional">optional</span><% } %> | <%= arg.description %> |<% } %><% } %>
| **<%= arg.name %>** | <span class="mp-arg-type"><%= arg.types %></span></br></span><% if (arg.required) { %><span class="mp-arg-required">required</span><% } else { %><span class="mp-arg-optional">optional</span><% } %> | <%= arg.description %> |<% } %><% } %><% if (item.returns.length) { %>
#### Returns:
| Type | Description |
| ----- | ------------- |<% for (const ret of item.returns) { %>
| <span class="mp-arg-type"><%= ret.types %></span> | <%= ret.description %> |<% } %><% } %>
<% } %>
<% } %>
{
"name": "mixpanel-browser",
"version": "2.35.0",
"version": "2.36.0",
"description": "The official Mixpanel JavaScript browser client library",

@@ -13,2 +13,3 @@ "main": "dist/mixpanel.cjs.js",

"build-full": "FULL=1 ./build.sh",
"build-test-polyfill": "webpack tests/vendor/core-js-polyfills.src.js tests/vendor/core-js-polyfills.js",
"dox": "node doc/build-docs.js",

@@ -21,3 +22,3 @@ "dox-publish": "rdme docs doc/readme.io --key=$RDME_API_KEY --version=1.0",

"test": "npm run lint && npm run unit-test",
"unit-test": "BABEL_ENV=test mocha --compilers js:babel-core/register tests/unit/*.js",
"unit-test": "BABEL_ENV=test mocha --require babel-core/register tests/unit/*.js",
"validate": "npm ls"

@@ -43,2 +44,3 @@ },

"cookie-parser": "1.3.4",
"core-js": "3.6.5",
"dox": "0.9.0",

@@ -49,4 +51,5 @@ "eslint": "4.18.2",

"jsdom-global": "3.0.2",
"localStorage": "1.0.4",
"lodash": "4.17.13",
"mocha": "2.4.5",
"mocha": "7.1.1",
"morgan": "1.9.1",

@@ -57,5 +60,6 @@ "rdme": "3.0.0",

"rollup-plugin-npm": "1.4.0",
"sinon": "4.4.2",
"sinon": "8.1.1",
"sinon-chai": "3.5.0",
"webpack": "1.12.2"
}
}
var Config = {
DEBUG: false,
LIB_VERSION: '2.35.0'
LIB_VERSION: '2.36.0'
};
export default Config;

@@ -247,3 +247,5 @@ /**

if (options.track && optValue) { // only track event if opting in (optValue=true)
options.track(options.trackEventName || '$opt_in', options.trackProperties);
options.track(options.trackEventName || '$opt_in', options.trackProperties, {
'send_immediately': true
});
}

@@ -250,0 +252,0 @@ }

/* eslint camelcase: "off" */
import { addOptOutCheckMixpanelGroup } from './gdpr-utils';
import { apiActions } from './api-actions';
import { _, console } from './utils';
import { _ } from './utils';

@@ -142,14 +142,7 @@ /**

var date_encoded_data = _.encodeDates(data);
var truncated_data = _.truncate(date_encoded_data, 255);
var json_data = _.JSONEncode(date_encoded_data);
var encoded_data = _.base64Encode(json_data);
console.log(data);
this._mixpanel._send_request(
this._mixpanel.get_config('api_host') + '/groups/',
{'data': encoded_data},
this._mixpanel._prepare_callback(callback, truncated_data)
);
return truncated_data;
return this._mixpanel._track_or_batch({
truncated_data: _.truncate(date_encoded_data, 255),
endpoint: this._get_config('api_host') + '/groups/',
batcher: this._mixpanel.request_batchers.groups
}, callback);
};

@@ -156,0 +149,0 @@

@@ -333,5 +333,3 @@ /* eslint camelcase: "off" */

var date_encoded_data = _.encodeDates(data);
var truncated_data = _.truncate(date_encoded_data, 255);
var json_data = _.JSONEncode(date_encoded_data);
var encoded_data = _.base64Encode(json_data);
var truncated_data = _.truncate(date_encoded_data, 255);

@@ -350,12 +348,7 @@ if (!this._identify_called()) {

console.log('MIXPANEL PEOPLE REQUEST:');
console.log(truncated_data);
this._mixpanel._send_request(
this._get_config('api_host') + '/engage/',
{'data': encoded_data},
this._mixpanel._prepare_callback(callback, truncated_data)
);
return truncated_data;
return this._mixpanel._track_or_batch({
truncated_data: truncated_data,
endpoint: this._get_config('api_host') + '/engage/',
batcher: this._mixpanel.request_batchers.people
}, callback);
};

@@ -362,0 +355,0 @@

@@ -44,2 +44,3 @@ /* eslint camelcase: "off", eqeqeq: "off" */

nativeIndexOf = ArrayProto.indexOf,
nativeMap = ArrayProto.map,
nativeIsArray = Array.isArray,

@@ -97,3 +98,17 @@ breaker = {};

var log_func_with_prefix = function(func, prefix) {
return function() {
arguments[0] = '[' + prefix + '] ' + arguments[0];
return func.apply(console, arguments);
};
};
var console_with_prefix = function(prefix) {
return {
log: log_func_with_prefix(console.log, prefix),
error: log_func_with_prefix(console.error, prefix),
critical: log_func_with_prefix(console.critical, prefix)
};
};
// UNDERSCORE

@@ -222,2 +237,14 @@ // Embed part of the Underscore Library

_.map = function(arr, callback) {
if (nativeMap && arr.map === nativeMap) {
return arr.map(callback);
} else {
var results = [];
_.each(arr, function(item) {
results.push(callback(item));
});
return results;
}
};
_.keys = function(obj) {

@@ -1054,27 +1081,33 @@ var results = [];

// _.localStorage
var _localStorage_supported = null;
_.localStorage = {
is_supported: function() {
if (_localStorage_supported !== null) {
return _localStorage_supported;
}
var _localStorageSupported = null;
var localStorageSupported = function(storage, forceCheck) {
if (_localStorageSupported !== null && !forceCheck) {
return _localStorageSupported;
}
var supported = true;
try {
var key = '__mplssupport__',
val = 'xyz';
_.localStorage.set(key, val);
if (_.localStorage.get(key) !== val) {
supported = false;
}
_.localStorage.remove(key);
} catch (err) {
var supported = true;
try {
storage = storage || window.localStorage;
var key = '__mplss_' + cheap_guid(8),
val = 'xyz';
storage.setItem(key, val);
if (storage.getItem(key) !== val) {
supported = false;
}
storage.removeItem(key);
} catch (err) {
supported = false;
}
_localStorageSupported = supported;
return supported;
};
// _.localStorage
_.localStorage = {
is_supported: function(force_check) {
var supported = localStorageSupported(null, force_check);
if (!supported) {
console.error('localStorage unsupported; falling back to cookie store');
}
_localStorage_supported = supported;
return supported;

@@ -1594,3 +1627,3 @@ },

'$lib_version': Config.LIB_VERSION,
'$insert_id': Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
'$insert_id': cheap_guid(),
'time': _.timestamp() / 1000 // epoch time in seconds

@@ -1619,2 +1652,7 @@ });

var cheap_guid = function(maxlen) {
var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
return maxlen ? guid.substring(0, maxlen) : guid;
};
// naive way to extract domain name (example.com) from full hostname (my.sub.example.com)

@@ -1648,2 +1686,10 @@ var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;

var JSONStringify = null, JSONParse = null;
if (typeof JSON !== 'undefined') {
JSONStringify = JSON.stringify;
JSONParse = JSON.parse;
}
JSONStringify = JSONStringify || _.JSONEncode;
JSONParse = JSONParse || _.JSONDecode;
// EXPORTS (for closure compiler)

@@ -1662,2 +1708,15 @@ _['toArray'] = _.toArray;

export { _, userAgent, console, win as window, document, navigator, extract_domain };
export {
_,
userAgent,
console,
win as window,
document,
navigator,
cheap_guid,
console_with_prefix,
extract_domain,
localStorageSupported,
JSONStringify,
JSONParse
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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