File: examples/mpa/worker_for_test.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly Web SDK   examples/mpa/worker_for_test.js   Download  
File: examples/mpa/worker_for_test.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Countly Web SDK
Track site accesses and errors the Countly API
Author: By
Last change: [Web] Add warnings to all SDK example apps that would check if propper credentials have been set or it still has the defaults. (#473)

* feat: add warning for defaults

* Delete screenlog.0

* feat: warn

* Update index.html

* Update index.js

* Update example_ga_adapter.html

* Update example_async.html

* Update example_apm_async.html
Date: 2 months ago
Size: 1,099 bytes


Class file image Download
importScripts("../../lib/countly.js"); const COUNTLY_SERVER_KEY = ""; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === ""){ console.warn("Please do not use default set of app key and server url") } // initializing countly with params Countly.init({ app_key: COUNTLY_APP_KEY, url: COUNTLY_SERVER_KEY, //your server goes here debug: true, test_mode: true }); onmessage = function(e) { console.log(`Worker: Message received from main script:[${JSON.stringify(}]`); const data =; const type =; if (type === "event") { Countly.add_event(data); } else if (type === "view") { Countly.track_pageview(data); } else if (type === "session") { if (data === "begin_session") { Countly.begin_session(); return; } Countly.end_session(null, true); } else if (type === "get") { const queues = Countly._internals.getLocalQueues(); postMessage(queues); } };