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 0.1.1 to 1.0.0

6

dist/mixpanel-micro.d.ts

@@ -25,3 +25,7 @@ interface State {

declare function mute(): void;
declare function unmute(): void;
declare function init(token: string): void;
declare function getProperty<Key extends keyof State>(key: Key): State[Key];
declare function track(eventName: string, data: Partial<State>): void;

@@ -31,2 +35,2 @@ declare function identify(id: string): void;

export { State, identify, init, register, setPeople, track };
export { State, getProperty, identify, init, mute, register, setPeople, track, unmute };

189

dist/mixpanel-micro.js

@@ -37,33 +37,16 @@ Object.defineProperty(exports, "__esModule", {

function getBrowserVersion(e, r) {
var t = null;
switch (e) {
case "Chrome":
case "Chrome iOS":
case "UC Browser":
case "Microsoft Edge":
case "Mobile Safari":
case "Safari":
case "Opera":
case "Firefox":
case "Samsung Internet":
t = r.match(/(?:SamsungBrowser|Edge|Chrome|FxiOS|CriOS|UCBrowser|UCWEB|Version|Opera|OPR|Firefox|FxiOS)\/(\d+(\.\d+)?)/);
break;
case "Konqueror":
t = r.match(/Konqueror:(\d+(\.\d+)?)/);
break;
case "Android Mobile":
t = r.match(/android\s(\d+(\.\d+)?)/);
break;
case "Internet Explorer":
t = r.match(/(rv:|MSIE )(\d+(\.\d+)?)/);
break;
case "Mozilla":
t = r.match(/rv:(\d+(\.\d+)?)/);
function getBrowserVersion(e, t) {
var r = null;
if ("Konqueror" === e) {
r = t.match(/Konqueror:(\d+(\.\d+)?)/);
} else if ("Android Mobile" === e) {
r = t.match(/android\s(\d+(\.\d+)?)/);
} else if ("Internet Explorer" === e) {
r = t.match(/(rv:|MSIE )(\d+(\.\d+)?)/);
} else if ("Mozilla" === e) {
r = t.match(/rv:(\d+(\.\d+)?)/);
} else {
r = t.match(/(?:SamsungBrowser|Edge|Chrome|FxiOS|CriOS|UCBrowser|UCWEB|Version|Opera|OPR|Firefox|FxiOS)\/(\d+(\.\d+)?)/);
}
return t && parseFloat(t[t.length - 2]) || null;
return r && parseFloat(r[r.length - 2]) || null;
}

@@ -73,12 +56,12 @@

function init$2(r) {
var t = navigator.userAgent || "";
var i = function makeUUID() {
function init$2(t) {
var r = navigator.userAgent || "";
var n = function makeUUID() {
function T() {
var e = Date.now();
var r = 0;
var t = 0;
while (e === Date.now()) {
r++;
t++;
}
return e.toString(16) + r.toString(16);
return e.toString(16) + t.toString(16);
}

@@ -90,27 +73,27 @@ var e = (screen.height * screen.width).toString(16);

var e = navigator.userAgent;
var r = [];
function xor(e, t) {
var i = 0;
for (var n = 0; n < t.length; n++) {
i |= r[n] << 8 * n;
var t = [];
function xor(e, r) {
var n = 0;
for (var i = 0; i < r.length; i++) {
n |= t[i] << 8 * i;
}
return e ^ i;
return e ^ n;
}
var t;
var i = 0;
for (var n = 0; n < e.length; n++) {
t = e.charCodeAt(n);
r.unshift(255 & t);
if (r.length >= 4) {
i = xor(i, r);
r.length = 0;
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) {
n = xor(n, t);
t.length = 0;
}
}
if (r.length > 0) {
i = xor(i, r);
if (t.length > 0) {
n = xor(n, t);
}
return i.toString(16);
return n.toString(16);
}()}-${e}-${T()}`;
}();
var n = function getBrowser(e) {
var i = function getBrowser(e) {
if ("opera" in window || / OPR\//.test(e)) {

@@ -147,9 +130,9 @@ return /Mini/.test(e) ? "Opera Mini" : "Opera";

}
}(t);
}(r);
e = {
token: r,
$os: getOS(t),
$browser: n,
$browser_version: getBrowserVersion(n, t),
$device: getDevice(t),
token: t,
$os: getOS(r),
$browser: i,
$browser_version: getBrowserVersion(i, r),
$device: getDevice(r),
$screen_height: screen.height,

@@ -160,4 +143,4 @@ $screen_width: screen.width,

$current_url: window.location.href,
distinct_id: i,
$device_id: i,
distinct_id: n,
$device_id: n,
mp_lib: "mixpanel-lite",

@@ -179,8 +162,8 @@ $lib_version: "0.0.0",

function register(r) {
for (var t in r) {
if (r[t]) {
e[t] = r[t];
function register(t) {
for (var r in t) {
if (t[r]) {
e[r] = t[r];
} else {
delete e[t];
delete e[r];
}

@@ -190,7 +173,7 @@ }

var r = "https://api.mixpanel.com/track?ip=1&verbose=1&data=";
var t = "https://api.mixpanel.com/track?ip=1&verbose=1&data=";
var t = "https://api.mixpanel.com/engage?ip=1&verbose=1&data=";
var r = "https://api.mixpanel.com/engage?ip=1&verbose=1&data=";
var i = 3;
var n = 3;

@@ -201,12 +184,14 @@ function isOnline() {

function replacer(e, r) {
return null == r || "" === r ? void 0 : r;
function replacer(e, t) {
return null == t || "" === t ? void 0 : t;
}
var n = [];
var i = [];
var o = !1;
var s = !1;
async function flushPayload(e) {
var n = "$set" in e ? t : r;
var i = "$set" in e ? r : t;
var o = function base64(e) {

@@ -216,7 +201,7 @@ return btoa(unescape(encodeURIComponent(e)));

var s = Date.now();
n += `${encodeURIComponent(o)}&_=${s}`;
if (!navigator.sendBeacon(n)) {
for (var a = 0; a < i && isOnline(); a++) {
i += `${encodeURIComponent(o)}&_=${s}`;
if (!navigator.sendBeacon(i)) {
for (var a = 0; a < n && isOnline(); a++) {
try {
if ((await fetch(n, {
if ((await fetch(i, {
method: "POST",

@@ -241,12 +226,20 @@ keepalive: !0

var e;
while ((e = n.shift()) && isOnline()) {
while ((e = i.shift()) && isOnline()) {
if (!await flushPayload(e)) {
n.unshift(e);
i.unshift(e);
}
}
o = !1;
if (i.length) {
setTimeout(send, 5e3);
}
}
function send(e) {
n.push(e);
if (s) {
return;
}
if (e) {
i.push(e);
}
if (!o && isOnline()) {

@@ -264,4 +257,8 @@ o = !0;

function track(e, r) {
var t = rand16() + rand16();
function getProperty(e) {
return (getState() || {})[e];
}
function track(e, t) {
var r = rand16() + rand16();
send({

@@ -271,4 +268,4 @@ event: e,

...getState(),
...r,
$insert_id: t
...t,
$insert_id: r
}

@@ -278,4 +275,6 @@ });

exports.getProperty = getProperty;
exports.identify = function identify(e) {
var r = (getState() || {}).distinct_id;
var t = getProperty("distinct_id");
register({

@@ -286,3 +285,3 @@ distinct_id: e,

track("$identify", {
$anon_distinct_id: r,
$anon_distinct_id: t,
distinct_id: e,

@@ -313,9 +312,13 @@ $user_id: e

exports.mute = function mute() {
s = !0;
o = !0;
};
exports.register = register;
exports.setPeople = function setPeople(e) {
var r = getState() || {};
send({
$token: r.token,
$distinct_id: r.distinct_id,
$token: getProperty("token"),
$distinct_id: getProperty("distinct_id"),
$set: e

@@ -326,2 +329,8 @@ });

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