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

@0no-co/mixpanel-micro

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0no-co/mixpanel-micro - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

dist/mixpanel-micro.d.ts

@@ -12,3 +12,3 @@ interface State {

$lib_version: '0.0.0';
token: string;
token?: string;
$anon_distinct_id?: string;

@@ -15,0 +15,0 @@ distinct_id: string;

@@ -55,119 +55,112 @@ Object.defineProperty(exports, "__esModule", {

function init$2(t) {
var r = navigator.userAgent || "";
var n = function makeUUID() {
function T() {
var e = Date.now();
var t = 0;
while (e === Date.now()) {
t++;
var t;
var r = {};
function getBaseState() {
if (!e) {
var t = navigator.userAgent || "";
var r = function makeUUID() {
function T() {
var e = Date.now();
var t = 0;
while (e === Date.now()) {
t++;
}
return e.toString(16) + t.toString(16);
}
return e.toString(16) + t.toString(16);
}
var e = (screen.height * screen.width).toString(16);
return `${T()}-${function R() {
return Math.random().toString(16).replace(".", "");
}()}-${function UA() {
var e = navigator.userAgent;
var t = [];
function xor(e, r) {
var e = (screen.height * screen.width).toString(16);
return `${T()}-${function R() {
return Math.random().toString(16).replace(".", "");
}()}-${function UA() {
var e = navigator.userAgent;
var t = [];
function xor(e, r) {
var n = 0;
for (var i = 0; i < r.length; i++) {
n |= t[i] << 8 * i;
}
return e ^ n;
}
var r;
var n = 0;
for (var i = 0; i < r.length; i++) {
n |= t[i] << 8 * i;
for (var i = 0; i < e.length; i++) {
r = e.charCodeAt(i);
t.unshift(255 & r);
if (t.length >= 4) {
n = xor(n, t);
t.length = 0;
}
}
return e ^ n;
}
var r;
var n = 0;
for (var i = 0; i < e.length; i++) {
r = e.charCodeAt(i);
t.unshift(255 & r);
if (t.length >= 4) {
if (t.length > 0) {
n = xor(n, t);
t.length = 0;
}
return n.toString(16);
}()}-${e}-${T()}`;
}();
var n = function getBrowser(e) {
if ("opera" in window || / OPR\//.test(e)) {
return /Mini/.test(e) ? "Opera Mini" : "Opera";
} else if (/Edge/.test(e)) {
return "Microsoft Edge";
} else if (/FBIOS/.test(e)) {
return "Facebook Mobile";
} else if (/Chrome/.test(e)) {
return "Chrome";
} else if (/SamsungBrowser\//.test(e)) {
return "Samsung Internet";
} else if (/CriOS/.test(e)) {
return "Chrome iOS";
} else if (/UC(?:WEB|Browser)/.test(e)) {
return "UC Browser";
} else if (/FxiOS/.test(e)) {
return "Firefox iOS";
} else if (/Safari/.test(e)) {
return /Mobile/.test(e) ? "Mobile Safari" : "Safari";
} else if (/Android/.test(e)) {
return "Android Mobile";
} else if (/Konqueror/.test(e)) {
return "Konqueror";
} else if (/Firefox/.test(e)) {
return "Firefox";
} else if (/MSIE|Trident\//.test(e)) {
return "Internet Explorer";
} else if (/Gecko/.test(e)) {
return "Mozilla";
} else {
return null;
}
if (t.length > 0) {
n = xor(n, t);
}
return n.toString(16);
}()}-${e}-${T()}`;
}();
var i = function getBrowser(e) {
if ("opera" in window || / OPR\//.test(e)) {
return /Mini/.test(e) ? "Opera Mini" : "Opera";
} else if (/Edge/.test(e)) {
return "Microsoft Edge";
} else if (/FBIOS/.test(e)) {
return "Facebook Mobile";
} else if (/Chrome/.test(e)) {
return "Chrome";
} else if (/SamsungBrowser\//.test(e)) {
return "Samsung Internet";
} else if (/CriOS/.test(e)) {
return "Chrome iOS";
} else if (/UC(?:WEB|Browser)/.test(e)) {
return "UC Browser";
} else if (/FxiOS/.test(e)) {
return "Firefox iOS";
} else if (/Safari/.test(e)) {
return /Mobile/.test(e) ? "Mobile Safari" : "Safari";
} else if (/Android/.test(e)) {
return "Android Mobile";
} else if (/Konqueror/.test(e)) {
return "Konqueror";
} else if (/Firefox/.test(e)) {
return "Firefox";
} else if (/MSIE|Trident\//.test(e)) {
return "Internet Explorer";
} else if (/Gecko/.test(e)) {
return "Mozilla";
} else {
return null;
}
}(r);
e = {
token: t,
$os: getOS(r),
$browser: i,
$browser_version: getBrowserVersion(i, r),
$device: getDevice(r),
$screen_height: screen.height,
$screen_width: screen.width,
$referrer: document.referrer,
$referring_domain: (o = (document.referrer || "").split("/"), o.length >= 3 ? o[2] : null),
$current_url: window.location.href,
distinct_id: n,
$device_id: n,
mp_lib: "mixpanel-lite",
$lib_version: "0.0.0",
doNotTrack: "1" == `${navigator.doNotTrack}`
};
var o;
}
function getState() {
if (e) {
e.$current_url = window.location.href;
e.referrer = document.referrer;
e.time = Math.round(Date.now() / 1e3);
return e;
}(t);
e = {
$os: getOS(t),
$browser: n,
$browser_version: getBrowserVersion(n, t),
$device: getDevice(t),
$screen_height: screen.height,
$screen_width: screen.width,
$referrer: document.referrer,
$referring_domain: (i = (document.referrer || "").split("/"), i.length >= 3 ? i[2] : null),
$current_url: window.location.href,
distinct_id: r,
$device_id: r,
mp_lib: "mixpanel-lite",
$lib_version: "0.0.0",
doNotTrack: "1" == `${navigator.doNotTrack}`
};
}
var i;
return e;
}
function register(t) {
for (var r in t) {
if (t[r]) {
e[r] = t[r];
} else {
delete e[r];
}
function register(e) {
for (var t in e) {
r[t] = e[t] || null;
}
}
var t = "https://api.mixpanel.com/track?ip=1&verbose=1&data=";
var n = "https://api.mixpanel.com/track";
var r = "https://api.mixpanel.com/engage?ip=1&verbose=1&data=";
var i = "https://api.mixpanel.com/engage";
var n = 3;
var o = 3;

@@ -182,17 +175,31 @@ function isOnline() {

var i = [];
var s = [];
var o = !1;
var a = !1;
var s = !1;
var u = !1;
var _assemblePayload = e => "$set" in e ? {
...e,
$distinct_id: getBaseState().distinct_id,
$token: t || void 0
} : {
event: e.event,
properties: {
...getBaseState(),
...e.properties,
token: t || void 0
}
};
async function _flushPayload(e) {
var i = "$set" in e ? r : t;
var o = function base64(e) {
var t = "$set" in e ? i : n;
var r = _assemblePayload(e);
var s = function base64(e) {
return btoa(unescape(encodeURIComponent(e)));
}(JSON.stringify(e, replacer));
var s = Date.now();
i += `${encodeURIComponent(o)}&_=${s}`;
if (!navigator.sendBeacon(i)) {
for (var a = 0; a < n && isOnline(); a++) {
}(JSON.stringify(r, replacer));
var a = Date.now();
var u = t + `?ip=1&verbose=1&data=${encodeURIComponent(s)}&_=${a}`;
if (!navigator.sendBeacon(u)) {
for (var l = 0; l < o && isOnline(); l++) {
await new Promise((e => {

@@ -202,3 +209,3 @@ setTimeout(e, 500 + 1e3 * Math.random());

try {
if ((await fetch(i, {
if ((await fetch(u, {
method: "POST",

@@ -220,12 +227,12 @@ keepalive: !0

if (function hasState() {
return !!e;
return null != t;
}()) {
var t;
while ((t = i.shift()) && isOnline()) {
if (!await _flushPayload(t)) {
i.unshift(t);
var e;
while ((e = s.shift()) && isOnline()) {
if (!await _flushPayload(e)) {
s.unshift(e);
}
}
o = !1;
if (i.length) {
a = !1;
if (s.length) {
setTimeout(send, 5e3);

@@ -237,8 +244,8 @@ }

function send(e) {
if (!s) {
if (!u) {
if (e) {
i.push(e);
s.push(e);
}
if (!o && isOnline()) {
o = !0;
if (!a && isOnline()) {
a = !0;
if ("function" == typeof requestIdleCallback) {

@@ -255,39 +262,40 @@ requestIdleCallback(_flushQueue);

function getProperty(e) {
return (getState() || {})[e];
}
function track(e, t) {
var r = rand16() + rand16();
var n = {
...r
};
if (t) {
for (var i in t) {
n[i] = t[i] || n[i] || null;
}
}
n.$insert_id = rand16() + rand16();
send({
event: e,
properties: {
...getState(),
...t,
$insert_id: r
}
properties: n
});
}
exports.getProperty = getProperty;
exports.getProperty = function getProperty(e) {
return r[e] ? r[e] : getBaseState()[e];
};
exports.identify = function identify(e) {
var t = getProperty("distinct_id");
register({
$anon_distinct_id: getBaseState().distinct_id,
distinct_id: e,
$user_id: e
});
track("$identify", {
$anon_distinct_id: t,
distinct_id: e,
$user_id: e
});
track("$identify");
};
exports.init = function init(e) {
init$2(e);
return function init$1() {
!function initState(e) {
getBaseState();
t = e;
}(e);
return function initSend() {
function onOnline() {
if (!o) {
o = !0;
if (!a) {
a = !0;
_flushQueue();

@@ -297,4 +305,4 @@ }

function onVisibilityChange(e) {
if (!o && "hidden" === document.visibilityState) {
o = !0;
if (!a && "hidden" === document.visibilityState) {
a = !0;
_flushQueue();

@@ -314,4 +322,4 @@ }

exports.mute = function mute() {
s = !0;
o = !0;
u = !0;
a = !0;
};

@@ -323,4 +331,2 @@

send({
$token: getProperty("token"),
$distinct_id: getProperty("distinct_id"),
$set: e

@@ -333,6 +339,6 @@ });

exports.unmute = function unmute() {
s = !1;
o = !1;
u = !1;
a = !1;
send();
};
//# sourceMappingURL=mixpanel-micro.js.map

@@ -1,2 +0,2 @@

function e(e){return/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/Android/.test(e)?"Android":null}function t(e){return/Windows/i.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Android/.test(e)?"Android":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":null}function n(e,t){var n;return(n=t.match("Konqueror"===e?/Konqueror:(\d+(\.\d+)?)/:"Android Mobile"===e?/android\s(\d+(\.\d+)?)/:"Internet Explorer"===e?/(rv:|MSIE )(\d+(\.\d+)?)/:"Mozilla"===e?/rv:(\d+(\.\d+)?)/:/(?:SamsungBrowser|Edge|Chrome|FxiOS|CriOS|UCBrowser|UCWEB|Version|Opera|OPR|Firefox|FxiOS)\/(\d+(\.\d+)?)/))&&parseFloat(n[n.length-2])||null}var r;function i(){if(r)return r.$current_url=window.location.href,r.referrer=document.referrer,r.time=Math.round(Date.now()/1e3),r}function o(e){for(var t in e)e[t]?r[t]=e[t]:delete r[t]}Object.defineProperty(exports,"__esModule",{value:!0});var s="https://api.mixpanel.com/track?ip=1&verbose=1&data=",a="https://api.mixpanel.com/engage?ip=1&verbose=1&data=",d=3;function u(){return!1!==navigator.onLine}function c(e,t){return null==t||""===t?void 0:t}var f=[],l=!1,h=!1;async function v(e){var t,n="$set"in e?a:s,r=(t=JSON.stringify(e,c),btoa(unescape(encodeURIComponent(t)))),i=Date.now();if(n+=`${encodeURIComponent(r)}&_=${i}`,!navigator.sendBeacon(n)){for(var o=0;o<d&&u();o++){await new Promise((e=>{setTimeout(e,500+1e3*Math.random())}));try{if((await fetch(n,{method:"POST",keepalive:!0})).status<500)return!0}catch(e){}}return!1}return!0}async function p(){if(r){for(var e;(e=f.shift())&&u();)await v(e)||f.unshift(e);l=!1,f.length&&setTimeout(g,5e3)}}function g(e){h||(e&&f.push(e),!l&&u()&&(l=!0,"function"==typeof requestIdleCallback?requestIdleCallback(p):setTimeout(p,200)))}var m=()=>Math.random().toString(36).slice(2,10);function w(e){return(i()||{})[e]}function S(e,t){var n=m()+m();g({event:e,properties:{...i(),...t,$insert_id:n}})}exports.getProperty=w,exports.identify=function(e){var t=w("distinct_id");o({distinct_id:e,$user_id:e}),S("$identify",{$anon_distinct_id:t,distinct_id:e,$user_id:e})},exports.init=function(i){return function(i){var o,s=navigator.userAgent||"",a=function(){function e(){for(var e=Date.now(),t=0;e===Date.now();)t++;return e.toString(16)+t.toString(16)}var t=(screen.height*screen.width).toString(16);return`${e()}-${Math.random().toString(16).replace(".","")}-${function(){var e,t=navigator.userAgent,n=[];function r(e,t){for(var r=0,i=0;i<t.length;i++)r|=n[i]<<8*i;return e^r}for(var i=0,o=0;o<t.length;o++)e=t.charCodeAt(o),n.unshift(255&e),n.length>=4&&(i=r(i,n),n.length=0);return n.length>0&&(i=r(i,n)),i.toString(16)}()}-${t}-${e()}`}(),d=function(e){return"opera"in window||/ OPR\//.test(e)?/Mini/.test(e)?"Opera Mini":"Opera":/Edge/.test(e)?"Microsoft Edge":/FBIOS/.test(e)?"Facebook Mobile":/Chrome/.test(e)?"Chrome":/SamsungBrowser\//.test(e)?"Samsung Internet":/CriOS/.test(e)?"Chrome iOS":/UC(?:WEB|Browser)/.test(e)?"UC Browser":/FxiOS/.test(e)?"Firefox iOS":/Safari/.test(e)?/Mobile/.test(e)?"Mobile Safari":"Safari":/Android/.test(e)?"Android Mobile":/Konqueror/.test(e)?"Konqueror":/Firefox/.test(e)?"Firefox":/MSIE|Trident\//.test(e)?"Internet Explorer":/Gecko/.test(e)?"Mozilla":null}(s);r={token:i,$os:t(s),$browser:d,$browser_version:n(d,s),$device:e(s),$screen_height:screen.height,$screen_width:screen.width,$referrer:document.referrer,$referring_domain:(o=(document.referrer||"").split("/"),o.length>=3?o[2]:null),$current_url:window.location.href,distinct_id:a,$device_id:a,mp_lib:"mixpanel-lite",$lib_version:"0.0.0",doNotTrack:"1"==`${navigator.doNotTrack}`}}(i),function(){function e(){l||(l=!0,p())}function t(e){l||"hidden"!==document.visibilityState||(l=!0,p())}return window.addEventListener("online",e),document.addEventListener("visibilitychange",t),()=>{e(),window.removeEventListener("online",e),document.removeEventListener("visibilitychange",t)}}()},exports.mute=function(){h=!0,l=!0},exports.register=o,exports.setPeople=function(e){g({$token:w("token"),$distinct_id:w("distinct_id"),$set:e})},exports.track=S,exports.unmute=function(){h=!1,l=!1,g()};
function e(e){return/iPad/.test(e)?"iPad":/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/Android/.test(e)?"Android":null}function t(e){return/Windows/i.test(e)?"Windows":/iPhone|iPad|iPod/.test(e)?"iOS":/Android/.test(e)?"Android":/Mac/i.test(e)?"Mac OS X":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"Chrome OS":null}function n(e,t){var n;return(n=t.match("Konqueror"===e?/Konqueror:(\d+(\.\d+)?)/:"Android Mobile"===e?/android\s(\d+(\.\d+)?)/:"Internet Explorer"===e?/(rv:|MSIE )(\d+(\.\d+)?)/:"Mozilla"===e?/rv:(\d+(\.\d+)?)/:/(?:SamsungBrowser|Edge|Chrome|FxiOS|CriOS|UCBrowser|UCWEB|Version|Opera|OPR|Firefox|FxiOS)\/(\d+(\.\d+)?)/))&&parseFloat(n[n.length-2])||null}var r,i;Object.defineProperty(exports,"__esModule",{value:!0});var o={};function s(){if(!r){var i=navigator.userAgent||"",o=function(){function e(){for(var e=Date.now(),t=0;e===Date.now();)t++;return e.toString(16)+t.toString(16)}var t=(screen.height*screen.width).toString(16);return`${e()}-${Math.random().toString(16).replace(".","")}-${function(){var e,t=navigator.userAgent,n=[];function r(e,t){for(var r=0,i=0;i<t.length;i++)r|=n[i]<<8*i;return e^r}for(var i=0,o=0;o<t.length;o++)e=t.charCodeAt(o),n.unshift(255&e),n.length>=4&&(i=r(i,n),n.length=0);return n.length>0&&(i=r(i,n)),i.toString(16)}()}-${t}-${e()}`}(),s=function(e){return"opera"in window||/ OPR\//.test(e)?/Mini/.test(e)?"Opera Mini":"Opera":/Edge/.test(e)?"Microsoft Edge":/FBIOS/.test(e)?"Facebook Mobile":/Chrome/.test(e)?"Chrome":/SamsungBrowser\//.test(e)?"Samsung Internet":/CriOS/.test(e)?"Chrome iOS":/UC(?:WEB|Browser)/.test(e)?"UC Browser":/FxiOS/.test(e)?"Firefox iOS":/Safari/.test(e)?/Mobile/.test(e)?"Mobile Safari":"Safari":/Android/.test(e)?"Android Mobile":/Konqueror/.test(e)?"Konqueror":/Firefox/.test(e)?"Firefox":/MSIE|Trident\//.test(e)?"Internet Explorer":/Gecko/.test(e)?"Mozilla":null}(i);r={$os:t(i),$browser:s,$browser_version:n(s,i),$device:e(i),$screen_height:screen.height,$screen_width:screen.width,$referrer:document.referrer,$referring_domain:(a=(document.referrer||"").split("/"),a.length>=3?a[2]:null),$current_url:window.location.href,distinct_id:o,$device_id:o,mp_lib:"mixpanel-lite",$lib_version:"0.0.0",doNotTrack:"1"==`${navigator.doNotTrack}`}}var a;return r}function a(e){for(var t in e)o[t]=e[t]||null}var d="https://api.mixpanel.com/track",u="https://api.mixpanel.com/engage",c=3;function l(){return!1!==navigator.onLine}function f(e,t){return null==t||""===t?void 0:t}var v=[],h=!1,p=!1,g=e=>"$set"in e?{...e,$distinct_id:s().distinct_id,$token:i||void 0}:{event:e.event,properties:{...s(),...e.properties,token:i||void 0}};async function m(e){var t,n="$set"in e?u:d,r=g(e),i=(t=JSON.stringify(r,f),btoa(unescape(encodeURIComponent(t)))),o=Date.now(),s=n+`?ip=1&verbose=1&data=${encodeURIComponent(i)}&_=${o}`;if(!navigator.sendBeacon(s)){for(var a=0;a<c&&l();a++){await new Promise((e=>{setTimeout(e,500+1e3*Math.random())}));try{if((await fetch(s,{method:"POST",keepalive:!0})).status<500)return!0}catch(e){}}return!1}return!0}async function S(){if(null!=i){for(var e;(e=v.shift())&&l();)await m(e)||v.unshift(e);h=!1,v.length&&setTimeout($,5e3)}}function $(e){p||(e&&v.push(e),!h&&l()&&(h=!0,"function"==typeof requestIdleCallback?requestIdleCallback(S):setTimeout(S,200)))}var w=()=>Math.random().toString(36).slice(2,10);function x(e,t){var n={...o};if(t)for(var r in t)n[r]=t[r]||n[r]||null;n.$insert_id=w()+w(),$({event:e,properties:n})}exports.getProperty=function(e){return o[e]?o[e]:s()[e]},exports.identify=function(e){a({$anon_distinct_id:s().distinct_id,distinct_id:e,$user_id:e}),x("$identify")},exports.init=function(e){return function(e){s(),i=e}(e),function(){function e(){h||(h=!0,S())}function t(e){h||"hidden"!==document.visibilityState||(h=!0,S())}return window.addEventListener("online",e),document.addEventListener("visibilitychange",t),()=>{e(),window.removeEventListener("online",e),document.removeEventListener("visibilitychange",t)}}()},exports.mute=function(){p=!0,h=!0},exports.register=a,exports.setPeople=function(e){$({$set:e})},exports.track=x,exports.unmute=function(){p=!1,h=!1,$()};
//# sourceMappingURL=mixpanel-micro.min.js.map
{
"name": "@0no-co/mixpanel-micro",
"description": "Tiny implementation of the Mixpanel browser API for modern browsers",
"version": "1.2.0",
"version": "1.3.0",
"sideEffects": false,

@@ -6,0 +6,0 @@ "public": true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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