0.2.0 • Published 2 years ago

crowne v0.2.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

crowne

Analytics

UMD

<script src="https://crowne.io/v1/web.js"></script>
<script defer>
  var Crowne = crowne('your-api-key', {
    // options
  });
</script>

ESM

import { crowne } from 'crowne/analytics';

let Crowne = crowne('your-api-key', {
  // options
});

Events

import * as crowne from 'crowne/events';

// via fetch()
await crowne.report('your-api-key', {
  type: 'ping',
  timestamp: Date.now(),
});

// via navigator.sendBeacon()
await crowne.beacon('your-api-key', [
  { type: 'ping', pong: false },
  { type: 'hello', name: 'world' },
]);

// Setup a `Client` to collect events,
// choosing the `Reporter` method to use.
// Events will be batch-reported:
//   * every `options.limit` events in queue; or
//   * every `options.interval` milliseconds
// whichever comes first.
let client = crowne.batch('your-api-key', crowne.beacon, {
  limit: 50, // default
  interval: 10e3 // (10s) default
});

client.push(
  { type: 'ping' },
  { type: 'pong' },
);

client.push({
  type: 'hello',
  name: 'world',
});

client.size();
//-> 3

// Manually report 1-50 event(s) from queue
client.report();

// Terminate the client
// NOTE: Will report all queued events
client.end();
0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago