@aicore/core-analytics-client-lib 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,7 +33,7 @@ in the `initAnalyticsSession` call below:
33
33
  };}
34
34
  function analyticsLibLoaded() {
35
35
  initAnalyticsSession('your_analytics_account_ID', 'appName');
36
- analytics.event("core-analytics", "client-lib", "loadTime", 1, (new Date().getTime())-analytics.loadStartTime);
36
+ analytics.valueEvent("core-analytics", "client-lib", "loadTime", (new Date().getTime())-analytics.loadStartTime);
37
37
  }
38
38
  </script>
39
39
  ```
@@ -43,34 +43,56 @@ NB: The script is loaded async, so it will not block other js scripts. `analytic
43
43
  after the above code and need not wait for the script load to complete.
44
44
 
45
45
  ## Raising analytics events
46
- We can now start logging analytics events by calling `analytics.event` API.
47
- The events will be aggregated and send to the analytics server periodically.
46
+ Events are aggregated and sent to the analytics server periodically.
47
+ Two APIs are available depending on your use case:
48
+
49
+ ### `analytics.countEvent` - Count occurrences
50
+ Use this to track how many times something happens.
48
51
 
49
52
  ```javascript
50
- // analyticsEvent(eventType, eventCategory, subCategory, eventCount, eventValue);
53
+ // countEvent(eventType, eventCategory, subCategory, eventCount)
54
+
55
+ // Count a single occurrence
56
+ analytics.countEvent("platform", "os", "linux");
57
+
58
+ // Count multiple occurrences at once (e.g., html file opened 100 times)
59
+ analytics.countEvent("file", "opened", "html", 100);
60
+ ```
61
+
62
+ #### Parameters
63
+ * `eventType` - A string, required
64
+ * `eventCategory` - A string, required
65
+ * `subCategory` - A string, required
66
+ * `eventCount` (_Optional_) : A non-negative number indicating the number of times the event happened. Defaults to 1.
67
+
68
+ ### `analytics.valueEvent` - Track values
69
+ Use this to measure quantities like latencies, durations, sizes, or anything where you need
70
+ running averages and distributions.
51
71
 
52
- // Eg: event without counts and values
53
- analytics.event("platform", "os", "linux");
72
+ ```javascript
73
+ // valueEvent(eventType, eventCategory, subCategory, eventValue, count)
54
74
 
55
- // Eg: event with count, here it logs that html file is opened 100 times
56
- analytics.event("file", "opened", "html", 100);
75
+ // Track startup time of 250 milliseconds
76
+ // Note that the value is unitless from analytics perspective. Unit is deduced from subCategory name.
77
+ analytics.valueEvent("platform", "performance", "startupTimeMs", 250);
57
78
 
58
- // Eg: event with count and value, here it logs that the startup time is 250 milliseconds.
59
- // Note that the value is unitless from analytics perspective. unit is deduced from subCategory name
60
- analytics.event("platform", "performance", "startupTimeMs", 1, 250);
79
+ // Track fractional values (e.g., CPU utilization)
80
+ analytics.valueEvent("platform", "CPU", "utilization", .45);
61
81
 
62
- // Eg: event with fractional value.
63
- analytics.event("platform", "CPU", "utilization", 1, .45);
64
- // Eg. Here we register that the system has 8 cores with each core having 2300MHz frequency.
65
- analytics.event("platform", "CPU", "coreCountsAndFrequencyMhz", 8, 2300);
82
+ // Track that a system has 8 cores with each core having 2300MHz frequency
83
+ analytics.valueEvent("platform", "CPU", "coreCountsAndFrequencyMhz", 2300, 8);
66
84
  ```
67
- ### API parameters
85
+
86
+ #### Parameters
68
87
  * `eventType` - A string, required
69
88
  * `eventCategory` - A string, required
70
89
  * `subCategory` - A string, required
71
- * `eventCount` (_Optional_) : A non-negative number indicating the number of times the event (or an event with a
72
- particular value if a value is specified) happened. defaults to 1.
73
- * `eventValue` (_Optional_) : A number value associated with the event. defaults to 0
90
+ * `eventValue` (_Optional_) : A numeric value associated with the event. Defaults to 0.
91
+ * `count` (_Optional_) : A non-negative number indicating how many times this value occurred. Defaults to 1.
92
+
93
+ ### Deprecated: `analytics.event`
94
+ The legacy `analytics.event(eventType, eventCategory, subCategory, eventCount, eventValue)` API is still
95
+ available for backwards compatibility but is deprecated. Please migrate to `countEvent` or `valueEvent`.
74
96
 
75
97
 
76
98
  ## Advanced Usages
@@ -91,9 +113,9 @@ function _initCoreAnalytics() {
91
113
  script.type = 'text/javascript';
92
114
  script.async = true;
93
115
  script.onload = function(){
94
- // replace `your_analytics_account_ID` and `appName` below with your values
116
+ // replace `your_analytics_account_ID` and `appName` below with your values
95
117
  window.initAnalyticsSession('your_analytics_account_ID', 'appName'); // if you have a custom analytics server
96
- window.analytics.event("core-analytics", "client-lib", "loadTime", 1,
118
+ window.analytics.valueEvent("core-analytics", "client-lib", "loadTime",
97
119
  (new Date().getTime())- window.analytics.loadStartTime);
98
120
  };
99
121
  script.src = 'https://unpkg.com/@aicore/core-analytics-client-lib/dist/analytics.min.js';
@@ -124,7 +146,7 @@ which means that any events that happen within 3 seconds cannot be distinguished
124
146
  // Init with default values and server controlled config. use the following `analyticsLibLoaded` function
125
147
  function analyticsLibLoaded() {
126
148
  initAnalyticsSession('your_analytics_account_ID', 'appName');
127
- analytics.event("core-analytics", "client-lib", "loadTime", 1, (new Date().getTime())-analytics.loadStartTime);
149
+ analytics.valueEvent("core-analytics", "client-lib", "loadTime", (new Date().getTime())-analytics.loadStartTime);
128
150
  }
129
151
 
130
152
  //Replace initAnalyticsSession in analyticsLibLoaded function for the below use cases.
@@ -1,4 +1,4 @@
1
- function initAnalyticsSession(n,t,e,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,U=!1;function T(...n){window.analytics.debugMode&&console.log("analytics client: ",...n)}function A(...n){window.analytics.debugMode&&console.error("analytics client: ",...n)}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(n){n.backoffCount=(n.backoffCount||0)+1,T(`Failed to call core analytics server. Will retry in ${30*n.backoffCount}s: `),setTimeout(()=>{R(n)},3e4*n.backoffCount)}function B(t){var n,e=JSON.stringify(t);e.length>p&&console.warn(`Analytics event generated is very large at greater than ${e.length}B. This
2
- typically means that you may be sending too many value events? .`),T("Sending Analytics data of length: ",e.length,"B"),n=["Sending data:",t],window.analytics.debugMode&&console.info("analytics client: ",...n),window.navigator.onLine?window.fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:e}).then(n=>{200!==n.status&&(400!==n.status?k(t):console.error("Bad Request, this is most likely a problem with the library, update to latest version."))}).catch(n=>{A(n),k(t)}):k(t)}function R(n){U||(n||(n=m,E=0,L(),m=N()),0!==n.numEventsTotal&&B(n))}function L(n){S&&(clearInterval(S),S=null),n||(S=setInterval(()=>{E+=c},1e3*c))}function M(n){L(n),D&&(clearInterval(D),D=null),n||(D=setInterval(R,1e3*u))}function _(n,t,e,o=1,a=0){if(!U){var i=n,r=t,s=e,l=o,u=a;if($(),!i||!r||!s)throw new Error("missing eventType or category or subCategory");if("number"!=typeof l||l<0)throw new Error("invalid count, count should be a positive number");if("number"!=typeof u)throw new Error("invalid value, value should be a number");i=n,r=t,s=e,(l=m.events)[i]=l[i]||{},l[i][r]=l[i][r]||{},l[i][r][s]=l[i][r][s]||{time:[],valueCount:[]};var u=m.events,l=u[n][t][e],i=l.time;(0<i.length?i[i.length-1]:null)!==E?(i.push(E),0===a?l.valueCount.push(o):((r={})[a]=o,l.valueCount.push(r))):(s=l.valueCount.length-1,u=s,i=n,r=t,l=e,s=o,n=a,i=m.events[i][r][l],(r="number"==typeof i.valueCount[u])&&0===n?i.valueCount[u]+=s:r&&0!==n?((l={})[n]=s,l[0]=i.valueCount[u],i.valueCount[u]=l):r||((l=i.valueCount[u])[n]=(l[n]||0)+s)),m.numEventsTotal+=1}}if(!n||!t)throw new Error("accountID and appName must exist for init");d=e?e.toString().replace(/\/$/,""):I,i=n,r=t,u=o||60,c=a||3,f=d+"/ingest",s=function(){let n=localStorage.getItem(v);return n||(n=crypto.randomUUID(),localStorage.setItem(v,n)),n}(),l=function(){let n=sessionStorage.getItem(g);return n||(n=Math.random().toString(36).substr(2,10),sessionStorage.setItem(g,n)),n}(),m=N(),M(),w=o,h=a,new Promise(t=>{var n;window.navigator.onLine?(n=d+(`/getAppConfig?accountID=${i}&appName=`+r),window.fetch(n).then(n=>{switch(n.status){case 200:return void n.json().then(n=>{t(n)}).catch(n=>{A("remote response invalid. Continuing with defaults.",n),t({})});case 400:A("Bad Request, check library version compatible?",n),t({});break;default:A("Could not update from remote config. Continuing with defaults.",n),t({})}}).catch(n=>{A("Could not update from remote config. Continuing with defaults.",n),t({})})):t({})}).then(n=>{y!=={}&&(y=n,u=w||y.postIntervalSecondsInit||60,c=h||y.granularitySecInit||3,d=y.analyticsURLInit||d||I,M(U=!0===y.disabled),T(`Init analytics Config from remote. disabled: ${U}
3
- postIntervalSeconds:${u}, granularitySec: ${c} ,URL: `+d),U)&&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:U,uuid:s,sessionID:l,postIntervalSeconds:u,granularitySec:c,analyticsURL:d,serverConfig:y}},analytics.countEvent=function(n,t,e,o=1){return _(n,t,e,o,0)},analytics.valueEvent=function(n,t,e,o=0,a=1){return _(n,t,e,a,o)}}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,n=>(n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16))});
1
+ function initAnalyticsSession(n,t,e,a,o){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,U=!1;function T(...n){window.analytics.debugMode&&console.log("analytics client: ",...n)}function A(...n){window.analytics.debugMode&&console.error("analytics client: ",...n)}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(n){n.backoffCount=(n.backoffCount||0)+1,T(`Failed to call core analytics server. Will retry in ${30*n.backoffCount}s: `),setTimeout(()=>{R(n)},3e4*n.backoffCount)}function B(t){var n,e=JSON.stringify(t);e.length>p&&console.warn(`Analytics event generated is very large at greater than ${e.length}B. This
2
+ typically means that you may be sending too many value events? .`),T("Sending Analytics data of length: ",e.length,"B"),n=["Sending data:",t],window.analytics.debugMode&&console.info("analytics client: ",...n),window.navigator.onLine?window.fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:e}).then(n=>{200!==n.status&&(400!==n.status?k(t):console.error("Bad Request, this is most likely a problem with the library, update to latest version."))}).catch(n=>{A(n),k(t)}):k(t)}function R(n){U||(n||(n=m,E=0,L(),m=N()),0!==n.numEventsTotal&&B(n))}function L(n){S&&(clearInterval(S),S=null),n||(S=setInterval(()=>{E+=c},1e3*c))}function M(n){L(n),D&&(clearInterval(D),D=null),n||(D=setInterval(R,1e3*u))}function _(n,t,e,a=1,o=0){if(!U){var i=n,r=t,s=e,l=a,u=o;if($(),!i||!r||!s)throw new Error("missing eventType or category or subCategory");if("number"!=typeof l||l<0)throw new Error("invalid count, count should be a positive number");if("number"!=typeof u)throw new Error("invalid value, value should be a number");i=n,r=t,s=e,(l=m.events)[i]=l[i]||{},l[i][r]=l[i][r]||{},l[i][r][s]=l[i][r][s]||{time:[],valueCount:[]};var u=m.events,l=u[n][t][e],i=l.time;(0<i.length?i[i.length-1]:null)!==E?(i.push(E),0===o?l.valueCount.push(a):((r={})[o]=a,l.valueCount.push(r))):(s=l.valueCount.length-1,u=s,i=n,r=t,l=e,s=a,n=o,i=m.events[i][r][l],(r="number"==typeof i.valueCount[u])&&0===n?i.valueCount[u]+=s:r&&0!==n?((l={})[n]=s,l[0]=i.valueCount[u],i.valueCount[u]=l):r||((l=i.valueCount[u])[n]=(l[n]||0)+s)),m.numEventsTotal+=1}}if(!n||!t)throw new Error("accountID and appName must exist for init");d=e?e.toString().replace(/\/$/,""):I,i=n,r=t,u=a||60,c=o||3,f=d+"/ingest",s=function(){let n=localStorage.getItem(v);return n||(n=crypto.randomUUID(),localStorage.setItem(v,n)),n}(),l=function(){let n=sessionStorage.getItem(g);return n||(n=Math.random().toString(36).substr(2,10),sessionStorage.setItem(g,n)),n}(),m=N(),M(),w=a,h=o,new Promise(t=>{var n;window.navigator.onLine?(n=d+(`/getAppConfig?accountID=${i}&appName=`+r),window.fetch(n).then(n=>{switch(n.status){case 200:return void n.json().then(n=>{t(n)}).catch(n=>{A("remote response invalid. Continuing with defaults.",n),t({})});case 400:A("Bad Request, check library version compatible?",n),t({});break;default:A("Could not update from remote config. Continuing with defaults.",n),t({})}}).catch(n=>{A("Could not update from remote config. Continuing with defaults.",n),t({})})):t({})}).then(n=>{y!=={}&&(y=n,u=w||y.postIntervalSecondsInit||60,c=h||y.granularitySecInit||3,d=y.analyticsURLInit||d||I,M(U=!0===y.disabled),T(`Init analytics Config from remote. disabled: ${U}
3
+ postIntervalSeconds:${u}, granularitySec: ${c} ,URL: `+d),U)&&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:U,uuid:s,sessionID:l,postIntervalSeconds:u,granularitySec:c,analyticsURL:d,serverConfig:y}},analytics.event=_,analytics.countEvent=function(n,t,e,a=1){return _(n,t,e,a,0)},analytics.valueEvent=function(n,t,e,a=0,o=1){return _(n,t,e,o,a)}}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,n=>(n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16))});
4
4
  //# sourceMappingURL=analytics.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"src/analytics.js","sources":["src/analytics.js"],"names":["initAnalyticsSession","accountIDInit","appNameInit","analyticsURLInit","postIntervalSecondsInit","granularitySecInit","let","accountID","appName","userID","sessionID","postIntervalSeconds","granularitySec","analyticsURL","postURL","serverConfig","USERID_LOCAL_STORAGE_KEY","SESSION_ID_LOCAL_STORAGE_KEY","POST_LARGE_DATA_THRESHOLD_BYTES","currentAnalyticsEvent","postIntervalSecondsInitial","granularitySecInitial","eventData","IS_NODE_ENV","window","DEFAULT_BASE_URL","granularityTimer","postTimer","currentQuantisedTime","disabled","debugLog","args","analytics","debugMode","console","log","debugError","error","Error","_createAnalyticsEvent","schemaVersion","uuid","unixTimestampUTC","Date","numEventsTotal","events","_validateCurrentState","_retryPost","eventToSend","backoffCount","setTimeout","_postCurrentAnalyticsEvent","DEFAULT_RETRY_TIME_IN_SECONDS","_postEventWithRetry","textToSend","JSON","stringify","length","warn","debugInfo","info","navigator","onLine","fetch","method","headers","Content-Type","body","then","res","status","catch","_resetGranularityTimer","disable","clearInterval","setInterval","_setupTimers","event","eventType","eventCategory","subCategory","eventCount","eventValue","_validateEvent","category","count","value","time","valueCount","eventItem","timeArray","push","modificationIndex","index","newValue","storedValueIsCount","newValueCount","storedValueObject","toString","replace","localUserID","localStorage","getItem","crypto","randomUUID","setItem","localSessionID","sessionStorage","Math","random","substr","Promise","configURL","json","serverResponse","resolve","err","updatedServerConfig","_initData","_getCurrentAnalyticsEvent","parse","_getAppConfig","countEvent","valueEvent","c","getRandomValues","Uint8Array"],"mappings":"AAwCA,SAASA,qBAAqBC,EAAeC,EAAaC,EACtDC,EAAyBC,GACzBC,IAAIC,EAAWC,EAASC,EAAQC,EAAWC,EACvCC,EAAgBC,EAAcC,EAASC,EAAa,GACxD,MAGMC,EAA2B,0BAC3BC,EAA+B,6BAC/BC,EAAkC,IACxCZ,IAAIa,EAAwB,KAC5B,IAkN+BC,EAA4BC,EAsKnDC,E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AwBC,CAAc,EACzFgB,IACCK,QAAQwB,4DAA4DnD,KAAaC,CAAS,CAGtG,CAAC,EAoJL,IAAQc,KAAaU,UAAUsF,UAC3BzC,EAAM,GAAGvD,CAAS,EAEtBU,UAAUsF,UAAY,GAGtBtF,UAAUuF,0BA1UV,WAGI,OAFAzE,EAAsB,EAEfS,KAAKiE,MAAMjE,KAAKC,UAAUrC,CAAqB,CAAC,CAC3D,EAuUAa,UAAUyF,cArLV,WACI,MAAO,CACHlH,UAAAA,EAAWC,QAAAA,EAASqB,SAAAA,EACpBY,KAAMhC,EAAQC,UAAAA,EACdC,oBAAAA,EAAqBC,eAAAA,EAAgBC,aAAAA,EAAcE,aAAAA,CACvD,CACJ,EAkLAiB,UAAU0F,WAzDV,SAAoB5C,EAAWC,EAAeC,EAAaC,EAAa,GACpE,OAAOJ,EAAMC,EAAWC,EAAeC,EAAaC,EAAY,CAAC,CACrE,EAwDAjD,UAAU2F,WAlCV,SAAoB7C,EAAWC,EAAeC,EAAaE,EAAa,EAAGG,EAAQ,GAC/E,OAAOR,EAAMC,EAAWC,EAAeC,EAAaK,EAAOH,CAAU,CACzE,CAiCJ,CAjbI1D,OAAOQ,YACPR,OAAOQ,UAAY,CACfsF,UAAW,GACXrF,UAAW,CAAA,CACf,GAGyB,KAAA,IAAlBT,OAAO+E,SACd/E,OAAO+E,OAAS,IAGd,eAAgBA,SAGlBA,OAAOC,WAAa,WAChB,OACI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAML,QAAQ,SAEpCyB,IAAMA,EAAIrB,OAAOsB,gBAAgB,IAAIC,WAAW,CAAC,CAAC,EAAE,GAAK,IAAMF,EAAI,GAAG1B,SAAS,EAAE,CACrF,CACJ"}
1
+ {"version":3,"sourceRoot":"src/analytics.js","sources":["src/analytics.js"],"names":["initAnalyticsSession","accountIDInit","appNameInit","analyticsURLInit","postIntervalSecondsInit","granularitySecInit","let","accountID","appName","userID","sessionID","postIntervalSeconds","granularitySec","analyticsURL","postURL","serverConfig","USERID_LOCAL_STORAGE_KEY","SESSION_ID_LOCAL_STORAGE_KEY","POST_LARGE_DATA_THRESHOLD_BYTES","currentAnalyticsEvent","postIntervalSecondsInitial","granularitySecInitial","eventData","IS_NODE_ENV","window","DEFAULT_BASE_URL","granularityTimer","postTimer","currentQuantisedTime","disabled","debugLog","args","analytics","debugMode","console","log","debugError","error","Error","_createAnalyticsEvent","schemaVersion","uuid","unixTimestampUTC","Date","numEventsTotal","events","_validateCurrentState","_retryPost","eventToSend","backoffCount","setTimeout","_postCurrentAnalyticsEvent","DEFAULT_RETRY_TIME_IN_SECONDS","_postEventWithRetry","textToSend","JSON","stringify","length","warn","debugInfo","info","navigator","onLine","fetch","method","headers","Content-Type","body","then","res","status","catch","_resetGranularityTimer","disable","clearInterval","setInterval","_setupTimers","event","eventType","eventCategory","subCategory","eventCount","eventValue","_validateEvent","category","count","value","time","valueCount","eventItem","timeArray","push","modificationIndex","index","newValue","storedValueIsCount","newValueCount","storedValueObject","toString","replace","localUserID","localStorage","getItem","crypto","randomUUID","setItem","localSessionID","sessionStorage","Math","random","substr","Promise","configURL","json","serverResponse","resolve","err","updatedServerConfig","_initData","_getCurrentAnalyticsEvent","parse","_getAppConfig","countEvent","valueEvent","c","getRandomValues","Uint8Array"],"mappings":"AAwCA,SAASA,qBAAqBC,EAAeC,EAAaC,EACtDC,EAAyBC,GACzBC,IAAIC,EAAWC,EAASC,EAAQC,EAAWC,EACvCC,EAAgBC,EAAcC,EAASC,EAAa,GACxD,MAGMC,EAA2B,0BAC3BC,EAA+B,6BAC/BC,EAAkC,IACxCZ,IAAIa,EAAwB,KAC5B,IAkN+BC,EAA4BC,EAsKnDC,EAxXFC,EAAiC,aAAlB,OAAOC,OAC5BlB,IAAImB,EAAmB,4BAEnBC,EACAC,EACAC,EAAuB,EACvBC,EAAW,CAAA,EAEf,SAASC,KAAYC,GACbP,OAAOQ,UAAUC,WAGrBC,QAAQC,IAAI,qBAAsB,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,0BA1UV,WAGI,OAFAzE,EAAsB,EAEfS,KAAKiE,MAAMjE,KAAKC,UAAUrC,CAAqB,CAAC,CAC3D,EAuUAa,UAAUyF,cArLV,WACI,MAAO,CACHlH,UAAAA,EAAWC,QAAAA,EAASqB,SAAAA,EACpBY,KAAMhC,EAAQC,UAAAA,EACdC,oBAAAA,EAAqBC,eAAAA,EAAgBC,aAAAA,EAAcE,aAAAA,CACvD,CACJ,EAmLAiB,UAAU6C,MAAQA,EAClB7C,UAAU0F,WA3DV,SAAoB5C,EAAWC,EAAeC,EAAaC,EAAa,GACpE,OAAOJ,EAAMC,EAAWC,EAAeC,EAAaC,EAAY,CAAC,CACrE,EA0DAjD,UAAU2F,WApCV,SAAoB7C,EAAWC,EAAeC,EAAaE,EAAa,EAAGG,EAAQ,GAC/E,OAAOR,EAAMC,EAAWC,EAAeC,EAAaK,EAAOH,CAAU,CACzE,CAmCJ,CAnbI1D,OAAOQ,YACPR,OAAOQ,UAAY,CACfsF,UAAW,GACXrF,UAAW,CAAA,CACf,GAGyB,KAAA,IAAlBT,OAAO+E,SACd/E,OAAO+E,OAAS,IAGd,eAAgBA,SAGlBA,OAAOC,WAAa,WAChB,OACI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAML,QAAQ,SAEpCyB,IAAMA,EAAIrB,OAAOsB,gBAAgB,IAAIC,WAAW,CAAC,CAAC,EAAE,GAAK,IAAMF,EAAI,GAAG1B,SAAS,EAAE,CACrF,CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicore/core-analytics-client-lib",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Analytics client library for https://github.com/aicore/Core-Analytics-Server",
5
5
  "main": "dist/analytics.min.js",
6
6
  "type": "module",
package/src/analytics.js CHANGED
@@ -435,6 +435,8 @@ function initAnalyticsSession(accountIDInit, appNameInit, analyticsURLInit,
435
435
  analytics._getAppConfig = _getAppConfig;
436
436
 
437
437
  // Public API
438
+ /** @deprecated Use {@link countEvent} or {@link valueEvent} instead. */
439
+ analytics.event = event;
438
440
  analytics.countEvent = countEvent;
439
441
  analytics.valueEvent = valueEvent;
440
442
  }