@borisch/snitch 1.0.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 +88 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/packages/common/anonymous-id-store.d.ts +2 -0
- package/dist/packages/common/anonymous-id-store.js +27 -0
- package/dist/packages/common/anonymous-id-store.js.map +1 -0
- package/dist/packages/common/create-unique-id.d.ts +1 -0
- package/dist/packages/common/create-unique-id.js +14 -0
- package/dist/packages/common/create-unique-id.js.map +1 -0
- package/dist/packages/common/plugin-interfaces.d.ts +22 -0
- package/dist/packages/common/plugin-interfaces.js +3 -0
- package/dist/packages/common/plugin-interfaces.js.map +1 -0
- package/dist/packages/common/tmr.d.ts +38 -0
- package/dist/packages/common/tmr.js +16 -0
- package/dist/packages/common/tmr.js.map +1 -0
- package/dist/packages/common/tracker-interfaces.d.ts +8 -0
- package/dist/packages/common/tracker-interfaces.js +3 -0
- package/dist/packages/common/tracker-interfaces.js.map +1 -0
- package/dist/packages/snitch/index.d.ts +2 -0
- package/dist/packages/snitch/index.js +8 -0
- package/dist/packages/snitch/index.js.map +1 -0
- package/dist/packages/snitch/snitch.d.ts +4 -0
- package/dist/packages/snitch/snitch.js +20 -0
- package/dist/packages/snitch/snitch.js.map +1 -0
- package/dist/packages/snitch/use-plugins.d.ts +11 -0
- package/dist/packages/snitch/use-plugins.js +40 -0
- package/dist/packages/snitch/use-plugins.js.map +1 -0
- package/dist/packages/snitch-plugin-beacon-transport/beacon-transport.d.ts +6 -0
- package/dist/packages/snitch-plugin-beacon-transport/beacon-transport.js +22 -0
- package/dist/packages/snitch-plugin-beacon-transport/beacon-transport.js.map +1 -0
- package/dist/packages/snitch-plugin-beacon-transport/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-beacon-transport/index.js +8 -0
- package/dist/packages/snitch-plugin-beacon-transport/index.js.map +1 -0
- package/dist/packages/snitch-plugin-debug-logger/debug-logger.d.ts +2 -0
- package/dist/packages/snitch-plugin-debug-logger/debug-logger.js +22 -0
- package/dist/packages/snitch-plugin-debug-logger/debug-logger.js.map +1 -0
- package/dist/packages/snitch-plugin-debug-logger/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-debug-logger/index.js +8 -0
- package/dist/packages/snitch-plugin-debug-logger/index.js.map +1 -0
- package/dist/packages/snitch-plugin-engagement/engagement.d.ts +4 -0
- package/dist/packages/snitch-plugin-engagement/engagement.js +19 -0
- package/dist/packages/snitch-plugin-engagement/engagement.js.map +1 -0
- package/dist/packages/snitch-plugin-engagement/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-engagement/index.js +8 -0
- package/dist/packages/snitch-plugin-engagement/index.js.map +1 -0
- package/dist/packages/snitch-plugin-exceptions/exceptions.d.ts +2 -0
- package/dist/packages/snitch-plugin-exceptions/exceptions.js +31 -0
- package/dist/packages/snitch-plugin-exceptions/exceptions.js.map +1 -0
- package/dist/packages/snitch-plugin-exceptions/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-exceptions/index.js +8 -0
- package/dist/packages/snitch-plugin-exceptions/index.js.map +1 -0
- package/dist/packages/snitch-plugin-flag/flag-service.d.ts +36 -0
- package/dist/packages/snitch-plugin-flag/flag-service.js +37 -0
- package/dist/packages/snitch-plugin-flag/flag-service.js.map +1 -0
- package/dist/packages/snitch-plugin-flag/flag.d.ts +5 -0
- package/dist/packages/snitch-plugin-flag/flag.js +88 -0
- package/dist/packages/snitch-plugin-flag/flag.js.map +1 -0
- package/dist/packages/snitch-plugin-flag/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-flag/index.js +8 -0
- package/dist/packages/snitch-plugin-flag/index.js.map +1 -0
- package/dist/packages/snitch-plugin-launch/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-launch/index.js +8 -0
- package/dist/packages/snitch-plugin-launch/index.js.map +1 -0
- package/dist/packages/snitch-plugin-launch/launch.d.ts +2 -0
- package/dist/packages/snitch-plugin-launch/launch.js +29 -0
- package/dist/packages/snitch-plugin-launch/launch.js.map +1 -0
- package/dist/packages/snitch-plugin-location/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-location/index.js +8 -0
- package/dist/packages/snitch-plugin-location/index.js.map +1 -0
- package/dist/packages/snitch-plugin-location/listen-for-location-change.d.ts +1 -0
- package/dist/packages/snitch-plugin-location/listen-for-location-change.js +18 -0
- package/dist/packages/snitch-plugin-location/listen-for-location-change.js.map +1 -0
- package/dist/packages/snitch-plugin-location/location.d.ts +7 -0
- package/dist/packages/snitch-plugin-location/location.js +36 -0
- package/dist/packages/snitch-plugin-location/location.js.map +1 -0
- package/dist/packages/snitch-plugin-s2s-transport/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-s2s-transport/index.js +8 -0
- package/dist/packages/snitch-plugin-s2s-transport/index.js.map +1 -0
- package/dist/packages/snitch-plugin-s2s-transport/s2s-transport.d.ts +8 -0
- package/dist/packages/snitch-plugin-s2s-transport/s2s-transport.js +27 -0
- package/dist/packages/snitch-plugin-s2s-transport/s2s-transport.js.map +1 -0
- package/dist/packages/snitch-plugin-screens/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-screens/index.js +8 -0
- package/dist/packages/snitch-plugin-screens/index.js.map +1 -0
- package/dist/packages/snitch-plugin-screens/screens.d.ts +6 -0
- package/dist/packages/snitch-plugin-screens/screens.js +31 -0
- package/dist/packages/snitch-plugin-screens/screens.js.map +1 -0
- package/dist/packages/snitch-plugin-scroll/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-scroll/index.js +8 -0
- package/dist/packages/snitch-plugin-scroll/index.js.map +1 -0
- package/dist/packages/snitch-plugin-scroll/listen-for-scroll-change.d.ts +2 -0
- package/dist/packages/snitch-plugin-scroll/listen-for-scroll-change.js +24 -0
- package/dist/packages/snitch-plugin-scroll/listen-for-scroll-change.js.map +1 -0
- package/dist/packages/snitch-plugin-scroll/scroll.d.ts +2 -0
- package/dist/packages/snitch-plugin-scroll/scroll.js +40 -0
- package/dist/packages/snitch-plugin-scroll/scroll.js.map +1 -0
- package/dist/packages/snitch-plugin-session/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-session/index.js +8 -0
- package/dist/packages/snitch-plugin-session/index.js.map +1 -0
- package/dist/packages/snitch-plugin-session/session.d.ts +14 -0
- package/dist/packages/snitch-plugin-session/session.js +99 -0
- package/dist/packages/snitch-plugin-session/session.js.map +1 -0
- package/dist/packages/snitch-plugin-session/storage.d.ts +11 -0
- package/dist/packages/snitch-plugin-session/storage.js +61 -0
- package/dist/packages/snitch-plugin-session/storage.js.map +1 -0
- package/dist/packages/snitch-plugin-session/utm.d.ts +6 -0
- package/dist/packages/snitch-plugin-session/utm.js +25 -0
- package/dist/packages/snitch-plugin-session/utm.js.map +1 -0
- package/dist/packages/snitch-plugin-topmailru-transport/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-topmailru-transport/index.js +8 -0
- package/dist/packages/snitch-plugin-topmailru-transport/index.js.map +1 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-counter-mock.d.ts +5 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-counter-mock.js +13 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-counter-mock.js.map +1 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-transport.d.ts +4 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-transport.js +59 -0
- package/dist/packages/snitch-plugin-topmailru-transport/topmailru-transport.js.map +1 -0
- package/dist/packages/snitch-plugin-useragent/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-useragent/index.js +8 -0
- package/dist/packages/snitch-plugin-useragent/index.js.map +1 -0
- package/dist/packages/snitch-plugin-useragent/useragent.d.ts +2 -0
- package/dist/packages/snitch-plugin-useragent/useragent.js +13 -0
- package/dist/packages/snitch-plugin-useragent/useragent.js.map +1 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/index.js +8 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/index.js.map +1 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-send.d.ts +25 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-send.js +63 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-send.js.map +1 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-transport.d.ts +3 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-transport.js +42 -0
- package/dist/packages/snitch-plugin-vkbridge-transport/vkbridge-transport.js.map +1 -0
- package/dist/packages/snitch-plugin-vkma-launch/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-vkma-launch/index.js +8 -0
- package/dist/packages/snitch-plugin-vkma-launch/index.js.map +1 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch-params.d.ts +9 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch-params.js +28 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch-params.js.map +1 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch.d.ts +2 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch.js +37 -0
- package/dist/packages/snitch-plugin-vkma-launch/vkma-launch.js.map +1 -0
- package/dist/packages/snitch-plugin-web-vitals/index.d.ts +2 -0
- package/dist/packages/snitch-plugin-web-vitals/index.js +8 -0
- package/dist/packages/snitch-plugin-web-vitals/index.js.map +1 -0
- package/dist/packages/snitch-plugin-web-vitals/web-vitals.d.ts +2 -0
- package/dist/packages/snitch-plugin-web-vitals/web-vitals.js +25 -0
- package/dist/packages/snitch-plugin-web-vitals/web-vitals.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Snitch
|
|
2
|
+
|
|
3
|
+
Modular analytics tracking library. Compose your tracker from small, focused plugins and transports.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @borisch/snitch
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { snitch, sessionPlugin, scrollPlugin, beaconTransportPlugin } from '@borisch/snitch'
|
|
15
|
+
|
|
16
|
+
const captureEvent = snitch(
|
|
17
|
+
sessionPlugin(),
|
|
18
|
+
scrollPlugin({ threshold: 25 }),
|
|
19
|
+
beaconTransportPlugin({ url: 'https://analytics.example.com/collect' })
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// Manually capture events
|
|
23
|
+
captureEvent('button_click', { buttonId: 'signup' })
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The `snitch()` function accepts any number of plugins and returns a `captureEvent` function. Plugins can:
|
|
27
|
+
|
|
28
|
+
- **Provide event parameters** (automatically attached to every event)
|
|
29
|
+
- **Emit events** on their own (e.g. scroll milestones, page views)
|
|
30
|
+
- **Transport events** to a backend (Beacon API, fetch, VK Bridge, etc.)
|
|
31
|
+
- **Intercept events** before they are sent
|
|
32
|
+
|
|
33
|
+
## Plugins
|
|
34
|
+
|
|
35
|
+
| Plugin | Factory | Description |
|
|
36
|
+
| ------------------ | ------------------------ | ---------------------------------------------------------- |
|
|
37
|
+
| Session | `sessionPlugin()` | Generates a unique session ID, attaches it to every event |
|
|
38
|
+
| Launch | `launchPlugin()` | Captures a `launch` event on initialization |
|
|
39
|
+
| Scroll | `scrollPlugin(opts)` | Tracks scroll depth milestones (default: 25/50/75/100%) |
|
|
40
|
+
| Location | `locationPlugin()` | Attaches page URL and referrer to every event |
|
|
41
|
+
| Engagement | `engagementPlugin(opts)` | Tracks time spent on page, emits engagement events |
|
|
42
|
+
| Screens | `screenPlugin()` | Tracks screen/page view events |
|
|
43
|
+
| Exceptions | `exceptionsPlugin()` | Captures unhandled errors and unhandled promise rejections |
|
|
44
|
+
| Web Vitals | `webVitalsPlugin()` | Reports Core Web Vitals (LCP, FID, CLS, etc.) |
|
|
45
|
+
| Flag | `flagPlugin(opts)` | Attaches a static key-value flag to every event |
|
|
46
|
+
| User Agent | `useragentPlugin()` | Attaches `navigator.userAgent` to every event |
|
|
47
|
+
| Debug Logger | `debugLoggerPlugin()` | Logs all events to the console (for development) |
|
|
48
|
+
| VK Mini App Launch | `vkmaLaunchPlugin()` | Parses VK Mini App launch parameters |
|
|
49
|
+
|
|
50
|
+
## Transports
|
|
51
|
+
|
|
52
|
+
| Transport | Factory | Description |
|
|
53
|
+
| ----------- | -------------------------------- | ------------------------------------------------------------------------------- |
|
|
54
|
+
| Beacon | `beaconTransportPlugin(opts)` | Sends events as URL query params via `navigator.sendBeacon()` |
|
|
55
|
+
| S2S | `s2sTransportPlugin(opts)` | Sends events as URL query params via `fetch()` GET (for server-side / Node 18+) |
|
|
56
|
+
| Top Mail.ru | `topmailruTransportPlugin(opts)` | Sends events to Top Mail.ru counter |
|
|
57
|
+
| VK Bridge | `vkBridgeTransportPlugin(opts)` | Sends events via VK Bridge |
|
|
58
|
+
|
|
59
|
+
## Types
|
|
60
|
+
|
|
61
|
+
All public types are exported for TypeScript consumers:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import type { Plugin, EventTransport, TrackerEventPayload } from '@borisch/snitch'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Writing a Custom Plugin
|
|
68
|
+
|
|
69
|
+
A plugin is any object that partially implements the `Plugin` interface:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import type { Plugin } from '@borisch/snitch'
|
|
73
|
+
|
|
74
|
+
function myPlugin(): Plugin {
|
|
75
|
+
return {
|
|
76
|
+
getEventPayloadParams() {
|
|
77
|
+
return { customParam: 'value' }
|
|
78
|
+
},
|
|
79
|
+
sendEvent(eventName, eventParams) {
|
|
80
|
+
// custom transport logic
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { default as snitch } from './packages/snitch/index';
|
|
2
|
+
export { default } from './packages/snitch/index';
|
|
3
|
+
export type { Plugin, EventPayloadParamsProvider, InitializationHandler, EventSource, BeforeCaptureEventHandler, EventTransport, MixinProvider, } from './packages/common/plugin-interfaces';
|
|
4
|
+
export type { TrackerEventPayload, EventHandler, TrackerInitializationOptions, } from './packages/common/tracker-interfaces';
|
|
5
|
+
export { default as scrollPlugin } from './packages/snitch-plugin-scroll/index';
|
|
6
|
+
export { default as locationPlugin } from './packages/snitch-plugin-location/index';
|
|
7
|
+
export { default as sessionPlugin } from './packages/snitch-plugin-session/index';
|
|
8
|
+
export { default as launchPlugin } from './packages/snitch-plugin-launch/index';
|
|
9
|
+
export { default as engagementPlugin } from './packages/snitch-plugin-engagement/index';
|
|
10
|
+
export { default as screenPlugin } from './packages/snitch-plugin-screens/index';
|
|
11
|
+
export { default as exceptionsPlugin } from './packages/snitch-plugin-exceptions/index';
|
|
12
|
+
export { default as webVitalsPlugin } from './packages/snitch-plugin-web-vitals/index';
|
|
13
|
+
export { default as flagPlugin } from './packages/snitch-plugin-flag/index';
|
|
14
|
+
export { default as debugLoggerPlugin } from './packages/snitch-plugin-debug-logger/index';
|
|
15
|
+
export { default as useragentPlugin } from './packages/snitch-plugin-useragent/index';
|
|
16
|
+
export { default as beaconTransportPlugin } from './packages/snitch-plugin-beacon-transport/index';
|
|
17
|
+
export { default as s2sTransportPlugin } from './packages/snitch-plugin-s2s-transport/index';
|
|
18
|
+
export { default as topmailruTransportPlugin } from './packages/snitch-plugin-topmailru-transport/index';
|
|
19
|
+
export { default as vkBridgeTransportPlugin } from './packages/snitch-plugin-vkbridge-transport/index';
|
|
20
|
+
export { default as vkmaLaunchPlugin } from './packages/snitch-plugin-vkma-launch/index';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.vkmaLaunchPlugin = exports.vkBridgeTransportPlugin = exports.topmailruTransportPlugin = exports.s2sTransportPlugin = exports.beaconTransportPlugin = exports.useragentPlugin = exports.debugLoggerPlugin = exports.flagPlugin = exports.webVitalsPlugin = exports.exceptionsPlugin = exports.screenPlugin = exports.engagementPlugin = exports.launchPlugin = exports.sessionPlugin = exports.locationPlugin = exports.scrollPlugin = exports.default = exports.snitch = void 0;
|
|
7
|
+
// Core
|
|
8
|
+
var index_1 = require("./packages/snitch/index");
|
|
9
|
+
Object.defineProperty(exports, "snitch", { enumerable: true, get: function () { return __importDefault(index_1).default; } });
|
|
10
|
+
var index_2 = require("./packages/snitch/index");
|
|
11
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(index_2).default; } });
|
|
12
|
+
// Plugins
|
|
13
|
+
var index_3 = require("./packages/snitch-plugin-scroll/index");
|
|
14
|
+
Object.defineProperty(exports, "scrollPlugin", { enumerable: true, get: function () { return __importDefault(index_3).default; } });
|
|
15
|
+
var index_4 = require("./packages/snitch-plugin-location/index");
|
|
16
|
+
Object.defineProperty(exports, "locationPlugin", { enumerable: true, get: function () { return __importDefault(index_4).default; } });
|
|
17
|
+
var index_5 = require("./packages/snitch-plugin-session/index");
|
|
18
|
+
Object.defineProperty(exports, "sessionPlugin", { enumerable: true, get: function () { return __importDefault(index_5).default; } });
|
|
19
|
+
var index_6 = require("./packages/snitch-plugin-launch/index");
|
|
20
|
+
Object.defineProperty(exports, "launchPlugin", { enumerable: true, get: function () { return __importDefault(index_6).default; } });
|
|
21
|
+
var index_7 = require("./packages/snitch-plugin-engagement/index");
|
|
22
|
+
Object.defineProperty(exports, "engagementPlugin", { enumerable: true, get: function () { return __importDefault(index_7).default; } });
|
|
23
|
+
var index_8 = require("./packages/snitch-plugin-screens/index");
|
|
24
|
+
Object.defineProperty(exports, "screenPlugin", { enumerable: true, get: function () { return __importDefault(index_8).default; } });
|
|
25
|
+
var index_9 = require("./packages/snitch-plugin-exceptions/index");
|
|
26
|
+
Object.defineProperty(exports, "exceptionsPlugin", { enumerable: true, get: function () { return __importDefault(index_9).default; } });
|
|
27
|
+
var index_10 = require("./packages/snitch-plugin-web-vitals/index");
|
|
28
|
+
Object.defineProperty(exports, "webVitalsPlugin", { enumerable: true, get: function () { return __importDefault(index_10).default; } });
|
|
29
|
+
var index_11 = require("./packages/snitch-plugin-flag/index");
|
|
30
|
+
Object.defineProperty(exports, "flagPlugin", { enumerable: true, get: function () { return __importDefault(index_11).default; } });
|
|
31
|
+
var index_12 = require("./packages/snitch-plugin-debug-logger/index");
|
|
32
|
+
Object.defineProperty(exports, "debugLoggerPlugin", { enumerable: true, get: function () { return __importDefault(index_12).default; } });
|
|
33
|
+
var index_13 = require("./packages/snitch-plugin-useragent/index");
|
|
34
|
+
Object.defineProperty(exports, "useragentPlugin", { enumerable: true, get: function () { return __importDefault(index_13).default; } });
|
|
35
|
+
// Transports
|
|
36
|
+
var index_14 = require("./packages/snitch-plugin-beacon-transport/index");
|
|
37
|
+
Object.defineProperty(exports, "beaconTransportPlugin", { enumerable: true, get: function () { return __importDefault(index_14).default; } });
|
|
38
|
+
var index_15 = require("./packages/snitch-plugin-s2s-transport/index");
|
|
39
|
+
Object.defineProperty(exports, "s2sTransportPlugin", { enumerable: true, get: function () { return __importDefault(index_15).default; } });
|
|
40
|
+
var index_16 = require("./packages/snitch-plugin-topmailru-transport/index");
|
|
41
|
+
Object.defineProperty(exports, "topmailruTransportPlugin", { enumerable: true, get: function () { return __importDefault(index_16).default; } });
|
|
42
|
+
var index_17 = require("./packages/snitch-plugin-vkbridge-transport/index");
|
|
43
|
+
Object.defineProperty(exports, "vkBridgeTransportPlugin", { enumerable: true, get: function () { return __importDefault(index_17).default; } });
|
|
44
|
+
// Platform-specific
|
|
45
|
+
var index_18 = require("./packages/snitch-plugin-vkma-launch/index");
|
|
46
|
+
Object.defineProperty(exports, "vkmaLaunchPlugin", { enumerable: true, get: function () { return __importDefault(index_18).default; } });
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,iDAA2D;AAAlD,gHAAA,OAAO,OAAU;AAC1B,iDAAiD;AAAxC,iHAAA,OAAO,OAAA;AAmBhB,UAAU;AACV,+DAA+E;AAAtE,sHAAA,OAAO,OAAgB;AAChC,iEAAmF;AAA1E,wHAAA,OAAO,OAAkB;AAClC,gEAAiF;AAAxE,uHAAA,OAAO,OAAiB;AACjC,+DAA+E;AAAtE,sHAAA,OAAO,OAAgB;AAChC,mEAAuF;AAA9E,0HAAA,OAAO,OAAoB;AACpC,gEAAgF;AAAvE,sHAAA,OAAO,OAAgB;AAChC,mEAAuF;AAA9E,0HAAA,OAAO,OAAoB;AACpC,oEAAsF;AAA7E,0HAAA,OAAO,OAAmB;AACnC,8DAA2E;AAAlE,qHAAA,OAAO,OAAc;AAC9B,sEAA0F;AAAjF,4HAAA,OAAO,OAAqB;AACrC,mEAAqF;AAA5E,0HAAA,OAAO,OAAmB;AAEnC,aAAa;AACb,0EAAkG;AAAzF,gIAAA,OAAO,OAAyB;AACzC,uEAA4F;AAAnF,6HAAA,OAAO,OAAsB;AACtC,6EAAwG;AAA/F,mIAAA,OAAO,OAA4B;AAC5C,4EAAsG;AAA7F,kIAAA,OAAO,OAA2B;AAE3C,oBAAoB;AACpB,qEAAwF;AAA/E,2HAAA,OAAO,OAAoB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAnonymousUserId = exports.setAnonymousUserId = void 0;
|
|
4
|
+
const LOCAL_STORAGE_USER_ID_KEY = 'isdp:auid';
|
|
5
|
+
let anonymousUserIdCache;
|
|
6
|
+
function setAnonymousUserId(userId) {
|
|
7
|
+
try {
|
|
8
|
+
localStorage.setItem(LOCAL_STORAGE_USER_ID_KEY, userId);
|
|
9
|
+
}
|
|
10
|
+
catch (error) { }
|
|
11
|
+
anonymousUserIdCache = userId;
|
|
12
|
+
}
|
|
13
|
+
exports.setAnonymousUserId = setAnonymousUserId;
|
|
14
|
+
function getAnonymousUserId() {
|
|
15
|
+
if (anonymousUserIdCache)
|
|
16
|
+
return anonymousUserIdCache;
|
|
17
|
+
try {
|
|
18
|
+
anonymousUserIdCache = localStorage.getItem(LOCAL_STORAGE_USER_ID_KEY);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.warn(error);
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return anonymousUserIdCache;
|
|
25
|
+
}
|
|
26
|
+
exports.getAnonymousUserId = getAnonymousUserId;
|
|
27
|
+
//# sourceMappingURL=anonymous-id-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anonymous-id-store.js","sourceRoot":"","sources":["../../../packages/common/anonymous-id-store.ts"],"names":[],"mappings":";;;AAAA,MAAM,yBAAyB,GAAG,WAAW,CAAA;AAC7C,IAAI,oBAAmC,CAAA;AAEvC,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,IAAI;QACF,YAAY,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAA;KACxD;IAAC,OAAO,KAAK,EAAE,GAAE;IAClB,oBAAoB,GAAG,MAAM,CAAA;AAC/B,CAAC;AALD,gDAKC;AAED,SAAgB,kBAAkB;IAChC,IAAI,oBAAoB;QAAE,OAAO,oBAAoB,CAAA;IACrD,IAAI;QACF,oBAAoB,GAAG,YAAY,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAA;KACvE;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACnB,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AATD,gDASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function createUniqueId(): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function createUniqueId() {
|
|
4
|
+
let uniqueId = '';
|
|
5
|
+
const length = 32;
|
|
6
|
+
const alphabet = 'useandom26T198340PX75pxJACKVERYMINDBUSHWOLFGQZbfghjklqvwyzrict';
|
|
7
|
+
const alphabetLength = alphabet.length;
|
|
8
|
+
for (var i = 0; i < length; i++) {
|
|
9
|
+
uniqueId += alphabet.charAt(Math.floor(Math.random() * alphabetLength));
|
|
10
|
+
}
|
|
11
|
+
return uniqueId;
|
|
12
|
+
}
|
|
13
|
+
exports.default = createUniqueId;
|
|
14
|
+
//# sourceMappingURL=create-unique-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-unique-id.js","sourceRoot":"","sources":["../../../packages/common/create-unique-id.ts"],"names":[],"mappings":";;AAAA,SAAwB,cAAc;IACpC,IAAI,QAAQ,GAAG,EAAE,CAAA;IACjB,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,MAAM,QAAQ,GAAG,gEAAgE,CAAA;IACjF,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAA;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAA;KACxE;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AATD,iCASC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventHandler, TrackerEventPayload } from './tracker-interfaces';
|
|
2
|
+
export interface EventPayloadParamsProvider {
|
|
3
|
+
getEventPayloadParams(): {
|
|
4
|
+
[key: string]: string | number;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface InitializationHandler {
|
|
8
|
+
onInit(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface EventSource {
|
|
11
|
+
setEventHandler(eventHandler: EventHandler): void;
|
|
12
|
+
}
|
|
13
|
+
export interface BeforeCaptureEventHandler {
|
|
14
|
+
beforeCaptureEvent(eventName: string, eventParams?: TrackerEventPayload): void;
|
|
15
|
+
}
|
|
16
|
+
export interface EventTransport {
|
|
17
|
+
sendEvent(eventName: string, eventParams?: TrackerEventPayload): void;
|
|
18
|
+
}
|
|
19
|
+
export interface MixinProvider {
|
|
20
|
+
getMixins(): Record<string, Function>;
|
|
21
|
+
}
|
|
22
|
+
export declare type Plugin = Partial<EventPayloadParamsProvider & InitializationHandler & BeforeCaptureEventHandler & EventTransport & EventSource & MixinProvider>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-interfaces.js","sourceRoot":"","sources":["../../../packages/common/plugin-interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
_tmr: TMRCounter | UninitializedTMRCounter;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare type UninitializedTMRCounter = Array<TMRInstructionSendCustomEvent | TMRInstructionSetUserId | TMRInstructionUnsetUserId | TMRInstructionSetOnReadyCallback>;
|
|
7
|
+
interface TMRInstruction {
|
|
8
|
+
id: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TMRInstructionSendCustomEvent extends TMRInstruction {
|
|
12
|
+
type: 'reachGoal';
|
|
13
|
+
goal: string;
|
|
14
|
+
params?: IMRCustomEventParams;
|
|
15
|
+
value?: number;
|
|
16
|
+
version?: string;
|
|
17
|
+
userid?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IMRCustomEventParams {
|
|
20
|
+
[key: string]: string | number | boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface TMRInstructionSetUserId {
|
|
23
|
+
type: 'setUserID';
|
|
24
|
+
userid: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TMRInstructionUnsetUserId {
|
|
27
|
+
type: 'deleteUserID';
|
|
28
|
+
}
|
|
29
|
+
export interface TMRInstructionSetOnReadyCallback {
|
|
30
|
+
type: 'onReady';
|
|
31
|
+
callback: Function;
|
|
32
|
+
}
|
|
33
|
+
export interface TMRCounter {
|
|
34
|
+
push(instruction: TMRInstructionSendCustomEvent | TMRInstructionSetUserId | TMRInstructionUnsetUserId | TMRInstructionSetOnReadyCallback): void;
|
|
35
|
+
getUserID(): string | undefined;
|
|
36
|
+
}
|
|
37
|
+
export declare const getTMRCounterUserId: () => string | null | undefined;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTMRCounterUserId = void 0;
|
|
4
|
+
const getTMRCounterUserId = () => {
|
|
5
|
+
const _tmr = window._tmr;
|
|
6
|
+
if (_tmr.getUserID)
|
|
7
|
+
return _tmr.getUserID();
|
|
8
|
+
const userId = window._tmr.reduce((userId, eventCandidate) => {
|
|
9
|
+
if (eventCandidate.type === 'setUserID')
|
|
10
|
+
return eventCandidate.userid;
|
|
11
|
+
return userId;
|
|
12
|
+
}, '');
|
|
13
|
+
return userId || null;
|
|
14
|
+
};
|
|
15
|
+
exports.getTMRCounterUserId = getTMRCounterUserId;
|
|
16
|
+
//# sourceMappingURL=tmr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmr.js","sourceRoot":"","sources":["../../../packages/common/tmr.ts"],"names":[],"mappings":";;;AAwDO,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAkB,CAAA;IACtC,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAC,SAAS,EAAE,CAAA;IAC3C,MAAM,MAAM,GAAI,MAAM,CAAC,IAAgC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE;QACxF,IAAI,cAAc,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,cAAc,CAAC,MAAM,CAAA;QACrE,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,OAAO,MAAM,IAAI,IAAI,CAAA;AACvB,CAAC,CAAA;AARY,QAAA,mBAAmB,uBAQ/B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin } from './plugin-interfaces';
|
|
2
|
+
export declare type TrackerEventPayload = {
|
|
3
|
+
[key: string]: string | number;
|
|
4
|
+
};
|
|
5
|
+
export declare type EventHandler = (eventName: string, eventPayload?: TrackerEventPayload) => void;
|
|
6
|
+
export declare type TrackerInitializationOptions = {
|
|
7
|
+
plugins?: Array<Plugin>;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracker-interfaces.js","sourceRoot":"","sources":["../../../packages/common/tracker-interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const snitch_1 = __importDefault(require("./snitch"));
|
|
7
|
+
exports.default = snitch_1.default;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/snitch/index.ts"],"names":[],"mappings":";;;;;AAAA,sDAA6B;AAC7B,kBAAe,gBAAM,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Plugin } from '../common/plugin-interfaces';
|
|
2
|
+
import { TrackerEventPayload } from '../common/tracker-interfaces';
|
|
3
|
+
declare const _default: (...args: Array<Plugin>) => (eventName: string, eventPayload?: TrackerEventPayload | undefined) => void;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const use_plugins_1 = __importDefault(require("./use-plugins"));
|
|
7
|
+
exports.default = (...args) => {
|
|
8
|
+
const plugins = use_plugins_1.default(args);
|
|
9
|
+
const captureEvent = (eventName, eventPayload) => {
|
|
10
|
+
plugins.callBeforeCaptureEventHandlers(eventName, eventPayload);
|
|
11
|
+
plugins.callTransports(eventName, plugins.callEventPayloadParamsProviders({
|
|
12
|
+
...eventPayload
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
plugins.setEventHandler(captureEvent);
|
|
16
|
+
plugins.callInitializationHandlers();
|
|
17
|
+
plugins.applyMixins(captureEvent);
|
|
18
|
+
return captureEvent;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=snitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snitch.js","sourceRoot":"","sources":["../../../packages/snitch/snitch.ts"],"names":[],"mappings":";;;;;AAEA,gEAAsC;AAEtC,kBAAe,CAAC,GAAG,IAAmB,EAAE,EAAE;IACxC,MAAM,OAAO,GAAG,qBAAU,CAAC,IAAI,CAAC,CAAA;IAEhC,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE,YAAkC,EAAE,EAAE;QAC7E,OAAO,CAAC,8BAA8B,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;QAC/D,OAAO,CAAC,cAAc,CACpB,SAAS,EACT,OAAO,CAAC,+BAA+B,CAAC;YACtC,GAAG,YAAY;SAChB,CAAC,CACH,CAAA;IACH,CAAC,CAAA;IAED,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAA;IACrC,OAAO,CAAC,0BAA0B,EAAE,CAAA;IACpC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IACjC,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from '../common/plugin-interfaces';
|
|
2
|
+
import { EventHandler, TrackerEventPayload } from '../common/tracker-interfaces';
|
|
3
|
+
declare const _default: (plugins: Array<Plugin>) => {
|
|
4
|
+
callBeforeCaptureEventHandlers(eventName: string, eventPayload?: TrackerEventPayload | undefined): void;
|
|
5
|
+
callEventPayloadParamsProviders(eventPayload: TrackerEventPayload): TrackerEventPayload;
|
|
6
|
+
callTransports(eventName: string, eventPayload?: TrackerEventPayload | undefined): void;
|
|
7
|
+
callInitializationHandlers(): void;
|
|
8
|
+
setEventHandler(eventHandler: EventHandler): void;
|
|
9
|
+
applyMixins(eventHandler: EventHandler): void;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = (plugins) => ({
|
|
4
|
+
callBeforeCaptureEventHandlers(eventName, eventPayload) {
|
|
5
|
+
plugins.forEach(plugin => {
|
|
6
|
+
var _a;
|
|
7
|
+
(_a = plugin.beforeCaptureEvent) === null || _a === void 0 ? void 0 : _a.call(plugin, eventName, eventPayload);
|
|
8
|
+
});
|
|
9
|
+
},
|
|
10
|
+
callEventPayloadParamsProviders(eventPayload) {
|
|
11
|
+
return plugins.reduce((params, plugin) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return ({
|
|
14
|
+
...params,
|
|
15
|
+
...(((_a = plugin.getEventPayloadParams) === null || _a === void 0 ? void 0 : _a.call(plugin)) || {})
|
|
16
|
+
});
|
|
17
|
+
}, eventPayload);
|
|
18
|
+
},
|
|
19
|
+
callTransports(eventName, eventPayload) {
|
|
20
|
+
plugins.forEach(plugin => {
|
|
21
|
+
var _a;
|
|
22
|
+
(_a = plugin.sendEvent) === null || _a === void 0 ? void 0 : _a.call(plugin, eventName, eventPayload);
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
callInitializationHandlers() {
|
|
26
|
+
plugins.forEach(plugin => { var _a; return (_a = plugin.onInit) === null || _a === void 0 ? void 0 : _a.call(plugin); });
|
|
27
|
+
},
|
|
28
|
+
setEventHandler(eventHandler) {
|
|
29
|
+
plugins.forEach(plugin => { var _a; return (_a = plugin.setEventHandler) === null || _a === void 0 ? void 0 : _a.call(plugin, eventHandler); });
|
|
30
|
+
},
|
|
31
|
+
applyMixins(eventHandler) {
|
|
32
|
+
Object.setPrototypeOf(eventHandler, plugins.reduce((mixins, plugin) => {
|
|
33
|
+
if (plugin.getMixins) {
|
|
34
|
+
return { ...mixins, ...plugin.getMixins() };
|
|
35
|
+
}
|
|
36
|
+
return mixins;
|
|
37
|
+
}, {}));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=use-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-plugins.js","sourceRoot":"","sources":["../../../packages/snitch/use-plugins.ts"],"names":[],"mappings":";;AAGA,kBAAe,CAAC,OAAsB,EAAE,EAAE,CAAC,CAAC;IAC1C,8BAA8B,CAAC,SAAiB,EAAE,YAAkC;QAClF,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;;YACvB,MAAA,MAAM,CAAC,kBAAkB,+CAAzB,MAAM,EAAsB,SAAS,EAAE,YAAY,CAAC,CAAA;QACtD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,+BAA+B,CAAC,YAAiC;QAC/D,OAAO,OAAO,CAAC,MAAM,CACnB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;;YAAC,OAAA,CAAC;gBACnB,GAAG,MAAM;gBACT,GAAG,CAAC,CAAA,MAAA,MAAM,CAAC,qBAAqB,+CAA5B,MAAM,CAA0B,KAAI,EAAE,CAAC;aAC5C,CAAC,CAAA;SAAA,EACF,YAAY,CACb,CAAA;IACH,CAAC;IAED,cAAc,CAAC,SAAiB,EAAE,YAAkC;QAClE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;;YACvB,MAAA,MAAM,CAAC,SAAS,+CAAhB,MAAM,EAAa,SAAS,EAAE,YAAY,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,0BAA0B;QACxB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,MAAM,+CAAb,MAAM,CAAW,CAAA,EAAA,CAAC,CAAA;IAC9C,CAAC;IAED,eAAe,CAAC,YAA0B;QACxC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAC,OAAA,MAAA,MAAM,CAAC,eAAe,+CAAtB,MAAM,EAAmB,YAAY,CAAC,CAAA,EAAA,CAAC,CAAA;IACnE,CAAC;IAED,WAAW,CAAC,YAA0B;QACpC,MAAM,CAAC,cAAc,CACnB,YAAY,EACZ,OAAO,CAAC,MAAM,CAAC,CAAC,MAAgC,EAAE,MAAM,EAAE,EAAE;YAC1D,IAAI,MAAM,CAAC,SAAS,EAAE;gBACpB,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,CAAA;aAC5C;YACD,OAAO,MAAM,CAAA;QACf,CAAC,EAAE,EAAE,CAAC,CACP,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function beaconTransportPlugin(options) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const hostname = (_a = options === null || options === void 0 ? void 0 : options.hostname) !== null && _a !== void 0 ? _a : window.location.hostname;
|
|
6
|
+
const path = (_b = options === null || options === void 0 ? void 0 : options.path) !== null && _b !== void 0 ? _b : '/_snitch';
|
|
7
|
+
return {
|
|
8
|
+
sendEvent(eventName, eventParams) {
|
|
9
|
+
const protocol = window.location.protocol;
|
|
10
|
+
const params = new URLSearchParams({ event: eventName });
|
|
11
|
+
if (eventParams) {
|
|
12
|
+
for (const key of Object.keys(eventParams)) {
|
|
13
|
+
params.set(key, String(eventParams[key]));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const url = `${protocol}//${hostname}${path}?${params.toString()}`;
|
|
17
|
+
navigator.sendBeacon(url);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.default = beaconTransportPlugin;
|
|
22
|
+
//# sourceMappingURL=beacon-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"beacon-transport.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-beacon-transport/beacon-transport.ts"],"names":[],"mappings":";;AAQA,SAAwB,qBAAqB,CAAC,OAAgC;;IAC5E,MAAM,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA;IAC9D,MAAM,IAAI,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,UAAU,CAAA;IAExC,OAAO;QACL,SAAS,CAAC,SAAiB,EAAE,WAAiC;YAC5D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA;YACzC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;YACxD,IAAI,WAAW,EAAE;gBACf,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;oBAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;iBAC1C;aACF;YACD,MAAM,GAAG,GAAG,GAAG,QAAQ,KAAK,QAAQ,GAAG,IAAI,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAA;YAClE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,wCAiBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const beacon_transport_1 = __importDefault(require("./beacon-transport"));
|
|
7
|
+
exports.default = beacon_transport_1.default;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-beacon-transport/index.ts"],"names":[],"mappings":";;;;;AAAA,0EAAsD;AACtD,kBAAe,0BAAqB,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function engagementPlugin() {
|
|
4
|
+
let lastLogTS = null;
|
|
5
|
+
function logLine(message) {
|
|
6
|
+
const now = new Date();
|
|
7
|
+
console.log(`%c[${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}]${lastLogTS ? ` (+${Math.floor((now.getTime() - lastLogTS) / 1e3)}s)` : ''} %cSnitch: %c${message}`, 'color: gray', 'color: black', 'font-weight: bold');
|
|
8
|
+
lastLogTS = now.getTime();
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
onInit() {
|
|
12
|
+
logLine('snitch instance created');
|
|
13
|
+
},
|
|
14
|
+
beforeCaptureEvent(eventName, eventPayload) {
|
|
15
|
+
logLine(`captured event '${eventName}'`);
|
|
16
|
+
if (eventPayload && Object.keys(eventPayload).length !== 0)
|
|
17
|
+
console.table(eventPayload);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.default = engagementPlugin;
|
|
22
|
+
//# sourceMappingURL=debug-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-logger.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-debug-logger/debug-logger.ts"],"names":[],"mappings":";;AAEA,SAAwB,gBAAgB;IACtC,IAAI,SAAS,GAAkB,IAAI,CAAA;IACnC,SAAS,OAAO,CAAC,OAAe;QAC9B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,OAAO,CAAC,GAAG,CACT,MAAM,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,IAC1D,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAI,SAAoB,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EACpF,gBAAgB,OAAO,EAAE,EACzB,aAAa,EACb,cAAc,EACd,mBAAmB,CACpB,CAAA;QACD,SAAS,GAAG,GAAG,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;IACD,OAAO;QACL,MAAM;YACJ,OAAO,CAAC,yBAAyB,CAAC,CAAA;QACpC,CAAC;QAED,kBAAkB,CAAC,SAAiB,EAAE,YAAiC;YACrE,OAAO,CAAC,mBAAmB,SAAS,GAAG,CAAC,CAAA;YACxC,IAAI,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QACzF,CAAC;KACF,CAAA;AACH,CAAC;AAxBD,mCAwBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const debug_logger_1 = __importDefault(require("./debug-logger"));
|
|
7
|
+
exports.default = debug_logger_1.default;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-debug-logger/index.ts"],"names":[],"mappings":";;;;;AAAA,kEAA8C;AAC9C,kBAAe,sBAAiB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const DEFAULT_ENGAGEMENT_TRACKING_INTERVAL_MSEC = 10 * 1000; // 10 seconds
|
|
4
|
+
function engagementPlugin(options = { engagementTrackingIntervalMsec: DEFAULT_ENGAGEMENT_TRACKING_INTERVAL_MSEC }) {
|
|
5
|
+
let captureEvent;
|
|
6
|
+
return {
|
|
7
|
+
setEventHandler(eventHandler) {
|
|
8
|
+
captureEvent = eventHandler;
|
|
9
|
+
},
|
|
10
|
+
onInit() {
|
|
11
|
+
setInterval(() => {
|
|
12
|
+
if (document.hidden === false)
|
|
13
|
+
captureEvent('engage');
|
|
14
|
+
}, options.engagementTrackingIntervalMsec);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.default = engagementPlugin;
|
|
19
|
+
//# sourceMappingURL=engagement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engagement.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-engagement/engagement.ts"],"names":[],"mappings":";;AAGA,MAAM,yCAAyC,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,aAAa;AAEzE,SAAwB,gBAAgB,CACtC,UAEI,EAAE,8BAA8B,EAAE,yCAAyC,EAAE;IAEjF,IAAI,YAA0B,CAAA;IAE9B,OAAO;QACL,eAAe,CAAC,YAA0B;YACxC,YAAY,GAAG,YAAY,CAAA;QAC7B,CAAC;QAED,MAAM;YACJ,WAAW,CAAC,GAAG,EAAE;gBACf,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK;oBAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;YACvD,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAA;QAC5C,CAAC;KACF,CAAA;AACH,CAAC;AAlBD,mCAkBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const engagement_1 = __importDefault(require("./engagement"));
|
|
7
|
+
exports.default = engagement_1.default;
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/snitch-plugin-engagement/index.ts"],"names":[],"mappings":";;;;;AAAA,8DAA2C;AAC3C,kBAAe,oBAAgB,CAAA"}
|