@wireapp/telemetry 0.1.0
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 +80 -0
- package/lib/countly.d.ts +75 -0
- package/lib/countly.d.ts.map +1 -0
- package/lib/embed.cjs.js +1 -0
- package/lib/embed.d.ts +1 -0
- package/lib/embed.d.ts.map +1 -0
- package/lib/embed.js +159 -0
- package/lib/index.cjs.js +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +78 -0
- package/lib/telemetry.d.ts +218 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Wire
|
|
2
|
+
|
|
3
|
+
This repository is part of the source code of Wire. You can find more information at [wire.com](https://wire.com) or by contacting opensource@wire.com.
|
|
4
|
+
|
|
5
|
+
You can find the published source code at [github.com/wireapp](https://github.com/wireapp).
|
|
6
|
+
|
|
7
|
+
For licensing information, see the attached LICENSE file and the list of third-party licenses at [wire.com/legal/licenses/](https://wire.com/legal/licenses/).
|
|
8
|
+
|
|
9
|
+
## Telemetry
|
|
10
|
+
|
|
11
|
+
The Telemetry package provides utilities for tracking and logging various events and metrics within the Wire applications. It helps in monitoring the application's performance, usage patterns, and potential issues.
|
|
12
|
+
|
|
13
|
+
Under the hood uses [Countly](https://countly.com/).
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add @wireapp/telemetry
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @wireapp/telemetry
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
The current library implementation uses Countly as a provider. Countly provides its [JavaScript SDK](https://support.countly.com/hc/en-us/articles/360037441932-Web-analytics-JavaScript), which requires unusual implementation (asynchronous mode).
|
|
30
|
+
|
|
31
|
+
#### Embed script
|
|
32
|
+
|
|
33
|
+
To initialize the library code you have to include the `embed.js` script on you HTML page.
|
|
34
|
+
|
|
35
|
+
One way to do it is to diretcly copy telemetry package, and store it in the client build directory.
|
|
36
|
+
|
|
37
|
+
`copy_server_assets.js`:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const fs = require('fs-extra');
|
|
41
|
+
|
|
42
|
+
const distFolder = '../dist/';
|
|
43
|
+
const npmModulesFolder = '../../node_modules/';
|
|
44
|
+
|
|
45
|
+
fs.copySync(
|
|
46
|
+
path.resolve(__dirname, npmModulesFolder, '@wireapp/telemetry/lib/embed.js'),
|
|
47
|
+
path.resolve(__dirname, distFolder, 'libs/wire/telemetry/embed.js'),
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`package.json`:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
"scripts": {
|
|
55
|
+
"copy-assets": "node ./bin/copy_server_assets.js"
|
|
56
|
+
},
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`index.html`:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<script src="./libs/wire/telemetry/embed.js"></script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Initialization
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import * as telemetry from '@wireapp/telemetry';
|
|
69
|
+
|
|
70
|
+
const {COUNTLY_ENABLE_LOGGING, VERSION, COUNTLY_API_KEY, COUNTLY_SERVER_URL} = Config.getConfig();
|
|
71
|
+
|
|
72
|
+
telemetry.initialize({
|
|
73
|
+
appVersion: VERSION,
|
|
74
|
+
provider: {
|
|
75
|
+
apiKey: COUNTLY_API_KEY,
|
|
76
|
+
serverUrl: COUNTLY_SERVER_URL,
|
|
77
|
+
enableLogging: COUNTLY_ENABLE_LOGGING,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
package/lib/countly.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface Countly {
|
|
2
|
+
/**
|
|
3
|
+
* Countly does not provide Typescript types, so we have to define the q array as any[].
|
|
4
|
+
* The documentation for everything than can be pushed to q is here is linked above.
|
|
5
|
+
*/
|
|
6
|
+
q: {
|
|
7
|
+
push: (args: [EventType, ...any]) => void;
|
|
8
|
+
};
|
|
9
|
+
app_key: string;
|
|
10
|
+
device_id: string;
|
|
11
|
+
url: string;
|
|
12
|
+
app_version?: string;
|
|
13
|
+
country_code?: string;
|
|
14
|
+
city?: string;
|
|
15
|
+
ip_address?: string;
|
|
16
|
+
debug: boolean;
|
|
17
|
+
ignore_bots: boolean;
|
|
18
|
+
interval: number;
|
|
19
|
+
queue_size: number;
|
|
20
|
+
fail_timeout: number;
|
|
21
|
+
inactivity_time: number;
|
|
22
|
+
session_update: number;
|
|
23
|
+
max_events: number;
|
|
24
|
+
max_breadcrumb_count: number;
|
|
25
|
+
ignore_referrers: string[];
|
|
26
|
+
checksum_salt: string;
|
|
27
|
+
ignore_prefetch: boolean;
|
|
28
|
+
heatmap_whitelist: string[];
|
|
29
|
+
force_post: boolean;
|
|
30
|
+
ignore_visitor: boolean;
|
|
31
|
+
require_consent: boolean;
|
|
32
|
+
utm: {
|
|
33
|
+
[key: string]: boolean;
|
|
34
|
+
};
|
|
35
|
+
use_session_cookie: boolean;
|
|
36
|
+
session_cookie_timeout: number;
|
|
37
|
+
remote_config: boolean;
|
|
38
|
+
rc_automatic_optin_for_ab: boolean;
|
|
39
|
+
use_explicit_rc_api: boolean;
|
|
40
|
+
namespace: string;
|
|
41
|
+
track_domains: boolean;
|
|
42
|
+
headers: {
|
|
43
|
+
[key: string]: string;
|
|
44
|
+
};
|
|
45
|
+
storage: 'localstorage' | 'cookies' | 'none';
|
|
46
|
+
/**
|
|
47
|
+
* provide metrics override or custom metrics for this user.
|
|
48
|
+
* For more information on the specific metric keys used by Countly, check:
|
|
49
|
+
* https://support.countly.com/hc/en-us/articles/9290669873305-A-Deeper-Look-at-SDK-concepts#setting-custom-user-metrics
|
|
50
|
+
*/
|
|
51
|
+
metrics: {
|
|
52
|
+
[key: string]: any;
|
|
53
|
+
};
|
|
54
|
+
init: () => void;
|
|
55
|
+
offline_mode: boolean;
|
|
56
|
+
}
|
|
57
|
+
export type EventType = 'add_consent' | 'add_event' | 'change_id' | 'begin_session' | 'end_session' | 'disable_offline_mode' | 'enable_offline_mode' | 'track_clicks' | 'track_performance' | 'track_pageview' | 'track_sessions' | 'track_scrolls' | 'track_links' | 'track_errors' | 'remove_consent' | 'userData.set' | 'userData.save';
|
|
58
|
+
/**
|
|
59
|
+
* - `sessions`: Tracks when, how often, and how long users use your website.
|
|
60
|
+
* - `events`: Allows your events to be sent to the server.
|
|
61
|
+
* - `views`: Allows for the views/pages accessed by a user to be tracked.
|
|
62
|
+
* - `scrolls`: Allows a user’s scrolls to be tracked on the heatmap.
|
|
63
|
+
* - `clicks`: Allows a user’s clicks and link clicks to be tracked on the heatmap.
|
|
64
|
+
* - `forms`: Allows a user’s form submissions to be tracked.
|
|
65
|
+
* - `crashes`: Allows JavaScript errors to be tracked.
|
|
66
|
+
* - `attribution`: Allows direct attribution tracking.
|
|
67
|
+
* - `users`: Allows user information, including custom properties, to be collected/provided.
|
|
68
|
+
* - `star-rating`: Allows user rating and feedback tracking through rating widgets.
|
|
69
|
+
* - `feedback`: Allows survey, NPS, and rating widgets usage and reporting.
|
|
70
|
+
* - `apm`: Allows performance tracking of the application by recording traces.
|
|
71
|
+
* - `location`: Allows a user’s location (country, city area) to be recorded.
|
|
72
|
+
* - `remote-config`: Allows users to download remote config from the server.
|
|
73
|
+
*/
|
|
74
|
+
export type CountlyConsentFeatures = 'sessions' | 'events' | 'views' | 'scrolls' | 'clicks' | 'forms' | 'crashes' | 'attribution' | 'users' | 'star-rating' | 'feedback' | 'location' | 'remote-config' | 'apm';
|
|
75
|
+
//# sourceMappingURL=countly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countly.d.ts","sourceRoot":"","sources":["../src/countly.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,CAAC,EAAE;QACD,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,GAAG,GAAG,CAAC,KAAK,IAAI,CAAC;KAC3C,CAAC;IAEF,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,GAAG,EAAE,MAAM,CAAC;IAEZ,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,OAAO,CAAC;IAEf,WAAW,EAAE,OAAO,CAAC;IAErB,QAAQ,EAAE,MAAM,CAAC;IAEjB,UAAU,EAAE,MAAM,CAAC;IAEnB,YAAY,EAAE,MAAM,CAAC;IAErB,eAAe,EAAE,MAAM,CAAC;IAExB,cAAc,EAAE,MAAM,CAAC;IAEvB,UAAU,EAAE,MAAM,CAAC;IAEnB,oBAAoB,EAAE,MAAM,CAAC;IAE7B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAE3B,aAAa,EAAE,MAAM,CAAC;IAEtB,eAAe,EAAE,OAAO,CAAC;IAEzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,UAAU,EAAE,OAAO,CAAC;IAEpB,cAAc,EAAE,OAAO,CAAC;IAExB,eAAe,EAAE,OAAO,CAAC;IAEzB,GAAG,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAC,CAAC;IAE9B,kBAAkB,EAAE,OAAO,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAC;IAE/B,aAAa,EAAE,OAAO,CAAC;IAEvB,yBAAyB,EAAE,OAAO,CAAC;IAEnC,mBAAmB,EAAE,OAAO,CAAC;IAE7B,SAAS,EAAE,MAAM,CAAC;IAElB,aAAa,EAAE,OAAO,CAAC;IAEvB,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAC;IAEjC,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;IAC7C;;;;OAIG;IACH,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IAE9B,IAAI,EAAE,MAAM,IAAI,CAAC;IAEjB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,WAAW,GACX,WAAW,GACX,eAAe,GACf,aAAa,GACb,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,cAAc,GACd,eAAe,CAAC;AAEpB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,QAAQ,GACR,OAAO,GACP,SAAS,GACT,QAAQ,GACR,OAAO,GACP,SAAS,GACT,aAAa,GACb,OAAO,GACP,aAAa,GACb,UAAU,GACV,UAAU,GACV,eAAe,GACf,KAAK,CAAC"}
|
package/lib/embed.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/embed.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../src/embed.ts"],"names":[],"mappings":""}
|
package/lib/embed.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
(function(ma,L){"object"===typeof exports&&"undefined"!==typeof module?L(exports):"function"===typeof define&&define.amd?define(["exports"],L):(ma="undefined"!==typeof globalThis?globalThis:ma||self,L(ma.Countly=ma.Countly||{}))})(this,function(ma){function L(l){"@babel/helpers - typeof";return L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(k){return typeof k}:function(k){return k&&"function"==typeof Symbol&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},L(l)}
|
|
2
|
+
function zb(l,k){for(var q=0;q<k.length;q++){var t=k[q];t.enumerable=t.enumerable||!1;t.configurable=!0;"value"in t&&(t.writable=!0);Object.defineProperty(l,Wb(t.key),t)}}function Wb(l){a:if("object"===typeof l&&null!==l){var k=l[Symbol.toPrimitive];if(void 0!==k){l=k.call(l,"string");if("object"!==typeof l)break a;throw new TypeError("@@toPrimitive must return a primitive value.");}l=String(l)}return"symbol"===typeof l?l:String(l)}function Ab(l){var k=[];if("undefined"!==typeof l.options)for(var q=
|
|
3
|
+
0;q<l.options.length;q++)l.options[q].selected&&k.push(l.options[q].value);return k.join(", ")}function fb(){var l=Bb("xxxxxxxx","[x]");var k=Date.now().toString();return l+k}function gb(){return Bb("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx","[xy]")}function Bb(l,k){var q=(new Date).getTime();return l.replace(new RegExp(k,"g"),function(t){var C=(q+16*Math.random())%16|0;return("x"===t?C:C&3|8).toString(16)})}function F(){return Math.floor((new Date).getTime()/1E3)}function hb(){var l=(new Date).getTime();
|
|
4
|
+
Pa>=l?Pa++:Pa=l;return Pa}function u(l,k,q){if(k&&Object.keys(k).length){if("undefined"!==typeof k[l])return k[l]}else if("undefined"!==typeof p[l])return p[l];return q}function ib(l,k,q){for(var t in p.i)p.i[t].tracking_crashes&&p.i[t].recordError(l,k,q)}function jb(l,k){var q=[],t;for(t in l)q.push(t+"="+encodeURIComponent(l[t]));var C=q.join("&");return k?Cb(C,k).then(function(O){return C+="&checksum256="+O}):Promise.resolve(C)}function ta(l){return"string"===typeof l&&"/"===l.substring(l.length-
|
|
5
|
+
1)?l.substring(0,l.length-1):l}function za(l,k){for(var q={},t,C=0,O=k.length;C<O;C++)t=k[C],"undefined"!==typeof l[t]&&(q[t]=l[t]);return q}function ba(l,k,q,t,C,O){var Q={};if(l){if(Object.keys(l).length>t){var W={},Aa=0,na;for(na in l)Aa<t&&(W[na]=l[na],Aa++);l=W}for(var Ba in l)t=z(Ba,k,C,O),W=z(l[Ba],q,C,O),Q[t]=W}return Q}function z(l,k,q,t){var C=l;"number"===typeof l&&(l=l.toString());"string"===typeof l&&l.length>k&&(C=l.substring(0,k),t(c.DEBUG,q+", Key: [ "+l+" ] is longer than accepted length. It will be truncated."));
|
|
6
|
+
return C}function Cb(l,k){l=(new TextEncoder).encode(l+k);return crypto.subtle.digest("SHA-256",l).then(function(q){return Array.from(new Uint8Array(q)).map(function(t){return t.toString(16).padStart(2,"0")}).join("")})}function A(l,k,q){x&&(null===l||"undefined"===typeof l?Ca()&&console.warn("[WARNING] [Countly] add_event_listener, Can't bind ["+k+"] event to nonexisting element"):"undefined"!==typeof l.addEventListener?l.addEventListener(k,q,!1):l.attachEvent("on"+k,q))}function Qa(l){return l?
|
|
7
|
+
"undefined"!==typeof l.target?l.target:l.srcElement:window.event.srcElement}function ua(l){if(l)return l;(l=navigator.userAgent)||(l=kb());return l}function kb(l){if(l)return l;l="";navigator.userAgentData&&(l=navigator.userAgentData.brands.map(function(k){return k.brand+":"+k.version}).join(),l+=navigator.userAgentData.mobile?" mobi ":" ",l+=navigator.userAgentData.platform);return l}function Db(l){if(!l){if(navigator.userAgentData&&navigator.userAgentData.mobile)return"phone";l=ua()}l=l.toLowerCase();
|
|
8
|
+
var k="desktop",q=/(mobi|ipod|phone|blackberry|opera mini|fennec|minimo|symbian|psp|nintendo ds|archos|skyfire|puffin|blazer|bolt|gobrowser|iris|maemo|semc|teashark|uzard)/;/(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(l)?k="tablet":q.test(l)&&(k="phone");return k}function Eb(l){var k=/(CountlySiteBot|nuhk|Googlebot|GoogleSecurityScanner|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver|bingbot|Google Web Preview|Mediapartners-Google|AdsBot-Google|Baiduspider|Ezooms|YahooSeeker|AltaVista|AVSearch|Mercator|Scooter|InfoSeek|Ultraseek|Lycos|Wget|YandexBot|Yandex|YaDirectFetcher|SiteBot|Exabot|AhrefsBot|MJ12bot|TurnitinBot|magpie-crawler|Nutch Crawler|CMS Crawler|rogerbot|Domnutch|ssearch_bot|XoviBot|netseer|digincore|fr-crawler|wesee|AliasIO|contxbot|PingdomBot|BingPreview|HeadlessChrome|Lighthouse)/;
|
|
9
|
+
if(l)return k.test(l);l=k.test(ua());k=k.test(kb());return l||k}function lb(l){"undefined"===typeof l.pageY&&"number"===typeof l.clientX&&document.documentElement&&(l.pageX=l.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l.pageY=l.clientY+document.body.scrollTop+document.documentElement.scrollTop);return l}function Ra(){var l=document;return Math.max(Math.max(l.body.scrollHeight,l.documentElement.scrollHeight),Math.max(l.body.offsetHeight,l.documentElement.offsetHeight),Math.max(l.body.clientHeight,
|
|
10
|
+
l.documentElement.clientHeight))}function mb(){var l=document;return Math.max(Math.max(l.body.scrollWidth,l.documentElement.scrollWidth),Math.max(l.body.offsetWidth,l.documentElement.offsetWidth),Math.max(l.body.clientWidth,l.documentElement.clientWidth))}function Fb(){var l=document;return Math.min(Math.min(l.body.clientHeight,l.documentElement.clientHeight),Math.min(l.body.offsetHeight,l.documentElement.offsetHeight),window.innerHeight)}function Gb(l,k,q,t,C,O){l=document.createElement(l);var Q;
|
|
11
|
+
l.setAttribute(k,q);l.setAttribute(t,C);k=function(){Q||O();Q=!0};O&&(l.onreadystatechange=k,l.onload=k);document.getElementsByTagName("head")[0].appendChild(l)}function Hb(l,k){Gb("script","type","text/javascript","src",l,k)}function Sa(l,k){Gb("link","rel","stylesheet","href",l,k)}function Ib(){if(x){var l=document.getElementById("cly-loader");if(!l){var k=document.head||document.getElementsByTagName("head")[0],q=document.createElement("style");q.type="text/css";q.styleSheet?q.styleSheet.cssText=
|
|
12
|
+
"#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}":q.appendChild(document.createTextNode("#cly-loader {height: 4px; width: 100%; position: absolute; z-index: 99999; overflow: hidden; background-color: #fff; top:0px; left:0px;}#cly-loader:before{display: block; position: absolute; content: ''; left: -200px; width: 200px; height: 4px; background-color: #2EB52B; animation: cly-loading 2s linear infinite;}@keyframes cly-loading { from {left: -200px; width: 30%;} 50% {width: 30%;} 70% {width: 70%;} 80% { left: 50%;} 95% {left: 120%;} to {left: 100%;}}"));
|
|
13
|
+
k.appendChild(q);l=document.createElement("div");l.setAttribute("id","cly-loader");document.body.onload=function(){if(p.showLoaderProtection)Ca()&&console.warn("[WARNING] [Countly] showloader, Loader is already on");else try{document.body.appendChild(l)}catch(t){Ca()&&console.error("[ERROR] [Countly] showLoader, Body is not loaded for loader to append: "+t)}}}l.style.display="block"}}function Ca(){return p&&p.debug&&"undefined"!==typeof console?!0:!1}function Jb(){if(x){p.showLoaderProtection=!0;
|
|
14
|
+
var l=document.getElementById("cly-loader");l&&(l.style.display="none")}}function Xb(l){var k=document.createElement("script"),q=document.createElement("script");k.async=!0;q.async=!0;k.src=p.customSourceBoomerang||Kb.BOOMERANG_SRC;q.src=p.customSourceCountlyBoomerang||Kb.CLY_BOOMERANG_SRC;document.getElementsByTagName("head")[0].appendChild(k);document.getElementsByTagName("head")[0].appendChild(q);var t=!1,C=!1;k.onload=function(){t=!0};q.onload=function(){C=!0};var O=0,Q=setInterval(function(){O+=
|
|
15
|
+
50;if(t&&C||1500<=O){if(p.debug){var W="BoomerangJS loaded:["+t+"], countly_boomerang loaded:["+C+"].";t&&C?console.log("[DEBUG] "+W):console.warn("[WARNING] "+W+" Initializing without APM.")}p.init(l);clearInterval(Q)}},50)}var M={NPS:"[CLY]_nps",SURVEY:"[CLY]_survey",STAR_RATING:"[CLY]_star_rating",VIEW:"[CLY]_view",ORIENTATION:"[CLY]_orientation",ACTION:"[CLY]_action"},Yb=Object.values(M),c={ERROR:"[ERROR] ",WARNING:"[WARNING] ",INFO:"[INFO] ",DEBUG:"[DEBUG] ",VERBOSE:"[VERBOSE] "},Kb={BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/boomerang.min.js",
|
|
16
|
+
CLY_BOOMERANG_SRC:"https://cdn.jsdelivr.net/npm/countly-sdk-web@latest/plugin/boomerang/countly_boomerang.js"},U=Object.freeze({errorCount:"cly_hc_error_count",warningCount:"cly_hc_warning_count",statusCode:"cly_hc_status_code",errorMessage:"cly_hc_error_message"}),Lb=/^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?::([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?::([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,x="undefined"!==typeof window,p=globalThis.Countly||{},
|
|
17
|
+
Pa=0,Ub=function(l,k,q){k&&zb(l.prototype,k);q&&zb(l,q);Object.defineProperty(l,"prototype",{writable:!1});return l}(function q(k){function t(a,d){if(f.ignore_visitor)b(c.ERROR,"Adding event failed. Possible bot or user opt out");else if(a.key){a.count||(a.count=1);Yb.includes(a.key)||(a.key=z(a.key,f.maxKeyLength,"add_cly_event",b));a.segmentation=ba(a.segmentation,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"add_cly_event",b);a=za(a,["key","count","sum","dur","segmentation"]);a.timestamp=
|
|
18
|
+
hb();var e=new Date;a.hour=e.getHours();a.dow=e.getDay();a.id=d||fb();a.key===M.VIEW?a.pvid=Da||"":a.cvid=ia||"";I.push(a);w("cly_event",I);b(c.INFO,"With event ID: ["+a.id+"], successfully adding the last event:",a)}else b(c.ERROR,"Adding event failed. Event must have a key property")}function C(a,d,e,h,m){b(c.INFO,"fetch_remote_config_explicit, Fetching sequence initiated");var g={method:"rc",av:f.app_version};a&&(g.keys=JSON.stringify(a));d&&(g.omit_keys=JSON.stringify(d));var n;"legacy"===h&&
|
|
19
|
+
(g.method="fetch_remote_config");0===e&&(g.oi=0);1===e&&(g.oi=1);"function"===typeof m&&(n=m);f.check_consent("sessions")&&(g.metrics=JSON.stringify(Ta()));f.check_consent("remote-config")?(Ea(g),ca("fetch_remote_config_explicit",f.url+Ua,g,function(r,v,G){if(!r){try{var N=JSON.parse(G);if(g.keys||g.omit_keys)for(var J in N)S[J]=N[J];else S=N;w("cly_remote_configs",S)}catch(Fa){b(c.ERROR,"fetch_remote_config_explicit, Had an issue while parsing the response: "+Fa)}n&&(b(c.INFO,"fetch_remote_config_explicit, Callback function is provided"),
|
|
20
|
+
n(r,S))}},!0)):(b(c.ERROR,"fetch_remote_config_explicit, Remote config requires explicit consent"),n&&n(Error("Remote config requires explicit consent"),S))}function O(){b(c.INFO,"checkIgnore, Checking if user or visit should be ignored");f.ignore_prefetch&&x&&"undefined"!==typeof document.visibilityState&&"prerender"===document.visibilityState&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to prerendering"));f.ignore_bots&&Eb()&&(f.ignore_visitor=!0,b(c.DEBUG,"checkIgnore, Ignoring visit due to bot"))}
|
|
21
|
+
function Q(){0<I.length&&(b(c.DEBUG,"Flushing events"),P({events:JSON.stringify(I)}),I=[],w("cly_event",I))}function W(a,d){if(x)if(document.getElementById("countly-feedback-sticker-"+a._id))b(c.ERROR,"Widget with same ID exists");else try{var e=document.createElement("div");e.className="countly-iframe-wrapper";e.id="countly-iframe-wrapper-"+a._id;var h=document.createElement("span");h.className="countly-feedback-close-icon";h.id="countly-feedback-close-icon-"+a._id;h.innerText="x";var m=document.createElement("iframe");
|
|
22
|
+
m.name="countly-feedback-iframe";m.id="countly-feedback-iframe";m.src=f.url+"/feedback?widget_id="+a._id+"&app_key="+f.app_key+"&device_id="+f.device_id+"&sdk_version="+oa;document.body.appendChild(e);e.appendChild(h);e.appendChild(m);A(document.getElementById("countly-feedback-close-icon-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="none";document.getElementById("cfbg").style.display="none"});if(d){var g=document.createElementNS("http://www.w3.org/2000/svg",
|
|
23
|
+
"svg");g.id="feedback-sticker-svg";g.setAttribute("aria-hidden","true");g.setAttribute("data-prefix","far");g.setAttribute("data-icon","grin");g.setAttribute("class","svg-inline--fa fa-grin fa-w-16");g.setAttribute("role","img");g.setAttribute("xmlns","http://www.w3.org/2000/svg");g.setAttribute("viewBox","0 0 496 512");var n=document.createElementNS("http://www.w3.org/2000/svg","path");n.id="smileyPathInStickerSvg";n.setAttribute("fill","white");n.setAttribute("d","M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm105.6-151.4c-25.9 8.3-64.4 13.1-105.6 13.1s-79.6-4.8-105.6-13.1c-9.9-3.1-19.4 5.4-17.7 15.3 7.9 47.1 71.3 80 123.3 80s115.3-32.9 123.3-80c1.6-9.8-7.7-18.4-17.7-15.3zM168 240c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32z");
|
|
24
|
+
var r=document.createElement("span");r.innerText=a.trigger_button_text;var v=document.createElement("div");v.style.color=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color;v.style.backgroundColor=7>a.trigger_bg_color.length?"#"+a.trigger_bg_color:a.trigger_bg_color;v.className="countly-feedback-sticker "+a.trigger_position+"-"+a.trigger_size;v.id="countly-feedback-sticker-"+a._id;g.appendChild(n);v.appendChild(g);v.appendChild(r);document.body.appendChild(v);var G=document.getElementById("smileyPathInStickerSvg");
|
|
25
|
+
G&&(G.style.fill=7>a.trigger_font_color.length?"#"+a.trigger_font_color:a.trigger_font_color);A(document.getElementById("countly-feedback-sticker-"+a._id),"click",function(){document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block";document.getElementById("cfbg").style.display="block"})}else document.getElementById("countly-iframe-wrapper-"+a._id).style.display="block",document.getElementById("cfbg").style.display="block"}catch(N){b(c.ERROR,"Somethings went wrong while element injecting process: "+
|
|
26
|
+
N)}else b(c.WARNING,"processWidget, window object is not available. Not processing widget.")}function Aa(){var a;if("undefined"!==typeof f.onload&&0<f.onload.length){for(a=0;a<f.onload.length;a++)if("function"===typeof f.onload[a])f.onload[a](f);f.onload=[]}}function na(){if(Y){var a={name:Y};f.check_consent("views")&&(t({key:M.VIEW,dur:pa?F()-Ga:Ha,segmentation:a},ia),Y=null)}}function Ba(){if(ja){var a=y("cly_session");if(!a||parseInt(a)<=F())X=!1,f.begin_session(!Ia);w("cly_session",F()+60*Ja)}}
|
|
27
|
+
function Ea(a){a.app_key=f.app_key;a.device_id=f.device_id;a.sdk_name=va;a.sdk_version=oa;a.t=D;a.av=f.app_version;var d=Mb();if(a.metrics){var e=JSON.parse(a.metrics);e._ua||(e._ua=d,a.metrics=JSON.stringify(e))}else a.metrics=JSON.stringify({_ua:d});f.check_consent("location")?(f.country_code&&(a.country_code=f.country_code),f.city&&(a.city=f.city),null!==f.ip_address&&(a.ip_address=f.ip_address)):a.location="";a.timestamp=hb();d=new Date;a.hour=d.getHours();a.dow=d.getDay()}function P(a){f.ignore_visitor?
|
|
28
|
+
b(c.WARNING,"User is opt_out will ignore the request: "+a):f.app_key&&f.device_id?(Ea(a),H.length>Va&&H.shift(),H.push(a),w("cly_queue",H,!0)):b(c.ERROR,"app_key or device_id is missing ",f.app_key,f.device_id)}function Wa(){Aa();if(f.ignore_visitor)Xa=!1,b(c.WARNING,"User opt_out, no heartbeat");else{Xa=!0;Ya&&"undefined"!==typeof p.q&&0<p.q.length&&wa();if(X&&Ia&&pa){var a=F();a-ka>Za&&(f.session_duration(a-ka),ka=a,0<f.hcErrorCount&&w(U.errorCount,f.hcErrorCount),0<f.hcWarningCount&&w(U.warningCount,
|
|
29
|
+
f.hcWarningCount))}0<I.length&&!f.test_mode_eq&&(I.length<=Ka?(P({events:JSON.stringify(I)}),I=[]):(a=I.splice(0,Ka),P({events:JSON.stringify(a)})),w("cly_event",I));!K&&0<H.length&&$a&&F()>nb&&($a=!1,a=H[0],a.rr=H.length,b(c.DEBUG,"Processing request",a),w("cly_queue",H,!0),f.test_mode||ca("send_request_queue",f.url+ob,a,function(d,e){d?nb=F()+ab:H.shift();w("cly_queue",H,!0);$a=!0},!1));setTimeout(Wa,bb)}}function wa(){if("undefined"===typeof p||"undefined"===typeof p.i)b(c.DEBUG,"Countly is not finished initialization yet, will process the queue after initialization is done");
|
|
30
|
+
else{var a=p.q;p.q=[];for(var d=0;d<a.length;d++){var e=a[d];b(c.DEBUG,"Processing queued calls:"+e);if("function"===typeof e)e();else if(Array.isArray(e)&&0<e.length){var h=f,m=0;try{p.i[e[m]]&&(h=p.i[e[m]],m++)}catch(n){b(c.DEBUG,"No instance found for the provided key while processing async queue");p.q.push(e);continue}if("function"===typeof h[e[m]])h[e[m]].apply(h,e.slice(m+1));else if(0===e[m].indexOf("userData.")){var g=e[m].replace("userData.","");"function"===typeof h.userData[g]&&h.userData[g].apply(h,
|
|
31
|
+
e.slice(m+1))}else"function"===typeof p[e[m]]&&p[e[m]].apply(p,e.slice(m+1))}}}}function pb(){var a=y("cly_id");return a?(D=y("cly_id_type"),a):gb()}function Mb(){return f.metrics._ua||ua()}function Ta(){var a=JSON.parse(JSON.stringify(f.metrics||{}));a._app_version=a._app_version||f.app_version;a._ua=a._ua||ua();if(x&&screen.width){var d=screen.width?parseInt(screen.width):0,e=screen.height?parseInt(screen.height):0;if(0!==d&&0!==e){if(navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)&&
|
|
32
|
+
window.devicePixelRatio)d=Math.round(d*window.devicePixelRatio),e=Math.round(e*window.devicePixelRatio);else if(90===Math.abs(window.orientation)){var h=d;d=e;e=h}a._resolution=a._resolution||""+d+"x"+e}}x&&window.devicePixelRatio&&(a._density=a._density||window.devicePixelRatio);d=navigator.language||navigator.browserLanguage||navigator.systemLanguage||navigator.userLanguage;"undefined"!==typeof d&&(a._locale=a._locale||d);qb()&&(a._store=a._store||document.referrer);b(c.DEBUG,"Got metrics",a);return a}
|
|
33
|
+
function qb(a){if(!x)return!1;a=a||document.referrer;var d=!1;if("undefined"===typeof a||0===a.length)b(c.DEBUG,"Invalid referrer:["+a+"], ignoring.");else{var e=Lb.exec(a);if(e)if(e[11])if(e[11]===window.location.hostname)b(c.DEBUG,"Referrer is current host:["+a+"], ignoring.");else if(da&&da.length)for(d=!0,e=0;e<da.length;e++){if(0<=a.indexOf(da[e])){b(c.DEBUG,"Referrer in ignore list:["+a+"], ignoring.");d=!1;break}}else b(c.DEBUG,"Valid referrer:["+a+"]"),d=!0;else b(c.DEBUG,"No path found in referrer:["+
|
|
34
|
+
a+"], ignoring.");else b(c.DEBUG,"Referrer is corrupt:["+a+"], ignoring.")}return d}function b(a,d){if(f.debug&&"undefined"!==typeof console){arguments[2]&&"object"===L(arguments[2])&&(arguments[2]=JSON.stringify(arguments[2]));Ya||(d="["+f.app_key+"] "+d);a||(a=c.DEBUG);for(var e="",h=2;h<arguments.length;h++)e+=arguments[h];e=a+"[Countly] "+d+e;a===c.ERROR?(console.error(e),qa.incrementErrorCount()):a===c.WARNING?(console.warn(e),qa.incrementWarningCount()):a===c.INFO?console.info(e):a===c.VERBOSE?
|
|
35
|
+
console.log(e):console.debug(e)}}function ca(a,d,e,h,m){x?Nb(a,d,e,h,m):Ob(a,d,e,h,m)}function Nb(a,d,e,h,m){m=m||!1;try{b(c.DEBUG,"Sending XML HTTP request");var g=new XMLHttpRequest;e=e||{};jb(e,f.salt).then(function(n){var r="GET";if(f.force_post||2E3<=n.length)r="POST";"GET"===r?g.open("GET",d+"?"+n,!0):(g.open("POST",d,!0),g.setRequestHeader("Content-type","application/x-www-form-urlencoded"));for(var v in f.headers)g.setRequestHeader(v,f.headers[v]);g.onreadystatechange=function(){4===this.readyState&&
|
|
36
|
+
(b(c.DEBUG,a+" HTTP request completed with status code: ["+this.status+"] and response: ["+this.responseText+"]"),(m?rb(this.status,this.responseText):sb(this.status,this.responseText))?"function"===typeof h&&h(!1,e,this.responseText):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(this.status,this.responseText),"function"===typeof h&&h(!0,e,this.status,this.responseText)))};"GET"===r?g.send():g.send(n)})}catch(n){b(c.ERROR,a+" Something went wrong while making an XML HTTP request: "+
|
|
37
|
+
n),"function"===typeof h&&h(!0,e)}}function Ob(a,d,e,h,m){m=m||!1;var g;try{b(c.DEBUG,"Sending Fetch request");var n="GET",r={"Content-type":"application/x-www-form-urlencoded"},v=null;e=e||{};jb(e,f.salt).then(function(G){f.force_post||2E3<=G.length?(n="POST",v=G):d+="?"+G;for(var N in f.headers)r[N]=f.headers[N];fetch(d,{method:n,headers:r,body:v}).then(function(J){g=J;return g.text()}).then(function(J){b(c.DEBUG,a+" Fetch request completed wit status code: ["+g.status+"] and response: ["+J+"]");
|
|
38
|
+
(m?rb(g.status,J):sb(g.status,J))?"function"===typeof h&&h(!1,e,J):(b(c.ERROR,a+" Invalid response from server"),"send_request_queue"===a&&qa.saveRequestCounters(g.status,J),"function"===typeof h&&h(!0,e,g.status,J))})["catch"](function(J){b(c.ERROR,a+" Failed Fetch request: "+J);"function"===typeof h&&h(!0,e)})})}catch(G){b(c.ERROR,a+" Something went wrong with the Fetch request attempt: "+G),"function"===typeof h&&h(!0,e)}}function sb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+
|
|
39
|
+
a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"!==Object.prototype.toString.call(e)?(b(c.ERROR,"Http response is not JSON Object"),!1):!!e.result}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function rb(a,d){if(!(200<=a&&300>a))return b(c.ERROR,"Http response status code:["+a+"] is not within the expected range"),!1;try{var e=JSON.parse(d);return"[object Object]"===Object.prototype.toString.call(e)||Array.isArray(e)?!0:(b(c.ERROR,"Http response is not JSON Object nor JSON Array"),
|
|
40
|
+
!1)}catch(h){return b(c.ERROR,"Http response is not JSON: "+h),!1}}function Pb(){x?La=Math.max(La,window.scrollY,document.body.scrollTop,document.documentElement.scrollTop):b(c.WARNING,"processScroll, window object is not available. Not processing scroll.")}function tb(){if(!x)b(c.WARNING,"processScrollView, window object is not available. Not processing scroll view.");else if(Ma){Ma=!1;var a=Ra(),d=mb(),e=Fb();f.check_consent("scrolls")&&(a={type:"scroll",y:La+e,width:d,height:a,view:f.getViewUrl()},
|
|
41
|
+
a=ba(a,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processScrollView",b),f.track_domains&&(a.domain=window.location.hostname),t({key:M.ACTION,segmentation:a}))}}function Qb(a){w("cly_token",a)}function Rb(a,d,e){var h=new Date;h.setTime(h.getTime()+864E5*e);e="; expires="+h.toGMTString();document.cookie=a+"="+d+e+"; path=/"}function y(a,d,e){if("none"===f.storage||"object"!==L(f.storage)&&!x)b(c.DEBUG,"Storage is disabled. Value with key: ["+a+"] won't be retrieved");else{e||(a=f.app_key+
|
|
42
|
+
"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a));if("object"===L(f.storage)&&"function"===typeof f.storage.getItem){var h=f.storage.getItem(a);return a.endsWith("cly_id")?h:f.deserialize(h)}void 0===d&&(d=ra);if(d)h=localStorage.getItem(a);else if("localstorage"!==f.storage)a:{d=a+"=";e=document.cookie.split(";");h=0;for(var m=e.length;h<m;h++){for(var g=e[h];" "===g.charAt(0);)g=g.substring(1,g.length);if(0===g.indexOf(d)){h=g.substring(d.length,g.length);break a}}h=null}return a.endsWith("cly_id")?
|
|
43
|
+
h:f.deserialize(h)}}function w(a,d,e,h){"none"===f.storage||"object"!==L(f.storage)&&!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be stored"):(h||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"undefined"!==typeof d&&null!==d&&("object"===L(f.storage)&&"function"===typeof f.storage.setItem?f.storage.setItem(a,d):(void 0===e&&(e=ra),d=f.serialize(d),e?localStorage.setItem(a,d):"localstorage"!==f.storage&&Rb(a,d,30))))}function T(a,d,e){"none"===f.storage||"object"!==L(f.storage)&&
|
|
44
|
+
!x?b(c.DEBUG,"Storage is disabled. Value with key: "+a+" won't be removed"):(e||(a=f.app_key+"/"+a,f.namespace&&(a=ta(f.namespace)+"/"+a)),"object"===L(f.storage)&&"function"===typeof f.storage.removeItem?f.storage.removeItem(a):(void 0===d&&(d=ra),d?localStorage.removeItem(a):"localstorage"!==f.storage&&Rb(a,"",-1)))}function Zb(){if(y(f.namespace+"cly_id",!1,!0)){w("cly_id",y(f.namespace+"cly_id",!1,!0));w("cly_id_type",y(f.namespace+"cly_id_type",!1,!0));w("cly_event",y(f.namespace+"cly_event",
|
|
45
|
+
!1,!0));w("cly_session",y(f.namespace+"cly_session",!1,!0));var a=y(f.namespace+"cly_queue",!1,!0);Array.isArray(a)&&(a=a.filter(function(d){return d.app_key===f.app_key}),w("cly_queue",a));y(f.namespace+"cly_cmp_id",!1,!0)&&(w("cly_cmp_id",y(f.namespace+"cly_cmp_id",!1,!0)),w("cly_cmp_uid",y(f.namespace+"cly_cmp_uid",!1,!0)));y(f.namespace+"cly_ignore",!1,!0)&&w("cly_ignore",y(f.namespace+"cly_ignore",!1,!0));T("cly_id",!1,!0);T("cly_id_type",!1,!0);T("cly_event",!1,!0);T("cly_session",!1,!0);T("cly_queue",
|
|
46
|
+
!1,!0);T("cly_cmp_id",!1,!0);T("cly_cmp_uid",!1,!0);T("cly_ignore",!1,!0)}}if(!(this instanceof q))throw new TypeError("Cannot call a class as a function");var f=this,Ya=!p.i,X=!1,ob="/i",Ua="/o/sdk",bb=u("interval",k,500),Va=u("queue_size",k,1E3),H=[],I=[],S={},sa=[],ea={},da=u("ignore_referrers",k,[]),ub=null,Ia=!0,ka,vb=0,Y=null,Ga=0,Ha=0,nb=0,ab=u("fail_timeout",k,60),Na=u("inactivity_time",k,20),Oa=0,Za=u("session_update",k,60),Ka=u("max_events",k,100),xa=u("max_logs",k,null),ja=u("use_session_cookie",
|
|
47
|
+
k,!0),Ja=u("session_cookie_timeout",k,30),$a=!0,Xa=!1,K=u("offline_mode",k,!1),fa={},pa=!0,Sb=F(),ra=!0,ya=null,D=1,Ma=!1,La=0,wb=!1,ia=null,Da=null,la=null,va=u("sdk_name",k,"javascript_native_web"),oa=u("sdk_version",k,"24.4.1");try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(a){b(c.ERROR,"Local storage test failed, Halting local storage support: "+a),ra=!1}for(var E={},xb=0;xb<p.features.length;xb++)E[p.features[xb]]={};this.initialize=function(){this.serialize=
|
|
48
|
+
u("serialize",k,p.serialize);this.deserialize=u("deserialize",k,p.deserialize);this.getViewName=u("getViewName",k,p.getViewName);this.getViewUrl=u("getViewUrl",k,p.getViewUrl);this.getSearchQuery=u("getSearchQuery",k,p.getSearchQuery);this.DeviceIdType=p.DeviceIdType;this.namespace=u("namespace",k,"");this.clearStoredId=u("clear_stored_id",k,!1);this.app_key=u("app_key",k,null);this.onload=u("onload",k,[]);this.utm=u("utm",k,{source:!0,medium:!0,campaign:!0,term:!0,content:!0});this.ignore_prefetch=
|
|
49
|
+
u("ignore_prefetch",k,!0);this.rcAutoOptinAb=u("rc_automatic_optin_for_ab",k,!0);this.useExplicitRcApi=u("use_explicit_rc_api",k,!1);this.debug=u("debug",k,!1);this.test_mode=u("test_mode",k,!1);this.test_mode_eq=u("test_mode_eq",k,!1);this.metrics=u("metrics",k,{});this.headers=u("headers",k,{});this.url=ta(u("url",k,""));this.app_version=u("app_version",k,"0.0");this.country_code=u("country_code",k,null);this.city=u("city",k,null);this.ip_address=u("ip_address",k,null);this.ignore_bots=u("ignore_bots",
|
|
50
|
+
k,!0);this.force_post=u("force_post",k,!1);this.remote_config=u("remote_config",k,!1);this.ignore_visitor=u("ignore_visitor",k,!1);this.require_consent=u("require_consent",k,!1);this.track_domains=x?u("track_domains",k,!0):void 0;this.storage=u("storage",k,"default");this.enableOrientationTracking=x?u("enable_orientation_tracking",k,!0):void 0;this.maxKeyLength=u("max_key_length",k,128);this.maxValueSize=u("max_value_size",k,256);this.maxSegmentationValues=u("max_segmentation_values",k,100);this.maxBreadcrumbCount=
|
|
51
|
+
u("max_breadcrumb_count",k,null);this.maxStackTraceLinesPerThread=u("max_stack_trace_lines_per_thread",k,30);this.maxStackTraceLineLength=u("max_stack_trace_line_length",k,200);this.heatmapWhitelist=u("heatmap_whitelist",k,[]);f.salt=u("salt",k,null);f.hcErrorCount=y(U.errorCount)||0;f.hcWarningCount=y(U.warningCount)||0;f.hcStatusCode=y(U.statusCode)||-1;f.hcErrorMessage=y(U.errorMessage)||"";xa&&!this.maxBreadcrumbCount?(this.maxBreadcrumbCount=xa,b(c.WARNING,"initialize, 'maxCrashLogs' is deprecated. Use 'maxBreadcrumbCount' instead!")):
|
|
52
|
+
xa||this.maxBreadcrumbCount||(this.maxBreadcrumbCount=100);"cookie"===this.storage&&(ra=!1);this.rcAutoOptinAb||this.useExplicitRcApi||(b(c.WARNING,"initialize, Auto opting is disabled, switching to explicit RC API"),this.useExplicitRcApi=!0);Array.isArray(da)||(da=[]);""===this.url&&(b(c.ERROR,"initialize, Please provide server URL"),this.ignore_visitor=!0);y("cly_ignore")&&(this.ignore_visitor=!0);Zb();H=y("cly_queue")||[];I=y("cly_event")||[];S=y("cly_remote_configs")||{};this.clearStoredId&&(y("cly_id")&&
|
|
53
|
+
!g&&(this.device_id=y("cly_id"),b(c.DEBUG,"initialize, temporarily using the previous device ID to flush existing events"),D=y("cly_id_type"),D||(b(c.DEBUG,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED, for event flushing"),D=0),Q(),this.device_id=void 0,D=1),b(c.INFO,"initialize, Clearing the device ID storage"),T("cly_id"),T("cly_id_type"),T("cly_session"));O();if(x)if(window.name&&0===window.name.indexOf("cly:"))try{this.passed_data=JSON.parse(window.name.replace("cly:",
|
|
54
|
+
""))}catch(r){b(c.ERROR,"initialize, Could not parse name: "+window.name+", error: "+r)}else if(location.hash&&0===location.hash.indexOf("#cly:"))try{this.passed_data=JSON.parse(location.hash.replace("#cly:",""))}catch(r){b(c.ERROR,"initialize, Could not parse hash: "+location.hash+", error: "+r)}if((this.passed_data&&this.passed_data.app_key&&this.passed_data.app_key===this.app_key||this.passed_data&&!this.passed_data.app_key&&Ya)&&this.passed_data.token&&this.passed_data.purpose){this.passed_data.token!==
|
|
55
|
+
y("cly_old_token")&&(Qb(this.passed_data.token),w("cly_old_token",this.passed_data.token));var a=[];Array.isArray(this.heatmapWhitelist)?(this.heatmapWhitelist.push(this.url),a=this.heatmapWhitelist.map(function(r){return ta(r)})):a=[this.url];a.includes(this.passed_data.url)&&"heatmap"===this.passed_data.purpose&&(this.ignore_visitor=!0,Ib(),Hb(this.passed_data.url+"/views/heatmap.js",Jb))}if(this.ignore_visitor)b(c.WARNING,"initialize, ignore_visitor:["+this.ignore_visitor+"], this user will not be tracked");
|
|
56
|
+
else{"javascript_native_web"===va&&"24.4.1"===oa?b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"]"):b(c.DEBUG,"initialize, SDK name:["+va+"], version:["+oa+"], default name:[javascript_native_web] and default version:[24.4.1]");b(c.DEBUG,"initialize, app_key:["+this.app_key+"], url:["+this.url+"]");b(c.DEBUG,"initialize, device_id:["+u("device_id",k,void 0)+"]");b(c.DEBUG,"initialize, require_consent is enabled:["+this.require_consent+"]");try{b(c.DEBUG,"initialize, metric override:["+JSON.stringify(this.metrics)+
|
|
57
|
+
"]"),b(c.DEBUG,"initialize, header override:["+JSON.stringify(this.headers)+"]"),b(c.DEBUG,"initialize, number of onload callbacks provided:["+this.onload.length+"]"),b(c.DEBUG,"initialize, utm tags:["+JSON.stringify(this.utm)+"]"),da&&b(c.DEBUG,"initialize, referrers to ignore :["+JSON.stringify(da)+"]"),b(c.DEBUG,"initialize, salt given:["+!!f.salt+"]")}catch(r){b(c.ERROR,"initialize, Could not stringify some config object values")}b(c.DEBUG,"initialize, app_version:["+this.app_version+"]");b(c.DEBUG,
|
|
58
|
+
"initialize, provided location info; country_code:["+this.country_code+"], city:["+this.city+"], ip_address:["+this.ip_address+"]");""!==this.namespace&&b(c.DEBUG,"initialize, namespace given:["+this.namespace+"]");this.clearStoredId&&b(c.DEBUG,"initialize, clearStoredId flag set to:["+this.clearStoredId+"]");this.ignore_prefetch&&b(c.DEBUG,"initialize, ignoring pre-fetching and pre-rendering from counting as real website visits :["+this.ignore_prefetch+"]");this.test_mode&&b(c.WARNING,"initialize, test_mode:["+
|
|
59
|
+
this.test_mode+"], request queue won't be processed");this.test_mode_eq&&b(c.WARNING,"initialize, test_mode_eq:["+this.test_mode_eq+"], event queue won't be processed");this.heatmapWhitelist&&b(c.DEBUG,"initialize, heatmap whitelist:["+JSON.stringify(this.heatmapWhitelist)+"], these domains will be whitelisted");"default"!==this.storage&&b(c.DEBUG,"initialize, storage is set to:["+this.storage+"]");this.ignore_bots&&b(c.DEBUG,"initialize, ignore traffic from bots :["+this.ignore_bots+"]");this.force_post&&
|
|
60
|
+
b(c.DEBUG,"initialize, forced post method for all requests:["+this.force_post+"]");this.remote_config&&b(c.DEBUG,"initialize, remote_config callback provided:["+!!this.remote_config+"]");"boolean"===typeof this.rcAutoOptinAb&&b(c.DEBUG,"initialize, automatic RC optin is enabled:["+this.rcAutoOptinAb+"]");this.useExplicitRcApi||b(c.WARNING,"initialize, will use legacy RC API. Consider enabling new API during init with use_explicit_rc_api flag");this.track_domains&&b(c.DEBUG,"initialize, tracking domain info:["+
|
|
61
|
+
this.track_domains+"]");this.enableOrientationTracking&&b(c.DEBUG,"initialize, enableOrientationTracking:["+this.enableOrientationTracking+"]");ja||b(c.WARNING,"initialize, use_session_cookie is enabled:["+ja+"]");K&&b(c.DEBUG,"initialize, offline_mode:["+K+"], user info won't be send to the servers");K&&b(c.DEBUG,"initialize, stored remote configs:["+JSON.stringify(S)+"]");b(c.DEBUG,"initialize, 'getViewName' callback override provided:["+(this.getViewName!==p.getViewName)+"]");b(c.DEBUG,"initialize, 'getSearchQuery' callback override provided:["+
|
|
62
|
+
(this.getSearchQuery!==p.getSearchQuery)+"]");128!==this.maxKeyLength&&b(c.DEBUG,"initialize, maxKeyLength set to:["+this.maxKeyLength+"] characters");256!==this.maxValueSize&&b(c.DEBUG,"initialize, maxValueSize set to:["+this.maxValueSize+"] characters");100!==this.maxSegmentationValues&&b(c.DEBUG,"initialize, maxSegmentationValues set to:["+this.maxSegmentationValues+"] key/value pairs");100!==this.maxBreadcrumbCount&&b(c.DEBUG,"initialize, maxBreadcrumbCount for custom logs set to:["+this.maxBreadcrumbCount+
|
|
63
|
+
"] entries");30!==this.maxStackTraceLinesPerThread&&b(c.DEBUG,"initialize, maxStackTraceLinesPerThread set to:["+this.maxStackTraceLinesPerThread+"] lines");200!==this.maxStackTraceLineLength&&b(c.DEBUG,"initialize, maxStackTraceLineLength set to:["+this.maxStackTraceLineLength+"] characters");500!==bb&&b(c.DEBUG,"initialize, interval for heartbeats set to:["+bb+"] milliseconds");1E3!==Va&&b(c.DEBUG,"initialize, queue_size set to:["+Va+"] items max");60!==ab&&b(c.DEBUG,"initialize, fail_timeout set to:["+
|
|
64
|
+
ab+"] seconds of wait time after a failed connection to server");20!==Na&&b(c.DEBUG,"initialize, inactivity_time set to:["+Na+"] minutes to consider a user as inactive after no observable action");60!==Za&&b(c.DEBUG,"initialize, session_update set to:["+Za+"] seconds to check if extending a session is needed while the user is active");100!==Ka&&b(c.DEBUG,"initialize, max_events set to:["+Ka+"] events to send in one batch");xa&&b(c.WARNING,"initialize, max_logs set to:["+xa+"] breadcrumbs to store for crash logs max, deprecated ");
|
|
65
|
+
30!==Ja&&b(c.DEBUG,"initialize, session_cookie_timeout set to:["+Ja+"] minutes to expire a cookies session");a=null;g=f.getSearchQuery();var d=!1,e={};if(g){0===g.indexOf("?")&&(g=g.substring(1));g=g.split("&");for(var h=0;h<g.length;h++){var m=g[h].split("=");"cly_id"===m[0]?w("cly_cmp_id",m[1]):"cly_uid"===m[0]?w("cly_cmp_uid",m[1]):"cly_device_id"===m[0]?a=m[1]:0===(m[0]+"").indexOf("utm_")&&this.utm[m[0].replace("utm_","")]&&(e[m[0].replace("utm_","")]=m[1],d=!0)}}var g="[CLY]_temp_id"===y("cly_id");
|
|
66
|
+
h=u("device_id",k,void 0);"number"===typeof h&&(h=h.toString());y("cly_id")&&!g?(this.device_id=y("cly_id"),b(c.INFO,"initialize, Set the stored device ID"),D=y("cly_id_type"),D||(b(c.INFO,"initialize, No device ID type info from the previous session, falling back to DEVELOPER_SUPPLIED"),D=0)):null!==a?(b(c.INFO,"initialize, Device ID set by URL"),this.device_id=a,D=3):h?(b(c.INFO,"initialize, Device ID set by developer"),this.device_id=h,k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==
|
|
67
|
+
p.device_id&&(D=0)):K||g?(this.device_id="[CLY]_temp_id",D=2,K&&g?b(c.INFO,"initialize, Temp ID set, continuing offline mode from previous app session"):K&&!g?b(c.INFO,"initialize, Temp ID set, entering offline mode"):(K=!0,b(c.INFO,"initialize, Temp ID set, enabling offline mode"))):(b(c.INFO,"initialize, Generating the device ID"),this.device_id=u("device_id",k,pb()),k&&Object.keys(k).length?void 0!==k.device_id&&(D=0):void 0!==p.device_id&&(D=0));w("cly_id",this.device_id);w("cly_id_type",D);if(d){la=
|
|
68
|
+
{};for(var n in this.utm)e[n]?(this.userData.set("utm_"+n,e[n]),la[n]=e[n]):this.userData.unset("utm_"+n);this.userData.save()}Aa();setTimeout(function(){p.noHeartBeat?b(c.WARNING,"initialize, Heartbeat disabled. This is for testing purposes only!"):Wa();f.remote_config&&f.fetch_remote_config(f.remote_config)},1);x&&document.documentElement.setAttribute("data-countly-useragent",ua());qa.sendInstantHCRequest();b(c.INFO,"initialize, Countly initialized")}};this.halt=function(){b(c.WARNING,"halt, Resetting Countly");
|
|
69
|
+
p.i=void 0;p.q=[];p.noHeartBeat=void 0;Ya=!p.i;X=!1;ob="/i";Ua="/o/sdk";bb=500;Va=1E3;H=[];I=[];S={};sa=[];ea={};da=[];ub=null;Ia=!0;vb=0;Y=null;nb=Ha=Ga=0;ab=60;Na=20;Oa=0;Za=60;Ka=100;xa=null;ja=!0;Ja=30;$a=!0;K=Xa=!1;fa={};pa=!0;Sb=F();ra=!0;ya=null;D=1;Ma=!1;La=0;wb=!1;la=Da=ia=null;try{localStorage.setItem("cly_testLocal",!0),localStorage.removeItem("cly_testLocal")}catch(d){b(c.ERROR,"halt, Local storage test failed, will fallback to cookies"),ra=!1}p.features="sessions events views scrolls clicks forms crashes attribution users star-rating location apm feedback remote-config".split(" ");
|
|
70
|
+
E={};for(var a=0;a<p.features.length;a++)E[p.features[a]]={};f.app_key=void 0;f.device_id=void 0;f.onload=void 0;f.utm=void 0;f.ignore_prefetch=void 0;f.debug=void 0;f.test_mode=void 0;f.test_mode_eq=void 0;f.metrics=void 0;f.headers=void 0;f.url=void 0;f.app_version=void 0;f.country_code=void 0;f.city=void 0;f.ip_address=void 0;f.ignore_bots=void 0;f.force_post=void 0;f.rcAutoOptinAb=void 0;f.useExplicitRcApi=void 0;f.remote_config=void 0;f.ignore_visitor=void 0;f.require_consent=void 0;f.track_domains=
|
|
71
|
+
void 0;f.storage=void 0;f.enableOrientationTracking=void 0;f.salt=void 0;f.maxKeyLength=void 0;f.maxValueSize=void 0;f.maxSegmentationValues=void 0;f.maxBreadcrumbCount=void 0;f.maxStackTraceLinesPerThread=void 0;f.maxStackTraceLineLength=void 0};this.group_features=function(a){b(c.INFO,"group_features, Grouping features");if(a)for(var d in a)E[d]?b(c.WARNING,"group_features, Feature name ["+d+"] is already reserved"):"string"===typeof a[d]?E[d]={features:[a[d]]}:a[d]&&Array.isArray(a[d])&&a[d].length?
|
|
72
|
+
E[d]={features:a[d]}:b(c.ERROR,"group_features, Incorrect feature list for ["+d+"] value: ["+a[d]+"]");else b(c.ERROR,"group_features, Incorrect features:["+a+"]")};this.check_consent=function(a){b(c.INFO,"check_consent, Checking if consent is given for specific feature:["+a+"]");if(!this.require_consent)return b(c.INFO,"check_consent, require_consent is off, no consent is necessary"),!0;if(E[a])return!(!E[a]||!E[a].optin);b(c.ERROR,"check_consent, No feature available for ["+a+"]");return!1};this.get_device_id_type=
|
|
73
|
+
function(){b(c.INFO,"check_device_id_type, Retrieving the current device id type.["+D+"]");switch(D){case 1:var a=f.DeviceIdType.SDK_GENERATED;break;case 3:case 0:a=f.DeviceIdType.DEVELOPER_SUPPLIED;break;case 2:a=f.DeviceIdType.TEMPORARY_ID;break;default:a=-1}return a};this.get_device_id=function(){b(c.INFO,"get_device_id, Retrieving the device id: ["+f.device_id+"]");return f.device_id};this.check_any_consent=function(){b(c.INFO,"check_any_consent, Checking if any consent is given");if(!this.require_consent)return b(c.INFO,
|
|
74
|
+
"check_any_consent, require_consent is off, no consent is necessary"),!0;for(var a in E)if(E[a]&&E[a].optin)return!0;b(c.INFO,"check_any_consent, No consents given");return!1};this.add_consent=function(a){b(c.INFO,"add_consent, Adding consent for ["+a+"]");if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add_consent(a[d]);else E[a]?E[a].features?(E[a].optin=!0,this.add_consent(E[a].features)):!0!==E[a].optin&&(E[a].optin=!0,Tb(),setTimeout(function(){"sessions"===a&&fa.begin_session?(f.begin_session.apply(f,
|
|
75
|
+
fa.begin_session),fa.begin_session=null):"views"===a&&fa.track_pageview&&(Y=null,f.track_pageview.apply(f,fa.track_pageview),fa.track_pageview=null)},1)):b(c.ERROR,"add_consent, No feature available for ["+a+"]")};this.remove_consent=function(a){b(c.INFO,"remove_consent, Removing consent for ["+a+"]");this.remove_consent_internal(a,!0)};this.remove_consent_internal=function(a,d){d=d||!1;if(Array.isArray(a))for(var e=0;e<a.length;e++)this.remove_consent_internal(a[e],d);else E[a]?E[a].features?this.remove_consent_internal(E[a].features,
|
|
76
|
+
d):(E[a].optin=!1,d&&!1!==E[a].optin&&Tb()):b(c.WARNING,"remove_consent, No feature available for ["+a+"]")};var cb,Tb=function(){cb&&(clearTimeout(cb),cb=null);cb=setTimeout(function(){for(var a={},d=0;d<p.features.length;d++)a[p.features[d]]=!0===E[p.features[d]].optin?!0:!1;P({consent:JSON.stringify(a)});b(c.DEBUG,"Consent update request has been sent to the queue.")},1E3)};this.enable_offline_mode=function(){b(c.INFO,"enable_offline_mode, Enabling offline mode");this.remove_consent_internal(p.features,
|
|
77
|
+
!1);K=!0;this.device_id="[CLY]_temp_id";f.device_id=this.device_id;D=2};this.disable_offline_mode=function(a){if(K){b(c.INFO,"disable_offline_mode, Disabling offline mode");K=!1;a&&this.device_id!==a?(this.device_id=a,f.device_id=this.device_id,D=0,w("cly_id",this.device_id),w("cly_id_type",0),b(c.INFO,"disable_offline_mode, Changing id to: "+this.device_id)):(this.device_id=pb(),"[CLY]_temp_id"===this.device_id&&(this.device_id=gb()),f.device_id=this.device_id,this.device_id!==y("cly_id")&&(w("cly_id",
|
|
78
|
+
this.device_id),w("cly_id_type",1)));a=!1;if(0<H.length)for(var d=0;d<H.length;d++)"[CLY]_temp_id"===H[d].device_id&&(H[d].device_id=this.device_id,a=!0);a&&w("cly_queue",H,!0)}else b(c.WARNING,"disable_offline_mode, Countly was not in offline mode.")};this.begin_session=function(a,d){b(c.INFO,"begin_session, Starting the session. There was an ongoing session: ["+X+"]");a&&b(c.INFO,"begin_session, Heartbeats are disabled");d&&b(c.INFO,"begin_session, Session starts irrespective of session cookie");
|
|
79
|
+
if(this.check_consent("sessions")){if(!X){this.enableOrientationTracking&&(this.report_orientation(),A(window,"resize",function(){f.report_orientation()}));ka=F();X=!0;Ia=!a;var e=y("cly_session");b(c.VERBOSE,"begin_session, Session state, forced: ["+d+"], useSessionCookie: ["+ja+"], seconds to expire: ["+(e-ka)+"], expired: ["+(parseInt(e)<=F())+"] ");if(d||!ja||!e||parseInt(e)<=F())b(c.INFO,"begin_session, Session started"),null===ya&&(ya=!0),e={begin_session:1},e.metrics=JSON.stringify(Ta()),P(e);
|
|
80
|
+
w("cly_session",F()+60*Ja)}}else fa.begin_session=arguments};this.session_duration=function(a){b(c.INFO,"session_duration, Reporting session duration");this.check_consent("sessions")&&X&&(b(c.INFO,"session_duration, Session extended: ",a),P({session_duration:a}),Ba())};this.end_session=function(a,d){b(c.INFO,"end_session, Ending the current session. There was an on going session:["+X+"]");this.check_consent("sessions")&&X&&(a=a||F()-ka,na(),!ja||d?(b(c.INFO,"end_session, Session ended"),P({end_session:1,
|
|
81
|
+
session_duration:a})):this.session_duration(a),X=!1)};this.set_id=function(a){b(c.INFO,"set_id, Changing the device ID to:["+a+"]");null==a||""===a?b(c.WARNING,"set_id, The provided device is not a valid ID"):0===D?this.change_id(a,!1):this.change_id(a,!0)};this.change_id=function(a,d){b(c.INFO,"change_id, Changing the device ID to: ["+a+"] with merge:["+d+"]");if(a&&"string"===typeof a&&0!==a.length)if(K)b(c.WARNING,"change_id, Offline mode was on, initiating disabling sequence instead."),this.disable_offline_mode(a);
|
|
82
|
+
else if(this.device_id==a)b(c.DEBUG,"change_id, Provided device ID is equal to the current device ID. Aborting.");else{d||(wa(),Q(),this.end_session(null,!0),ea={},this.remove_consent_internal(p.features,!1));var e=this.device_id;this.device_id=a;f.device_id=this.device_id;D=0;w("cly_id",this.device_id);w("cly_id_type",0);b(c.INFO,"change_id, Changing ID from:["+e+"] to ["+a+"]");d?P({old_device_id:e}):this.begin_session(!Ia,!0);this.remote_config&&(S={},w("cly_remote_configs",S),this.fetch_remote_config(this.remote_config))}else b(c.WARNING,
|
|
83
|
+
"change_id, The provided device ID is not a valid ID")};this.add_event=function(a){b(c.INFO,"add_event, Adding event: ",a);switch(a.key){case M.NPS:var d=this.check_consent("feedback");break;case M.SURVEY:d=this.check_consent("feedback");break;case M.STAR_RATING:d=this.check_consent("star-rating");break;case M.VIEW:d=this.check_consent("views");break;case M.ORIENTATION:d=this.check_consent("users");break;case M.ACTION:d=this.check_consent("clicks")||this.check_consent("scrolls");break;default:d=this.check_consent("events")}d&&
|
|
84
|
+
t(a)};this.start_event=function(a){a&&"string"===typeof a?(b(c.INFO,"start_event, Starting timed event with key: ["+a+"]"),a=z(a,f.maxKeyLength,"start_event",b),ea[a]?b(c.WARNING,"start_event, Timed event with key: ["+a+"] already started"):ea[a]=F()):b(c.WARNING,"start_event, you have to provide a valid string key instead of: ["+a+"]")};this.cancel_event=function(a){if(!a||"string"!==typeof a)return b(c.WARNING,"cancel_event, you have to provide a valid string key instead of: ["+a+"]"),!1;b(c.INFO,
|
|
85
|
+
"cancel_event, Canceling timed event with key: ["+a+"]");a=z(a,f.maxKeyLength,"cancel_event",b);if(ea[a])return delete ea[a],b(c.INFO,"cancel_event, Timed event with key: ["+a+"] is canceled"),!0;b(c.WARNING,"cancel_event, Timed event with key: ["+a+"] was not found");return!1};this.end_event=function(a){a?(b(c.INFO,"end_event, Ending timed event"),"string"===typeof a&&(a=z(a,f.maxKeyLength,"end_event",b),a={key:a}),a.key?ea[a.key]?(a.dur=F()-ea[a.key],this.add_event(a),delete ea[a.key]):b(c.ERROR,
|
|
86
|
+
"end_event, Timed event with key: ["+a.key+"] was not started"):b(c.ERROR,"end_event, Timed event must have a key property")):b(c.WARNING,"end_event, you have to provide a valid string key or event object instead of: ["+a+"]")};this.report_orientation=function(a){b(c.INFO,"report_orientation, Reporting orientation");this.check_consent("users")&&t({key:M.ORIENTATION,segmentation:{mode:a||(window.innerWidth>window.innerHeight?"landscape":"portrait")}})};this.report_conversion=function(a,d){b(c.WARNING,
|
|
87
|
+
"report_conversion, Deprecated function call! Use 'recordDirectAttribution' in place of this call. Call will be redirected now!");this.recordDirectAttribution(a,d)};this.recordDirectAttribution=function(a,d){b(c.INFO,"recordDirectAttribution, Recording the attribution for campaign ID: ["+a+"] and the user ID: ["+d+"]");this.check_consent("attribution")&&(a=a||y("cly_cmp_id")||"cly_organic",(d=d||y("cly_cmp_uid"))?P({campaign_id:a,campaign_user:d}):P({campaign_id:a}))};this.user_details=function(a){b(c.INFO,
|
|
88
|
+
"user_details, Trying to add user details: ",a);this.check_consent("users")&&(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),a.name=z(a.name,f.maxValueSize,"user_details",b),a.username=z(a.username,f.maxValueSize,"user_details",b),a.email=z(a.email,f.maxValueSize,"user_details",b),a.organization=z(a.organization,f.maxValueSize,"user_details",b),a.phone=z(a.phone,f.maxValueSize,"user_details",b),a.picture=z(a.picture,4096,"user_details",b),a.gender=z(a.gender,f.maxValueSize,"user_details",
|
|
89
|
+
b),a.byear=z(a.byear,f.maxValueSize,"user_details",b),a.custom=ba(a.custom,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"user_details",b),P({user_details:JSON.stringify(za(a,"name username email organization phone picture gender byear custom".split(" ")))}))};var Z={},ha=function(a,d,e){f.check_consent("users")&&(Z[a]||(Z[a]={}),"$push"===e||"$pull"===e||"$addToSet"===e?(Z[a][e]||(Z[a][e]=[]),Z[a][e].push(d)):Z[a][e]=d)};this.userData={set:function(a,d){b(c.INFO,"[userData] set, Setting user's custom property value: ["+
|
|
90
|
+
d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData set",b);d=z(d,f.maxValueSize,"userData set",b);Z[a]=d},unset:function(a){b(c.INFO,"[userData] unset, Resetting user's custom property with key: ["+a+"] ");Z[a]=""},set_once:function(a,d){b(c.INFO,"[userData] set_once, Setting user's unique custom property value: ["+d+"] under the key: ["+a+"] ");a=z(a,f.maxKeyLength,"userData set_once",b);d=z(d,f.maxValueSize,"userData set_once",b);ha(a,d,"$setOnce")},increment:function(a){b(c.INFO,"[userData] increment, Increasing user's custom property value under the key: ["+
|
|
91
|
+
a+"] by one");a=z(a,f.maxKeyLength,"userData increment",b);ha(a,1,"$inc")},increment_by:function(a,d){b(c.INFO,"[userData] increment_by, Increasing user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData increment_by",b);d=z(d,f.maxValueSize,"userData increment_by",b);ha(a,d,"$inc")},multiply:function(a,d){b(c.INFO,"[userData] multiply, Multiplying user's custom property value under the key: ["+a+"] by: ["+d+"]");a=z(a,f.maxKeyLength,"userData multiply",b);
|
|
92
|
+
d=z(d,f.maxValueSize,"userData multiply",b);ha(a,d,"$mul")},max:function(a,d){b(c.INFO,"[userData] max, Saving user's maximum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData max",b);d=z(d,f.maxValueSize,"userData max",b);ha(a,d,"$max")},min:function(a,d){b(c.INFO,"[userData] min, Saving user's minimum custom property value compared to the value: ["+d+"] under the key: ["+a+"]");a=z(a,f.maxKeyLength,"userData min",b);d=z(d,f.maxValueSize,
|
|
93
|
+
"userData min",b);ha(a,d,"$min")},push:function(a,d){b(c.INFO,"[userData] push, Pushing a value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push",b);d=z(d,f.maxValueSize,"userData push",b);ha(a,d,"$push")},push_unique:function(a,d){b(c.INFO,"[userData] push_unique, Pushing a unique value: ["+d+"] under the key: ["+a+"] to user's custom property array");a=z(a,f.maxKeyLength,"userData push_unique",b);d=z(d,f.maxValueSize,"userData push_unique",b);
|
|
94
|
+
ha(a,d,"$addToSet")},pull:function(a,d){b(c.INFO,"[userData] pull, Removing the value: ["+d+"] under the key: ["+a+"] from user's custom property array");ha(a,d,"$pull")},save:function(){b(c.INFO,"[userData] save, Saving changes to user's custom property");f.check_consent("users")&&(wa(),Q(),b(c.INFO,"user_details, flushed the event queue"),P({user_details:JSON.stringify({custom:Z})}));Z={}}};this.report_trace=function(a){b(c.INFO,"report_trace, Reporting performance trace");if(this.check_consent("apm")){for(var d=
|
|
95
|
+
"type name stz etz apm_metrics apm_attr".split(" "),e=0;e<d.length;e++)if("apm_attr"!==d[e]&&"undefined"===typeof a[d[e]]){b(c.WARNING,"report_trace, APM trace don't have the property: "+d[e]);return}a.name=z(a.name,f.maxKeyLength,"report_trace",b);a.app_metrics=ba(a.app_metrics,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"report_trace",b);d=za(a,d);d.timestamp=a.stz;a=new Date;d.hour=a.getHours();d.dow=a.getDay();P({apm:JSON.stringify(d)});b(c.INFO,"report_trace, Successfully adding APM trace: ",
|
|
96
|
+
d)}};this.track_errors=function(a){x?(b(c.INFO,"track_errors, Started tracking errors"),p.i[this.app_key].tracking_crashes=!0,window.cly_crashes||(window.cly_crashes=!0,ub=a,window.onerror=function r(e,h,m,g,n){if(void 0!==n&&null!==n)ib(n,!1);else{g=g||window.event&&window.event.errorCharacter;n="";"undefined"!==typeof e&&(n+=e+"\n");"undefined"!==typeof h&&(n+="at "+h);"undefined"!==typeof m&&(n+=":"+m);"undefined"!==typeof g&&(n+=":"+g);n+="\n";try{e=[];for(var v=r.caller;v;)e.push(v.name),v=v.caller;
|
|
97
|
+
n+=e.join("\n")}catch(G){b(c.ERROR,"track_errors, Call stack generation experienced a problem: "+G)}ib(n,!1)}},window.addEventListener("unhandledrejection",function(e){ib(Error("Unhandled rejection (reason: "+(e.reason&&e.reason.stack?e.reason.stack:e.reason)+")."),!0)}))):b(c.WARNING,"track_errors, window object is not available. Not tracking errors.")};this.log_error=function(a,d){b(c.INFO,"log_error, Logging errors");this.recordError(a,!0,d)};this.add_log=function(a){b(c.INFO,"add_log, Adding a new log of breadcrumbs: [ "+
|
|
98
|
+
a+" ]");if(this.check_consent("crashes")){for(a=z(a,f.maxValueSize,"add_log",b);sa.length>=f.maxBreadcrumbCount;)sa.shift(),b(c.WARNING,"add_log, Reached maximum crashLogs size. Will erase the oldest one.");sa.push(a)}};this.fetch_remote_config=function(a,d,e){var h=null,m=null,g=null;a&&(e||"function"!==typeof a?Array.isArray(a)&&(h=a):g=a);d&&(e||"function"!==typeof d?Array.isArray(d)&&(m=d):g=d);g||"function"!==typeof e||(g=e);this.useExplicitRcApi?(b(c.INFO,"fetch_remote_config, Fetching remote config"),
|
|
99
|
+
C(h,m,this.rcAutoOptinAb?1:0,null,g)):(b(c.WARNING,"fetch_remote_config, Fetching remote config, with legacy API"),C(h,m,null,"legacy",g))};this.enrollUserToAb=function(a){b(c.INFO,"enrollUserToAb, Providing AB test keys to opt in for");a&&Array.isArray(a)&&0!==a.length?(a={method:"ab",keys:JSON.stringify(a),av:f.app_version},Ea(a),ca("enrollUserToAb",this.url+Ua,a,function(d,e,h){if(!d)try{var m=JSON.parse(h);b(c.DEBUG,"enrollUserToAb, Parsed the response's result: ["+m.result+"]")}catch(g){b(c.ERROR,
|
|
100
|
+
"enrollUserToAb, Had an issue while parsing the response: "+g)}},!0)):b(c.ERROR,"enrollUserToAb, No keys provided")};this.get_remote_config=function(a){b(c.INFO,"get_remote_config, Getting remote config from storage");return"undefined"!==typeof a?S[a]:S};this.stop_time=function(){b(c.INFO,"stop_time, Stopping tracking duration");pa&&(pa=!1,vb=F()-ka,Ha=F()-Ga)};this.start_time=function(){b(c.INFO,"start_time, Starting tracking duration");pa||(pa=!0,ka=F()-vb,Ga=F()-Ha,Ha=0,Ba())};this.track_sessions=
|
|
101
|
+
function(){function a(){document[e]||!document.hasFocus()?f.stop_time():f.start_time()}function d(){Oa>=Na&&f.start_time();Oa=0}if(x){b(c.INFO,"track_session, Starting tracking user session");this.begin_session();this.start_time();A(window,"beforeunload",function(){wa();Q();f.end_session()});var e="hidden";A(window,"focus",a);A(window,"blur",a);A(window,"pageshow",a);A(window,"pagehide",a);"onfocusin"in document&&(A(window,"focusin",a),A(window,"focusout",a));e in document?document.addEventListener("visibilitychange",
|
|
102
|
+
a):"mozHidden"in document?(e="mozHidden",document.addEventListener("mozvisibilitychange",a)):"webkitHidden"in document?(e="webkitHidden",document.addEventListener("webkitvisibilitychange",a)):"msHidden"in document&&(e="msHidden",document.addEventListener("msvisibilitychange",a));A(window,"mousemove",d);A(window,"click",d);A(window,"keydown",d);A(window,"scroll",d);setInterval(function(){Oa++;Oa>=Na&&f.stop_time()},6E4)}else b(c.WARNING,"track_sessions, window object is not available. Not tracking sessions.")};
|
|
103
|
+
this.track_pageview=function(a,d,e){if(x||a)if(b(c.INFO,"track_pageview, Tracking page views"),b(c.VERBOSE,"track_pageview, last view is:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]"),Y&&wb&&(b(c.DEBUG,"track_pageview, Scroll registry triggered"),tb(),Ma=!0,La=0),na(),Da=ia,ia=fb(),(a=z(a,f.maxKeyLength,"track_pageview",b))&&Array.isArray(a)&&(d=a,a=null),a||(a=this.getViewName()),void 0===a||""===a)b(c.ERROR,"track_pageview, No page name to track (it is either undefined or empty string). No page view can be tracked.");
|
|
104
|
+
else if(null===a)b(c.ERROR,"track_pageview, View name returned as null. Page view will be ignored.");else{if(d&&d.length)for(var h=0;h<d.length;h++)try{if((new RegExp(d[h])).test(a)){b(c.INFO,"track_pageview, Ignoring the page: "+a);return}}catch(r){b(c.ERROR,"track_pageview, Problem with finding ignore list item: "+d[h]+", error: "+r)}Y=a;Ga=F();b(c.VERBOSE,"track_pageview, last view is assigned:["+Y+"], current view ID is:["+ia+"], previous view ID is:["+Da+"]");h={name:a,visit:1,view:f.getViewUrl()};
|
|
105
|
+
h=ba(h,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);this.track_domains&&(h.domain=window.location.hostname);if(ja)if(X)ya&&(ya=!1,h.start=1);else{var m=y("cly_session");if(!m||parseInt(m)<=F())ya=!1,h.start=1}else x&&"undefined"!==typeof document.referrer&&document.referrer.length&&(m=Lb.exec(document.referrer))&&m[11]&&m[11]!==window.location.hostname&&(h.start=1);if(la&&Object.keys(la).length){b(c.INFO,"track_pageview, Adding fresh utm tags to segmentation:["+JSON.stringify(la)+
|
|
106
|
+
"]");for(var g in la)"undefined"===typeof h["utm_"+g]&&(h["utm_"+g]=la[g])}x&&qb()&&(b(c.INFO,"track_pageview, Adding referrer to segmentation:["+document.referrer+"]"),h.referrer=document.referrer);if(e){e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"track_pageview",b);for(var n in e)"undefined"===typeof h[n]&&(h[n]=e[n])}this.check_consent("views")?t({key:M.VIEW,segmentation:h},ia):fa.track_pageview=arguments}else b(c.WARNING,"track_pageview, window object is not available. Not tracking page views is page is not provided.")};
|
|
107
|
+
this.track_view=function(a,d,e){b(c.INFO,"track_view, Initiating tracking page views");this.track_pageview(a,d,e)};this.track_clicks=function(a){if(x){b(c.INFO,"track_clicks, Starting to track clicks");a&&b(c.INFO,"track_clicks, Tracking the specified children:["+a+"]");a=a||document;var d=!0;A(a,"click",function(e){if(d){d=!1;lb(e);if("undefined"!==typeof e.pageX&&"undefined"!==typeof e.pageY){var h=Ra(),m=mb();f.check_consent("clicks")&&(e={type:"click",x:e.pageX,y:e.pageY,width:m,height:h,view:f.getViewUrl()},
|
|
108
|
+
e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"processClick",b),f.track_domains&&(e.domain=window.location.hostname),t({key:M.ACTION,segmentation:e}))}setTimeout(function(){d=!0},1E3)}})}else b(c.WARNING,"track_clicks, window object is not available. Not tracking clicks.")};this.track_scrolls=function(a){x?(b(c.INFO,"track_scrolls, Starting to track scrolls"),a&&b(c.INFO,"track_scrolls, Tracking the specified children"),a=a||window,wb=Ma=!0,A(a,"scroll",Pb),A(a,"beforeunload",tb)):
|
|
109
|
+
b(c.WARNING,"track_scrolls, window object is not available. Not tracking scrolls.")};this.track_links=function(a){x?(b(c.INFO,"track_links, Starting to track clicks to links"),a&&b(c.INFO,"track_links, Tracking the specified children"),a=a||document,A(a,"click",function(d){a:{var e=Qa(d);var h;for(h="A";e;){if(e.nodeName.toUpperCase()===h)break a;e=e.parentElement}e=void 0}e&&(lb(d),f.check_consent("clicks")&&t({key:"linkClick",segmentation:{href:e.href,text:e.innerText,id:e.id,view:f.getViewUrl()}}))})):
|
|
110
|
+
b(c.WARNING,"track_links, window object is not available. Not tracking links.")};this.track_forms=function(a,d){function e(h){return h.name||h.id||h.type||h.nodeName}x?(b(c.INFO,"track_forms, Starting to track form submissions. DOM object provided:["+!!a+"] Tracking hidden inputs :["+!!d+"]"),a=a||document,A(a,"submit",function(h){h=Qa(h);var m={id:h.attributes.id&&h.attributes.id.nodeValue,name:h.attributes.name&&h.attributes.name.nodeValue,action:h.attributes.action&&h.attributes.action.nodeValue,
|
|
111
|
+
method:h.attributes.method&&h.attributes.method.nodeValue,view:f.getViewUrl()},g;if("undefined"!==typeof h.elements){for(var n=0;n<h.elements.length;n++)(g=h.elements[n])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore")&&("undefined"===typeof m["input:"+e(g)]&&(m["input:"+e(g)]=[]),"select"===g.nodeName.toLowerCase()?"undefined"!==typeof g.multiple?m["input:"+e(g)].push(Ab(g)):m["input:"+e(g)].push(g.options[g.selectedIndex].value):"input"===g.nodeName.toLowerCase()?"undefined"!==
|
|
112
|
+
typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&m["input:"+e(g)].push(g.value):("hidden"!==g.type.toLowerCase()||d)&&m["input:"+e(g)].push(g.value):m["input:"+e(g)].push(g.value):"textarea"===g.nodeName.toLowerCase()?m["input:"+e(g)].push(g.value):"undefined"!==typeof g.value&&m["input:"+e(g)].push(g.value));for(var r in m)m[r]&&"function"===typeof m[r].join&&(m[r]=m[r].join(", "))}f.check_consent("forms")&&t({key:"formSubmit",segmentation:m})})):b(c.WARNING,
|
|
113
|
+
"track_forms, window object is not available. Not tracking forms.")};this.collect_from_forms=function(a,d){x?(b(c.INFO,"collect_from_forms, Starting to collect possible user data. DOM object provided:["+!!a+"] Submitting custom user property:["+!!d+"]"),a=a||document,A(a,"submit",function(e){e=Qa(e);var h={},m=!1,g;if("undefined"!==typeof e.elements){var n={},r=a.getElementsByTagName("LABEL"),v;for(v=0;v<r.length;v++)r[v].htmlFor&&""!==r[v].htmlFor&&(n[r[v].htmlFor]=r[v].innerText||r[v].textContent||
|
|
114
|
+
r[v].innerHTML);for(v=0;v<e.elements.length;v++)if((g=e.elements[v])&&"password"!==g.type&&-1===g.className.indexOf("cly_user_ignore"))if(r="","select"===g.nodeName.toLowerCase()?r="undefined"!==typeof g.multiple?Ab(g):g.options[g.selectedIndex].value:"input"===g.nodeName.toLowerCase()?"undefined"!==typeof g.type?"checkbox"===g.type.toLowerCase()||"radio"===g.type.toLowerCase()?g.checked&&(r=g.value):r=g.value:r=g.value:"textarea"===g.nodeName.toLowerCase()?r=g.value:"undefined"!==typeof g.value&&
|
|
115
|
+
(r=g.value),g.className&&-1!==g.className.indexOf("cly_user_")){var G=g.className.split(" ");for(g=0;g<G.length;g++)if(0===G[g].indexOf("cly_user_")){h[G[g].replace("cly_user_","")]=r;m=!0;break}}else if(g.type&&"email"===g.type.toLowerCase()||g.name&&-1!==g.name.toLowerCase().indexOf("email")||g.id&&-1!==g.id.toLowerCase().indexOf("email")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("email")||/[^@\s]+@[^@\s]+\.[^@\s]+/.test(r))h.email||(h.email=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("username")||
|
|
116
|
+
g.id&&-1!==g.id.toLowerCase().indexOf("username")||g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("username"))h.username||(h.username=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("tel")||-1!==g.name.toLowerCase().indexOf("phone")||-1!==g.name.toLowerCase().indexOf("number"))||g.id&&(-1!==g.id.toLowerCase().indexOf("tel")||-1!==g.id.toLowerCase().indexOf("phone")||-1!==g.id.toLowerCase().indexOf("number"))||g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("tel")||-1!==n[g.id].toLowerCase().indexOf("phone")||
|
|
117
|
+
-1!==n[g.id].toLowerCase().indexOf("number")))h.phone||(h.phone=r),m=!0;else if(g.name&&(-1!==g.name.toLowerCase().indexOf("org")||-1!==g.name.toLowerCase().indexOf("company"))||g.id&&(-1!==g.id.toLowerCase().indexOf("org")||-1!==g.id.toLowerCase().indexOf("company"))||g.id&&n[g.id]&&(-1!==n[g.id].toLowerCase().indexOf("org")||-1!==n[g.id].toLowerCase().indexOf("company")))h.organization||(h.organization=r),m=!0;else if(g.name&&-1!==g.name.toLowerCase().indexOf("name")||g.id&&-1!==g.id.toLowerCase().indexOf("name")||
|
|
118
|
+
g.id&&n[g.id]&&-1!==n[g.id].toLowerCase().indexOf("name"))h.name||(h.name=""),h.name+=r+" ",m=!0}m&&(b(c.INFO,"collect_from_forms, Gathered user data",h),d?f.user_details({custom:h}):f.user_details(h))})):b(c.WARNING,"collect_from_forms, window object is not available. Not collecting from forms.")};this.collect_from_facebook=function(a){x?"undefined"!==typeof FB&&FB&&FB.api?(b(c.INFO,"collect_from_facebook, Starting to collect possible user data"),FB.api("/me",function(d){var e={};d.name&&(e.name=
|
|
119
|
+
d.name);d.email&&(e.email=d.email);"male"===d.gender?e.gender="M":"female"===d.gender&&(e.gender="F");if(d.birthday){var h=d.birthday.split("/").pop();h&&4===h.length&&(e.byear=h)}d.work&&d.work[0]&&d.work[0].employer&&d.work[0].employer.name&&(e.organization=d.work[0].employer.name);if(a){e.custom={};for(var m in a){h=a[m].split(".");for(var g=d,n=0;n<h.length&&(g=g[h[n]],"undefined"!==typeof g);n++);"undefined"!==typeof g&&(e.custom[m]=g)}}f.user_details(e)})):b(c.ERROR,"collect_from_facebook, Facebook SDK is not available"):
|
|
120
|
+
b(c.WARNING,"collect_from_facebook, window object is not available. Not collecting from Facebook.")};this.opt_out=function(){b(c.INFO,"opt_out, Opting out the user");this.ignore_visitor=!0;w("cly_ignore",!0)};this.opt_in=function(){b(c.INFO,"opt_in, Opting in the user");w("cly_ignore",!1);this.ignore_visitor=!1;O();this.ignore_visitor||Xa||Wa()};this.report_feedback=function(a){b(c.WARNING,"report_feedback, Deprecated function call! Use 'recordRatingWidgetWithID' or 'reportFeedbackWidgetManually' in place of this call. Call will be redirected to 'recordRatingWidgetWithID' now!");
|
|
121
|
+
this.recordRatingWidgetWithID(a)};this.recordRatingWidgetWithID=function(a){b(c.INFO,"recordRatingWidgetWithID, Providing information about user with ID: [ "+a.widget_id+" ]");if(this.check_consent("star-rating"))if(a.widget_id)if(a.rating){var d={key:M.STAR_RATING,count:1,segmentation:{}};d.segmentation=za(a,"widget_id contactMe platform app_version rating email comment".split(" "));d.segmentation.app_version||(d.segmentation.app_version=this.metrics._app_version||this.app_version);5<d.segmentation.rating?
|
|
122
|
+
(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating higher than 5. Changing it back to 5 now."),d.segmentation.rating=5):1>d.segmentation.rating&&(b(c.WARNING,"recordRatingWidgetWithID, You have entered a rating lower than 1. Changing it back to 1 now."),d.segmentation.rating=1);b(c.INFO,"recordRatingWidgetWithID, Reporting Rating Widget: ",d);t(d)}else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain rating property");else b(c.ERROR,"recordRatingWidgetWithID, Rating Widget must contain widget_id property")};
|
|
123
|
+
this.reportFeedbackWidgetManually=function(a,d,e){if(this.check_consent("feedback"))if(a&&d)if(a._id)if(K)b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets can not be reported in offline mode");else{b(c.INFO,"reportFeedbackWidgetManually, Providing information about user with, provided result of the widget with ID: [ "+a._id+" ] and type: ["+a.type+"]");var h=[];d=a.type;if("nps"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=
|
|
124
|
+
Math.round(e.rating);10<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 10. Changing it back to 10 now."),e.rating=10):0>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 0. Changing it back to 0 now."),e.rating=0);h=["rating","comment"]}var m=M.NPS}else if("survey"===d){if(e){if(1>Object.keys(e).length){b(c.ERROR,"reportFeedbackWidgetManually, Widget should have answers to be reported");return}h=Object.keys(e)}m=
|
|
125
|
+
M.SURVEY}else if("rating"===d){if(e){if(!e.rating){b(c.ERROR,"reportFeedbackWidgetManually, Widget must contain rating property");return}e.rating=Math.round(e.rating);5<e.rating?(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating higher than 5. Changing it back to 5 now."),e.rating=5):1>e.rating&&(b(c.WARNING,"reportFeedbackWidgetManually, You have entered a rating lower than 1. Changing it back to 1 now."),e.rating=1);h=["rating","comment","email","contactMe"]}m=M.STAR_RATING}else{b(c.ERROR,
|
|
126
|
+
"reportFeedbackWidgetManually, Widget has an unacceptable type");return}a={key:m,count:1,segmentation:{widget_id:a._id,platform:this.platform,app_version:this.metrics._app_version||this.app_version}};if(null===e)a.segmentation.closed=1;else{m=a.segmentation;if(h){for(var g,n=0,r=h.length;n<r;n++)g=h[n],"undefined"!==typeof e[g]&&(m[g]=e[g]);e=m}else e=void 0;a.segmentation=e}b(c.INFO,"reportFeedbackWidgetManually, Reporting "+d+": ",a);t(a)}else b(c.ERROR,"reportFeedbackWidgetManually, Feedback Widgets must contain _id property");
|
|
127
|
+
else b(c.ERROR,"reportFeedbackWidgetManually, Widget data and/or Widget object not provided. Aborting.")};this.show_feedback_popup=function(a){x?(b(c.WARNING,"show_feedback_popup, Deprecated function call! Use 'presentRatingWidgetWithID' in place of this call. Call will be redirected now!"),this.presentRatingWidgetWithID(a)):b(c.WARNING,"show_feedback_popup, window object is not available. Not showing feedback popup.")};this.presentRatingWidgetWithID=function(a){x?(b(c.INFO,"presentRatingWidgetWithID, Showing rating widget popup for the widget with ID: [ "+
|
|
128
|
+
a+" ]"),this.check_consent("star-rating")&&(K?b(c.ERROR,"presentRatingWidgetWithID, Cannot show ratingWidget popup in offline mode"):ca("presentRatingWidgetWithID,",this.url+"/o/feedback/widget",{widget_id:a,av:f.app_version},function(d,e,h){if(!d)try{var m=JSON.parse(h);W(m,!1)}catch(g){b(c.ERROR,"presentRatingWidgetWithID, JSON parse failed: "+g)}},!0))):b(c.WARNING,"presentRatingWidgetWithID, window object is not available. Not showing rating widget popup.")};this.initialize_feedback_popups=function(a){x?
|
|
129
|
+
(b(c.WARNING,"initialize_feedback_popups, Deprecated function call! Use 'initializeRatingWidgets' in place of this call. Call will be redirected now!"),this.initializeRatingWidgets(a)):b(c.WARNING,"initialize_feedback_popups, window object is not available. Not initializing feedback popups.")};this.initializeRatingWidgets=function(a){if(x){if(b(c.INFO,"initializeRatingWidgets, Initializing rating widget with provided widget IDs:[ "+a+"]"),this.check_consent("star-rating")){a||(a=y("cly_fb_widgets"));
|
|
130
|
+
for(var d=document.getElementsByClassName("countly-feedback-sticker");0<d.length;)d[0].remove();ca("initializeRatingWidgets,",this.url+"/o/feedback/multiple-widgets-by-id",{widgets:JSON.stringify(a),av:f.app_version},function(e,h,m){if(!e)try{var g=JSON.parse(m);for(e=0;e<g.length;e++)if("true"===g[e].is_active){var n=g[e].target_devices,r=Db();if(n[r])if("string"===typeof g[e].hide_sticker&&(g[e].hide_sticker="true"===g[e].hide_sticker),"all"!==g[e].target_page||g[e].hide_sticker){var v=g[e].target_pages;
|
|
131
|
+
for(h=0;h<v.length;h++){var G=v[h].substr(0,v[h].length-1)===window.location.pathname.substr(0,v[h].length-1),N=v[h]===window.location.pathname;(v[h].includes("*")&&G||N)&&!g[e].hide_sticker&&W(g[e],!0)}}else W(g[e],!0)}}catch(J){b(c.ERROR,"initializeRatingWidgets, JSON parse error: "+J)}},!0)}}else b(c.WARNING,"initializeRatingWidgets, window object is not available. Not initializing rating widgets.")};this.enable_feedback=function(a){x?(b(c.WARNING,"enable_feedback, Deprecated function call! Use 'enableRatingWidgets' in place of this call. Call will be redirected now!"),
|
|
132
|
+
this.enableRatingWidgets(a)):b(c.WARNING,"enable_feedback, window object is not available. Not enabling feedback.")};this.enableRatingWidgets=function(a){x?(b(c.INFO,"enableRatingWidgets, Enabling rating widget with params:",a),this.check_consent("star-rating")&&(K?b(c.ERROR,"enableRatingWidgets, Cannot enable rating widgets in offline mode"):(w("cly_fb_widgets",a.popups||a.widgets),Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css"),a=a.popups||a.widgets,0<a.length?(document.body.insertAdjacentHTML("beforeend",
|
|
133
|
+
'<div id="cfbg"></div>'),this.initializeRatingWidgets(a)):b(c.ERROR,"enableRatingWidgets, You should provide at least one widget id as param. Read documentation for more detail. https://resources.count.ly/plugins/feedback")))):b(c.WARNING,"enableRatingWidgets, window object is not available. Not enabling rating widgets.")};this.get_available_feedback_widgets=function(a){b(c.INFO,"get_available_feedback_widgets, Getting the feedback list, callback function is provided:["+!!a+"]");this.check_consent("feedback")?
|
|
134
|
+
K?b(c.ERROR,"get_available_feedback_widgets, Cannot enable feedback widgets in offline mode."):ca("get_available_feedback_widgets,",this.url+Ua,{method:"feedback",device_id:this.device_id,app_key:this.app_key,av:f.app_version},function(d,e,h){if(d)a&&a(null,d);else try{var m=JSON.parse(h).result||[];a&&a(m,null)}catch(g){b(c.ERROR,"get_available_feedback_widgets, Error while parsing feedback widgets list: "+g),a&&a(null,g)}},!1):a&&a(null,Error("Consent for feedback not provided."))};this.getFeedbackWidgetData=
|
|
135
|
+
function(a,d){if(a.type)if(b(c.INFO,"getFeedbackWidgetData, Retrieving data for: ["+JSON.stringify(a)+"], callback function is provided:["+!!d+"]"),this.check_consent("feedback"))if(K)b(c.ERROR,"getFeedbackWidgetData, Cannot enable feedback widgets in offline mode.");else{var e=this.url,h={widget_id:a._id,shown:1,sdk_version:oa,sdk_name:va,platform:this.platform,app_version:this.app_version};if("nps"===a.type)e+="/o/surveys/nps/widget";else if("survey"===a.type)e+="/o/surveys/survey/widget";else if("rating"===
|
|
136
|
+
a.type)e+="/o/surveys/rating/widget";else{b(c.ERROR,"getFeedbackWidgetData, Unknown type info: ["+a.type+"]");return}ca("getFeedbackWidgetData,",e,h,function(m,g,n){if(m)d&&d(null,m);else try{var r=JSON.parse(n);d&&d(r,null)}catch(v){b(c.ERROR,"getFeedbackWidgetData, Error while parsing feedback widgets list: "+v),d&&d(null,v)}},!0)}else d&&d(null,Error("Consent for feedback not provided."));else b(c.ERROR,"getFeedbackWidgetData, Expected the provided widget object to have a type but got: ["+JSON.stringify(a)+
|
|
137
|
+
"], aborting.")};this.present_feedback_widget=function(a,d,e,h){function m(B){document.getElementById("countly-surveys-wrapper-"+B._id).style.display="block";document.getElementById("csbg").style.display="block"}function g(B){if(!B.appearance.hideS){b(c.DEBUG,"present_feedback_widget, handling the sticker as it was not set to hidden");var V=document.createElement("div");V.innerText=B.appearance.text;V.style.color=7>B.appearance.text_color.length?"#"+B.appearance.text_color:B.appearance.text_color;
|
|
138
|
+
V.style.backgroundColor=7>B.appearance.bg_color.length?"#"+B.appearance.bg_color:B.appearance.bg_color;V.className="countly-feedback-sticker "+B.appearance.position+"-"+B.appearance.size;V.id="countly-feedback-sticker-"+B._id;document.body.appendChild(V);A(document.getElementById("countly-feedback-sticker-"+B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+B._id).style.display="flex";document.getElementById("csbg").style.display="block"})}A(document.getElementById("countly-feedback-close-icon-"+
|
|
139
|
+
B._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+B._id).style.display="none";document.getElementById("csbg").style.display="none"})}if(x){if(b(c.INFO,"present_feedback_widget, Presenting the feedback widget by appending to the element with ID: [ "+d+" ] and className: [ "+e+" ]"),this.check_consent("feedback"))if(!a||"object"!==L(a)||Array.isArray(a))b(c.ERROR,"present_feedback_widget, Please provide at least one feedback widget object.");else{b(c.INFO,"present_feedback_widget, Adding segmentation to feedback widgets:["+
|
|
140
|
+
JSON.stringify(h)+"]");h&&"object"===L(h)&&0!==Object.keys(h).length||(b(c.DEBUG,"present_feedback_widget, Segmentation is not an object or empty"),h=null);try{var n=this.url;if("nps"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: nps."),n+="/feedback/nps";else if("survey"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: survey."),n+="/feedback/survey";else if("rating"===a.type)b(c.DEBUG,"present_feedback_widget, Widget type: rating."),n+="/feedback/rating";else{b(c.ERROR,"present_feedback_widget, Feedback widget only accepts nps, rating and survey types.");
|
|
141
|
+
return}var r=window.origin||window.location.origin;if("rating"===a.type){b(c.DEBUG,"present_feedback_widget, Loading css for rating widget.");var v="ratings";Sa(this.url+"/star-rating/stylesheets/countly-feedback-web.css")}else b(c.DEBUG,"present_feedback_widget, Loading css for survey or nps."),Sa(this.url+"/surveys/stylesheets/countly-surveys.css"),v="surveys";n+="?widget_id="+a._id;n+="&app_key="+this.app_key;n+="&device_id="+this.device_id;n+="&sdk_name="+va;n+="&platform="+this.platform;n+="&app_version="+
|
|
142
|
+
this.app_version;n+="&sdk_version="+oa;var G={tc:1};h&&(G.sg=h);n+="&custom="+JSON.stringify(G);n+="&origin="+r;n+="&widget_v=web";var N=document.createElement("iframe");N.src=n;N.name="countly-"+v+"-iframe";N.id="countly-"+v+"-iframe";var J=!1;N.onload=function(){J&&(document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="none",document.getElementById("csbg").style.display="none");J=!0;b(c.DEBUG,"present_feedback_widget, Loaded iframe.")};for(var Fa=document.getElementById("csbg");Fa;)Fa.remove(),
|
|
143
|
+
Fa=document.getElementById("csbg"),b(c.DEBUG,"present_feedback_widget, Removing past overlay.");var aa=document.getElementsByClassName("countly-"+v+"-wrapper");for(h=0;h<aa.length;h++)aa[h].remove(),b(c.DEBUG,"present_feedback_widget, Removed a wrapper.");aa=document.createElement("div");aa.className="countly-"+v+"-wrapper";aa.id="countly-"+v+"-wrapper-"+a._id;"survey"===a.type&&(aa.className=aa.className+" "+a.appearance.position);var db=document.body;h=!1;d&&(document.getElementById(d)?(db=document.getElementById(d),
|
|
144
|
+
h=!0):b(c.ERROR,"present_feedback_widget, Provided ID not found."));h||e&&(document.getElementsByClassName(e)[0]?db=document.getElementsByClassName(e)[0]:b(c.ERROR,"present_feedback_widget, Provided class not found."));db.insertAdjacentHTML("beforeend",'<div id="csbg"></div>');db.appendChild(aa);if("rating"===a.type){var yb=document.createElement("div");yb.className="countly-ratings-overlay";yb.id="countly-ratings-overlay-"+a._id;aa.appendChild(yb);b(c.DEBUG,"present_feedback_widget, appended the rating overlay to wrapper");
|
|
145
|
+
A(document.getElementById("countly-ratings-overlay-"+a._id),"click",function(){document.getElementById("countly-ratings-wrapper-"+a._id).style.display="none"})}aa.appendChild(N);b(c.DEBUG,"present_feedback_widget, Appended the iframe");A(window,"message",function(B){var V={};try{V=JSON.parse(B.data),b(c.DEBUG,"present_feedback_widget, Parsed response message "+V)}catch($b){b(c.ERROR,"present_feedback_widget, Error while parsing message body "+$b)}V.close?(document.getElementById("countly-"+v+"-wrapper-"+
|
|
146
|
+
a._id).style.display="none",document.getElementById("csbg").style.display="none"):b(c.DEBUG,"present_feedback_widget, Closing signal not sent yet")});if("survey"===a.type){var R=!1;switch(a.showPolicy){case "afterPageLoad":"complete"===document.readyState?R||(R=!0,m(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||R||(R=!0,m(a))});break;case "afterConstantDelay":setTimeout(function(){R||(R=!0,m(a))},1E4);break;case "onAbandon":"complete"===document.readyState?A(document,
|
|
147
|
+
"mouseleave",function(){R||(R=!0,m(a))}):A(document,"readystatechange",function(B){"complete"===B.target.readyState&&A(document,"mouseleave",function(){R||(R=!0,m(a))})});break;case "onScrollHalfwayDown":A(window,"scroll",function(){if(!R){var B=Math.max(window.scrollY,document.body.scrollTop,document.documentElement.scrollTop),V=Ra();B>=V/2&&(R=!0,m(a))}});break;default:R||(R=!0,m(a))}}else if("nps"===a.type)document.getElementById("countly-"+v+"-wrapper-"+a._id).style.display="block",document.getElementById("csbg").style.display=
|
|
148
|
+
"block";else if("rating"===a.type){var eb=!1;"complete"===document.readyState?eb||(eb=!0,g(a)):A(document,"readystatechange",function(B){"complete"!==B.target.readyState||eb||(eb=!0,g(a))})}}catch(B){b(c.ERROR,"present_feedback_widget, Something went wrong while presenting the widget: "+B)}}}else b(c.WARNING,"present_feedback_widget, window object is not available. Not presenting feedback widget.")};this.recordError=function(a,d,e){b(c.INFO,"recordError, Recording error");if(this.check_consent("crashes")&&
|
|
149
|
+
a){e=e||ub;var h="";"object"===L(a)?"undefined"!==typeof a.stack?h=a.stack:("undefined"!==typeof a.name&&(h+=a.name+":"),"undefined"!==typeof a.message&&(h+=a.message+"\n"),"undefined"!==typeof a.fileName&&(h+="in "+a.fileName+"\n"),"undefined"!==typeof a.lineNumber&&(h+="on "+a.lineNumber),"undefined"!==typeof a.columnNumber&&(h+=":"+a.columnNumber)):h=a+"";if(h.length>f.maxStackTraceLineLength*f.maxStackTraceLinesPerThread){b(c.DEBUG,"record_error, Error stack is too long will be truncated");a=
|
|
150
|
+
h.split("\n");a.length>f.maxStackTraceLinesPerThread&&(a=a.splice(0,f.maxStackTraceLinesPerThread));h=0;for(var m=a.length;h<m;h++)a[h].length>f.maxStackTraceLineLength&&(a[h]=a[h].substring(0,f.maxStackTraceLineLength));h=a.join("\n")}d=!!d;a=Ta();h={_resolution:a._resolution,_error:h,_app_version:a._app_version,_run:F()-Sb,_not_os_specific:!0,_javascript:!0};if(m=navigator.battery||navigator.webkitBattery||navigator.mozBattery||navigator.msBattery)h._bat=Math.floor(100*m.level);"undefined"!==typeof navigator.onLine&&
|
|
151
|
+
(h._online=!!navigator.onLine);x&&(h._background=!document.hasFocus());0<sa.length&&(h._logs=sa.join("\n"));sa=[];h._nonfatal=d;h._view=this.getViewName();"undefined"!==typeof e&&(e=ba(e,f.maxKeyLength,f.maxValueSize,f.maxSegmentationValues,"record_error",b),h._custom=e);try{var g=document.createElement("canvas").getContext("experimental-webgl");h._opengl=g.getParameter(g.VERSION)}catch(n){b(c.ERROR,"Could not get the experimental-webgl context: "+n)}d={};d.crash=JSON.stringify(h);d.metrics=JSON.stringify({_ua:a._ua});
|
|
152
|
+
P(d)}};this.onStorageChange=function(a,d){b(c.DEBUG,"onStorageChange, Applying storage changes for key:",a);b(c.DEBUG,"onStorageChange, Applying storage changes for value:",d);switch(a){case "cly_queue":H=f.deserialize(d||"[]");break;case "cly_event":I=f.deserialize(d||"[]");break;case "cly_remote_configs":S=f.deserialize(d||"{}");break;case "cly_ignore":f.ignore_visitor=f.deserialize(d);break;case "cly_id":f.device_id=d;break;case "cly_id_type":D=f.deserialize(d)}};this._internals={store:w,getDocWidth:mb,
|
|
153
|
+
getDocHeight:Ra,getViewportHeight:Fb,get_page_coord:lb,get_event_target:Qa,add_event_listener:A,createNewObjectFromProperties:za,truncateObject:ba,truncateSingleValue:z,stripTrailingSlash:ta,prepareParams:jb,sendXmlHttpRequest:Nb,isResponseValid:sb,getInternalDeviceIdType:function(){return D},getMsTimestamp:hb,getTimestamp:F,isResponseValidBroad:rb,secureRandom:fb,log:b,checkIfLoggingIsOn:Ca,getMetrics:Ta,getUA:Mb,prepareRequest:Ea,generateUUID:gb,sendEventsForced:Q,isUUID:function(a){return/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-4[0-9a-fA-F]{3}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(a)},
|
|
154
|
+
calculateChecksum:Cb,isReferrerUsable:qb,getId:pb,heartBeat:Wa,toRequestQueue:P,reportViewDuration:na,loadJS:Hb,loadCSS:Sa,getLastView:function(){return Y},setToken:Qb,getToken:function(){var a=y("cly_token");T("cly_token");return a},showLoader:Ib,hideLoader:Jb,setValueInStorage:w,getValueFromStorage:y,removeValueFromStorage:T,add_cly_events:t,processScrollView:tb,processScroll:Pb,currentUserAgentString:ua,currentUserAgentDataString:kb,userAgentDeviceDetection:Db,userAgentSearchBotDetection:Eb,getRequestQueue:function(){return H},
|
|
155
|
+
getEventQueue:function(){return I},sendFetchRequest:Ob,processAsyncQueue:wa,makeNetworkRequest:ca,clearQueue:function(){H=[];w("cly_queue",[]);I=[];w("cly_event",[])},getLocalQueues:function(){return{eventQ:I,requestQ:H}}};var qa={sendInstantHCRequest:function(){var a=z(f.hcErrorMessage,1E3,"healthCheck",b);""!==a&&(a=JSON.stringify(a));a={hc:JSON.stringify({el:f.hcErrorCount,wl:f.hcWarningCount,sc:f.hcStatusCode,em:a}),metrics:JSON.stringify({_app_version:f.app_version})};Ea(a);ca("[healthCheck]",
|
|
156
|
+
f.url+ob,a,function(d){d||qa.resetAndSaveCounters()},!0)},resetAndSaveCounters:function(){qa.resetCounters();w(U.errorCount,f.hcErrorCount);w(U.warningCount,f.hcWarningCount);w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)},incrementErrorCount:function(){f.hcErrorCount++},incrementWarningCount:function(){f.hcWarningCount++},resetCounters:function(){f.hcErrorCount=0;f.hcWarningCount=0;f.hcStatusCode=-1;f.hcErrorMessage=""},saveRequestCounters:function(a,d){f.hcStatusCode=a;f.hcErrorMessage=
|
|
157
|
+
d;w(U.statusCode,f.hcStatusCode);w(U.errorMessage,f.hcErrorMessage)}};this.initialize()}),Vb=!0;p.features="apm attribution clicks crashes events feedback forms location remote-config scrolls sessions star-rating users views".split(" ");p.q=p.q||[];p.onload=p.onload||[];p.CountlyClass=Ub;p.init=function(k){k=k||{};if(p.loadAPMScriptsAsync&&Vb)Vb=!1,Xb(k);else{var q=k.app_key||p.app_key;if(!p.i||!p.i[q]){k=new Ub(k);if(!p.i){p.i={};for(var t in k)p[t]=k[t]}p.i[q]=k}return p.i[q]}};p.serialize=function(k){"object"===
|
|
158
|
+
L(k)&&(k=JSON.stringify(k));return k};p.deserialize=function(k){if(""===k)return k;try{k=JSON.parse(k)}catch(q){Ca()&&console.warn("[WARNING] [Countly] deserialize, Could not parse the file:["+k+"], error: "+q)}return k};p.getViewName=function(){return x?window.location.pathname:"web_worker"};p.getViewUrl=function(){return x?window.location.pathname:"web_worker"};p.getSearchQuery=function(){if(x)return window.location.search};p.DeviceIdType={DEVELOPER_SUPPLIED:0,SDK_GENERATED:1,TEMPORARY_ID:2};x&&
|
|
159
|
+
window.addEventListener("storage",function(k){var q=(k.key+"").split("/"),t=q.pop();q=q.pop();if(p.i&&p.i[q])p.i[q].onStorageChange(t,k.newValue)});ma.default=p;Object.defineProperty(ma,"__esModule",{value:!0})});
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["sessions","events","views","scrolls","clicks","forms","crashes","attribution","users","star-rating","feedback","location","remote-config","apm"],a=e=>{if(!i()){console.error("Telemetry script not loaded");return}window.Countly.app_version=e.appVersion,window.Countly.app_key=e.provider.apiKey,window.Countly.debug=e.provider.enableLogging??!1,window.Countly.url=e.provider.serverUrl,window.Countly.offline_mode=e.provider.offline_mode??!0,window.Countly.use_session_cookie=e.provider.useSessionCookie??!1,window.Countly.storage=e.provider.storage??"localstorage",window.Countly.require_consent=e.provider.requireConsent??!0,e.provider.autoSessionTracking&&window.Countly.q.push(["track_sessions"]),e.provider.autoPageViewTracking&&window.Countly.q.push(["track_pageview"]),e.provider.autoClickTracking&&window.Countly.q.push(["track_clicks"]),e.provider.autoScrollTracking&&window.Countly.q.push(["track_scrolls"]),e.provider.autoLinksTracking&&window.Countly.q.push(["track_links"]),e.provider.autoErrorTracking&&window.Countly.q.push(["track_errors"]),window.Countly.init()},i=()=>{const e=!!window.Countly&&!!window.Countly.q;return e||console.warn("Countly is not available"),e},l=e=>{Object.entries(e).forEach(o=>{const[n,s]=o;window.Countly.q.push(["userData.set",n,s])}),window.Countly.q.push(["userData.save"])},d=()=>{window.Countly.q.push(["begin_session"])},u=()=>{window.Countly.q.push(["end_session"])},w=({name:e,count:o,sum:n,duration:s,segmentation:r})=>{window.Countly.q.push(["add_event",{key:e,count:o,sum:n,dur:s,segmentation:r}])},c=()=>{window.Countly.q.push(["track_clicks"])},C=e=>{window.Countly.q.push(["track_pageview",e])},p=()=>{window.Countly.q.push(["add_consent",t])},y=()=>{window.Countly.q.push(["remove_consent",t])},v=e=>{window.Countly.q.push(["add_consent",e])},k=e=>{window.Countly.q.push(["remove_consent",e])},_=(e,o=!1)=>{window.Countly.q.push(["change_id",e,o])},h=e=>{window.Countly.q.push(["disable_offline_mode",e])},q=()=>{window.Countly.q.push(["enable_offline_mode"])},f=()=>window.Countly;exports.addAllConsentFeatures=p;exports.addConsentFeatures=v;exports.beginSession=d;exports.changeDeviceId=_;exports.disableOfflineMode=h;exports.enableOfflineMode=q;exports.endSession=u;exports.getProviderInstance=f;exports.initialize=a;exports.isLoaded=i;exports.removeAllConsentFeatures=y;exports.removeConsentFeatures=k;exports.setUserData=l;exports.trackClicks=c;exports.trackEvent=w;exports.trackPageView=C;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,cAAc,aAAa,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const t = [
|
|
2
|
+
"sessions",
|
|
3
|
+
"events",
|
|
4
|
+
"views",
|
|
5
|
+
"scrolls",
|
|
6
|
+
"clicks",
|
|
7
|
+
"forms",
|
|
8
|
+
"crashes",
|
|
9
|
+
"attribution",
|
|
10
|
+
"users",
|
|
11
|
+
"star-rating",
|
|
12
|
+
"feedback",
|
|
13
|
+
"location",
|
|
14
|
+
"remote-config",
|
|
15
|
+
"apm"
|
|
16
|
+
], a = (o) => {
|
|
17
|
+
if (!r()) {
|
|
18
|
+
console.error("Telemetry script not loaded");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
window.Countly.app_version = o.appVersion, window.Countly.app_key = o.provider.apiKey, window.Countly.debug = o.provider.enableLogging ?? !1, window.Countly.url = o.provider.serverUrl, window.Countly.offline_mode = o.provider.offline_mode ?? !0, window.Countly.use_session_cookie = o.provider.useSessionCookie ?? !1, window.Countly.storage = o.provider.storage ?? "localstorage", window.Countly.require_consent = o.provider.requireConsent ?? !0, o.provider.autoSessionTracking && window.Countly.q.push(["track_sessions"]), o.provider.autoPageViewTracking && window.Countly.q.push(["track_pageview"]), o.provider.autoClickTracking && window.Countly.q.push(["track_clicks"]), o.provider.autoScrollTracking && window.Countly.q.push(["track_scrolls"]), o.provider.autoLinksTracking && window.Countly.q.push(["track_links"]), o.provider.autoErrorTracking && window.Countly.q.push(["track_errors"]), window.Countly.init();
|
|
22
|
+
}, r = () => {
|
|
23
|
+
const o = !!window.Countly && !!window.Countly.q;
|
|
24
|
+
return o || console.warn("Countly is not available"), o;
|
|
25
|
+
}, u = (o) => {
|
|
26
|
+
Object.entries(o).forEach((e) => {
|
|
27
|
+
const [n, s] = e;
|
|
28
|
+
window.Countly.q.push(["userData.set", n, s]);
|
|
29
|
+
}), window.Countly.q.push(["userData.save"]);
|
|
30
|
+
}, l = () => {
|
|
31
|
+
window.Countly.q.push(["begin_session"]);
|
|
32
|
+
}, d = () => {
|
|
33
|
+
window.Countly.q.push(["end_session"]);
|
|
34
|
+
}, w = ({
|
|
35
|
+
name: o,
|
|
36
|
+
count: e,
|
|
37
|
+
sum: n,
|
|
38
|
+
duration: s,
|
|
39
|
+
segmentation: i
|
|
40
|
+
}) => {
|
|
41
|
+
window.Countly.q.push(["add_event", { key: o, count: e, sum: n, dur: s, segmentation: i }]);
|
|
42
|
+
}, c = () => {
|
|
43
|
+
window.Countly.q.push(["track_clicks"]);
|
|
44
|
+
}, p = (o) => {
|
|
45
|
+
window.Countly.q.push(["track_pageview", o]);
|
|
46
|
+
}, C = () => {
|
|
47
|
+
window.Countly.q.push(["add_consent", t]);
|
|
48
|
+
}, y = () => {
|
|
49
|
+
window.Countly.q.push(["remove_consent", t]);
|
|
50
|
+
}, k = (o) => {
|
|
51
|
+
window.Countly.q.push(["add_consent", o]);
|
|
52
|
+
}, v = (o) => {
|
|
53
|
+
window.Countly.q.push(["remove_consent", o]);
|
|
54
|
+
}, _ = (o, e = !1) => {
|
|
55
|
+
window.Countly.q.push(["change_id", o, e]);
|
|
56
|
+
}, h = (o) => {
|
|
57
|
+
window.Countly.q.push(["disable_offline_mode", o]);
|
|
58
|
+
}, q = () => {
|
|
59
|
+
window.Countly.q.push(["enable_offline_mode"]);
|
|
60
|
+
}, f = () => window.Countly;
|
|
61
|
+
export {
|
|
62
|
+
C as addAllConsentFeatures,
|
|
63
|
+
k as addConsentFeatures,
|
|
64
|
+
l as beginSession,
|
|
65
|
+
_ as changeDeviceId,
|
|
66
|
+
h as disableOfflineMode,
|
|
67
|
+
q as enableOfflineMode,
|
|
68
|
+
d as endSession,
|
|
69
|
+
f as getProviderInstance,
|
|
70
|
+
a as initialize,
|
|
71
|
+
r as isLoaded,
|
|
72
|
+
y as removeAllConsentFeatures,
|
|
73
|
+
v as removeConsentFeatures,
|
|
74
|
+
u as setUserData,
|
|
75
|
+
c as trackClicks,
|
|
76
|
+
w as trackEvent,
|
|
77
|
+
p as trackPageView
|
|
78
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Countly, CountlyConsentFeatures } from './countly';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
Countly: Countly;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
type TelemetryConsentFeatures = CountlyConsentFeatures;
|
|
8
|
+
export type TelemetryEvent<SegmentationType = string | number | boolean> = {
|
|
9
|
+
/**
|
|
10
|
+
* The name of the event
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* The number of events to be send
|
|
15
|
+
* @default 1
|
|
16
|
+
*/
|
|
17
|
+
count?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The sum to report with the event
|
|
20
|
+
*/
|
|
21
|
+
sum?: number;
|
|
22
|
+
/**
|
|
23
|
+
* The duration expressed in seconds, meant for reporting with the event
|
|
24
|
+
*/
|
|
25
|
+
duration?: number;
|
|
26
|
+
/**
|
|
27
|
+
* The an object with key/value pairs to report with the event as segments
|
|
28
|
+
*/
|
|
29
|
+
segmentation?: Record<string, SegmentationType>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Configuration options for initializing the analytics library.
|
|
33
|
+
*/
|
|
34
|
+
interface InitializeConfig {
|
|
35
|
+
/**
|
|
36
|
+
* The version of the application.
|
|
37
|
+
*/
|
|
38
|
+
appVersion: string;
|
|
39
|
+
provider: {
|
|
40
|
+
/**
|
|
41
|
+
* The URL of the analytics provider server.
|
|
42
|
+
*/
|
|
43
|
+
serverUrl: string;
|
|
44
|
+
/**
|
|
45
|
+
* The API key for the analytics provider.
|
|
46
|
+
*/
|
|
47
|
+
apiKey: string;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to automatically track user sessions (default: true).
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
autoSessionTracking?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to automatically track page views (default: true).
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
autoPageViewTracking?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to automatically track user clicks
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
autoClickTracking?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to automatically track user scrolls
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
autoScrollTracking?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to automatically track application errors
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
autoErrorTracking?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to automatically track link clicks
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
autoLinksTracking?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Whether to enable logging for debugging purposes
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
enableLogging?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Whether to require user consent before tracking data
|
|
85
|
+
* @default true
|
|
86
|
+
*/
|
|
87
|
+
requireConsent?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether to use cookies to track sessions
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
useSessionCookie?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Specifies the type of storage to use.
|
|
95
|
+
*
|
|
96
|
+
* By default, it uses local storage and falls back to cookies if local storage is unavailable.
|
|
97
|
+
* You can set the value to "localstorage" or "cookies" to force the use of a specific storage type,
|
|
98
|
+
* or use "none" to avoid using any storage and keep everything in memory.
|
|
99
|
+
* @default 'localstorage'
|
|
100
|
+
*/
|
|
101
|
+
storage?: 'localstorage' | 'cookies' | 'none';
|
|
102
|
+
/**
|
|
103
|
+
* Whether to enable offline mode.
|
|
104
|
+
*
|
|
105
|
+
* In offline mode, data is collected but not sent to the server until offline mode is disabled.
|
|
106
|
+
* If consent was enabled, it must be reestablished after enabling offline mode.
|
|
107
|
+
*
|
|
108
|
+
* @default true
|
|
109
|
+
*/
|
|
110
|
+
offline_mode?: boolean;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Initializes the analytics library with the provided configuration.
|
|
115
|
+
* @param {InitilaizeConfig} config - The configuration options.
|
|
116
|
+
*/
|
|
117
|
+
export declare const initialize: (config: InitializeConfig) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Checks if the analytics provider has been successfully loaded and is available for use.
|
|
120
|
+
*/
|
|
121
|
+
export declare const isLoaded: () => boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Sets user data in the analytics provider.
|
|
124
|
+
* @param {Record<string, Value>} userData - An object where the keys are the user data properties and the values are the corresponding data.
|
|
125
|
+
* @template Value - The type of the user data values (string, number, or boolean).
|
|
126
|
+
*/
|
|
127
|
+
export declare const setUserData: <Value = string | number | boolean>(userData: Record<string, Value>) => void;
|
|
128
|
+
/**
|
|
129
|
+
* Manually starts a new user session
|
|
130
|
+
*/
|
|
131
|
+
export declare const beginSession: () => void;
|
|
132
|
+
/**
|
|
133
|
+
* Manually ends the current user session
|
|
134
|
+
*/
|
|
135
|
+
export declare const endSession: () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Tracks a custom event.
|
|
138
|
+
*
|
|
139
|
+
* Events are a way to track any custom actions or other data you would like to track from your website.
|
|
140
|
+
* You may also set segments to view a breakdown of the action by providing the segment values.
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
export declare const trackEvent: <SegmentationType = string | number | boolean>({ name, count, sum, duration, segmentation, }: TelemetryEvent<SegmentationType>) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Automatically track clicks on the last reported view and display them on the heatmap.
|
|
146
|
+
*/
|
|
147
|
+
export declare const trackClicks: () => void;
|
|
148
|
+
/**
|
|
149
|
+
* Tracks a page view.
|
|
150
|
+
*
|
|
151
|
+
* This method will track the current page view by using location.path as the page name and then reporting it to the server.
|
|
152
|
+
* For single-page applications, pass the page name as a parameter to record the new page view.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} location - The URL or location of the page view.
|
|
155
|
+
*/
|
|
156
|
+
export declare const trackPageView: (location?: string) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Adds all available consent features to the analytics library.
|
|
159
|
+
*
|
|
160
|
+
* Use this to inform provider of the all features the user has consented to.
|
|
161
|
+
*/
|
|
162
|
+
export declare const addAllConsentFeatures: () => void;
|
|
163
|
+
/**
|
|
164
|
+
* Removes all available consent features from the analytics library.
|
|
165
|
+
*
|
|
166
|
+
* Use this to inform provider of the all features the user has withdrawn consent for.
|
|
167
|
+
*
|
|
168
|
+
*/
|
|
169
|
+
export declare const removeAllConsentFeatures: () => void;
|
|
170
|
+
/**
|
|
171
|
+
* Adds consent features to the analytics library.
|
|
172
|
+
*
|
|
173
|
+
* Use this to inform provider of the features the user has consented to.
|
|
174
|
+
*
|
|
175
|
+
* @param {TelemetryConsentFeatures[]} features - An array of consent features to add.
|
|
176
|
+
*/
|
|
177
|
+
export declare const addConsentFeatures: (features: TelemetryConsentFeatures[]) => void;
|
|
178
|
+
/**
|
|
179
|
+
* Removes consent features from the analytics library.
|
|
180
|
+
*
|
|
181
|
+
* Use this to inform provider of the features the user has withdrawn consent for.
|
|
182
|
+
*
|
|
183
|
+
* @param {TelemetryConsentFeatures[]} features - An array of consent features to remove.
|
|
184
|
+
*/
|
|
185
|
+
export declare const removeConsentFeatures: (features: TelemetryConsentFeatures[]) => void;
|
|
186
|
+
/**
|
|
187
|
+
* Changes the device ID in the analytics library.
|
|
188
|
+
*
|
|
189
|
+
* If the device ID is changed without merging and consent was enabled, all previously given consent will be removed.
|
|
190
|
+
* To merge data of both user IDs, pass `true` as the third parameter.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} newDeviceId - The new device ID to use.
|
|
193
|
+
* @param {boolean} [merge=false] - Whether to merge data of both user IDs.
|
|
194
|
+
*/
|
|
195
|
+
export declare const changeDeviceId: (newDeviceId: string, merge?: boolean) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Disables offline mode for a specific device.
|
|
198
|
+
*
|
|
199
|
+
* When offline mode is disabled, data collected while offline is sent to the server.
|
|
200
|
+
* If consent was enabled, it must be reestablished after disabling offline mode.
|
|
201
|
+
*
|
|
202
|
+
* @param {string} deviceId - The device ID for which to disable offline mode.
|
|
203
|
+
*/
|
|
204
|
+
export declare const disableOfflineMode: (deviceId: string) => void;
|
|
205
|
+
/**
|
|
206
|
+
* Enables offline mode.
|
|
207
|
+
*
|
|
208
|
+
* In offline mode, data is collected but not sent to the server until offline mode is disabled.
|
|
209
|
+
* If consent was enabled, it must be reestablished after enabling offline mode.
|
|
210
|
+
*/
|
|
211
|
+
export declare const enableOfflineMode: () => void;
|
|
212
|
+
/**
|
|
213
|
+
* Returns the underlying analytics provider instance, which provides access to the full analytics library API.
|
|
214
|
+
* @returns {AnalyticsProvider} - The analytics provider instance.
|
|
215
|
+
*/
|
|
216
|
+
export declare const getProviderInstance: () => Countly;
|
|
217
|
+
export { CountlyConsentFeatures as TelemetryConsentFeatures };
|
|
218
|
+
//# sourceMappingURL=telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,EAAE,KAAK,sBAAsB,EAAC,MAAM,WAAW,CAAC;AAE/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,CAAC;KAClB;CACF;AAED,KAAK,wBAAwB,GAAG,sBAAsB,CAAC;AAmBvD,MAAM,MAAM,cAAc,CAAC,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,IAAI;IACzE;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,UAAU,gBAAgB;IACxB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE;QACR;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC;QAClB;;WAEG;QACH,MAAM,EAAE,MAAM,CAAC;QACf;;;WAGG;QACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;QAC9B;;;WAGG;QACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B;;;WAGG;QACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B;;;WAGG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B;;;WAGG;QACH,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB;;;WAGG;QACH,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B;;;;;;;WAOG;QACH,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;QAC9C;;;;;;;WAOG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,WAAY,gBAAgB,KAAG,IAwCrD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,QAAO,OAM3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,KAAK,wCAAwC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAG,IAOhG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,QAAO,IAE7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,gBAAgB,6EAMxC,cAAc,CAAC,gBAAgB,CAAC,KAAG,IAErC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,IAE9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,cAAe,MAAM,KAAG,IAEjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAExC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAO,IAE3C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,aAAc,wBAAwB,EAAE,KAAG,IAEzE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,aAAc,wBAAwB,EAAE,KAAG,IAE5E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,gBAAiB,MAAM,UAAS,OAAO,KAAW,IAE5E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,IAErD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAAO,IAEpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAO,OAEtC,CAAC;AAEF,OAAO,EAAC,sBAAsB,IAAI,wBAAwB,EAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wireapp/telemetry",
|
|
3
|
+
"license": "GPL-3.0",
|
|
4
|
+
"repository": "https://github.com/wireapp/wire-web-packages/tree/main/packages/telemetry",
|
|
5
|
+
"files": [
|
|
6
|
+
"lib"
|
|
7
|
+
],
|
|
8
|
+
"main": "./lib/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
"./package.json": "./package.json",
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./lib/index.js",
|
|
13
|
+
"default": "./lib/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"version": "0.1.0",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.0.0",
|
|
19
|
+
"rimraf": "6.0.1",
|
|
20
|
+
"typescript": "^5.0.4",
|
|
21
|
+
"vite": "^5.4.10",
|
|
22
|
+
"vite-plugin-dts": "^4.3.0"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "yarn clean && vite build",
|
|
26
|
+
"clean": "rimraf lib"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"countly-sdk-web": "24.4.1"
|
|
30
|
+
}
|
|
31
|
+
}
|