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

@aicore/core-analytics-client-lib

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aicore/core-analytics-client-lib - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

4

dist/analytics.min.js

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

function initAnalyticsSession(e,t,n,o,a){let i,r,s,l,u,c,d,f,y={};const g="aicore.analytics.userID",v="aicore.analytics.sessionID",p=1e4;let m=null;var w,h,b,C="undefined"==typeof window;let I="https://analytics.core.ai",S,D,E=0,T=!1;function U(...e){window.analytics.debugMode&&console.log("analytics client: ",...e)}function A(...e){window.analytics.debugMode&&console.error("analytics client: ",...e)}if(C)throw new Error("Node environment is not currently supported");function N(){return{schemaVersion:1,accountID:i,appName:r,uuid:s,sessionID:l,unixTimestampUTC:+new Date,numEventsTotal:0,events:{}}}function $(){if(!m)throw new Error("Please call initSession before using any analytics event")}function k(e){e.backoffCount=(e.backoffCount||0)+1,U(`Failed to call core analytics server. Will retry in ${30*e.backoffCount}s: `),setTimeout(()=>{L(e)},3e4*e.backoffCount)}function B(t){var e,n=JSON.stringify(t);n.length>p&&console.warn(`Analytics event generated is very large at greater than ${n.length}B. This
typically means that you may be sending too many value events? .`),U("Sending Analytics data of length: ",n.length,"B"),e=["Sending data:",n],window.analytics.debugMode&&window.analytics.debugInfoLogsEnable&&console.info("analytics client: ",...e),window.navigator.onLine?window.fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:n}).then(e=>{200!==e.status&&(400!==e.status?k(t):console.error("Bad Request, this is most likely a problem with the library, update to latest version."))}).catch(e=>{A(e),k(t)}):k(t)}function L(e){T||(e||(e=m,E=0,R(),m=N()),0!==e.numEventsTotal&&B(e))}function R(e){S&&(clearInterval(S),S=null),e||(S=setInterval(()=>{E+=c},1e3*c))}function M(e){R(e),D&&(clearInterval(D),D=null),e||(D=setInterval(L,1e3*u))}function _(n,o,a,i=1,r=0){if(!T){var s=n,l=o,u=a,c=i,d=r;if($(),!s||!l||!u)throw new Error("missing eventType or category or subCategory");if("number"!=typeof c||c<0)throw new Error("invalid count, count should be a positive number");if("number"!=typeof d)throw new Error("invalid value, value should be a number");{s=n;l=o;u=a;let e=m.events;e[s]=e[s]||{},e[s][l]=e[s][l]||{},e[s][l][u]=e[s][l][u]||{time:[],valueCount:[]}}let t=m.events;c=t[n][o][a].time;if((0<c.length?c[c.length-1]:null)===E){d=t[n][o][a].valueCount.length-1;{var s=d,l=n,u=o,c=a,d=i,f=r;let t=m.events;var e="number"==typeof t[l][u][c].valueCount[s];if(e&&0===f)t[l][u][c].valueCount[s]+=d;else if(e&&0!==f){let e={};e[f]=d,e[0]=t[l][u][c].valueCount[s],t[l][u][c].valueCount[s]=e}else if(!e){let e=t[l][u][c].valueCount[s];e[f]=(e[f]||0)+d}m.numEventsTotal+=1}}else{if(t[n][o][a].time.push(E),0===r)t[n][o][a].valueCount.push(i);else{let e={};e[r]=i,t[n][o][a].valueCount.push(e)}m.numEventsTotal+=1}}}if(!e||!t)throw new Error("accountID and appName must exist for init");d=n?n.toString().replace(/\/$/,""):I,i=e,r=t,u=o||60,c=a||3,f=d+"/ingest",s=function(){let e=localStorage.getItem(g);return e||(e=crypto.randomUUID(),localStorage.setItem(g,e)),e}(),l=function(){let e=sessionStorage.getItem(v);return e||(e=Math.random().toString(36).substr(2,10),sessionStorage.setItem(v,e)),e}(),m=N(),M(),w=o,h=a,new Promise(t=>{var e;window.navigator.onLine?(e=d+(`/getAppConfig?accountID=${i}&appName=`+r),window.fetch(e).then(e=>{switch(e.status){case 200:return void e.json().then(e=>{t(e)}).catch(e=>{A("remote response invalid. Continuing with defaults.",e),t({})});case 400:A("Bad Request, check library version compatible?",e),t({});break;default:A("Could not update from remote config. Continuing with defaults.",e),t({})}}).catch(e=>{A("Could not update from remote config. Continuing with defaults.",e),t({})})):t({})}).then(e=>{y!=={}&&(y=e,u=w||y.postIntervalSecondsInit||60,c=h||y.granularitySecInit||3,d=y.analyticsURLInit||d||I,M(T=!0===y.disabled),U(`Init analytics Config from remote. disabled: ${T}
function initAnalyticsSession(e,t,n,o,a){let i,r,s,l,u,c,d,f,y={};const v="aicore.analytics.userID",g="aicore.analytics.sessionID",p=1e4;let m=null;var w,h,b,C="undefined"==typeof window;let I="https://analytics.core.ai",S,D,E=0,T=!1;function U(...e){window.analytics.debugMode&&console.log("analytics client: ",...e)}function A(...e){window.analytics.debugMode&&console.error("analytics client: ",...e)}if(C)throw new Error("Node environment is not currently supported");function N(){return{schemaVersion:1,accountID:i,appName:r,uuid:s,sessionID:l,unixTimestampUTC:+new Date,numEventsTotal:0,events:{}}}function $(){if(!m)throw new Error("Please call initSession before using any analytics event")}function k(e){e.backoffCount=(e.backoffCount||0)+1,U(`Failed to call core analytics server. Will retry in ${30*e.backoffCount}s: `),setTimeout(()=>{R(e)},3e4*e.backoffCount)}function B(t){var e,n=JSON.stringify(t);n.length>p&&console.warn(`Analytics event generated is very large at greater than ${n.length}B. This
typically means that you may be sending too many value events? .`),U("Sending Analytics data of length: ",n.length,"B"),e=["Sending data:",t],window.analytics.debugMode&&console.info("analytics client: ",...e),window.navigator.onLine?window.fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:n}).then(e=>{200!==e.status&&(400!==e.status?k(t):console.error("Bad Request, this is most likely a problem with the library, update to latest version."))}).catch(e=>{A(e),k(t)}):k(t)}function R(e){T||(e||(e=m,E=0,L(),m=N()),0!==e.numEventsTotal&&B(e))}function L(e){S&&(clearInterval(S),S=null),e||(S=setInterval(()=>{E+=c},1e3*c))}function M(e){L(e),D&&(clearInterval(D),D=null),e||(D=setInterval(R,1e3*u))}function _(n,o,a,i=1,r=0){if(!T){var s=n,l=o,u=a,c=i,d=r;if($(),!s||!l||!u)throw new Error("missing eventType or category or subCategory");if("number"!=typeof c||c<0)throw new Error("invalid count, count should be a positive number");if("number"!=typeof d)throw new Error("invalid value, value should be a number");{s=n;l=o;u=a;let e=m.events;e[s]=e[s]||{},e[s][l]=e[s][l]||{},e[s][l][u]=e[s][l][u]||{time:[],valueCount:[]}}let t=m.events;c=t[n][o][a].time;if((0<c.length?c[c.length-1]:null)===E){d=t[n][o][a].valueCount.length-1;{var s=d,l=n,u=o,c=a,d=i,f=r;let t=m.events;var e="number"==typeof t[l][u][c].valueCount[s];if(e&&0===f)t[l][u][c].valueCount[s]+=d;else if(e&&0!==f){let e={};e[f]=d,e[0]=t[l][u][c].valueCount[s],t[l][u][c].valueCount[s]=e}else if(!e){let e=t[l][u][c].valueCount[s];e[f]=(e[f]||0)+d}m.numEventsTotal+=1}}else{if(t[n][o][a].time.push(E),0===r)t[n][o][a].valueCount.push(i);else{let e={};e[r]=i,t[n][o][a].valueCount.push(e)}m.numEventsTotal+=1}}}if(!e||!t)throw new Error("accountID and appName must exist for init");d=n?n.toString().replace(/\/$/,""):I,i=e,r=t,u=o||60,c=a||3,f=d+"/ingest",s=function(){let e=localStorage.getItem(v);return e||(e=crypto.randomUUID(),localStorage.setItem(v,e)),e}(),l=function(){let e=sessionStorage.getItem(g);return e||(e=Math.random().toString(36).substr(2,10),sessionStorage.setItem(g,e)),e}(),m=N(),M(),w=o,h=a,new Promise(t=>{var e;window.navigator.onLine?(e=d+(`/getAppConfig?accountID=${i}&appName=`+r),window.fetch(e).then(e=>{switch(e.status){case 200:return void e.json().then(e=>{t(e)}).catch(e=>{A("remote response invalid. Continuing with defaults.",e),t({})});case 400:A("Bad Request, check library version compatible?",e),t({});break;default:A("Could not update from remote config. Continuing with defaults.",e),t({})}}).catch(e=>{A("Could not update from remote config. Continuing with defaults.",e),t({})})):t({})}).then(e=>{y!=={}&&(y=e,u=w||y.postIntervalSecondsInit||60,c=h||y.granularitySecInit||3,d=y.analyticsURLInit||d||I,M(T=!0===y.disabled),U(`Init analytics Config from remote. disabled: ${T}
postIntervalSeconds:${u}, granularitySec: ${c} ,URL: `+d),T&&console.warn(`Core Analytics is disabled from the server for app: ${i}:`+r))});for(b of analytics._initData)_(...b);analytics._initData=[],analytics._getCurrentAnalyticsEvent=function(){return $(),JSON.parse(JSON.stringify(m))},analytics._getAppConfig=function(){return{accountID:i,appName:r,disabled:T,uuid:s,sessionID:l,postIntervalSeconds:u,granularitySec:c,analyticsURL:d,serverConfig:y}},analytics.event=_}window.analytics||(window.analytics={_initData:[],debugMode:!1}),void 0===window.crypto&&(window.crypto={}),"randomUUID"in crypto||(crypto.randomUUID=function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))});
//# sourceMappingURL=analytics.min.js.map
{
"name": "@aicore/core-analytics-client-lib",
"version": "1.0.10",
"version": "1.0.11",
"description": "Analytics client library for https://github.com/aicore/Core-Analytics-Server",

@@ -50,12 +50,12 @@ "main": "dist/analytics.min.js",

"devDependencies": {
"@commitlint/cli": "16.3.0",
"@commitlint/config-conventional": "16.2.4",
"c8": "7.11.2",
"@commitlint/cli": "17.0.2",
"@commitlint/config-conventional": "17.0.2",
"c8": "7.11.3",
"chai": "4.3.6",
"eslint": "8.15.0",
"eslint": "8.16.0",
"husky": "7.0.4",
"mocha": "9.2.2",
"uglify-js": "3.15.5",
"http-server": "14.1.0"
"http-server": "14.1.1"
}
}

@@ -146,8 +146,2 @@ # Core Analytics Client Lib - JS

To see info level logs that shows actual analytics data being sent to server, set or unset the below property:
```js
window.analytics.debugInfoLogsEnable = true;
```
# Contribute to core-analytics-client-lib

@@ -154,0 +148,0 @@

@@ -68,3 +68,3 @@ // GNU AGPL-3.0 License Copyright (c) 2021 - present core.ai . All rights reserved.

function debugInfo(...args) {
if(window.analytics.debugMode && window.analytics.debugInfoLogsEnable){
if(window.analytics.debugMode){
console.info("analytics client: ", ...args);

@@ -150,3 +150,3 @@ }

debugLog("Sending Analytics data of length: ", textToSend.length, "B");
debugInfo("Sending data:", textToSend);
debugInfo("Sending data:", eventToSend);
if(!window.navigator.onLine){

@@ -153,0 +153,0 @@ _retryPost(eventToSend);

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