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 days ago
Size: 1,099 bytes
 

Contents

Class file image Download
importScripts("../../lib/countly.js"); const COUNTLY_SERVER_KEY = "https://your.server.ly"; const COUNTLY_APP_KEY = "YOUR_APP_KEY"; if(COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly"){ 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(e.data)}]`); const data = e.data.data; const type = e.data.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); } };