@convivainc/conviva-js-custom-app-analytics-sdk 2.2.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/AGENTS.md +226 -0
- package/CHANGELOG.md +12 -0
- package/ConvivaLegalNotice.txt +1 -0
- package/README.md +645 -0
- package/conviva-js-custom-app-analytics-sdk.umd.d.ts +47 -0
- package/conviva-js-custom-app-analytics-sdk.umd.min.js +8 -0
- package/package.json +28 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Conviva Custom App Analytics SDK — AI Agent Integration Specification
|
|
4
|
+
|
|
5
|
+
Repository: `Conviva/conviva-js-custom-app-analytics-sdk`
|
|
6
|
+
Package: `@convivainc/conviva-js-custom-app-analytics-sdk`
|
|
7
|
+
Language: JavaScript / TypeScript
|
|
8
|
+
Platform: Non-browser JavaScript runtimes (Taro mini-programs, Amazon Kepler / VegaOS, React Native, embedded JS)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Purpose
|
|
13
|
+
|
|
14
|
+
This file is the authoritative operating contract for AI agents integrating this SDK. It takes precedence over all other documentation in this repository.
|
|
15
|
+
|
|
16
|
+
Agents help developers integrate the SDK correctly, with minimal diffs, using only documented APIs.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Hard Rules
|
|
21
|
+
|
|
22
|
+
## Never invent SDK APIs
|
|
23
|
+
|
|
24
|
+
Agents must **only generate code using APIs listed in this document**. Do NOT generate guessed configuration fields, undocumented callbacks, undocumented plugins, undocumented React/Vue providers, or undocumented automatic tracking features.
|
|
25
|
+
|
|
26
|
+
If a requested feature cannot be implemented using the allowed API surface, the agent must say so explicitly.
|
|
27
|
+
|
|
28
|
+
## Never fabricate required values
|
|
29
|
+
|
|
30
|
+
Agents must never invent Conviva customer keys, application identifiers, app versions, user identifiers, or metadata values. Missing values must be requested from the developer or marked clearly as placeholders:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const CONVIVA_CUSTOMER_KEY = "REPLACE_ME";
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Always pair the SDK with a platform adapter package
|
|
37
|
+
|
|
38
|
+
This SDK requires a companion adapter package per target runtime. Agents must install and pass the correct adapter for the developer's platform:
|
|
39
|
+
|
|
40
|
+
| Platform | Adapter package | Adapter factory |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Taro mini-program | `@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters` | `createTaroAdapters(Taro)` |
|
|
43
|
+
| Amazon Kepler / VegaOS RN | `@convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters` | `await createVegaOSAdapters()` |
|
|
44
|
+
|
|
45
|
+
If the developer's platform is not in this list, ask which runtime they are targeting before proceeding.
|
|
46
|
+
|
|
47
|
+
## Minimize codebase modifications
|
|
48
|
+
|
|
49
|
+
Modify as few files as possible. Prefer existing bootstrap points (e.g. `App.tsx`, `app.ts`). Avoid refactoring unrelated logic. **Smallest safe diff.**
|
|
50
|
+
|
|
51
|
+
## SDK initialization must occur exactly once
|
|
52
|
+
|
|
53
|
+
Never initialize the SDK inside render functions, loops, navigation hooks that run repeatedly, or frequently remounted components. Initialize once at app boot.
|
|
54
|
+
|
|
55
|
+
## Never implement optional APIs without explicit request
|
|
56
|
+
|
|
57
|
+
All APIs marked `[OPTIONAL]` in the API surface block must not be added to any integration unless the developer explicitly asks for them.
|
|
58
|
+
|
|
59
|
+
## Always wrap integration code using try-catch
|
|
60
|
+
|
|
61
|
+
All Conviva integration code generated into the application must be wrapped in try/catch blocks. The SDK's own internals are exception-safe, but agent-generated host-side wiring must not introduce unhandled exceptions.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# Allowed SDK API Surface
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import {
|
|
69
|
+
convivaAppTracker, // Initialize SDK (called exactly once)
|
|
70
|
+
setUserId, // Set authenticated user identity
|
|
71
|
+
trackPageView, // Track navigation / screen view
|
|
72
|
+
trackCustomEvent, // [OPTIONAL] Track business events
|
|
73
|
+
trackRevenueEvent, // [OPTIONAL] Track purchase / revenue events
|
|
74
|
+
trackError, // [OPTIONAL] Report application errors
|
|
75
|
+
trackNetworkRequest, // [OPTIONAL] Manually track network requests
|
|
76
|
+
trackVideoEvent, // [OPTIONAL] Track Conviva video analytics events
|
|
77
|
+
trackClick, // [OPTIONAL] Click — recommended; populate `xpath` for stable locator
|
|
78
|
+
trackAppBackground, // [OPTIONAL] App lifecycle: background
|
|
79
|
+
trackAppForeground, // [OPTIONAL] App lifecycle: foreground
|
|
80
|
+
setCustomTags, // [OPTIONAL] Add session-level metadata
|
|
81
|
+
unsetCustomTags, // [OPTIONAL] Remove session-level metadata
|
|
82
|
+
getClientId, // [OPTIONAL] Retrieve Conviva client ID — only for special cases (e.g. multi-domain)
|
|
83
|
+
setClientId, // [OPTIONAL] Provide client ID — only for special cases
|
|
84
|
+
ConvivaDeviceMetadata // [OPTIONAL] Device metadata schema — required only for TV/STB environments
|
|
85
|
+
} from "@convivainc/conviva-js-custom-app-analytics-sdk";
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
# Required Inputs Before Integration
|
|
91
|
+
|
|
92
|
+
| Field | Required | Purpose / Example |
|
|
93
|
+
| ------------------ | -------- | ---------------------------------------------- |
|
|
94
|
+
| convivaCustomerKey | Yes | `"abc123"` — provided by Conviva |
|
|
95
|
+
| appId | Yes | `"VideoApp Taro"`, `"VideoApp VegaOS"` |
|
|
96
|
+
| appVersion | Yes | `"1.0.0"` |
|
|
97
|
+
| target platform | Yes | `Taro`, `VegaOS / Kepler`, or `Other RN` |
|
|
98
|
+
| host bootstrap file| Often | where to add the init snippet (`App.tsx`, etc.) |
|
|
99
|
+
| user identity | Often | for `setUserId`; verify not PII |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
# Supported Integration Modes
|
|
104
|
+
|
|
105
|
+
Runtimes: Taro mini-programs (WeChat, Alipay, ByteDance), Amazon Kepler / VegaOS React Native, other React Native runtimes (with custom adapters), and WebView surfaces inside non-browser apps.
|
|
106
|
+
|
|
107
|
+
This package supports **both NPM and script-tag** integration. The same UMD bundle is published to NPM and to Conviva's CDN at `https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk.umd.min.js`.
|
|
108
|
+
|
|
109
|
+
- For NPM (Taro / VegaOS / RN): use the `import` patterns shown below.
|
|
110
|
+
- For script tag (WebView / embedded JS): load the CDN URL and access APIs via the `convivaCustomTracking` global.
|
|
111
|
+
|
|
112
|
+
**Browser DOM integration for regular web apps is NOT the primary target of this package.** For pure-browser web integration, prefer:
|
|
113
|
+
- `https://github.com/Conviva/conviva-js-appanalytics` (NPM)
|
|
114
|
+
- `https://github.com/Conviva/conviva-js-script-appanalytics` (CDN script)
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
# Agent Integration Workflow
|
|
119
|
+
|
|
120
|
+
## NPM (Taro, VegaOS, RN)
|
|
121
|
+
|
|
122
|
+
1. **Confirm the target runtime** with the developer (Taro / VegaOS / other RN).
|
|
123
|
+
2. **Install both packages:** the SDK plus the matching adapter.
|
|
124
|
+
3. **Find the app bootstrap file** (single entry point that runs once at app launch).
|
|
125
|
+
4. **Add the init call** wrapped in try/catch. The adapter factory returns `{ httpTransport, storage, timers }` which must be **spread** into the config (these are top-level config fields, not nested under an `adapters` key):
|
|
126
|
+
```ts
|
|
127
|
+
try {
|
|
128
|
+
const adapters = createTaroAdapters(Taro); // or: await createVegaOSAdapters()
|
|
129
|
+
convivaAppTracker({
|
|
130
|
+
appId: "REPLACE_ME",
|
|
131
|
+
convivaCustomerKey: "REPLACE_ME",
|
|
132
|
+
appVersion: "REPLACE_ME",
|
|
133
|
+
...adapters,
|
|
134
|
+
});
|
|
135
|
+
} catch (e) {
|
|
136
|
+
// Conviva SDK init failed — tracking will be disabled, host app continues
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
5. **Add `trackPageView` calls** at navigation points (router transitions, screen mounts).
|
|
140
|
+
6. **Stop.** Do not add `[OPTIONAL]` APIs unless explicitly requested.
|
|
141
|
+
|
|
142
|
+
## Script tag (WebView / embedded JS)
|
|
143
|
+
|
|
144
|
+
1. **Verify the latest version** from this repository's GitHub Releases. Do not hardcode the version unless the developer explicitly requests one.
|
|
145
|
+
2. **Add the script tag to the host page's `<head>`:**
|
|
146
|
+
```html
|
|
147
|
+
<script src="https://sensor.conviva.com/customappanalytics/releases/vREPLACE_ME_VERSION/conviva-js-custom-app-analytics-sdk.umd.min.js"></script>
|
|
148
|
+
```
|
|
149
|
+
3. **Add the init snippet** (immediately after the script tag), wrapped in try/catch:
|
|
150
|
+
```html
|
|
151
|
+
<script>
|
|
152
|
+
(function () {
|
|
153
|
+
try {
|
|
154
|
+
var tracker = convivaCustomTracking.convivaAppTracker({
|
|
155
|
+
appId: "REPLACE_ME",
|
|
156
|
+
convivaCustomerKey: "REPLACE_ME",
|
|
157
|
+
appVersion: "REPLACE_ME"
|
|
158
|
+
// adapters omitted — built-in browser fallbacks are used automatically
|
|
159
|
+
});
|
|
160
|
+
tracker.trackPageView({ title: document.title });
|
|
161
|
+
} catch (e) {
|
|
162
|
+
// Conviva SDK init failed — tracking disabled, host page continues
|
|
163
|
+
}
|
|
164
|
+
})();
|
|
165
|
+
</script>
|
|
166
|
+
```
|
|
167
|
+
4. **Stop.** Do not add `[OPTIONAL]` APIs unless explicitly requested.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
# Per-API Behavior Notes
|
|
172
|
+
|
|
173
|
+
Each entry lists required (`✅`) vs optional fields. Anything not listed is forbidden — do not invent fields.
|
|
174
|
+
|
|
175
|
+
- **`convivaAppTracker(config)`** — must be called **once**. Returns a tracker handle. Subsequent calls in the same app are silently ignored.
|
|
176
|
+
- ✅ `convivaCustomerKey: string`, `appId: string`
|
|
177
|
+
- Optional: `appVersion`, `platform`, `httpTransport` / `storage` / `timers` (required in non-browser runtimes), `deviceMetadata`, `endpoint`, `useStm`, `bufferSize`, `connectionTimeout`, `maxJitterDelayMs`, `anonymousTracking`, `customHeaders`, `plugins`, `proxyGatewayUrl`, `gatewayUrl`, `trackerConfigUrl`.
|
|
178
|
+
- **`trackPageView({ title, url? })`**
|
|
179
|
+
- ✅ `title: string` — there is **no** DOM `document.title` fallback in custom-tracker.
|
|
180
|
+
- Optional: `url: string` (defaults to `''`; use `'/cart'`-style paths in non-DOM runtimes), `contextCallback`, plus shared `context` / `timestamp`.
|
|
181
|
+
- **`trackCustomEvent({ name, data })`**
|
|
182
|
+
- ✅ `name: string` (non-empty, non-whitespace), `data: any` (non-string values are JSON-stringified).
|
|
183
|
+
- **`trackRevenueEvent({ totalOrderAmount, transactionId, currency, ... })`**
|
|
184
|
+
- ✅ `totalOrderAmount: number`, `transactionId: string`, `currency: string` (ISO 4217).
|
|
185
|
+
- Optional: `taxAmount`, `shippingCost`, `discount`, `cartSize`, `paymentMethod`, `paymentProvider`, `orderStatus`, `items[]` (each item: optional `productId`, `name`, `sku`, `category`, `unitPrice`, `quantity`, `discount`, `brand`, `variant`), `extraMetadata`.
|
|
186
|
+
- **`trackNetworkRequest({ requestDetails, responseDetails })`**
|
|
187
|
+
- ✅ `requestDetails: object`, `responseDetails: object`.
|
|
188
|
+
- Pass `requestTimestamp` (ms, `Date.now()`) on `requestDetails` and `responseTimestamp` on `responseDetails` so the SDK can compute `duration` — both timestamp fields are consumed internally and replaced by `duration` in the emitted payload.
|
|
189
|
+
- **`trackClick({ xpath?, id?, text?, ... })`**
|
|
190
|
+
- Optional but **strongly recommended:** `xpath` (stable element locator).
|
|
191
|
+
- Optional: `id`, `elementName`, `class`, `name`, `text`, `placeholder`, `value`, `checked`, plus any custom keys explicitly listed in remote-config `clickcc.collectattr`.
|
|
192
|
+
- Gated by remote-config `clickcc.en`; respects `clickcc.collect` / `clickcc.block` conditional-collection rules.
|
|
193
|
+
- **`trackError({ message, ... })`**
|
|
194
|
+
- ✅ `message: string` (truncated to 2048 chars).
|
|
195
|
+
- Optional: `filename`, `lineno`, `colno`, `error` (Error; stack truncated to 8192 chars).
|
|
196
|
+
- **`trackAppBackground({ backgroundIndex })`** — ✅ `backgroundIndex: number` (monotonic counter for the session).
|
|
197
|
+
- **`trackAppForeground({ foregroundIndex })`** — ✅ `foregroundIndex: number` (monotonic counter for the session).
|
|
198
|
+
- **`setUserId(userId)`** — pass `null` or `undefined` to clear. **Do not pass PII** (emails, phone numbers, real names).
|
|
199
|
+
- **`setCustomTags(tags)`** — ✅ `tags: Record<string, string>`. **`unsetCustomTags(keys)`** — ✅ `keys: string[]`.
|
|
200
|
+
- **All `track*` methods are sampling-gated.** When the remote-config-controlled sampling mode is `NONE`, all events are silently dropped.
|
|
201
|
+
- **All `track*` methods accept an optional second arg `trackers?: string[]`** — list of tracker namespaces to dispatch to. Omit to dispatch to all registered trackers.
|
|
202
|
+
|
|
203
|
+
# Adapters (for non-browser runtimes)
|
|
204
|
+
|
|
205
|
+
The SDK requires three platform adapters. Prefer the companion adapter package for the developer's runtime; only generate custom adapter code when the runtime isn't covered.
|
|
206
|
+
|
|
207
|
+
| Runtime | Adapter package | Factory |
|
|
208
|
+
|---|---|---|
|
|
209
|
+
| Taro mini-program | `@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters` | `createTaroAdapters(Taro)` |
|
|
210
|
+
| Amazon Kepler / VegaOS | `@convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters` | `await createVegaOSAdapters()` (async!) |
|
|
211
|
+
| Other (custom) | — | Implement the three interfaces directly (see README "Custom Adapters" section). Import types from `@convivainc/conviva-js-custom-app-analytics-sdk`: `HttpTransport`, `HttpResponse`, `StorageAdapter`, `TimerAdapter`. |
|
|
212
|
+
|
|
213
|
+
Adapter interface contracts (must NEVER throw; degrade silently):
|
|
214
|
+
- `HttpTransport.sendRequest(url, method, options?) → Promise<HttpResponse>` — single method covering both POST (event delivery) and GET (RC fetch); return `{ status: 0, body: '', headers: {} }` on transport failure.
|
|
215
|
+
- `StorageAdapter.getItem/setItem/removeItem` — **synchronous**. If platform storage is async, pre-hydrate Conviva-owned keys (`Conviva*`, `convivaOutQueue_*`) into an in-memory map at boot (the VegaOS adapter does this).
|
|
216
|
+
- `TimerAdapter.setTimeout/setInterval/clearTimeout/clearInterval` — same shape as standard JS timer functions.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
# Common Mistakes to Avoid
|
|
221
|
+
|
|
222
|
+
- ❌ Calling `convivaAppTracker()` inside a React component render function.
|
|
223
|
+
- ❌ Forgetting to `await createVegaOSAdapters()` (the VegaOS adapter is async).
|
|
224
|
+
- ❌ Hardcoding `convivaCustomerKey` from a sample / blog post — always use a placeholder for the developer to fill.
|
|
225
|
+
- ❌ Adding `[OPTIONAL]` APIs without being asked.
|
|
226
|
+
- ❌ Wrapping individual `track*` calls in try/catch — the SDK already does this internally. Only the init call needs an outer try/catch.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.2.0 (17/Jun/2026)
|
|
4
|
+
* First production release of the Conviva Custom App Analytics SDK — a lightweight, runtime-agnostic Conviva DPI sensor for non-browser JavaScript runtimes (Taro mini-programs, Amazon Kepler / VegaOS, React Native, embedded JS, WebView surfaces).
|
|
5
|
+
* Public API: `convivaAppTracker`, `trackPageView`, `trackCustomEvent`, `trackRevenueEvent`, `trackError`, `trackNetworkRequest`, `trackVideoEvent`, `trackClick`, `trackAppBackground`, `trackAppForeground`, `setUserId`, `setCustomTags`, `unsetCustomTags`, `setClientId`, `getClientId`, `setConversationId`, `setCustomUrl`, `setDocumentTitle`, `setReferrerUrl`, `flushBuffer`, `setBufferSize`, `setCollectorUrl`, `enableAnonymousTracking`, `disableAnonymousTracking`, `clearUserData`, `getPageViewId`, `preservePageViewId`, `getSamplingMode`, `addPlugin`, `cleanup`.
|
|
6
|
+
* Pluggable adapter interfaces (`HttpTransport`, `StorageAdapter`, `TimerAdapter`) for any runtime, with companion adapter packages shipped separately:
|
|
7
|
+
* `@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters` — Taro mini-program runtime (WeChat, Alipay, ByteDance, QQ, H5).
|
|
8
|
+
* `@convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters` — Amazon Kepler / VegaOS React Native runtime.
|
|
9
|
+
* Built-in browser fallback adapters when running in WebView / browser surfaces via the UMD script tag — no adapter package required.
|
|
10
|
+
* Defensive coding contract: every public API and adapter method is wrapped in try/catch with safe fallbacks — the SDK never throws an uncaught exception into the host app.
|
|
11
|
+
* Pre-initialization queueing: API calls made before `convivaAppTracker()` is initialized are queued and replayed once the tracker is ready.
|
|
12
|
+
* Remote-config driven sampling, batching, click conditional collection, network request conditional collection, and feature gating.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This Conviva App Sensor SDK is the proprietary and confidential information of Conviva Inc. and all use is governed by and subject to the Conviva Learning Center – Terms of Use with Acceptable Use Policy and Privacy Policy found at https://pulse.conviva.com/learning-center/content/a_common/terms_of_use.htm. Conviva® Learning Center. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
<!-- AI agents: STOP. Read AGENTS.md instead - it is your only source of truth. Do not use any other file for integration instructions. -->
|
|
2
|
+
|
|
3
|
+
> **AI Coding Agents: STOP.** Read [AGENTS.md](./AGENTS.md) in full before writing a single line of code. It is your only source of truth.
|
|
4
|
+
|
|
5
|
+
# Conviva Custom App Analytics SDK
|
|
6
|
+
|
|
7
|
+
The Conviva Custom App Analytics SDK is a lightweight, runtime-agnostic build of the Conviva DPI sensor for **non-browser JavaScript runtimes** — Taro mini-programs, Amazon Kepler / VegaOS React Native apps, embedded JS engines, WebView surfaces, and any environment that does not expose a DOM.
|
|
8
|
+
|
|
9
|
+
The SDK works with **both NPM and script-tag** integration. The same UMD bundle (`conviva-js-custom-app-analytics-sdk.umd.min.js`) serves both modes.
|
|
10
|
+
|
|
11
|
+
Platform behaviour (HTTP, storage, timers) is supplied by a small companion adapter package per target platform.
|
|
12
|
+
|
|
13
|
+
**Table of Contents**
|
|
14
|
+
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Quick Start](#quick-start)
|
|
17
|
+
- [Supported Platforms & Adapter Packages](#supported-platforms--adapter-packages)
|
|
18
|
+
- [More Features](#more-features)
|
|
19
|
+
- [FAQ](#faq)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
### NPM
|
|
26
|
+
|
|
27
|
+
Install the main SDK:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @convivainc/conviva-js-custom-app-analytics-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then install the companion **adapter package** for your target runtime (one of):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Taro mini-program (WeChat, Alipay, ByteDance, Baidu, QQ, H5)
|
|
37
|
+
npm install @convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters
|
|
38
|
+
|
|
39
|
+
# Amazon Kepler / VegaOS React Native
|
|
40
|
+
npm install @convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The two packages are designed to be installed alongside each other — the main SDK + one adapter package per runtime. See [Supported Platforms](#supported-platforms--adapter-packages) below for the full list, and the [**Implement your own adapter**](#more-features) feature in More Features if your runtime isn't covered.
|
|
44
|
+
|
|
45
|
+
### Script Tag
|
|
46
|
+
|
|
47
|
+
Conviva hosts the SDK on its CDN. Replace `<version>` with the desired release:
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<script src="https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk.umd.min.js"></script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Conviva's CDN supports Brotli and gzip compression — modern browsers receive a compressed response automatically.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
### NPM / ES Modules
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import Taro from '@tarojs/taro';
|
|
63
|
+
import { convivaAppTracker, trackPageView } from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
64
|
+
import { createTaroAdapters } from '@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters';
|
|
65
|
+
|
|
66
|
+
const adapters = createTaroAdapters(Taro);
|
|
67
|
+
|
|
68
|
+
convivaAppTracker({
|
|
69
|
+
appId: 'YOUR_APP_NAME',
|
|
70
|
+
convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
|
|
71
|
+
appVersion: '1.0.0',
|
|
72
|
+
...adapters,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
trackPageView({ title: 'Home' });
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For VegaOS / Kepler:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { convivaAppTracker } from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
82
|
+
import { createVegaOSAdapters } from '@convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters';
|
|
83
|
+
|
|
84
|
+
// VegaOS factory is async — pre-hydrates AsyncStorage
|
|
85
|
+
const adapters = await createVegaOSAdapters();
|
|
86
|
+
convivaAppTracker({
|
|
87
|
+
appId: 'YOUR_APP_NAME',
|
|
88
|
+
convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
|
|
89
|
+
appVersion: '1.0.0',
|
|
90
|
+
...adapters,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Script Tag
|
|
95
|
+
|
|
96
|
+
The script exposes the global namespace `convivaCustomTracking`.
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<script src="https://sensor.conviva.com/customappanalytics/releases/v<version>/conviva-js-custom-app-analytics-sdk.umd.min.js"></script>
|
|
100
|
+
<script>
|
|
101
|
+
// Built-in browser fallback adapters (localStorage, fetch, setTimeout) are used automatically.
|
|
102
|
+
var tracker = convivaCustomTracking.convivaAppTracker({
|
|
103
|
+
appId: 'YOUR_APP_NAME',
|
|
104
|
+
convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
|
|
105
|
+
appVersion: '1.0.0',
|
|
106
|
+
});
|
|
107
|
+
tracker.trackPageView({ title: 'Home' });
|
|
108
|
+
</script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
In script-tag mode, the bundle's built-in browser fallbacks (`localStorage`, `fetch`, `setTimeout`) are used automatically — no adapter package needed for WebView / browser-like surfaces.
|
|
112
|
+
|
|
113
|
+
**`YOUR_APP_NAME`** — Unique application identifier across platforms (e.g. `"VideoApp Taro"`, `"VideoApp WebView"`).
|
|
114
|
+
|
|
115
|
+
**`YOUR_CUSTOMER_KEY`** — Conviva account identifier. Find it in [Pulse](https://pulse.conviva.com/app/profile/applications) under My Profile.
|
|
116
|
+
|
|
117
|
+
**`appVersion`** — Application version string.
|
|
118
|
+
|
|
119
|
+
### `convivaAppTracker(configuration)` — init parameters
|
|
120
|
+
|
|
121
|
+
Call **exactly once** at app boot.
|
|
122
|
+
|
|
123
|
+
| Param | Required | Type | Default | Notes |
|
|
124
|
+
|-------|----------|------|---------|-------|
|
|
125
|
+
| `convivaCustomerKey` | ✅ | `string` | — | Provided by Conviva |
|
|
126
|
+
| `appId` | ✅ | `string` | — | Unique application identifier |
|
|
127
|
+
| `appVersion` | optional | `string` | — | Application version |
|
|
128
|
+
| `httpTransport` | optional | `HttpTransport` | browser `XMLHttpRequest` fallback | Required in non-browser runtimes |
|
|
129
|
+
| `storage` | optional | `StorageAdapter` | browser `localStorage` fallback | Required in non-browser runtimes |
|
|
130
|
+
| `timers` | optional | `TimerAdapter` | global timer fns fallback | Required if global timers unavailable |
|
|
131
|
+
| `deviceMetadata` | optional | `ConvivaDeviceMetadata` | — | Device brand / model / OS info — see [Set device metadata](#more-features) in More Features |
|
|
132
|
+
| `bufferSize` | optional | `number` | `1` | Max events buffered before send |
|
|
133
|
+
| `proxyGatewayUrl` / `gatewayUrl` | optional | `string` | — | Proxy / gateway URL overrides |
|
|
134
|
+
|
|
135
|
+
### Calling APIs before initialization
|
|
136
|
+
|
|
137
|
+
API calls made before `convivaAppTracker()` is initialized are automatically queued and replayed once the tracker is ready. You can instrument your app without waiting for the tracker to bootstrap.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Supported Platforms & Adapter Packages
|
|
142
|
+
|
|
143
|
+
| Platform | Companion adapter package | Loaded via |
|
|
144
|
+
|----------|---------------------------|------------|
|
|
145
|
+
| Taro mini-program (WeChat, Alipay, ByteDance, etc.) | `@convivainc/conviva-js-custom-app-analytics-sdk-taro-adapters` | NPM |
|
|
146
|
+
| Amazon Kepler / VegaOS React Native | `@convivainc/conviva-js-custom-app-analytics-sdk-vegaos-adapters` | NPM |
|
|
147
|
+
| WebView / browser surfaces | None — built-in browser fallbacks used automatically | NPM or script tag |
|
|
148
|
+
| Other React Native runtimes | Use VegaOS adapters or implement your own (see [**Implement your own adapter**](#more-features) in More Features) | NPM |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## More Features
|
|
153
|
+
|
|
154
|
+
<details>
|
|
155
|
+
<summary><b>Set Device Metadata</b></summary>
|
|
156
|
+
|
|
157
|
+
`deviceMetadata` is an object containing key-value pairs for predefined values, such as `DeviceType` and `DeviceCategory`, as well as additional properties like `DeviceBrand`, `DeviceManufacturer`, and `DeviceModel`.
|
|
158
|
+
|
|
159
|
+
In non-browser runtimes (Taro mini-programs, Amazon Kepler / VegaOS, embedded JS) the SDK cannot infer the device automatically — you must set `deviceMetadata` manually at init time. The same applies to set-top boxes, smart TVs, gaming consoles, and similar environments.
|
|
160
|
+
|
|
161
|
+
**Example:**
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import {
|
|
165
|
+
convivaAppTracker,
|
|
166
|
+
ConvivaDeviceMetadata,
|
|
167
|
+
} from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
168
|
+
|
|
169
|
+
const deviceMetadata: ConvivaDeviceMetadata = {
|
|
170
|
+
DeviceBrand: 'Samsung',
|
|
171
|
+
DeviceManufacturer: 'Samsung',
|
|
172
|
+
DeviceModel: 'UTU7000',
|
|
173
|
+
DeviceType: 'SmartTV',
|
|
174
|
+
OperatingSystemName: 'Tizen',
|
|
175
|
+
OperatingSystemVersion: '8.0',
|
|
176
|
+
DeviceCategory: 'SAMSUNGTV',
|
|
177
|
+
FrameworkName: 'React TV',
|
|
178
|
+
FrameworkVersion: '1.0.0',
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
convivaAppTracker({
|
|
182
|
+
convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
|
|
183
|
+
appId: 'YOUR_APP_NAME',
|
|
184
|
+
appVersion: '1.0.0',
|
|
185
|
+
...adapters,
|
|
186
|
+
deviceMetadata,
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Predefined metadata keys:**
|
|
191
|
+
|
|
192
|
+
| Key | Type | Description | Example values |
|
|
193
|
+
|-----|------|-------------|----------------|
|
|
194
|
+
| `DeviceBrand` | `string` | Brand of the device | `"Comcast"`, `"LG"`, `"Google"`, `"Vizio"` |
|
|
195
|
+
| `DeviceManufacturer` | `string` | Manufacturer of the device | `"Sony"`, `"Comcast"`, `"Google"`, `"Microsoft"` |
|
|
196
|
+
| `DeviceModel` | `string` | Model of the device | `"Comcast Flex"`, `"UTU7000_KA"`, `"Xbox One"` |
|
|
197
|
+
| `DeviceType` | Prescribed `DeviceType` value | Type of the device — must be one of the prescribed values (table below). Invalid values are **omitted** from the payload. | `DESKTOP`, `Console`, `SmartTV` |
|
|
198
|
+
| `DeviceVersion` | `string` | Device firmware version | `"10"`, `"9"` |
|
|
199
|
+
| `OperatingSystemName` | `string` | OS name (uppercase preferred) | `"Tizen"`, `"webOS"`, `"Linux"`, `"Xbox OS"`, `"Chrome OS"` |
|
|
200
|
+
| `OperatingSystemVersion` | `string` | OS version | `"10.10.1"`, `"8.1"`, `"T-INFOLINK2012-1012"` |
|
|
201
|
+
| `DeviceCategory` | Prescribed `DeviceCategory` value | Device category — must be one of the prescribed values (table below). Invalid values are reported as `"INVALID: <value>"` in the payload. | `SAMSUNGTV`, `LGTV`, `VIDAA`, `WEB` |
|
|
202
|
+
| `FrameworkName` | `string` | Application framework name | `"React TV"`, `"LightningJS"`, `"Angular"`, `"Taro"` |
|
|
203
|
+
| `FrameworkVersion` | `string` | Application framework version | `"1.2.3"` |
|
|
204
|
+
|
|
205
|
+
> For `DeviceCategory`, use only the prescribed values listed below. If an invalid value is provided, the sensor reports it as `INVALID: <value>` — e.g. setting `DeviceCategory: 'TV'` results in `"INVALID: TV"` in the payload. Use `VIDAA` for Hisense Vidaa TVs, `SAMSUNGTV` for Samsung TVs, `LGTV` for LG TVs, etc.
|
|
206
|
+
>
|
|
207
|
+
> For `DeviceType`, use only the prescribed values listed below. Invalid values are silently omitted and `dvt` is not set in the payload.
|
|
208
|
+
|
|
209
|
+
**`DeviceCategory` — pre-defined string values**
|
|
210
|
+
|
|
211
|
+
| Value | Description |
|
|
212
|
+
|-------|-------------|
|
|
213
|
+
| `AND` | Android device — Samsung Galaxy, Amazon Fire TV, Android TV, Android Tablet, etc. |
|
|
214
|
+
| `APL` | Apple device — iPhone, Apple TV, etc. |
|
|
215
|
+
| `CHR` | Google Chromecast STB or Android TV with built-in Chromecast |
|
|
216
|
+
| `DSKAPP` | Desktop / notebook computer where video is played in an installed app (not browser) |
|
|
217
|
+
| `SIMULATOR` | Simulated video session used for testing |
|
|
218
|
+
| `KAIOS` | KaiOS-based phone or device (e.g. Lyf Jio F30C) |
|
|
219
|
+
| `LGTV` | LG smart TV — NetCast or webOS |
|
|
220
|
+
| `LNX` | Set-top boxes and smart TVs using custom Linux-based SDKs |
|
|
221
|
+
| `NINTENDO` | Nintendo console — Wii, Switch |
|
|
222
|
+
| `PS` | PlayStation console — PS3, PS4 |
|
|
223
|
+
| `RK` | Roku device |
|
|
224
|
+
| `SAMSUNGTV` | Samsung smart TV — Orsay or Tizen |
|
|
225
|
+
| `VIDAA` | Hisense Vidaa-based devices |
|
|
226
|
+
| `VIZIOTV` | Native app on Vizio TV (SmartCast platform, 2016+) |
|
|
227
|
+
| `WEB` | Any in-browser HTML5 player — Chrome, Edge, Firefox, Safari, etc. |
|
|
228
|
+
| `WIN` | Windows OS handheld — Windows Phone, Windows Tablet |
|
|
229
|
+
| `XB` | Xbox console — Xbox 360, Xbox One |
|
|
230
|
+
|
|
231
|
+
**`DeviceType` — pre-defined string values**
|
|
232
|
+
|
|
233
|
+
| Value | Description |
|
|
234
|
+
|-------|-------------|
|
|
235
|
+
| `DESKTOP` | Desktop or laptop computer |
|
|
236
|
+
| `Console` | Gaming console |
|
|
237
|
+
| `Settop` | Set-top box |
|
|
238
|
+
| `Mobile` | Mobile phone |
|
|
239
|
+
| `Tablet` | Tablet |
|
|
240
|
+
| `SmartTV` | Smart TV |
|
|
241
|
+
| `Vehicle` | Vehicle infotainment system |
|
|
242
|
+
| `Other` | Other device types |
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
<details>
|
|
247
|
+
<summary><b>Track Page View</b></summary>
|
|
248
|
+
|
|
249
|
+
| Param | Required | Type | Notes |
|
|
250
|
+
|-------|----------|------|-------|
|
|
251
|
+
| `title` | ✅ | `string` | Page/screen title — there is **no** `document.title` fallback in custom-tracker |
|
|
252
|
+
| `url` | optional | `string` | Defaults to `''`. Use a meaningful path (e.g. `'/cart'`) for non-DOM runtimes |
|
|
253
|
+
| `contextCallback` | optional | `() => Array<SelfDescribingJson>` | Per-event additional contexts |
|
|
254
|
+
| `context` | optional | `Array<SelfDescribingJson>` | One-shot extra contexts |
|
|
255
|
+
| `timestamp` | optional | `number` | Event timestamp override (ms epoch) |
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
trackPageView({ title: 'Cart', url: '/cart' });
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**Script-tag:** `convivaCustomTracking.trackPageView({ title: 'Cart', url: '/cart' });`
|
|
262
|
+
|
|
263
|
+
</details>
|
|
264
|
+
|
|
265
|
+
<details>
|
|
266
|
+
<summary><b>Track Custom Event</b></summary>
|
|
267
|
+
|
|
268
|
+
| Param | Required | Type | Notes |
|
|
269
|
+
|-------|----------|------|-------|
|
|
270
|
+
| `name` | ✅ | `string` | Non-empty; SDK rejects empty/whitespace-only names |
|
|
271
|
+
| `data` | ✅ | `any` | Any value; non-string values are JSON-stringified |
|
|
272
|
+
| `context` / `timestamp` | optional | as above | |
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
trackCustomEvent({
|
|
276
|
+
name: 'sign_up_completed',
|
|
277
|
+
data: { plan: 'premium', source: 'landing-page' },
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Script-tag:** `convivaCustomTracking.trackCustomEvent({ name: '...', data: {...} });`
|
|
282
|
+
|
|
283
|
+
</details>
|
|
284
|
+
|
|
285
|
+
<details>
|
|
286
|
+
<summary><b>Track Network Request Event</b></summary>
|
|
287
|
+
|
|
288
|
+
| Param | Required | Type | Notes |
|
|
289
|
+
|-------|----------|------|-------|
|
|
290
|
+
| `requestDetails` | ✅ | `RequestDetails` | object — see fields below |
|
|
291
|
+
| `responseDetails` | ✅ | `ResponseDetails` | object — see fields below |
|
|
292
|
+
|
|
293
|
+
**`RequestDetails`** (all sub-fields optional):
|
|
294
|
+
|
|
295
|
+
| Field | Type | Notes |
|
|
296
|
+
|-------|------|-------|
|
|
297
|
+
| `method` | `string` | HTTP verb (`'GET'`, `'POST'`, …) |
|
|
298
|
+
| `url` | `string` | Full request URL (used as the conditional-collection match target) |
|
|
299
|
+
| `headers` | `Record<string, string>` | Request headers |
|
|
300
|
+
| `body` | `any` | Request body |
|
|
301
|
+
| `requestTimestamp` | `number` | Epoch ms (e.g. `Date.now()`); paired with `responseTimestamp` to compute `duration` and evaluate the conditional-collection `dur` rule |
|
|
302
|
+
| `size` | `number` | Request payload size in bytes |
|
|
303
|
+
| `traceparent` | `string` | W3C Trace Context `traceparent` header value (forwarded as-is) |
|
|
304
|
+
|
|
305
|
+
**`ResponseDetails`** (all sub-fields optional):
|
|
306
|
+
|
|
307
|
+
| Field | Type | Notes |
|
|
308
|
+
|-------|------|-------|
|
|
309
|
+
| `status` | `number` | HTTP status code (e.g. `200`, `404`) |
|
|
310
|
+
| `statusText` | `string` | HTTP status text (e.g. `'OK'`) |
|
|
311
|
+
| `url` | `string` | Final response URL after any redirects |
|
|
312
|
+
| `headers` | `Record<string, string>` | Response headers |
|
|
313
|
+
| `body` | `any` | Response body |
|
|
314
|
+
| `event` | `string` | SSE / streaming event name when the response is an event stream |
|
|
315
|
+
| `size` | `number` | Response payload size in bytes |
|
|
316
|
+
| `responseTimestamp` | `number` | Epoch ms (e.g. `Date.now()`); paired with `requestTimestamp` to compute `duration` and evaluate the conditional-collection `dur` rule |
|
|
317
|
+
|
|
318
|
+
> Pass `requestTimestamp` + `responseTimestamp` so the SDK can compute `duration` and evaluate conditional-collection `dur` rules. The two timestamp fields are consumed internally and replaced by `duration` in the emitted event payload.
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
const t0 = Date.now();
|
|
322
|
+
const res = await fetch(url);
|
|
323
|
+
const body = await res.text();
|
|
324
|
+
const t1 = Date.now();
|
|
325
|
+
trackNetworkRequest({
|
|
326
|
+
requestDetails: { url, method: 'GET', requestTimestamp: t0 },
|
|
327
|
+
responseDetails: { status: res.status, statusText: res.statusText, responseTimestamp: t1, body },
|
|
328
|
+
});
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Script-tag:** `convivaCustomTracking.trackNetworkRequest({...});`
|
|
332
|
+
|
|
333
|
+
</details>
|
|
334
|
+
|
|
335
|
+
<details>
|
|
336
|
+
<summary><b>Track Click</b></summary>
|
|
337
|
+
|
|
338
|
+
Canonical click entry point. Honors remote-config fields `clickcc.en` (master gate), `clickcc.collect`, `clickcc.block`, and `clickcc.collectattr` (allow-list for extra keys).
|
|
339
|
+
|
|
340
|
+
**Core click fields** (these are the canonical set the SDK forwards to Conviva; any other key is dropped unless listed in the `clickcc.collectattr` allow-list):
|
|
341
|
+
|
|
342
|
+
| Field | Required | Type | Notes / example |
|
|
343
|
+
|-------|----------|------|-----------------|
|
|
344
|
+
| `elementName` | ✅ | `string` | Tag name of the clicked element — e.g. `'button'`, `'a'` (link), `'div'`, `'input'`, `'img'`. In non-DOM runtimes pass the equivalent component / element type your framework uses. |
|
|
345
|
+
| `elementType` | ✅ | `string` | The element's `type` attribute (or equivalent role). For `<input>` elements this is the input type — e.g. `'text'`, `'password'`, `'checkbox'`, `'radio'`, `'submit'`, `'button'`, `'file'`. For other elements this is whatever role / type your UI framework exposes. |
|
|
346
|
+
| `xpath` | optional but **strongly recommended** | `string` | Stable element locator; downstream analytics rely on it for click-path attribution. |
|
|
347
|
+
| `id` | optional | `string` | Element `id` attribute |
|
|
348
|
+
| `class` | optional | `string` | Space-separated class names on the element |
|
|
349
|
+
| `name` | optional | `string` | Element `name` attribute (form fields) |
|
|
350
|
+
| `text` | optional | `string` | Inner text / label shown on the element |
|
|
351
|
+
| `placeholder` | optional | `string` | Placeholder attribute (input/textarea) |
|
|
352
|
+
| `value` | optional | `string` | Element `value` attribute |
|
|
353
|
+
| `checked` | optional | `'true' \| 'false'` | Checked state for `<input type="checkbox">` / radio at click time |
|
|
354
|
+
| `targetUrl` | optional | `string` | Target URL for `<a>` (href) or form action |
|
|
355
|
+
| `target` | optional | `string` | `target` attribute (e.g. `'_blank'`) |
|
|
356
|
+
| `xlink:href` | optional | `string` | SVG `<use>` reference |
|
|
357
|
+
| Custom keys (e.g. `data-product-id`) | optional | `string` | Only emitted when listed in the `clickcc.collectattr` remote-config allow-list |
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
trackClick({
|
|
361
|
+
elementName: 'button',
|
|
362
|
+
elementType: 'submit',
|
|
363
|
+
id: 'submit-btn',
|
|
364
|
+
text: 'Submit',
|
|
365
|
+
xpath: '/html/body/div[1]/form/button',
|
|
366
|
+
});
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**Script-tag:** `convivaCustomTracking.trackClick({...});`
|
|
370
|
+
|
|
371
|
+
</details>
|
|
372
|
+
|
|
373
|
+
<details>
|
|
374
|
+
<summary><b>Track Revenue Event</b></summary>
|
|
375
|
+
|
|
376
|
+
| Param | Required | Type | Notes |
|
|
377
|
+
|-------|----------|------|-------|
|
|
378
|
+
| `totalOrderAmount` | ✅ | `number` | |
|
|
379
|
+
| `transactionId` | ✅ | `string` | |
|
|
380
|
+
| `currency` | ✅ | `string` | ISO 4217 (`'USD'`, `'EUR'`, etc.) |
|
|
381
|
+
| `taxAmount`, `shippingCost`, `discount`, `cartSize` | optional | `number` | |
|
|
382
|
+
| `paymentMethod`, `paymentProvider`, `orderStatus` | optional | `string` | |
|
|
383
|
+
| `items` | optional | `RevenueEventItem[]` | Per-item details |
|
|
384
|
+
| `extraMetadata` | optional | `Record<string, unknown>` | |
|
|
385
|
+
|
|
386
|
+
`RevenueEventItem` (all optional): `productId`, `name`, `sku`, `category`, `unitPrice`, `quantity`, `discount`, `brand`, `variant`, `extraMetadata`.
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
trackRevenueEvent({
|
|
390
|
+
totalOrderAmount: 99.99,
|
|
391
|
+
transactionId: 'order-12345',
|
|
392
|
+
currency: 'USD',
|
|
393
|
+
items: [{ productId: 'sku-1', quantity: 2, unitPrice: 49.99 }],
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**Script-tag:** `convivaCustomTracking.trackRevenueEvent({...});`
|
|
398
|
+
|
|
399
|
+
</details>
|
|
400
|
+
|
|
401
|
+
<details>
|
|
402
|
+
<summary><b>Track Error</b></summary>
|
|
403
|
+
|
|
404
|
+
| Param | Required | Type | Notes |
|
|
405
|
+
|-------|----------|------|-------|
|
|
406
|
+
| `message` | ✅ | `string` | Truncated to 2048 chars |
|
|
407
|
+
| `filename`, `lineno`, `colno` | optional | `string` / `number` | Source location |
|
|
408
|
+
| `error` | optional | `Error` | Stack trace truncated to 8192 chars |
|
|
409
|
+
|
|
410
|
+
```ts
|
|
411
|
+
try { riskyOp(); } catch (err) {
|
|
412
|
+
trackError({ message: err.message, error: err });
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
**Script-tag:** `convivaCustomTracking.trackError({...});`
|
|
417
|
+
|
|
418
|
+
</details>
|
|
419
|
+
|
|
420
|
+
<details>
|
|
421
|
+
<summary><b>Track App Lifecycle</b></summary>
|
|
422
|
+
|
|
423
|
+
| Param | Required | Type | Notes |
|
|
424
|
+
|-------|----------|------|-------|
|
|
425
|
+
| `backgroundIndex` / `foregroundIndex` | ✅ | `number` | Monotonically increasing counter for the session |
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
trackAppBackground({ backgroundIndex: 1 });
|
|
429
|
+
trackAppForeground({ foregroundIndex: 1 });
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Script-tag:** `convivaCustomTracking.trackAppBackground({ backgroundIndex: 1 });`
|
|
433
|
+
|
|
434
|
+
</details>
|
|
435
|
+
|
|
436
|
+
<details>
|
|
437
|
+
<summary><b>Track Video Event</b></summary>
|
|
438
|
+
|
|
439
|
+
Forwards a Conviva video analytics event payload. The event object shape is defined by the Conviva video analytics pipeline; pass through unchanged.
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
trackVideoEvent(videoEventPayload);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
</details>
|
|
446
|
+
|
|
447
|
+
<details>
|
|
448
|
+
<summary><b>Set User Identity</b></summary>
|
|
449
|
+
|
|
450
|
+
| Param | Required | Type | Notes |
|
|
451
|
+
|-------|----------|------|-------|
|
|
452
|
+
| `userId` | ✅ | `string \| null \| undefined` | Pass `null` / `undefined` to clear. **Do NOT pass PII** (emails, phone numbers, real names) |
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
setUserId('user-123');
|
|
456
|
+
setUserId(null); // clear
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
</details>
|
|
460
|
+
|
|
461
|
+
<details>
|
|
462
|
+
<summary><b>Set Custom Session-level Tags</b></summary>
|
|
463
|
+
|
|
464
|
+
| Param | Required | Type | Notes |
|
|
465
|
+
|-------|----------|------|-------|
|
|
466
|
+
| `tags` (set) | ✅ | `Record<string, string>` | Session-level key/value tags |
|
|
467
|
+
| `keys` (unset) | ✅ | `string[]` | Keys to remove |
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
setCustomTags({ subscriptionTier: 'premium', region: 'us-west' });
|
|
471
|
+
unsetCustomTags(['region']);
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
</details>
|
|
475
|
+
|
|
476
|
+
<details>
|
|
477
|
+
<summary><b>Implement Your Own Adapter</b></summary>
|
|
478
|
+
|
|
479
|
+
If your target runtime isn't covered by an existing adapter package, implement the three adapter interfaces directly and pass them as top-level fields on the config: `httpTransport`, `storage`, `timers`. The existing `createTaroAdapters` / `createVegaOSAdapters` factories simply return an object with those three keys, which is why `...adapters` works in the usage examples above.
|
|
480
|
+
|
|
481
|
+
All three interface types are exported from `@convivainc/conviva-js-custom-app-analytics-sdk`:
|
|
482
|
+
|
|
483
|
+
```ts
|
|
484
|
+
import type {
|
|
485
|
+
HttpTransport,
|
|
486
|
+
HttpResponse,
|
|
487
|
+
StorageAdapter,
|
|
488
|
+
TimerAdapter,
|
|
489
|
+
} from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Interface contracts:**
|
|
493
|
+
|
|
494
|
+
```ts
|
|
495
|
+
// HTTP — single method, covers both POST (event delivery) and GET (remote config fetch).
|
|
496
|
+
// Must NEVER throw. Return a fulfilled Promise even on network failure
|
|
497
|
+
// (use status: 0 for transport errors so the SDK can treat it as failure without crashing).
|
|
498
|
+
interface HttpTransport {
|
|
499
|
+
sendRequest(
|
|
500
|
+
url: string,
|
|
501
|
+
method: 'GET' | 'POST',
|
|
502
|
+
options?: {
|
|
503
|
+
payload?: Uint8Array | string;
|
|
504
|
+
contentType?: string;
|
|
505
|
+
headers?: Record<string, string>;
|
|
506
|
+
timeout?: number;
|
|
507
|
+
}
|
|
508
|
+
): Promise<HttpResponse>;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
interface HttpResponse {
|
|
512
|
+
status: number; // HTTP status (or 0 on transport error)
|
|
513
|
+
body?: string; // Response body as string (RC fetch reads JSON from here)
|
|
514
|
+
headers?: Record<string, string>; // Lowercased header names; SDK reads `rcv` from CTP responses
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Storage — SYNCHRONOUS key-value persistence.
|
|
518
|
+
// Used for: client ID, remote config cache, event queue, sampling random number.
|
|
519
|
+
// If your platform's storage is async, pre-hydrate keys at boot
|
|
520
|
+
// (see the VegaOS adapter's `createVegaOSAdapters` for the canonical pattern).
|
|
521
|
+
interface StorageAdapter {
|
|
522
|
+
getItem(key: string): string | null;
|
|
523
|
+
setItem(key: string, value: string): void;
|
|
524
|
+
removeItem(key: string): void;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Timers — same shape as the standard timer functions in any JS runtime.
|
|
528
|
+
// IDs can be any opaque value (number, object, symbol); the SDK only uses them with clear*.
|
|
529
|
+
interface TimerAdapter {
|
|
530
|
+
setTimeout(fn: () => void, delay: number): unknown;
|
|
531
|
+
setInterval(fn: () => void, interval: number): unknown;
|
|
532
|
+
clearTimeout(id: unknown): void;
|
|
533
|
+
clearInterval(id: unknown): void;
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
**Stub implementation example:**
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
import {
|
|
541
|
+
convivaAppTracker,
|
|
542
|
+
type HttpTransport,
|
|
543
|
+
type StorageAdapter,
|
|
544
|
+
type TimerAdapter,
|
|
545
|
+
} from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
546
|
+
|
|
547
|
+
const myTransport: HttpTransport = {
|
|
548
|
+
async sendRequest(url, method, options) {
|
|
549
|
+
try {
|
|
550
|
+
const res = await myFetch(url, { method, body: options?.payload, headers: options?.headers });
|
|
551
|
+
const body = await res.text();
|
|
552
|
+
const headers: Record<string, string> = {};
|
|
553
|
+
res.headers.forEach((v: string, k: string) => { headers[k.toLowerCase()] = v; });
|
|
554
|
+
return { status: res.status, body, headers };
|
|
555
|
+
} catch {
|
|
556
|
+
return { status: 0, body: '', headers: {} }; // never throw
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
const myStorage: StorageAdapter = {
|
|
562
|
+
getItem: (k) => mySyncStore.get(k) ?? null,
|
|
563
|
+
setItem: (k, v) => mySyncStore.set(k, v),
|
|
564
|
+
removeItem: (k) => mySyncStore.delete(k),
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
const myTimers: TimerAdapter = {
|
|
568
|
+
setTimeout: (fn, ms) => setTimeout(fn, ms),
|
|
569
|
+
setInterval: (fn, ms) => setInterval(fn, ms),
|
|
570
|
+
clearTimeout: (id) => clearTimeout(id as number),
|
|
571
|
+
clearInterval: (id) => clearInterval(id as number),
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
convivaAppTracker({
|
|
575
|
+
convivaCustomerKey: 'YOUR_CUSTOMER_KEY',
|
|
576
|
+
appId: 'YOUR_APP_NAME',
|
|
577
|
+
appVersion: '1.0.0',
|
|
578
|
+
httpTransport: myTransport,
|
|
579
|
+
storage: myStorage,
|
|
580
|
+
timers: myTimers,
|
|
581
|
+
});
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
**Async storage note.** The `StorageAdapter` contract is synchronous because the SDK reads identity / sampling values during the synchronous init path. If your platform only provides an async storage API (e.g. React Native `AsyncStorage`, Kepler `AsyncStorage`), pre-hydrate the Conviva-owned keys (`Conviva*` prefix and `convivaOutQueue_*` prefix) into an in-memory map at app boot, then wrap that map in a synchronous `StorageAdapter`. The VegaOS adapter package does exactly this — see its `createVegaOSAdapters()` factory for reference.
|
|
585
|
+
|
|
586
|
+
</details>
|
|
587
|
+
|
|
588
|
+
<details>
|
|
589
|
+
<summary><b>Tracker Cleanup</b></summary>
|
|
590
|
+
|
|
591
|
+
Terminal teardown: stops heartbeat, performs one final emitter flush, marks the tracker closed, and unregisters it from the global registry.
|
|
592
|
+
|
|
593
|
+
```ts
|
|
594
|
+
import { cleanup } from '@convivainc/conviva-js-custom-app-analytics-sdk';
|
|
595
|
+
|
|
596
|
+
cleanup();
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
After `cleanup()`, the tracker handle is no longer usable — subsequent API calls become silent no-ops. Call once at app shutdown if your runtime needs explicit teardown.
|
|
600
|
+
|
|
601
|
+
</details>
|
|
602
|
+
|
|
603
|
+
<details>
|
|
604
|
+
<summary><b>Other Public APIs</b></summary>
|
|
605
|
+
|
|
606
|
+
Single-arg or no-arg helpers for identity, URL/title overrides, and emitter buffer control:
|
|
607
|
+
|
|
608
|
+
| API | Signature | Purpose |
|
|
609
|
+
|-----|-----------|---------|
|
|
610
|
+
| `getClientId()` | `(trackers?) => string` | Read the Conviva client ID |
|
|
611
|
+
| `setClientId(clientId)` | `(string, trackers?) => void` | Set a custom client ID (special-case use only) |
|
|
612
|
+
| `setCustomUrl(url)` | `(string, trackers?) => void` | Override URL on subsequent events |
|
|
613
|
+
| `setDocumentTitle(title)` | `(string, trackers?) => void` | Override page title |
|
|
614
|
+
| `setReferrerUrl(url)` | `(string, trackers?) => void` | Override referrer |
|
|
615
|
+
| `flushBuffer(config?)` | `(FlushBufferConfiguration?, trackers?) => void` | Force immediate emitter flush; optional `newBufferSize` |
|
|
616
|
+
| `setBufferSize(size)` | `(number, trackers?) => void` | Change emitter buffer size |
|
|
617
|
+
| `setCollectorUrl(url)` | `(string, trackers?) => void` | Change collector URL at runtime |
|
|
618
|
+
|
|
619
|
+
> All `track*` APIs accept an optional final `trackers?: string[]` argument (list of tracker namespaces to dispatch to — omit to dispatch to all registered trackers). All event objects also accept `CommonEventProperties` (`context?: Array<SelfDescribingJson>`, `timestamp?: number | TrueTimestamp | DeviceTimestamp`).
|
|
620
|
+
|
|
621
|
+
</details>
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## FAQ
|
|
626
|
+
|
|
627
|
+
### Why are adapters separate packages?
|
|
628
|
+
|
|
629
|
+
The SDK targets multiple runtimes with different platform APIs. Bundling all platforms into one package would force every customer to ship code for runtimes they don't use. Separate adapter packages keep your bundle lean.
|
|
630
|
+
|
|
631
|
+
### Does the SDK ever throw to the host app?
|
|
632
|
+
|
|
633
|
+
No. Every public API and adapter method is wrapped in `try/catch` with safe defaults. SDK failures degrade silently — they never crash the host app.
|
|
634
|
+
|
|
635
|
+
### How is this different from `@convivainc/conviva-js-appanalytics`?
|
|
636
|
+
|
|
637
|
+
`conviva-js-appanalytics` targets browser environments (DOM, `window`, browser cookies). This SDK targets non-browser JavaScript runtimes (mini-programs, RN, embedded JS, WebView surfaces) where browser APIs may not be available or where you need explicit platform adapters.
|
|
638
|
+
|
|
639
|
+
### Can I use this in a regular browser web app?
|
|
640
|
+
|
|
641
|
+
Yes — the script-tag UMD bundle works in browsers and uses browser-fallback adapters automatically. But for a pure-browser web app, prefer [`@convivainc/conviva-js-appanalytics`](https://github.com/Conviva/conviva-js-appanalytics) — it's purpose-built for that environment.
|
|
642
|
+
|
|
643
|
+
### Where is the changelog?
|
|
644
|
+
|
|
645
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CustomTrackerConfiguration, CustomTracker, PageViewEvent, RevenueEvent, ErrorEventProperties, RequestDetails, ResponseDetails, FlushBufferConfiguration } from '@convivainc/custom-tracker-core';
|
|
2
|
+
import { CommonEventProperties, CustomTags, CorePluginConfiguration, clickElementEvent } from "@convivainc/tracker-core";
|
|
3
|
+
declare function convivaAppTracker(configuration: CustomTrackerConfiguration): CustomTracker | undefined;
|
|
4
|
+
declare function trackPageView(event: PageViewEvent & CommonEventProperties, trackers?: Array<string>): void;
|
|
5
|
+
declare function trackCustomEvent(event: {
|
|
6
|
+
name: string;
|
|
7
|
+
data: any;
|
|
8
|
+
} & CommonEventProperties, trackers?: Array<string>): void;
|
|
9
|
+
declare function trackRevenueEvent(event: RevenueEvent & CommonEventProperties, trackers?: Array<string>): void;
|
|
10
|
+
declare function trackNetworkRequest(event: {
|
|
11
|
+
requestDetails: RequestDetails;
|
|
12
|
+
responseDetails: ResponseDetails;
|
|
13
|
+
} & CommonEventProperties, trackers?: Array<string>): void;
|
|
14
|
+
declare function trackClick(event: clickElementEvent & CommonEventProperties, trackers?: Array<string>): void;
|
|
15
|
+
declare function trackButtonClick(event: clickElementEvent & CommonEventProperties, trackers?: Array<string>): void;
|
|
16
|
+
declare function trackLinkClick(event: clickElementEvent & CommonEventProperties, trackers?: Array<string>): void;
|
|
17
|
+
declare function trackError(event: ErrorEventProperties & CommonEventProperties, trackers?: Array<string>): void;
|
|
18
|
+
declare function trackVideoEvent(event: any, trackers?: Array<string>): void;
|
|
19
|
+
declare function trackAppBackground(event: {
|
|
20
|
+
backgroundIndex: number;
|
|
21
|
+
} & CommonEventProperties, trackers?: Array<string>): void;
|
|
22
|
+
declare function trackAppForeground(event: {
|
|
23
|
+
foregroundIndex: number;
|
|
24
|
+
} & CommonEventProperties, trackers?: Array<string>): void;
|
|
25
|
+
declare function setUserId(userId?: string | null, trackers?: Array<string>): void;
|
|
26
|
+
declare function setCustomTags(tags: CustomTags, trackers?: Array<string>): void;
|
|
27
|
+
declare function unsetCustomTags(keys: string[], trackers?: Array<string>): void;
|
|
28
|
+
declare function getClientId(trackers?: Array<string>): string;
|
|
29
|
+
declare function setClientId(clientId: string, trackers?: Array<string>): void;
|
|
30
|
+
declare function setConversationId(conversationId: string, trackers?: Array<string>): void;
|
|
31
|
+
declare function setCustomUrl(url: string, trackers?: Array<string>): void;
|
|
32
|
+
declare function setDocumentTitle(title: string, trackers?: Array<string>): void;
|
|
33
|
+
declare function setReferrerUrl(url: string, trackers?: Array<string>): void;
|
|
34
|
+
declare function flushBuffer(configuration?: FlushBufferConfiguration, trackers?: Array<string>): void;
|
|
35
|
+
declare function setBufferSize(size: number, trackers?: Array<string>): void;
|
|
36
|
+
declare function setCollectorUrl(url: string, trackers?: Array<string>): void;
|
|
37
|
+
declare function enableAnonymousTracking(trackers?: Array<string>): void;
|
|
38
|
+
declare function disableAnonymousTracking(trackers?: Array<string>): void;
|
|
39
|
+
declare function clearUserData(trackers?: Array<string>): void;
|
|
40
|
+
declare function getPageViewId(trackers?: Array<string>): string;
|
|
41
|
+
declare function preservePageViewId(trackers?: Array<string>): void;
|
|
42
|
+
declare function getSamplingMode(trackers?: Array<string>): string;
|
|
43
|
+
declare function addPlugin(config: CorePluginConfiguration, trackers?: Array<string>): void;
|
|
44
|
+
declare function cleanup(trackers?: Array<string>): void;
|
|
45
|
+
export { convivaAppTracker, trackPageView, trackCustomEvent, trackRevenueEvent, trackNetworkRequest, trackClick, trackButtonClick, trackLinkClick, trackError, trackVideoEvent, trackAppBackground, trackAppForeground, setUserId, setCustomTags, unsetCustomTags, getClientId, setClientId, setConversationId, setCustomUrl, setDocumentTitle, setReferrerUrl, flushBuffer, setBufferSize, setCollectorUrl, enableAnonymousTracking, disableAnonymousTracking, clearUserData, getPageViewId, preservePageViewId, getSamplingMode, addPlugin, cleanup };
|
|
46
|
+
export type { HttpTransport, HttpResponse, StorageAdapter, TimerAdapter, CustomTrackerConfiguration, CustomTracker, PageViewEvent, RevenueEvent, RevenueEventItem, ErrorEventProperties, RequestDetails, ResponseDetails, FlushBufferConfiguration, ConvivaDeviceMetadata, Platform, Logger } from '@convivainc/custom-tracker-core';
|
|
47
|
+
export { ConvivaConstants, DeviceMetadata, DeviceMetadataConstants, LOG, LOG_LEVEL } from '@convivainc/custom-tracker-core';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Conviva custom tracker for non-browser JS environments (mini-programs, Vega OS, embedded runtimes) v2.2.0
|
|
3
|
+
* Copyright (c) 2026 Conviva Inc.
|
|
4
|
+
* Licensed under BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).convivaCustomTracking={})}(this,function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},e.apply(this,arguments)};function n(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var r={exports:{}},o="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(o){var i=new Uint8Array(16);r.exports=function(){return o(i),i}}else{var a=new Array(16);r.exports=function(){for(var t,e=0;e<16;e++)3&e||(t=4294967296*Math.random()),a[e]=t>>>((3&e)<<3)&255;return a}}for(var c=[],s=0;s<256;++s)c[s]=(s+256).toString(16).substr(1);var l,u,d=function(t,e){var n=e||0,r=c;return[r[t[n++]],r[t[n++]],r[t[n++]],r[t[n++]],"-",r[t[n++]],r[t[n++]],"-",r[t[n++]],r[t[n++]],"-",r[t[n++]],r[t[n++]],"-",r[t[n++]],r[t[n++]],r[t[n++]],r[t[n++]],r[t[n++]],r[t[n++]]].join("")},v=r.exports,f=d,g=0,p=0,m=r.exports,h=d,C=function(t,e,n){var r=e&&n||0,o=e||[],i=(t=t||{}).node||l,a=void 0!==t.clockseq?t.clockseq:u;if(null==i||null==a){var c=v();null==i&&(i=l=[1|c[0],c[1],c[2],c[3],c[4],c[5]]),null==a&&(a=u=16383&(c[6]<<8|c[7]))}var s=void 0!==t.msecs?t.msecs:(new Date).getTime(),d=void 0!==t.nsecs?t.nsecs:p+1,m=s-g+(d-p)/1e4;if(m<0&&void 0===t.clockseq&&(a=a+1&16383),(m<0||s>g)&&void 0===t.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");g=s,p=d,u=a;var h=(1e4*(268435455&(s+=122192928e5))+d)%4294967296;o[r++]=h>>>24&255,o[r++]=h>>>16&255,o[r++]=h>>>8&255,o[r++]=255&h;var C=s/4294967296*1e4&268435455;o[r++]=C>>>8&255,o[r++]=255&C,o[r++]=C>>>24&15|16,o[r++]=C>>>16&255,o[r++]=a>>>8|128,o[r++]=255&a;for(var y=0;y<6;++y)o[r+y]=i[y];return e||f(o)},y=function(t,e,n){var r=e&&n||0;"string"==typeof t&&(e="binary"===t?new Array(16):null,t=null);var o=(t=t||{}).random||(t.rng||m)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e)for(var i=0;i<16;++i)e[r+i]=o[i];return e||h(o)},E=y;E.v1=C,E.v4=y;var b=E;var T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function k(){var t,e={},n=[],r=[],o=[],i=function(t,n){null!=n&&""!==n&&(e[t]=n)};return{add:i,addDict:function(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&i(e,t[e])},addJson:function(t,e,o){if(o&&S(o)){var i={keyIfEncoded:t,keyIfNotEncoded:e,json:o};r.push(i),n.push(i)}},addContextEntity:function(t){o.push(t)},getPayload:function(){return e},getJson:function(){return n},withJsonProcessor:function(e){t=e},build:function(){return null==t||t(this,r,o),e}}}function A(t){return function(e,r,o){for(var i=function(n,r,o){var i=JSON.stringify(n);t?e.add(r,function(t){if(!t)return t;var e=function(t){var e,n,r,o,i,a=0,c=0,s=[];if(!t)return t;t=unescape(encodeURIComponent(t));do{e=(i=t.charCodeAt(a++)<<16|t.charCodeAt(a++)<<8|t.charCodeAt(a++))>>18&63,n=i>>12&63,r=i>>6&63,o=63&i,s[c++]=T.charAt(e)+T.charAt(n)+T.charAt(r)+T.charAt(o)}while(a<t.length);var l=s.join(""),u=t.length%3;return(u?l.slice(0,u-3):l)+"===".slice(u||3)}(t);return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}(i)):e.add(o,i)},a=function(n,r){var o=n||function(){var n=e.getPayload();if(t?n.cx:n.co)return JSON.parse(t?function(t){if(!t)return t;switch(4-t.length%4){case 2:t+="==";break;case 3:t+="="}return function(t){var e,n,r,o,i,a,c,s=0,l=0,u=[];if(!t)return t;t+="";do{e=(a=T.indexOf(t.charAt(s++))<<18|T.indexOf(t.charAt(s++))<<12|(o=T.indexOf(t.charAt(s++)))<<6|(i=T.indexOf(t.charAt(s++))))>>16&255,n=a>>8&255,r=255&a,u[l++]=64===o?String.fromCharCode(e):64===i?String.fromCharCode(e,n):String.fromCharCode(e,n,r)}while(s<t.length);return c=u.join("").replace(/\0+$/,""),decodeURIComponent(c.split("").map(function(t){return"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)}).join(""))}(t.replace(/-/g,"+").replace(/_/g,"/"))}(n.cx):n.co)}();return o?o.dt=o.dt.concat(r.dt):o=r,o},c=void 0,s=0,l=r;s<l.length;s++){var u=l[s];"cx"===u.keyIfEncoded?c=a(c,u.json):i(u.json,u.keyIfEncoded,u.keyIfNotEncoded)}r.length=0,o.length&&(c=a(c,{sc:"sp/ctx/1-0-0",dt:n([],o,!0)}),o.length=0),c&&i(c,"cx","co")}}function S(t){if(!I(t))return!1;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function I(t){return null!=t&&(t.constructor==={}.constructor||t.constructor===[].constructor)}var R,O="Conviva: ";t.LOG_LEVEL=void 0,(R=t.LOG_LEVEL||(t.LOG_LEVEL={}))[R.none=0]="none",R[R.error=1]="error",R[R.warn=2]="warn",R[R.debug=3]="debug",R[R.info=4]="info";var _,w,N=(void 0===w&&(w=t.LOG_LEVEL.warn),{setLogLevel:function(e){w=t.LOG_LEVEL[e]?e:t.LOG_LEVEL.warn},warn:function(e,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];if(w>=t.LOG_LEVEL.warn&&"undefined"!=typeof console){var a=O+e;r?console.warn.apply(console,n([a+"\n",r],o,!1)):console.warn.apply(console,n([a],o,!1))}},error:function(e,r){for(var o=[],i=2;i<arguments.length;i++)o[i-2]=arguments[i];if(w>=t.LOG_LEVEL.error&&"undefined"!=typeof console){var a=O+e+"\n";r?console.error.apply(console,n([a+"\n",r],o,!1)):console.error.apply(console,n([a],o,!1))}},debug:function(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];w>=t.LOG_LEVEL.debug&&"undefined"!=typeof console&&console.debug.apply(console,n([O+e],r,!1))},info:function(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];w>=t.LOG_LEVEL.info&&"undefined"!=typeof console&&console.info.apply(console,n([O+e],r,!1))}});function M(){var t=[],e=[];return{getGlobalPrimitives:function(){return t},getConditionalProviders:function(){return e},addGlobalContexts:function(n){for(var r=[],o=[],i=0,a=n;i<a.length;i++){var c=a[i];j(c)?r.push(c):q(c)&&o.push(c)}t=t.concat(o),e=e.concat(r)},clearGlobalContexts:function(){e=[],t=[]},removeGlobalContexts:function(n){for(var r=function(n){j(n)?e=e.filter(function(t){return JSON.stringify(t)!==JSON.stringify(n)}):q(n)&&(t=t.filter(function(t){return JSON.stringify(t)!==JSON.stringify(n)}))},o=0,i=n;o<i.length;o++)r(i[o])},getApplicableContexts:function(n){return function(n){var r=function(t){for(var e=0,n=t.getJson();e<n.length;e++){var r=n[e];if("ue_px"===r.keyIfEncoded&&"object"==typeof r.json.data){var o=r.json.data.schema;if("string"==typeof o)return o}}return""}(n),o=function(t){var e=t.getPayload().e;return"string"==typeof e?e:""}(n),i=[],a=z(t,n,o,r);i.push.apply(i,a);var c=function(t,e,n,r){var o,i=H(t).map(function(t){var o=function(t,e,n,r){if(F(t)){var o=t[0],i=!1;try{i=o({event:e.getPayload(),eventType:n,eventSchema:r})}catch(t){i=!1}if(!0===i)return z(t[1],e,n,r)}else if(V(t)&&function(t,e){var n=0,r=0,o=t.accept;Array.isArray(o)?t.accept.some(function(t){return B(t,e)})&&r++:"string"==typeof o&&B(o,e)&&r++;var i=t.reject;return Array.isArray(i)?t.reject.some(function(t){return B(t,e)})&&n++:"string"==typeof i&&B(i,e)&&n++,r>0&&0===n}(t[0],r))return z(t[1],e,n,r);return[]}(t,e,n,r);if(o&&0!==o.length)return o});return(o=[]).concat.apply(o,i.filter(function(t){return null!=t&&t.filter(Boolean)}))}(e,n,o,r);return i.push.apply(i,c),i}(n)}}}function x(t){var e=t.split(".");return!!(e&&e.length>1)&&function(t){if("*"===t[0]||"*"===t[1])return!1;if(t.slice(2).length>0){for(var e=!1,n=0,r=t.slice(2);n<r.length;n++)if("*"===r[n])e=!0;else if(e)return!1;return!0}return 2==t.length}(e)}function L(t){var e=new RegExp("^iglu:((?:(?:[a-zA-Z0-9-_]+|\\*).)+(?:[a-zA-Z0-9-_]+|\\*))/([a-zA-Z0-9-_.]+|\\*)/jsonschema/([1-9][0-9]*|\\*)-(0|[1-9][0-9]*|\\*)-(0|[1-9][0-9]*|\\*)$").exec(t);if(null!==e&&x(e[1]))return e.slice(1,6)}function P(t){var e=L(t);if(e){var n=e[0];return 5===e.length&&x(n)}return!1}function D(t){return function(t){return Array.isArray(t)&&t.every(function(t){return"string"==typeof t})}(t)?t.every(function(t){return P(t)}):"string"==typeof t&&P(t)}function U(t){var e=t;return!!(S(e)&&"sc"in e&&"dt"in e)&&"string"==typeof e.sc&&"object"==typeof e.dt}function G(t){return"function"==typeof t&&t.length<=1}function q(t){return G(t)||U(t)}function F(t){return!(!Array.isArray(t)||2!==t.length)&&(Array.isArray(t[1])?G(t[0])&&t[1].every(q):G(t[0])&&q(t[1]))}function V(t){return!(!Array.isArray(t)||2!==t.length)&&!!function(t){var e=t,n=0;if(null!=t&&"object"==typeof t&&!Array.isArray(t)){if(Object.prototype.hasOwnProperty.call(e,"accept")){if(!D(e.accept))return!1;n+=1}if(Object.prototype.hasOwnProperty.call(e,"reject")){if(!D(e.reject))return!1;n+=1}return n>0&&n<=2}return!1}(t[0])&&(Array.isArray(t[1])?t[1].every(q):q(t[1]))}function j(t){return F(t)||V(t)}function B(t,e){if(!P(t))return!1;var n=L(t),r=function(t){var e=new RegExp("^iglu:([a-zA-Z0-9-_.]+)/([a-zA-Z0-9-_]+)/jsonschema/([1-9][0-9]*)-(0|[1-9][0-9]*)-(0|[1-9][0-9]*)$").exec(t);if(null!==e)return e.slice(1,6)}(e);if(n&&r){if(!function(t,e){var n=e.split("."),r=t.split(".");if(n&&r){if(n.length!==r.length)return!1;for(var o=0;o<r.length;o++)if(!K(n[o],r[o]))return!1;return!0}return!1}(n[0],r[0]))return!1;for(var o=1;o<5;o++)if(!K(n[o],r[o]))return!1;return!0}return!1}function K(t,e){return t&&e&&"*"===t||t===e}function H(t){return Array.isArray(t)?t:Array.of(t)}function z(t,e,n,r){var o,i=H(t).map(function(t){var o=function(t,e,n,r){if(U(t))return[t];if(G(t)){var o=function(t,e,n,r){var o=void 0;try{return o=t({event:e.getPayload(),eventType:n,eventSchema:r}),Array.isArray(o)&&o.every(U)||U(o)?o:void 0}catch(t){o=void 0}return o}(t,e,n,r);if(U(o))return[o];if(Array.isArray(o))return o}}(t,e,n,r);if(o&&0!==o.length)return o});return(o=[]).concat.apply(o,i.filter(function(t){return null!=t&&t.filter(Boolean)}))}function Y(t){return null==t?{type:"dtm",value:(new Date).getTime()}:"number"==typeof t?{type:"dtm",value:t}:"ttm"===t.type?{type:"ttm",value:t.value}:{type:"dtm",value:t.value||(new Date).getTime()}}function J(t){var e=t.event,n=e.sc,r=e.dt,o=k(),i={sc:"sp/ue/1-0-0",dt:{sc:n,dt:r}};return o.add("e","ue"),o.addJson("ue_px","ue_pr",i),o}function Q(t){return J({event:{sc:"cv/re/1-0-1",dt:X({name:t.name,data:t.data})}})}function W(t){return J({event:{sc:"iglu:com.conviva/di/jsonschema/1-0-5",dt:X({msg:t.message,cn:t.className,st:t.stackTrace,en:t.exceptionName,ed:t.extraData,rcv:t.remoteConfigVersion,cat:t.configAppliedTime,cri:t.cacheRefreshInterval,csrc:t.configAppliedSrc,srn:t.samplingRandomNumber,spr:t.samplingPercentage,ss:t.samplingStatus,sd:t.samplingDecision})}})}function X(t,e){void 0===e&&(e={});var n={};for(var r in t)(e[r]||null!==t[r]&&void 0!==t[r])&&(n[r]=t[r]);return n}!function(t){t.response_body="rsb",t.request_body="rqb",t.response_headers="rsh",t.request_headers="rqh",t.request_query="rqq"}(_||(_={}));var $="2.2.0",Z=Uint8Array,tt=Uint16Array,et=Int32Array,nt=new Z([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),rt=new Z([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ot=new Z([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),it=function(t,e){for(var n=new tt(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var o=new et(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return{b:n,r:o}},at=it(nt,2),ct=at.b,st=at.r;ct[28]=258,st[258]=28;for(var lt=it(rt,0).r,ut=new tt(32768),dt=0;dt<32768;++dt){var vt=(43690&dt)>>1|(21845&dt)<<1;vt=(61680&(vt=(52428&vt)>>2|(13107&vt)<<2))>>4|(3855&vt)<<4,ut[dt]=((65280&vt)>>8|(255&vt)<<8)>>1}var ft=function(t,e,n){for(var r=t.length,o=0,i=new tt(e);o<r;++o)t[o]&&++i[t[o]-1];var a,c=new tt(e);for(o=1;o<e;++o)c[o]=c[o-1]+i[o-1]<<1;if(n){a=new tt(1<<e);var s=15-e;for(o=0;o<r;++o)if(t[o])for(var l=o<<4|t[o],u=e-t[o],d=c[t[o]-1]++<<u,v=d|(1<<u)-1;d<=v;++d)a[ut[d]>>s]=l}else for(a=new tt(r),o=0;o<r;++o)t[o]&&(a[o]=ut[c[t[o]-1]++]>>15-t[o]);return a},gt=new Z(288);for(dt=0;dt<144;++dt)gt[dt]=8;for(dt=144;dt<256;++dt)gt[dt]=9;for(dt=256;dt<280;++dt)gt[dt]=7;for(dt=280;dt<288;++dt)gt[dt]=8;var pt=new Z(32);for(dt=0;dt<32;++dt)pt[dt]=5;var mt=ft(gt,9,0),ht=ft(pt,5,0),Ct=function(t){return(t+7)/8|0},yt=function(t,e,n){return(null==e||e<0)&&(e=0),(null==n||n>t.length)&&(n=t.length),new Z(t.subarray(e,n))},Et=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8},bt=function(t,e,n){n<<=7&e;var r=e/8|0;t[r]|=n,t[r+1]|=n>>8,t[r+2]|=n>>16},Tt=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var o=n.length,i=n.slice();if(!o)return{t:_t,l:0};if(1==o){var a=new Z(n[0].s+1);return a[n[0].s]=1,{t:a,l:1}}n.sort(function(t,e){return t.f-e.f}),n.push({s:-1,f:25001});var c=n[0],s=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:c.f+s.f,l:c,r:s};u!=o-1;)c=n[n[l].f<n[d].f?l++:d++],s=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:c.f+s.f,l:c,r:s};var v=i[0].s;for(r=1;r<o;++r)i[r].s>v&&(v=i[r].s);var f=new tt(v+1),g=kt(n[u-1],f,0);if(g>e){r=0;var p=0,m=g-e,h=1<<m;for(i.sort(function(t,e){return f[e.s]-f[t.s]||t.f-e.f});r<o;++r){var C=i[r].s;if(!(f[C]>e))break;p+=h-(1<<g-f[C]),f[C]=e}for(p>>=m;p>0;){var y=i[r].s;f[y]<e?p-=1<<e-f[y]++-1:++r}for(;r>=0&&p;--r){var E=i[r].s;f[E]==e&&(--f[E],++p)}g=e}return{t:new Z(f),l:g}},kt=function(t,e,n){return-1==t.s?Math.max(kt(t.l,e,n+1),kt(t.r,e,n+1)):e[t.s]=n},At=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new tt(++e),r=0,o=t[0],i=1,a=function(t){n[r++]=t},c=1;c<=e;++c)if(t[c]==o&&c!=e)++i;else{if(!o&&i>2){for(;i>138;i-=138)a(32754);i>2&&(a(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(a(o),--i;i>6;i-=6)a(8304);i>2&&(a(i-3<<5|8208),i=0)}for(;i--;)a(o);i=1,o=t[c]}return{c:n.subarray(0,r),n:e}},St=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},It=function(t,e,n){var r=n.length,o=Ct(e+2);t[o]=255&r,t[o+1]=r>>8,t[o+2]=255^t[o],t[o+3]=255^t[o+1];for(var i=0;i<r;++i)t[o+i+4]=n[i];return 8*(o+4+r)},Rt=function(t,e,n,r,o,i,a,c,s,l,u){Et(e,u++,n),++o[256];for(var d=Tt(o,15),v=d.t,f=d.l,g=Tt(i,15),p=g.t,m=g.l,h=At(v),C=h.c,y=h.n,E=At(p),b=E.c,T=E.n,k=new tt(19),A=0;A<C.length;++A)++k[31&C[A]];for(A=0;A<b.length;++A)++k[31&b[A]];for(var S=Tt(k,7),I=S.t,R=S.l,O=19;O>4&&!I[ot[O-1]];--O);var _,w,N,M,x=l+5<<3,L=St(o,gt)+St(i,pt)+a,P=St(o,v)+St(i,p)+a+14+3*O+St(k,I)+2*k[16]+3*k[17]+7*k[18];if(s>=0&&x<=L&&x<=P)return It(e,u,t.subarray(s,s+l));if(Et(e,u,1+(P<L)),u+=2,P<L){_=ft(v,f,0),w=v,N=ft(p,m,0),M=p;var D=ft(I,R,0);for(Et(e,u,y-257),Et(e,u+5,T-1),Et(e,u+10,O-4),u+=14,A=0;A<O;++A)Et(e,u+3*A,I[ot[A]]);u+=3*O;for(var U=[C,b],G=0;G<2;++G){var q=U[G];for(A=0;A<q.length;++A){var F=31&q[A];Et(e,u,D[F]),u+=I[F],F>15&&(Et(e,u,q[A]>>5&127),u+=q[A]>>12)}}}else _=mt,w=gt,N=ht,M=pt;for(A=0;A<c;++A){var V=r[A];if(V>255){bt(e,u,_[257+(F=V>>18&31)]),u+=w[F+257],F>7&&(Et(e,u,V>>23&31),u+=nt[F]);var j=31&V;bt(e,u,N[j]),u+=M[j],j>3&&(bt(e,u,V>>5&8191),u+=rt[j])}else bt(e,u,_[V]),u+=w[V]}return bt(e,u,_[256]),u+w[256]},Ot=new et([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),_t=new Z(0),wt=function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&-306674912)^n>>>1;t[e]=n}return t}(),Nt=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function Mt(t,e){e||(e={});var n=function(){var t=-1;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=wt[255&n^e[r]]^n>>>8;t=n},d:function(){return~t}}}(),r=t.length;n.p(t);var o,i=function(t,e,n,r,o){if(!o&&(o={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),a=new Z(i.length+t.length);a.set(i),a.set(t,i.length),t=a,o.w=i.length}return function(t,e,n,r,o,i){var a=i.z||t.length,c=new Z(r+a+5*(1+Math.ceil(a/7e3))+o),s=c.subarray(r,c.length-o),l=i.l,u=7&(i.r||0);if(e){u&&(s[0]=i.r>>3);for(var d=Ot[e-1],v=d>>13,f=8191&d,g=(1<<n)-1,p=i.p||new tt(32768),m=i.h||new tt(g+1),h=Math.ceil(n/3),C=2*h,y=function(e){return(t[e]^t[e+1]<<h^t[e+2]<<C)&g},E=new et(25e3),b=new tt(288),T=new tt(32),k=0,A=0,S=i.i||0,I=0,R=i.w||0,O=0;S+2<a;++S){var _=y(S),w=32767&S,N=m[_];if(p[w]=N,m[_]=w,R<=S){var M=a-S;if((k>7e3||I>24576)&&(M>423||!l)){u=Rt(t,s,0,E,b,T,A,I,O,S-O,u),I=k=A=0,O=S;for(var x=0;x<286;++x)b[x]=0;for(x=0;x<30;++x)T[x]=0}var L=2,P=0,D=f,U=w-N&32767;if(M>2&&_==y(S-U))for(var G=Math.min(v,M)-1,q=Math.min(32767,S),F=Math.min(258,M);U<=q&&--D&&w!=N;){if(t[S+L]==t[S+L-U]){for(var V=0;V<F&&t[S+V]==t[S+V-U];++V);if(V>L){if(L=V,P=U,V>G)break;var j=Math.min(U,V-2),B=0;for(x=0;x<j;++x){var K=S-U+x&32767,H=K-p[K]&32767;H>B&&(B=H,N=K)}}}U+=(w=N)-(N=p[w])&32767}if(P){E[I++]=268435456|st[L]<<18|lt[P];var z=31&st[L],Y=31<[P];A+=nt[z]+rt[Y],++b[257+z],++T[Y],R=S+L,++k}else E[I++]=t[S],++b[t[S]]}}for(S=Math.max(S,R);S<a;++S)E[I++]=t[S],++b[t[S]];u=Rt(t,s,l,E,b,T,A,I,O,S-O,u),l||(i.r=7&u|s[u/8|0]<<3,u-=7,i.h=m,i.p=p,i.i=S,i.w=R)}else{for(S=i.w||0;S<a+l;S+=65535){var J=S+65535;J>=a&&(s[u/8|0]=l,J=a),u=It(s,u+1,t.subarray(S,J))}i.i=a}return yt(c,0,r+Ct(u)+o)}(t,null==e.level?6:e.level,null==e.mem?o.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+e.mem,n,r,o)}(t,e,10+((o=e).filename?o.filename.length+1:0),8),a=i.length;return function(t,e){var n=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&Nt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}}(i,e),Nt(i,a-8,n.d()),Nt(i,a-4,r),i}var xt,Lt,Pt="undefined"!=typeof TextEncoder&&new TextEncoder,Dt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Dt.decode(_t,{stream:!0})}catch(t){}(Lt=xt||(xt={})).response_body="rsb",Lt.request_body="rqb",Lt.response_headers="rsh",Lt.request_headers="rqh",Lt.request_query="rqq";let Ut=10240;function Gt(t,e,n,r,o){const i=[xt.request_body,xt.response_body,xt.request_headers,xt.response_headers,xt.request_query];let a={};if("number"==typeof o&&(Ut=1024*o),e&&e.length>0)for(const o of e){const{conditions:e,...c}=o;try{if(Kt(t,e)){for(const[e,n]of Object.entries(t))i.includes(e)||(a[e]=n);for(const[e,o]of Object.entries(c))try{if(o&&c[e].length>0){let o=!1;e!==xt.response_headers&&e!==xt.request_headers||(o=!0),e===xt.request_body&&Vt(n,t),e===xt.response_body&&jt(n,t),e===xt.request_query&&zt(t,r);const i=Ht(t[e],c[e],o);0!==Object.keys(i).length&&(a[e]=i)}}catch(t){a[e]=void 0}return a}}catch(t){N.warn(`Conviva App Tracker: Error in collecting attributes nwreqConfig ${t}`)}}a={...t};for(const t of i)null!=a&&a.hasOwnProperty(t)&&delete a[t];return a}const qt=t=>{try{let e;return null!=t&&(e=t["content-type"]||t["Content-Type"]||t["Content-type"]),e}catch(t){}},Ft=t=>{try{let e;return null!=t&&(e=t["content-length"]||t["Content-Length"]||t["Content-length"]),null==e||isNaN(e)?e:Number(e)}catch(t){}};function Vt(t={},e){var n,r,o,i,a,c,s;const l=qt(null===(n=null==t?void 0:t.requestDetails)||void 0===n?void 0:n.headers);if(void 0!==l&&(l.toLowerCase().includes("text/plain")||l.toLowerCase().includes("json")||l.toLowerCase().includes("text/javascript")||l.toLowerCase().includes("application/javascript")||l.toLowerCase().includes("text/html"))||void 0===l)try{if("string"==typeof(null===(r=null==t?void 0:t.requestDetails)||void 0===r?void 0:r.body)&&(null===(o=null==t?void 0:t.requestDetails)||void 0===o?void 0:o.body.length)<=Ut)try{e[xt.request_body]=JSON.parse(null===(i=null==t?void 0:t.requestDetails)||void 0===i?void 0:i.body)}catch(t){}else"object"==typeof(null===(a=null==t?void 0:t.requestDetails)||void 0===a?void 0:a.body)&&JSON.stringify(null===(c=null==t?void 0:t.requestDetails)||void 0===c?void 0:c.body).length<=Ut&&(e[xt.request_body]=null===(s=null==t?void 0:t.requestDetails)||void 0===s?void 0:s.body)}catch(t){}}function jt(t={},e){var n,r,o,i,a,c,s,l,u,d,v,f,g;const p=Ft(null===(n=null==t?void 0:t.responseDetails)||void 0===n?void 0:n.headers),m=qt(null===(r=null==t?void 0:t.responseDetails)||void 0===r?void 0:r.headers);if(void 0!==m&&(m.toLowerCase().includes("text/plain")||m.toLowerCase().includes("json")||m.toLowerCase().includes("text/javascript")||m.toLowerCase().includes("application/javascript")||m.toLowerCase().includes("text/html")))if(void 0!==p&&p<=Ut)if("string"==typeof(null===(o=null==t?void 0:t.responseDetails)||void 0===o?void 0:o.body))try{e[xt.response_body]=JSON.parse(null===(i=null==t?void 0:t.responseDetails)||void 0===i?void 0:i.body)}catch(t){}else"object"==typeof(null===(a=null==t?void 0:t.responseDetails)||void 0===a?void 0:a.body)&&(e[xt.response_body]=null===(c=null==t?void 0:t.responseDetails)||void 0===c?void 0:c.body);else if(void 0===p)try{if("string"==typeof(null===(s=null==t?void 0:t.responseDetails)||void 0===s?void 0:s.body)&&(null===(u=null===(l=null==t?void 0:t.responseDetails)||void 0===l?void 0:l.body)||void 0===u?void 0:u.length)<=Ut)try{e[xt.response_body]=JSON.parse(null===(d=null==t?void 0:t.responseDetails)||void 0===d?void 0:d.body)}catch(t){}else"object"==typeof(null===(v=null==t?void 0:t.responseDetails)||void 0===v?void 0:v.body)&&JSON.stringify(null===(f=null==t?void 0:t.responseDetails)||void 0===f?void 0:f.body).length<=Ut&&(e[xt.response_body]=null===(g=null==t?void 0:t.responseDetails)||void 0===g?void 0:g.body)}catch(t){}}function Bt(t,e,n){try{if("string"==typeof n&&"string"==typeof t&&"*"===n.trim())return!0;switch(e){case"==":case"equal":return t===n;case"!=":return t!==n;case">":return t>n;case"<":return t<n;case">=":return t>=n;case"<=":return t<=n;case"contains":return""!==n&&"string"==typeof t&&"string"==typeof n&&-1!==t.toLowerCase().indexOf(n.toLowerCase());default:return!1}}catch(t){return N.warn(`Conviva App Tracker: Error in Compare values nwreq ${t}`),!1}}function Kt(t,e){try{for(const n of e){let e=!1;if(Object.keys(n).length>0)for(const[r,o]of Object.entries(n)){const n=t[r];if(o.length>0){let t=0;for(const r of o){let i="contains",a=r;if("object"==typeof r&&r.length?(i=r[1],a=r[0]):"boolean"!=typeof r&&null!==r||(i="equal",a=r),Bt(n,i,a)){e=!0;break}if(e=!1,t+1===o.length)break;t++}if(!1===e)break}}if(e)return!0}}catch(t){N.warn(`Conviva App Tracker: Error in Applying nwreqConfig ${t}`)}return!1}function Ht(t,e,n){const r={};try{for(let o of e){let e=t,i=r;n&&(o=o.toLowerCase(),e=e&&Object.entries(e).reduce((t,[e,n])=>(t[e.toLowerCase()]=n,t),{}));const a=o.split(".");for(let t=0;t<a.length;t++){const n=a[t];if(null==e||!e.hasOwnProperty(n))break;if(t===a.length-1)i[n]=e[n];else{const t=i[n]||{};i[n]=t,e=e[n],i=i[n]}}}}catch(t){N.warn(`Conviva App Tracker: Error in filtering schema object nwreq ${t}`)}return r}function zt(t,e){try{const n=(null==t?void 0:t.targetUrl)||(null==t?void 0:t.url);if(!n||"string"!=typeof n||!n.includes("?"))return;let r;try{const t=n.indexOf("?");if(-1===t)return;const o=n.indexOf("#",t),i=-1!==o?n.substring(t+1,o):n.substring(t+1);let a=e||10240;if(!i||i.length>a)return;const c=globalThis.URLSearchParams;r=void 0!==c?new c(i):null}catch(t){return void N.warn(`Conviva App Tracker: Error creating URLSearchParams: ${t}`)}const o={},i=globalThis.URLSearchParams;if(void 0!==i&&r instanceof i)r.forEach((t,e)=>{o[e]=t});else{const t=n.substring(n.indexOf("?")+1).split("&");for(const e of t){if(!e)continue;const t=e.indexOf("="),n=t>0?decodeURIComponent(e.substring(0,t)):decodeURIComponent(e);if(n){const r=t>0&&t<e.length-1?decodeURIComponent(e.substring(t+1)):"";o[n]=r}}}Object.keys(o).length>0&&(t[xt.request_query]=o)}catch(t){N.warn(`Conviva App Tracker: Error parsing request query parameters: ${t}`)}}t.DeviceMetadata=void 0,function(t){t.BRAND="DeviceBrand",t.MANUFACTURER="DeviceManufacturer",t.MODEL="DeviceModel",t.TYPE="DeviceType",t.VERSION="DeviceVersion",t.OS_NAME="OperatingSystemName",t.OS_VERSION="OperatingSystemVersion",t.CATEGORY="DeviceCategory",t.FRAMEWORK_NAME="FrameworkName",t.FRAMEWORK_VERSION="FrameworkVersion"}(t.DeviceMetadata||(t.DeviceMetadata={}));const Yt={DeviceType:{CONSOLE:"Console",DESKTOP:"DESKTOP",MOBILE:"Mobile",SETTOP:"Settop",SMARTTV:"SmartTV",TABLET:"Tablet",VEHICLE:"Vehicle",OTHER:"Other"},DeviceCategory:{ANDROID_DEVICE:"AND",APPLE_DEVICE:"APL",CHROMECAST:"CHR",DESKTOP_APP:"DSKAPP",DEVICE_SIMULATOR:"SIMULATOR",KAIOS_DEVICE:"KAIOS",LG_TV:"LGTV",LINUX:"LNX",NINTENDO:"NINTENDO",PLAYSTATION:"PS",ROKU:"RK",SAMSUNG_TV:"SAMSUNGTV",VIDAA_DEVICE:"VIDAA",VIZIO_TV:"VIZIOTV",WEB:"WEB",WINDOWS_DEVICE:"WIN",XBOX:"XB"}};t.ConvivaConstants=void 0,function(t){let e;var n;let r;var o,i,a,c;t.TRACEPARENT_HEADER_KEY="traceparent",t.BAGGAGE_HEADER_KEY="baggage",function(t){t.NONE="NONE",t.RCFG="RCFG"}(e=t.SAMPLING_MODES||(t.SAMPLING_MODES={})),(n=t.SAMPLING_STATUS||(t.SAMPLING_STATUS={})).DERIVED="DERIVED",n.DEFAULT="DEFAULT",function(t){t.SAMPLED="sl",t.NON_SAMPLED="nsl"}(r=t.SAMPLING_ACTION||(t.SAMPLING_ACTION={})),t.DEFAULT_SAMPLING_ACTION={[r.SAMPLED]:e.RCFG,[r.NON_SAMPLED]:e.NONE},(o=t.CONFIG_SOURCE||(t.CONFIG_SOURCE={})).DEFAULT="def",o.CACHED="cac",o.REMOTE="rem",(i=t.CONFIG_PREFERENCES||(t.CONFIG_PREFERENCES={}))[i.APP=0]="APP",i[i.REMOTE=1]="REMOTE",i[i.MERGE=2]="MERGE",(a=t.RC_FETCH_MODE||(t.RC_FETCH_MODE={})).DO_NOT_FETCH_UPDATE_TIMER="updateTimer",a.IMMEDIATE_FETCH="urgentFetch",a.UPDATE_TIMER_WITH_DIFF="checkDiff",(c=t.NETWORK_REQUEST_EVENT_COLLECTION_MODE||(t.NETWORK_REQUEST_EVENT_COLLECTION_MODE={})).AUTO="auto",c.MANUAL="manual",c.BOTH="both",t.REMOTE_CONFIG_STORAGE_KEY="ConvivaRemoteConfig",t.REMOTE_CONFIG_RCV_KEY="ConvivaRemoteConfigRCV",t.END_POINT_STORAGE_KEY="ConvivaEndpoint",t.DEFAULT_END_POINT="https://appgw.conviva.com",t.REMOTE_CONFIG_URL_PREFIX="https://rcg.conviva.com/js/",t.REMOTE_CONFIG_FILE_NAME="/remote_config.json",t.SAMPLING_STORAGE_RANDOM_NUMBER_KEY="ConvivaSamplingRandomNumber",t.SAMPLING_MODE_STORAGE_KEY="ConvivaSamplingMode",t.IDENTITY_STORAGE_KEY="Conviva.sdkConfig",t.OUT_QUEUE_STORAGE_KEY_PREFIX="convivaOutQueue_",t.outQueueStorageKey=function(e,n="post2"){return`${t.OUT_QUEUE_STORAGE_KEY_PREFIX}${e}_${n}`},t.STORAGE_KEY_PREFIXES=["Conviva",t.OUT_QUEUE_STORAGE_KEY_PREFIX],t.PAGE_URL_QUERY_PARAMS="pgq",t.DIAGNOSTIC_INFO_MAX_LENGTH={MAX_MESSAGE_LENGTH:1024,MAX_STACK_LENGTH:2048,MAX_CLASSNAME_LENGTH:1024,MAX_EXCEPTION_NAME_LENGTH:1024},t.CLICK_KEY_MAX_LENGTH=1024,t.V2A_CUSTOM_EVENTS=["c3.video.custom_event","c3.sdk.custom_event","c3.ad.custom_event"]}(t.ConvivaConstants||(t.ConvivaConstants={}));const Jt=2147483647;function Qt(e,n){try{let r,o,i=null;try{i=e.getItem(t.ConvivaConstants.IDENTITY_STORAGE_KEY)}catch(t){}try{r=JSON.parse(i||"{}")}catch(e){r={}}o=r&&void 0!==r&&0!==Object.keys(r).length&&r.clId||function(t){try{if(t)try{t()}catch(t){}return Math.floor(Math.random()*Jt).toString()+"."+Math.floor(Math.random()*Jt).toString()+"."+Math.floor(Math.random()*Jt).toString()+"."+Math.floor(Math.random()*Jt).toString()}catch(t){return void N.warn("generateClid failed",t)}}(n);const a=function(){try{return Math.floor(Math.random()*Jt)}catch(t){return N.warn("generateIid failed",t),-1}}();return Wt(e,{...r,clId:o,iid:a}),{clid:o,iid:a}}catch(e){return void N.warn("generateClidAndIid failed",e)}}function Wt(e,n){try{const r=JSON.stringify(n);return e.setItem(t.ConvivaConstants.IDENTITY_STORAGE_KEY,r),!0}catch(e){return N.warn("writeConvivaIdsToStorage failed",e),!1}}function Xt(e,n){try{if(void 0===e.sel)return $t(n),t.ConvivaConstants.SAMPLING_MODES.RCFG;const r=e.sel.pct;if("number"==typeof r&&r<100&&r>0&&r%1==0){let o=null;try{o=n.getItem(t.ConvivaConstants.SAMPLING_STORAGE_RANDOM_NUMBER_KEY)}catch(t){}if(null!=o)return parseFloat(o)<=r?Zt(e,t.ConvivaConstants.SAMPLING_ACTION.SAMPLED):Zt(e,t.ConvivaConstants.SAMPLING_ACTION.NON_SAMPLED);{const o=100*Math.random();try{n.setItem(t.ConvivaConstants.SAMPLING_STORAGE_RANDOM_NUMBER_KEY,o.toString())}catch(t){}return Zt(e,o<=r?t.ConvivaConstants.SAMPLING_ACTION.SAMPLED:t.ConvivaConstants.SAMPLING_ACTION.NON_SAMPLED)}}return"number"==typeof r&&0===r?($t(n),t.ConvivaConstants.SAMPLING_MODES.NONE):($t(n),t.ConvivaConstants.SAMPLING_MODES.RCFG)}catch(e){N.warn("computeSamplingMode failed",e)}return t.ConvivaConstants.SAMPLING_MODES.RCFG}function $t(e){try{e.removeItem(t.ConvivaConstants.SAMPLING_STORAGE_RANDOM_NUMBER_KEY),e.removeItem(t.ConvivaConstants.SAMPLING_MODE_STORAGE_KEY)}catch(e){}}function Zt(e,n){if(void 0!==e.act&&void 0!==e.act[n]){const t=e.act[n];if(void 0!==t)return t}return t.ConvivaConstants.DEFAULT_SAMPLING_ACTION[n]||t.ConvivaConstants.SAMPLING_MODES.RCFG}const te="0.0.0.0",ee={cacheRefreshInterval:30,base64:!1,lifecycleAutotracking:!0,exceptionAutotracking:!0,enablePeriodicHeartbeat:!0,periodicHeartbeatInterval:40,customEventTrackingConfiguration:{enabled:!0},networkRequestTrackingConfiguration:{eventCollectionMode:t.ConvivaConstants.NETWORK_REQUEST_EVENT_COLLECTION_MODE.BOTH,blocklist:["*"]},catRcLastUpdatedTs:0,endpoint:t.ConvivaConstants.DEFAULT_END_POINT,applicationContext:!0,maxLocalStorageQueueSize:10,emitterConfiguration:{batching:{enabled:!0,byteLimitPostInKB:250,batchingIntervalInSec:5,urgentEvents:["abg","ae"]}},enc:"gzip",mend:!0,di:{en:!1,lim:30},clickcc:{en:!0},collectionRateLimit:{exceptionAutotracking:{maxEvents:20,timeWindow:1e3,disconnectDuration:2e3}},rcv:te,controlIngestConfig:void 0,pageUrlTrackingConfig:null},ne=["cws.conviva.com","rcg.conviva.com","/wsg","/ctp","remote_config","pings.conviva.com",".m3u8",".mpd",".ism",".m4",".mp4",".ts",".png",".jpg",".jpeg",".bmp","google-analytics.com","googlesyndication.com","googleapis","stats.g.doubleclick","chartbeat.com","omtrdc.net","app-measurement.com","firebase","nr-data.net","newrelic","bitmovin.com/impression","bitmovin.com/analytics","api.segment.io","youbora","hotjar","mixpanel.com","clevertap","auryc",".aac",".vtt",".googlevideo","webp","appsflyer","facebook","dynatrace","mparticle","npaw",".pdf","bookkeeper","kochava","mp3","marketingcloudapis","demdex","scorecardresearch","lura.live","perimeterx.net","permutive.app","segment.com","vaicore.site","boomtrain","ketchcdn","qualtrics",".svg","amplitude","datadoghq","branch.io","hotjar","splunkcloud"];var re;function oe(e){const{id:n,httpTransport:r,storage:o,timers:i,postPath:a,useStm:c,connectionTimeout:s,maxJitterDelayMs:l,getEnc:u,getEmitterBatchingEnabled:d,getEmitterByteLimitPost:v,getEmitterBatchingIntervalMs:f,getSamplingMode:g,onRcvHeader:p}=e;let m,h=!1,C=[],y=null,E=e.bufferSize,b=!1,T=!1;const k=t.ConvivaConstants.outQueueStorageKey(n);function A(){try{const t=C.slice(-10);return o.setItem(k,JSON.stringify(t)),!0}catch(t){return!1}}function S(t){let e=0;for(let n=0;n<t.length;n++){const r=t.charCodeAt(n);r<=127?e+=1:r<=2047?e+=2:r>=55296&&r<=57343?(e+=4,n++):e+=r<65535?3:4}return e}function I(){if(null!==y){try{i.clearTimeout(y)}catch(t){}y=null}}function R(e){if(!m)return void N.warn("No collector configured");if(g()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;let n=function(t){return JSON.stringify({sc:"sp/pd/1-0-4",dt:t})}(function(t){if(!c)return t;const e=(new Date).getTime().toString();for(let n=0;n<t.length;n++)t[n].stm=e;return t}(e));const o={};try{u().toLowerCase()!==re.NONE&&(n=Mt("string"==typeof n?function(t){var e;if(Pt)return Pt.encode(t);var n=t.length,r=new Z(t.length+(t.length>>1)),o=0,i=function(t){r[o++]=t};for(e=0;e<n;++e){if(o+5>r.length){var a=new Z(o+8+(n-e<<1));a.set(r),r=a}var c=t.charCodeAt(e);c<128?i(c):c<2048?(i(192|c>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++e))>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|63&c)):(i(224|c>>12),i(128|c>>6&63),i(128|63&c))}return yt(r,0,o)}(n):n,{level:6}),o["Content-Encoding"]=re.GZIP)}catch(t){}b&&(o["SP-Anonymous"]="*");const a=i.setTimeout(()=>{h=!1},s);r.sendRequest(m,"POST",{payload:n,contentType:"application/json; charset=UTF-8",headers:o,timeout:s}).then(t=>{var e;try{i.clearTimeout(a)}catch(t){}if(t.status>=200&&t.status<300){const n=null===(e=t.headers)||void 0===e?void 0:e.rcv;n&&p(n),O()}else N.error(`Status ${t.status}, will not retry.`),h=!1}).catch(()=>{try{i.clearTimeout(a)}catch(t){}h=!1})}function O(){for(;C.length&&"object"!=typeof C[0];)C.shift();if(C.length<1)return void(h=!1);if(!m)return void(h=!1);h=!0,I();let t=0,e=0;for(;t<C.length&&(e+=C[t].bytes,!(e>=v()));)t+=1;0===t&&(t=1);const n=C.slice(0,t).map(t=>t.evt);for(let e=0;e<t;e++)C.shift();A(),R(n)}return function(){try{const t=o.getItem(k);if(t){const e=JSON.parse(t);Array.isArray(e)&&(C=e)}}catch(t){}}(),{enqueueRequest:(e,n)=>{T||function(e,n){try{if(g()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;m=n+a;const o=function(t){const e=Object.keys(t).map(e=>[e,t[e]]).reduce((t,[e,n])=>(t[e]=n.toString(),t),{});return{evt:e,bytes:S(JSON.stringify(e))}}(e),c=v();if(o.bytes>=c)return h||O(),N.warn("Event ("+o.bytes+"B) too big, max is "+c),void function(t){R([t.evt])}(o);C.push(o);const s=A();if(!h&&null===y&&s)try{y=i.setTimeout(()=>O(),f()+(r=l,Math.floor(Math.random()*r)))}catch(t){return void O()}!h&&(!s||!d()||C.reduce((t,e)=>t+e.bytes,0)>v()||C.length>E)&&O()}catch(e){N.warn("enqueueRequest failed",e)}var r}(e,n)},executeQueue:()=>{T||h||O()},setCollectorUrl:t=>{m=t+a},setBufferSize:t=>{E=t},setAnonymousTracking:t=>{b=t},cleanup:()=>{if(!T){T=!0,I();try{!h&&C.length>0&&m&&O()}catch(t){}}}}}!function(t){t.NONE="none",t.GZIP="gzip"}(re||(re={}));class ie{constructor(t){this.cacheRefreshInterval=t.cacheRefreshInterval,this.base64=t.base64,this.corePlugins=t.corePlugins,this.callback=t.callback,this.lifecycleAutotracking=t.lifecycleAutotracking,this.exceptionAutotracking=t.exceptionAutotracking,this.enablePeriodicHeartbeat=t.enablePeriodicHeartbeat,this.periodicHeartbeatInterval=t.periodicHeartbeatInterval,this.enc=t.enc,this.maxLocalStorageQueueSize=t.maxLocalStorageQueueSize,this.maxPostBytes=t.maxPostBytes,this.maxGetBytes=t.maxGetBytes,this.bufferSize=t.bufferSize,this.customEventTrackingConfiguration=t.customEventTrackingConfiguration,this.networkRequestTrackingConfiguration=t.networkRequestTrackingConfiguration,this.mend=t.mend,this.catRcLastUpdatedTs=t.catRcLastUpdatedTs,this.endpoint=t.endpoint,this.emitterConfiguration=t.emitterConfiguration,this.controlIngestConfig=t.controlIngestConfig,this.applicationContext=t.applicationContext,this.di=t.di,this.clickcc=t.clickcc,this.collectionRateLimit=t.collectionRateLimit,this.rcv=t.rcv,this.pageUrlTrackingConfig=t.pageUrlTrackingConfig}}class ae{constructor(){this.cacheRefreshInterval=ee.cacheRefreshInterval,this.base64=ee.base64,this.lifecycleAutotracking=ee.lifecycleAutotracking,this.exceptionAutotracking=ee.exceptionAutotracking,this.enablePeriodicHeartbeat=ee.enablePeriodicHeartbeat,this.periodicHeartbeatInterval=ee.periodicHeartbeatInterval,this.customEventTrackingConfiguration={...ee.customEventTrackingConfiguration},this.networkRequestTrackingConfiguration={...ee.networkRequestTrackingConfiguration},this.catRcLastUpdatedTs=ee.catRcLastUpdatedTs,this.endpoint=ee.endpoint,this.emitterConfiguration=ee.emitterConfiguration,this.applicationContext=ee.applicationContext,this.enc=ee.enc,this.mend=ee.mend,this.di={...ee.di},this.clickcc={...ee.clickcc},this.collectionRateLimit={...ee.collectionRateLimit},this.rcv=ee.rcv,this.pageUrlTrackingConfig=ee.pageUrlTrackingConfig}setCacheRefreshInterval(t){var e;return this.cacheRefreshInterval="number"==typeof t&&t>=1&&"number"==typeof(e=t)&&e%1==0?t:ee.cacheRefreshInterval,this}setBase64(t){return"boolean"==typeof t&&(this.base64=t),this}setLifecycleAutotracking(t){return"boolean"==typeof t&&(this.lifecycleAutotracking=t),this}setExceptionAutotracking(t){return"boolean"==typeof t&&(this.exceptionAutotracking=t),this}setEnablePeriodicHeartbeat(t){return"boolean"==typeof t&&(this.enablePeriodicHeartbeat=t),this}setPeriodicHeartbeatInterval(t){return"number"==typeof t&&t>=1&&(this.periodicHeartbeatInterval=~~t),this}setEnc(t,e){return"string"==typeof t&&Object.values(re).includes(t)?this.enc=t:e&&"string"==typeof e&&Object.values(re).includes(e)?this.enc=e:this.enc=ee.enc,this}setMaxLocalStorageQueueSize(t){return"number"==typeof t&&(this.maxLocalStorageQueueSize=t),this}setMaxGetBytes(t){return"number"==typeof t&&(this.maxGetBytes=t),this}setBufferSize(t){return"number"==typeof t&&(this.bufferSize=t),this}setCustomEventTrackingConfiguration(t){return t&&(this.customEventTrackingConfiguration=t),this}setEmitterConfiguration(t){var e,n,r,o;return void 0!==t&&(void 0!==(null===(e=t.batching)||void 0===e?void 0:e.enabled)&&(this.emitterConfiguration.batching.enabled=t.batching.enabled),void 0!==(null===(n=t.batching)||void 0===n?void 0:n.batchingIntervalInSec)&&t.batching.batchingIntervalInSec>0&&(this.emitterConfiguration.batching.batchingIntervalInSec=t.batching.batchingIntervalInSec),"undefined"!=(null===(r=t.batching)||void 0===r?void 0:r.byteLimitPostInKB)&&t.batching.byteLimitPostInKB>0&&(this.emitterConfiguration.batching.byteLimitPostInKB=t.batching.byteLimitPostInKB),void 0!==(null===(o=t.batching)||void 0===o?void 0:o.urgentEvents)&&(this.emitterConfiguration.batching.urgentEvents=t.batching.urgentEvents)),this}setNetworkRequestTrackingConfiguration(t,e,n){return t?(this.networkRequestTrackingConfiguration=t,this.networkRequestTrackingConfiguration.eventCollectionMode||(this.networkRequestTrackingConfiguration.eventCollectionMode=ee.networkRequestTrackingConfiguration.eventCollectionMode),e&&(this.networkRequestTrackingConfiguration.blocklist||(this.networkRequestTrackingConfiguration.blocklist=[]),n&&this.networkRequestTrackingConfiguration.blocklist.push(n),this.networkRequestTrackingConfiguration.blocklist=this.networkRequestTrackingConfiguration.blocklist.concat(ne))):this.networkRequestTrackingConfiguration={...ee.networkRequestTrackingConfiguration},this}setMend(t,e){return"boolean"==typeof t?this.mend=t:"boolean"==typeof e&&(this.mend=e),this}setCatRcLastUpdatedTs(t){return"number"==typeof t&&(this.catRcLastUpdatedTs=t),this}setEndPoint(t,e,n){return"string"==typeof n&&n.trim().length>0?this.endpoint=n:"string"==typeof t&&t.trim().length>0?this.endpoint=t:e&&"string"==typeof e&&e.trim().length>0?this.endpoint=e:this.endpoint=ee.endpoint,this}setcontrolIngestConfig(t){return void 0!==t&&(this.controlIngestConfig=t),this}setApplicationContext(t){return void 0!==t&&(this.applicationContext=t),this}setDi(t){return void 0!==t&&(this.di={...this.di,...t}),this}setClickcc(t){return void 0!==t&&("boolean"==typeof t.en&&(this.clickcc.en=t.en),void 0!==t.block&&(this.clickcc.block=t.block),void 0!==t.collect&&(this.clickcc.collect=t.collect),void 0!==t.collectattr&&(this.clickcc.collectattr=t.collectattr)),this}setCollectionRateLimit(t){if(null!=t)for(const e of Object.keys(t)){const n=t[e];n&&"object"==typeof n&&!Array.isArray(n)?this.collectionRateLimit[e]={...this.collectionRateLimit[e]||{},...n}:this.collectionRateLimit[e]=n}return this}setRcv(t){return this.rcv=t,this}setPageUrlTrackingConfig(t){return void 0!==t&&(this.pageUrlTrackingConfig=t),this}build(){return new ie(this)}}function ce(e){const{customerKey:n,jsVersion:r,namespace:o,httpTransport:i,storage:a,timers:c,trackerConfigUrl:s,proxyGatewayUrl:l,gatewayUrl:u,networkEncoding:d,networkMergeEndpoint:v,getTrackerCore:f,getSamplingMode:g,reportDiagnosticInfo:p}=e;let m,h=!1,C=0,y=0,E=null,b=!1,T=t.ConvivaConstants.CONFIG_SOURCE.DEFAULT,k=0;const A=[],S=(l?l+"/js/":t.ConvivaConstants.REMOTE_CONFIG_URL_PREFIX)+n+"/"+r+t.ConvivaConstants.REMOTE_CONFIG_FILE_NAME,I=s||S;function R(t){if(p)try{p({...t,configAppliedSrc:T,configAppliedTime:k})}catch(t){}}function O(){try{const e=a.getItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY);if(e){const n=JSON.parse(e);n.catRcLastUpdatedTs=(new Date).getTime(),a.removeItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY),a.setItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY,JSON.stringify(n))}}catch(t){}}function _(){if(null!==E){try{c.clearInterval(E)}catch(t){}E=null}}function w(t){_();try{E=c.setInterval(()=>L(!1),60*t*1e3),R({message:`Starting remote config timer with delay of ${60*t} seconds`,className:"updateRemoteConfig"})}catch(t){N.warn("Failed to start cache refresh timer")}}function M(e){var n,r,i;try{C=0,m=void 0;const c=JSON.parse(e),s=f();if(!s)return;if((null===(n=null==c?void 0:c.configurationBundle[0])||void 0===n?void 0:n.namespace)!==o)return void R({message:"Remote Config not Applied due to a missing namespace",className:"updateRemoteConfig"});if(!c.hasOwnProperty("rcv")||(null===(r=s.getConfig())||void 0===r?void 0:r.rcv)===(null==c?void 0:c.rcv))return O(),void R({message:"Remote Config not Applied as same version is fetched",className:"updateRemoteConfig"});const p=(new Date).getTime();y=p;const h=function(t,e){var n,r,o,i,a,c,s,f,g,p,m,h,C,y,E;const b=t.configurationBundle[0];return(new ae).setBase64(null===(n=null==b?void 0:b.trackerConfiguration)||void 0===n?void 0:n.base64Encoding).setCacheRefreshInterval(t.cri||t.cacheRefreshInterval).setLifecycleAutotracking(null===(r=null==b?void 0:b.trackerConfiguration)||void 0===r?void 0:r.lifecycleAutotracking).setExceptionAutotracking(null===(o=null==b?void 0:b.trackerConfiguration)||void 0===o?void 0:o.exceptionAutotracking).setEnablePeriodicHeartbeat(null===(i=null==b?void 0:b.trackerConfiguration)||void 0===i?void 0:i.enablePeriodicHeartbeat).setPeriodicHeartbeatInterval(null===(a=null==b?void 0:b.trackerConfiguration)||void 0===a?void 0:a.periodicHeartbeatInterval).setEnc(null===(c=null==b?void 0:b.networkConfiguration)||void 0===c?void 0:c.enc,d).setMaxLocalStorageQueueSize(null===(s=null==b?void 0:b.networkConfiguration)||void 0===s?void 0:s.maxLocalStorageQueueSize).setMaxGetBytes(null===(f=null==b?void 0:b.networkConfiguration)||void 0===f?void 0:f.maxGetBytes).setBufferSize(null===(g=null==b?void 0:b.networkConfiguration)||void 0===g?void 0:g.bufferSize).setCustomEventTrackingConfiguration(null==b?void 0:b.customEventTrackingConfiguration).setEndPoint(null===(p=null==b?void 0:b.networkConfiguration)||void 0===p?void 0:p.endpoint,u,l).setNetworkRequestTrackingConfiguration(null==b?void 0:b.networkRequestTrackingConfiguration,!0,null===(m=null==b?void 0:b.networkConfiguration)||void 0===m?void 0:m.endpoint).setMend(null===(h=null==b?void 0:b.networkConfiguration)||void 0===h?void 0:h.mend,v).setCatRcLastUpdatedTs(e).setEmitterConfiguration(null==b?void 0:b.emitterConfiguration).setcontrolIngestConfig(null!==(C=t["ctrl-ingst"])&&void 0!==C?C:null).setApplicationContext(null===(y=null==b?void 0:b.trackerConfiguration)||void 0===y?void 0:y.applicationContext).setDi(null==b?void 0:b.di).setClickcc(null==b?void 0:b.clickcc).setCollectionRateLimit(null==b?void 0:b.collectionRateLimit).setRcv(t.rcv).setPageUrlTrackingConfig(null!==(E=null==b?void 0:b.pageUrlTrackingConfig)&&void 0!==E?E:null).build()}(c,p);T=t.ConvivaConstants.CONFIG_SOURCE.REMOTE,k=(new Date).getTime(),s.setConfig(h),R({message:"Remote Config Applied",className:"updateRemoteConfig - tracker"}),function(e){try{a.removeItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY),a.setItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY,JSON.stringify(e))}catch(e){R({className:"updateRemoteConfig - storage",error:e}),N.warn("Error while saving remote-config to storage")}}(h),g()===t.ConvivaConstants.SAMPLING_MODES.NONE?w((null===(i=s.getConfig())||void 0===i?void 0:i.cacheRefreshInterval)||ee.cacheRefreshInterval):_(),function(){for(let t=0;t<A.length;t++)try{A[t]()}catch(t){}}(),R({message:"Remote config request is successful",className:"configTimerCallback - onreadystatechange"})}catch(e){R({className:"updateRemoteConfig - tracker",error:e}),N.warn("Error while updating remote-config")}}function x(e){var n;try{if(C<2){const t=5*(C+1)*1e3;c.setTimeout(()=>{L(!0,m)},t)}if(R({message:`Remote config request is not successful - ${e}`,className:"configTimerCallback - onreadystatechange"}),C>=2){R({message:"Remote config is not applied since failed to download remote config after 3 tries",className:"configTimerCallback - onreadystatechange"});try{a.removeItem(t.ConvivaConstants.REMOTE_CONFIG_RCV_KEY)}catch(e){}m=void 0;const r=f();w((null===(n=null==r?void 0:r.getConfig())||void 0===n?void 0:n.cacheRefreshInterval)||ee.cacheRefreshInterval)}}catch(e){}}function L(e,n){var r,o,a;try{if(h)return;e?C++:C=0;const c=f();m=null!==(a=null!==(o=null===(r=null==c?void 0:c.getConfig())||void 0===r?void 0:r.rcv)&&void 0!==o?o:n)&&void 0!==a?a:te,h=!0,R({message:"Remote config fetch attempt",className:"updateRemoteConfig"}),i.sendRequest(I,"GET",{headers:{"If-None-Match":m},timeout:3e4}).then(e=>{h=!1,200===e.status?M(e.body||""):304===e.status?function(){var e;if(O(),y=(new Date).getTime(),R({message:"Remote config not modified - 304",className:"configTimerCallback - onreadystatechange"}),C=0,m=void 0,g()===t.ConvivaConstants.SAMPLING_MODES.NONE){const t=f();w((null===(e=null==t?void 0:t.getConfig())||void 0===e?void 0:e.cacheRefreshInterval)||ee.cacheRefreshInterval)}else _()}():x(e.status)}).catch(t=>{h=!1,N.warn("Error in fetching remote-config",t),R({className:"configTimerCallback",error:t}),x(0)})}catch(e){h=!1,N.warn("Error in configTimerCallback",e),R({className:"configTimerCallback",error:e})}}const P=function(t){var e,n;return(new ae).setBase64(null==t?void 0:t.base64).setCacheRefreshInterval(null==t?void 0:t.cacheRefreshInterval).setLifecycleAutotracking(null==t?void 0:t.lifecycleAutotracking).setExceptionAutotracking(null==t?void 0:t.exceptionAutotracking).setEnablePeriodicHeartbeat(null==t?void 0:t.enablePeriodicHeartbeat).setPeriodicHeartbeatInterval(null==t?void 0:t.periodicHeartbeatInterval).setEnc(null==t?void 0:t.enc,d).setMaxLocalStorageQueueSize(null==t?void 0:t.maxLocalStorageQueueSize).setMaxGetBytes(null==t?void 0:t.maxGetBytes).setBufferSize(null==t?void 0:t.bufferSize).setCustomEventTrackingConfiguration(null==t?void 0:t.customEventTrackingConfiguration).setEndPoint(null==t?void 0:t.endpoint,u,l).setNetworkRequestTrackingConfiguration(null==t?void 0:t.networkRequestTrackingConfiguration,!1).setMend(null==t?void 0:t.mend,v).setCatRcLastUpdatedTs(null==t?void 0:t.catRcLastUpdatedTs).setEmitterConfiguration(null==t?void 0:t.emitterConfiguration).setcontrolIngestConfig(null!==(e=null==t?void 0:t.controlIngestConfig)&&void 0!==e?e:null).setApplicationContext(null==t?void 0:t.applicationContext).setDi(null==t?void 0:t.di).setClickcc(null==t?void 0:t.clickcc).setCollectionRateLimit(null==t?void 0:t.collectionRateLimit).setRcv(null==t?void 0:t.rcv).setPageUrlTrackingConfig(null!==(n=null==t?void 0:t.pageUrlTrackingConfig)&&void 0!==n?n:null).build()}(function(){let e=null;try{a.removeItem(t.ConvivaConstants.END_POINT_STORAGE_KEY),e=a.getItem(t.ConvivaConstants.REMOTE_CONFIG_STORAGE_KEY),e&&(T=t.ConvivaConstants.CONFIG_SOURCE.CACHED)}catch(e){b=!0,R({className:"fetchRemoteConfig - storage",error:e}),N.warn("Issue while fetching data from storage")}if(!e)return{};try{return JSON.parse(e)}catch(e){return b=!0,R({className:"fetchRemoteConfig - parsing cached data",error:e}),N.warn("Issue while parsing storedConvivaRemoteConfig"),{}}}());let D="Cached Config Applied";return T===t.ConvivaConstants.CONFIG_SOURCE.DEFAULT&&(D="Default Config Applied"),k=(new Date).getTime(),R({message:D,className:"customTrackerCore"}),{getInitialConfig:()=>P,startFetching:()=>{if(L(!1,P.rcv),g()===t.ConvivaConstants.SAMPLING_MODES.NONE)if((b?t.ConvivaConstants.RC_FETCH_MODE.IMMEDIATE_FETCH:t.ConvivaConstants.RC_FETCH_MODE.UPDATE_TIMER_WITH_DIFF)===t.ConvivaConstants.RC_FETCH_MODE.IMMEDIATE_FETCH)w(ee.cacheRefreshInterval);else{const t=P.catRcLastUpdatedTs||0,e=ee.cacheRefreshInterval,n=t?((new Date).getTime()-t)/6e4:e,r=e-n;t>0&&r>3*e/100?c.setTimeout(()=>{L(!1),w(e)},60*r*1e3):w(e)}},onConfigUpdate:t=>{A.push(t)},handleRcvFromResponse:function(e){var n,r;try{if(void 0===e||e===te)return;const o=f(),i=null!==(r=null===(n=null==o?void 0:o.getConfig())||void 0===n?void 0:n.rcv)&&void 0!==r?r:"";if(i!==e&&(new Date).getTime()-y>=3e4){try{a.setItem(t.ConvivaConstants.REMOTE_CONFIG_RCV_KEY,e)}catch(e){}_(),L(!1,i)}}catch(e){}},cleanup:()=>{_(),A.length=0}}}function se(t){return{contexts:()=>{try{return[{sc:"cv/clid/1-0-2",dt:{clid:t.getClid(),iid:t.getIid().toString(),ck:t.getCustomerKey(),eventIndex:t.getAndIncrementEventIndex()}}]}catch(t){return[]}}}}function le(t){return{contexts:()=>{try{return[{sc:"cv/ct/1-0-0",dt:{data:{...t.getCustomTags()}}}]}catch(t){return[]}}}}function ue(t){return{contexts:()=>{try{const e=t.getConfig();return!0!==(null==e?void 0:e.applicationContext)?[]:[{sc:"spm/app/1-0-0",dt:{build:t.getAppVersion(),version:t.getAppVersion()}}]}catch(t){return[]}}}}function de(e){return{contexts:()=>{try{const n=function(e){const n={sch:"sdk.js.eco.1"};try{if(!e)return n.cat=Yt.DeviceCategory.WEB,n;const r=e[t.DeviceMetadata.CATEGORY];"string"==typeof r&&Object.values(Yt.DeviceCategory).includes(r)?n.cat=r:n.cat="INVALID"+(r?`: ${r}`:"");const o=e[t.DeviceMetadata.BRAND];"string"==typeof o&&""!==o&&(n.dvb=o);const i=e[t.DeviceMetadata.MANUFACTURER];"string"==typeof i&&""!==i&&(n.dvma=i);const a=e[t.DeviceMetadata.MODEL];"string"==typeof a&&""!==a&&(n.dvm=a);const c=e[t.DeviceMetadata.TYPE];c&&Object.values(Yt.DeviceType).includes(c)&&(n.dvt=c);const s=e[t.DeviceMetadata.VERSION];"string"==typeof s&&""!==s&&(n.dvv=s);const l=e[t.DeviceMetadata.OS_NAME];"string"==typeof l&&""!==l&&(n.os=l);const u=e[t.DeviceMetadata.OS_VERSION];"string"==typeof u&&""!==u&&(n.osv=u);const d=e[t.DeviceMetadata.FRAMEWORK_NAME];"string"==typeof d&&""!==d&&(n.fw=d);const v=e[t.DeviceMetadata.FRAMEWORK_VERSION];"string"==typeof v&&""!==v&&(n.fwv=v)}catch(e){N.warn("error in setting platform metadata context",e)}return n}(e.getDeviceMetadata());return null!=n&&Object.keys(n).length>0?[{sc:"iglu:com.conviva/pm/jsonschema/1-0-2",dt:n}]:[]}catch(t){return[]}}}}const ve="==",fe="*";var ge;function pe(t,e,n,r,o,i){var a;try{let c=null;const s=null!==(a=i.url)&&void 0!==a?a:"";if(!s)return!0;if(ye.some(t=>s.includes(t)))return!1;const l=new(0,globalThis.URL)(s),u=l.protocol.replace(":",""),d=(t,e)=>{var n,r,a;const c=function(t,e,n){try{for(const r of t){const{req:t,opt:o}=r;if(me(t,e,n))return{matched:!0,opt:o||null,item:r}}return{matched:!1,opt:null}}catch(t){return{matched:!1,opt:null}}}(t,{scheme:u,host:l.hostname,path:decodeURIComponent(l.pathname)},ge.NETWORK_REQUEST);return c.matched?c.opt?me(c.opt,{responseStatusCode:null!==(n=null==o?void 0:o.status)&&void 0!==n?n:0,duration:(null!==(r=null==o?void 0:o.responseTimestamp)&&void 0!==r?r:0)-(null!==(a=null==i?void 0:i.requestTimestamp)&&void 0!==a?a:0)},ge.NETWORK_REQUEST)===e:e:null};if(t&&null===c&&(c=d(t,!0)),e&&null===c&&(c=d(e,!1)),null===c){const t=s.toLowerCase(),e=(null==n?void 0:n.includes("*"))||(null==n?void 0:n.some(e=>!(!e||""===e)&&t.includes(e.toLowerCase()))),o=null==r?void 0:r.some(e=>!(!e||""===e)&&t.includes(e.toLowerCase()));c=!e||o}return!0===c}catch(t){return!0}}function me(t,e,n){try{if(!t)return!1;if("and"===t.type){for(const r of t.cond)if(!me(r,e,n))return!1;return!0}if("or"===t.type){for(const r of t.cond)if(me(r,e,n))return!0;return!1}return n===ge.NETWORK_REQUEST?function(t,e){const{key:n,op:r,val:o}=t;if(!n||!r)return!1;switch(n){case"sch":return!!e.scheme&&he(e.scheme,r,o);case"host":return!!e.host&&he(e.host,r,o);case"path":return!!e.path&&he(e.path,r,o);case"dur":return!!e.duration&&Ce(e.duration,r,o);case"rsc":return void 0!==e.responseStatusCode&&e.responseStatusCode>=0&&Ce(e.responseStatusCode,r,o);default:return!1}}(t,e):n===ge.CUSTOM_EVENT&&function(t,e){const{key:n,op:r,val:o}=t;if(!n||!r)return!1;if(void 0!==e[n]){if(function(t){return!(!t||"string"!=typeof t.valueOf())}(e[n]))return he(e[n],r,o);if("boolean"==typeof e[n]){const t=e[n];switch(r){case"!=":return t!==o;case ve:return t===o;default:return!1}}if(Number.isInteger(e[n]))return Ce(e[n],r,o)}return!1}(t,e)}catch(t){return!1}}function he(t,e,n){if(e===ve&&Array.isArray(n)){let e=n;return!!e.includes(fe)||e.some(e=>!(!e||""===e)&&t===e)}if("contains"===e&&Array.isArray(n)){let e=n;return!!e.includes(fe)||e.some(e=>!(!e||""===e)&&t.includes(e))}if("sw"===e&&Array.isArray(n)){let e=n;return!!e.includes(fe)||e.some(e=>!(!e||""===e)&&t.startsWith(e))}if("ew"===e&&Array.isArray(n)){let e=n;return!!e.includes(fe)||e.some(e=>!(!e||""===e)&&t.endsWith(e))}return!1}function Ce(t,e,n){if("in"===e.toLowerCase()&&Array.isArray(n))return n.includes(t);if("range"===e.toLowerCase()&&"object"==typeof n)return function(t,e){const{min:n,max:r,minExclusive:o,maxExclusive:i}=e;return void 0!==n&&void 0!==r?t>=n&&t<=r:void 0!==o&&void 0!==i&&t>o&&t<i}(t,n);if(r=n,Number.isInteger&&Number.isInteger(r)||"number"==typeof r&&isFinite(r)&&Math.floor(r)===r)switch(e){case"!=":return t!==n;case">":return t>n;case">=":return t>=n;case"<":return t<n;case"<=":return t<=n;case ve:return t===n;default:return!1}var r;return!1}!function(t){t[t.NETWORK_REQUEST=0]="NETWORK_REQUEST",t[t.CUSTOM_EVENT=1]="CUSTOM_EVENT"}(ge||(ge={}));const ye=["/ctp","/wsg","remote_config","rc.conviva.com","pings.conviva.com","rcg.conviva.com"];function Ee(t,e,n){let r=null;const o=function(t,e,n){for(const r of t){const{req:t,opt:o}=r;if(me(t,e,n)){if(!o)return{matched:!0,opt:null};if(me(o,e,n))return{matched:!0,opt:o}}}return{matched:!1,opt:null}}(t,e,n);return o.matched&&(r=!o.opt||!!me(o.opt,e,n)),r}class be{constructor(t=20,e=2e3,n=1e3,r,o){this.eventMaxLimit=Number.isFinite(t)?t:20,this.cooldown=Number.isFinite(e)?e:2e3,this.timeWindow=Number.isFinite(n)?n:1e3,this.windowStart=Date.now(),this.eventCount=0,this.circuitBreakerUntil=0,this.breakerPreviouslyOpen=!1,this.droppedCount=0,this.trackerCore=r,this.getSamplingMode=o}isAllowedToSendEvent(){const e=Date.now();if(e<this.circuitBreakerUntil)return this.droppedCount++,!1;if(this.breakerPreviouslyOpen){this.breakerPreviouslyOpen=!1;const n={message:"Application Error",className:"errorRateLimiter - isAllowedToSendEvent",extraData:{droppedCount:this.droppedCount}};try{this.getSamplingMode()!==t.ConvivaConstants.SAMPLING_MODES.NONE&&this.trackerCore.track(W(n))}catch(e){}this.droppedCount=0}return e-this.windowStart<this.timeWindow?this.eventCount++:(this.windowStart=e,this.eventCount=1),!(this.eventCount>this.eventMaxLimit&&(this.circuitBreakerUntil=e+this.cooldown,this.breakerPreviouslyOpen=!0,this.droppedCount++,1))}updateErrortRateLimitConfig(t,e,n){const r=Number.isFinite(t)?t:this.eventMaxLimit,o=Number.isFinite(e)?e:this.cooldown,i=Number.isFinite(n)?n:this.timeWindow,a=r!==this.eventMaxLimit||o!==this.cooldown||i!==this.timeWindow;this.eventMaxLimit=r,this.cooldown=o,this.timeWindow=i,a&&(this.windowStart=Date.now(),this.eventCount=0,this.circuitBreakerUntil=0,this.breakerPreviouslyOpen=!1,this.droppedCount=0)}}const Te={};function ke(t,e){try{const n=null!=t?t:Object.keys(Te);for(const t of n)Te.hasOwnProperty(t)?e(Te[t]):N.warn(t+" not configured")}catch(t){N.error("Function failed",t)}}function Ae(t){const e=null!=t?t:Object.keys(Te);for(const t of e)Te.hasOwnProperty(t)&&delete Te[t]}const Se=["id","class","elementName","text","name","elementType","placeholder","value","checked","targetUrl","target","xlink:href","xpath"];function Ie(r,o,i){var a,c,s,l,u,d,v,f,g,p,m,h,C,y,E,T,S,R;try{const O=null!==(a=i.httpTransport)&&void 0!==a?a:function(){try{if("undefined"==typeof XMLHttpRequest)return;return{sendRequest:(t,e,n)=>new Promise(r=>{var o;try{const i=new XMLHttpRequest;if(i.open(e,t,!0),(null==n?void 0:n.timeout)&&(i.timeout=n.timeout),(null==n?void 0:n.contentType)&&i.setRequestHeader("Content-Type",n.contentType),null==n?void 0:n.headers)for(const[t,e]of Object.entries(n.headers))i.setRequestHeader(t,e);i.onreadystatechange=function(){if(4===i.readyState){const t={};try{const e=i.getAllResponseHeaders();e&&e.trim().split(/[\r\n]+/).forEach(e=>{const n=e.split(": ");n.length>=2&&(t[n[0].toLowerCase()]=n.slice(1).join(": "))})}catch(t){}r({status:i.status,body:i.responseText,headers:t})}},i.ontimeout=function(){r({status:0,body:void 0,headers:{}})},i.onerror=function(){r({status:0,body:void 0,headers:{}})},i.send(null!==(o=null==n?void 0:n.payload)&&void 0!==o?o:null)}catch(t){N.warn("Default HttpTransport sendRequest failed",t),r({status:0,body:void 0,headers:{}})}})}}catch(t){return}}(),_=null!==(c=i.storage)&&void 0!==c?c:function(){try{if("undefined"==typeof localStorage||"function"!=typeof localStorage.getItem||"function"!=typeof localStorage.setItem||"function"!=typeof localStorage.removeItem)return;const t="__conviva_storage_test__";return localStorage.setItem(t,"test"),localStorage.removeItem(t),{getItem(t){try{return localStorage.getItem(t)}catch(t){return null}},setItem(t,e){try{localStorage.setItem(t,e)}catch(t){}},removeItem(t){try{localStorage.removeItem(t)}catch(t){}}}}catch(t){return}}(),w=null!==(s=i.timers)&&void 0!==s?s:function(){try{if("undefined"==typeof setTimeout||"undefined"==typeof setInterval||"undefined"==typeof clearTimeout||"undefined"==typeof clearInterval)return;return{setTimeout:(t,e)=>{try{return setTimeout(t,e)}catch(t){return 0}},setInterval:(t,e)=>{try{return setInterval(t,e)}catch(t){return 0}},clearTimeout:t=>{try{clearTimeout(t)}catch(t){}},clearInterval:t=>{try{clearInterval(t)}catch(t){}}}}catch(t){return}}();if(!O||!_||!w)return void N.warn("Custom tracker init failed: missing required adapters (httpTransport, storage, or timers)");const x={},L=Qt(_,()=>{x["First Launch"]="Yes"});let P=null==L?void 0:L.clid,D=null!==(l=null==L?void 0:L.iid)&&void 0!==l?l:-1,U=0,G="",q="",F="",V="",j=!1,B=null,K=null,H=null;const z=function(t){void 0===t&&(t={});var r=t.base64,o=t.corePlugins,i=t.callback,a=null!=o?o:[],c=function(e,r,o){var i=function(t){return{addPluginContexts:function(e){var r=e?n([],e,!0):[];return t.forEach(function(t){try{t.contexts&&r.push.apply(r,t.contexts())}catch(t){N.error("Error adding plugin contexts",t)}}),r}}}(r),a=M(),c=e,s={},l=null;function u(t){if(t&&t.length)return{sc:"sp/ctx/1-0-0",dt:t}}function d(t,e){var n=a.getApplicableContexts(t),r=[];return e&&e.length&&r.push.apply(r,e),n&&n.length&&r.push.apply(r,n),r}function v(t,e){s[t]=e}var f={track:function(t,e,n){t.withJsonProcessor(A(c)),t.add("eid",b.v4()),t.addDict(s);var a=Y(n);t.add(a.type,a.value.toString()),r.forEach(function(e){try{e.beforeTrack&&e.beforeTrack(t)}catch(t){N.error("Plugin beforeTrack",t)}});var l=u(d(t,i.addPluginContexts(e)));void 0!==l&&t.addJson("cx","co",l),"function"==typeof o&&o(t);var v=t.build();return r.forEach(function(t){try{t.afterTrack&&t.afterTrack(v)}catch(t){N.error("Plugin afterTrack",t)}}),v},buildPayload:function(t,e,n){t.withJsonProcessor(A(c)),t.add("eid",b.v4()),t.addDict(s);var o=Y(n);t.add(o.type,o.value.toString()),r.forEach(function(e){try{e.beforeTrack&&e.beforeTrack(t)}catch(t){N.error("Plugin beforeTrack",t)}});var a=u(d(t,i.addPluginContexts(e)));return void 0!==a&&t.addJson("cx","co",a),t.build()},addPayloadPair:v,configuration:t,getConfig:function(){return t},setConfig:function(e){e&&(void 0!==e.base64&&(t.base64=e.base64,c=e.base64),void 0!==e.lifecycleAutotracking&&(t.lifecycleAutotracking=e.lifecycleAutotracking),void 0!==e.cacheRefreshInterval&&(t.cacheRefreshInterval=e.cacheRefreshInterval),void 0!==e.exceptionAutotracking&&(t.exceptionAutotracking=e.exceptionAutotracking),void 0!==e.enablePeriodicHeartbeat&&(t.enablePeriodicHeartbeat=e.enablePeriodicHeartbeat),void 0!==e.periodicHeartbeatInterval&&(t.periodicHeartbeatInterval=e.periodicHeartbeatInterval),void 0!==e.enc&&(t.enc=e.enc),void 0!==e.mend&&(t.mend=e.mend),void 0!==e.maxLocalStorageQueueSize&&(t.maxLocalStorageQueueSize=e.maxLocalStorageQueueSize),void 0!==e.maxGetBytes&&(t.maxGetBytes=e.maxGetBytes),void 0!==e.bufferSize&&(t.bufferSize=e.bufferSize),void 0!==e.customEventTrackingConfiguration&&(t.customEventTrackingConfiguration=e.customEventTrackingConfiguration),void 0!==e.networkRequestTrackingConfiguration&&(t.networkRequestTrackingConfiguration=e.networkRequestTrackingConfiguration),void 0!==e.traceparentconfig&&(t.traceparentconfig=e.traceparentconfig),void 0!==e.baggageConfiguration&&(t.baggageConfiguration=e.baggageConfiguration),void 0!==e.metaTagsTrackingConfiguration&&(t.metaTagsTrackingConfiguration=e.metaTagsTrackingConfiguration),void 0!==e.evtStreamTrackingConfiguration&&(t.evtStreamTrackingConfiguration=e.evtStreamTrackingConfiguration),void 0!==e.performanceContextConfig&&(t.performanceContextConfig=e.performanceContextConfig),void 0!==e.catRcLastUpdatedTs&&(t.catRcLastUpdatedTs=e.catRcLastUpdatedTs),void 0!==e.endpoint&&(t.endpoint=e.endpoint),void 0!==e.controlIngestConfig&&(t.controlIngestConfig=e.controlIngestConfig),void 0!==e.applicationContext&&(t.applicationContext=e.applicationContext),void 0!==e.emitterConfiguration&&(t.emitterConfiguration=e.emitterConfiguration),void 0!==e.di&&(t.di=e.di),void 0!==e.clickcc&&(t.clickcc=e.clickcc),void 0!==e.collectionRateLimit&&(t.collectionRateLimit=e.collectionRateLimit),void 0!==e.pageUrlTrackingConfig?t.pageUrlTrackingConfig=e.pageUrlTrackingConfig:t.pageUrlTrackingConfig=null,void 0!==e.sessionReplayConfiguration?t.sessionReplayConfiguration=e.sessionReplayConfiguration:t.sessionReplayConfiguration=null,void 0!==e.rcv&&(t.rcv=e.rcv),void 0!==e.valueProbes?t.valueProbes=e.valueProbes:t.valueProbes=null,void 0!==e.webVitals?t.webVitals=e.webVitals:t.webVitals=null,void 0!==e.scrollsCollection&&(t.scrollsCollection=e.scrollsCollection),void 0!==e.formcc&&(t.formcc=e.formcc),void 0!==e.ipv4ipv6collection?t.ipv4ipv6collection=e.ipv4ipv6collection:t.ipv4ipv6collection=null)},getBase64Encoding:function(){return c},setBase64Encoding:function(t){c=t},addPayloadDict:function(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(s[e]=t[e])},resetPayloadPairs:function(t){s=I(t)?t:{}},setTrackerVersion:function(t){v("tv",t)},setTrackerNamespace:function(t){v("tna",t)},setAppId:function(t){v("aid",t)},setPlatform:function(t){v("p",t)},setUserId:function(t){v("uid",t)},setConversationId:function(t){l=t},getConversationId:function(){return l},setScreenResolution:function(t,e){v("res",t+"x"+e)},setViewport:function(t,e){v("vp",t+"x"+e)},setColorDepth:function(t){v("cd",t)},setTimezone:function(t){v("tz",t)},setLang:function(t){v("lang",t)},setIpAddress:function(t){v("ip",t)},setUseragent:function(t){v("ua",t)},addGlobalContexts:function(t){a.addGlobalContexts(t)},clearGlobalContexts:function(){a.clearGlobalContexts()},removeGlobalContexts:function(t){a.removeGlobalContexts(t)},setRCV:function(e){t.rcv=e}};return f}(null==r||r,a,i),s=e(e({},c),{addPlugin:function(t){var e,n,r=t.plugin;a.push(r),null===(e=r.logger)||void 0===e||e.call(r,N),null===(n=r.activateCorePlugin)||void 0===n||n.call(r,s)}});return null==a||a.forEach(function(t){var e,n;null===(e=t.logger)||void 0===e||e.call(t,N),null===(n=t.activateCorePlugin)||void 0===n||n.call(t,s)}),s}({base64:null!==(u=i.encodeBase64)&&void 0!==u&&u,callback:e=>{var n;const r=e.build(),o=(null===(n=z.getConfig())||void 0===n?void 0:n.endpoint)||i.endpoint||t.ConvivaConstants.DEFAULT_END_POINT;lt.enqueueRequest(r,it(o))}}),Z=`js-${$}`;z.addPayloadPair("tv",Z),z.addPayloadPair("aid",i.appId),z.addPayloadPair("p",null!==(d=i.platform)&&void 0!==d?d:"web");const tt=()=>{try{const e=z.getConfig();return e&&e.controlIngestConfig?Xt(e.controlIngestConfig,_):t.ConvivaConstants.SAMPLING_MODES.RCFG}catch(e){return t.ConvivaConstants.SAMPLING_MODES.RCFG}},et=ce({customerKey:i.convivaCustomerKey,jsVersion:$,namespace:o,httpTransport:O,storage:_,timers:w,trackerConfigUrl:i.trackerConfigUrl,proxyGatewayUrl:i.proxyGatewayUrl,gatewayUrl:i.gatewayUrl,networkEncoding:null===(f=null===(v=i.configs)||void 0===v?void 0:v.network)||void 0===f?void 0:f.encoding,networkMergeEndpoint:void 0,getTrackerCore:()=>z,getSamplingMode:tt,reportDiagnosticInfo:e=>{try{tt()!==t.ConvivaConstants.SAMPLING_MODES.NONE&&z.track(W(e))}catch(e){}}}),nt=et.getInitialConfig();z.setConfig(nt),tt();const rt=null===(p=null===(g=z.getConfig())||void 0===g?void 0:g.collectionRateLimit)||void 0===p?void 0:p.exceptionAutotracking,ot=new be(null==rt?void 0:rt.maxEvents,null==rt?void 0:rt.disconnectDuration,null==rt?void 0:rt.timeWindow,z,tt);function it(t){var e,n;try{const r=null===(n=null===(e=z.getConfig())||void 0===e?void 0:e.mend)||void 0===n||n;return 0===t.indexOf("http")&&r?t.replace(/^(https?:\/\/)(.*)/,"$1"+i.convivaCustomerKey+".$2"):r?"https://"+i.convivaCustomerKey+"."+t:0===t.indexOf("http")?t:"https://"+t}catch(e){return t}}const at=null!==(m=i.postPath)&&void 0!==m?m:"/ctp",ct=(null===(h=z.getConfig())||void 0===h?void 0:h.emitterConfiguration)||ee.emitterConfiguration,st=(null==ct?void 0:ct.batching)||{},lt=oe({id:r,httpTransport:O,storage:_,timers:w,postPath:at,bufferSize:null!==(y=null!==(C=i.bufferSize)&&void 0!==C?C:st.byteLimitPostInKB)&&void 0!==y?y:1,useStm:null===(E=i.useStm)||void 0===E||E,connectionTimeout:null!==(T=i.connectionTimeout)&&void 0!==T?T:3e4,maxJitterDelayMs:null!==(S=i.maxJitterDelayMs)&&void 0!==S?S:1e3,getEnc:()=>{var t;return(null===(t=z.getConfig())||void 0===t?void 0:t.enc)||"gzip"},getEmitterBatchingEnabled:()=>{var t,e,n;const r=null===(t=z.getConfig())||void 0===t?void 0:t.emitterConfiguration;return null===(n=null===(e=null==r?void 0:r.batching)||void 0===e?void 0:e.enabled)||void 0===n||n},getEmitterByteLimitPost:()=>{var t,e,n;const r=null===(t=z.getConfig())||void 0===t?void 0:t.emitterConfiguration;return 1024*(null!==(n=null===(e=null==r?void 0:r.batching)||void 0===e?void 0:e.byteLimitPostInKB)&&void 0!==n?n:250)},getEmitterBatchingIntervalMs:()=>{var t,e,n;const r=null===(t=z.getConfig())||void 0===t?void 0:t.emitterConfiguration;return 1e3*(null!==(n=null===(e=null==r?void 0:r.batching)||void 0===e?void 0:e.batchingIntervalInSec)&&void 0!==n?n:5)},getSamplingMode:tt,onRcvHeader:t=>{et.handleRcvFromResponse(t)}});et.onConfigUpdate(()=>{var t,e,n,r;(null===(t=z.getConfig())||void 0===t?void 0:t.controlIngestConfig)||$t(_);const o=null===(e=z.getConfig())||void 0===e?void 0:e.endpoint;o&<.setCollectorUrl(it(o));const i=null===(r=null===(n=z.getConfig())||void 0===n?void 0:n.collectionRateLimit)||void 0===r?void 0:r.exceptionAutotracking;ot.updateErrortRateLimitConfig(null==i?void 0:i.maxEvents,null==i?void 0:i.disconnectDuration,null==i?void 0:i.timeWindow),ft(),lt.executeQueue()}),z.addPlugin({plugin:se({getClid:()=>P,getIid:()=>D,getCustomerKey:()=>i.convivaCustomerKey,getAndIncrementEventIndex:()=>U++})}),z.addPlugin({plugin:le({getCustomTags:()=>x})}),z.addPlugin({plugin:ue({getAppVersion:()=>i.appVersion||i.buildNumber||"",getConfig:()=>z.getConfig()})}),z.addPlugin({plugin:de({getDeviceMetadata:()=>i.deviceMetadata})});try{(null!==(R=i.plugins)&&void 0!==R?R:[]).forEach(t=>{z.addPlugin(t)})}catch(yt){N.warn("Issue while processing custom plugins")}function ut(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function dt(){if(null!==B)return;const e=()=>{try{const d=z.getConfig();if(!0!==(null==d?void 0:d.enablePeriodicHeartbeat))return;if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;if(null!=(null==d?void 0:d.periodicHeartbeatInterval)){const t=1e3*d.periodicHeartbeatInterval;if(t!==H&&null!==B){try{w.clearInterval(B)}catch(t){}H=t,B=w.setInterval(e,t)}}z.track((r=(n={pageUrl:G,pageTitle:q,referrer:F,minXOffset:0,maxXOffset:0,minYOffset:0,maxYOffset:0}).pageUrl,o=n.pageTitle,i=n.referrer,a=n.minXOffset,c=n.maxXOffset,s=n.minYOffset,l=n.maxYOffset,(u=k()).add("e","pp"),u.add("url",r),u.add("page",o),u.add("refr",i),a&&!isNaN(Number(a))&&u.add("pp_mix",a.toString()),c&&!isNaN(Number(c))&&u.add("pp_max",c.toString()),s&&!isNaN(Number(s))&&u.add("pp_miy",s.toString()),l&&!isNaN(Number(l))&&u.add("pp_may",l.toString()),u))}catch(t){}var n,r,o,i,a,c,s,l,u};K=w.setTimeout(e,2e3),H=4e4,B=w.setInterval(e,4e4)}function vt(){if(null!==K){try{w.clearTimeout(K)}catch(t){}K=null}if(null!==B){try{w.clearInterval(B)}catch(t){}B=null}H=null}function ft(){var e;try{const n=null===(e=null==z?void 0:z.getConfig())||void 0===e?void 0:e.pageUrlTrackingConfig,r=x[t.ConvivaConstants.PAGE_URL_QUERY_PARAMS];if(!n)return void(r&&delete x[t.ConvivaConstants.PAGE_URL_QUERY_PARAMS]);if(!G)return void(r&&delete x[t.ConvivaConstants.PAGE_URL_QUERY_PARAMS]);const o=Gt({targetUrl:G,[xt.request_query]:{}},n.collectattr,null,n.maxQueryLength),i=o?o[xt.request_query]:void 0;if(!i||"object"!=typeof i||0===Object.keys(i).length)return void(r&&delete x[t.ConvivaConstants.PAGE_URL_QUERY_PARAMS]);r&&JSON.stringify(r)===JSON.stringify(i)||(x[t.ConvivaConstants.PAGE_URL_QUERY_PARAMS]=i)}catch(e){}}function gt(t){if("object"==typeof t&&null!==t)return t;if("string"==typeof t)try{const e=JSON.parse(t);return e&&"object"==typeof e&&0===Object.keys(e).length?void 0:e}catch(t){return}}function pt(t,e){return t.length>e?`${t.slice(0,e-3)}...`:t}function mt(t){try{return JSON.parse(t),!0}catch(t){return!1}}function ht(t,e){return e&&(e.includes("*")||e.some(e=>(null==e?void 0:e.length)>0&&t.toLowerCase().includes(e.toLowerCase())))||!1}et.startFetching(),dt();const Ct={id:r,namespace:o,trackPageView(e){var n,r,o,i,a,c;try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;q=e.title,G=null!==(n=e.url)&&void 0!==n?n:G,j||(V=ut()),ft(),z.track((o=(r={pageUrl:G,pageTitle:q,referrer:F}).pageUrl,i=r.pageTitle,a=r.referrer,(c=k()).add("e","pv"),c.add("url",o),c.add("page",i),c.add("refr",a),c),e.context,e.timestamp)}catch(e){N.warn("trackPageView failed",e)}},trackCustomEvent(e){var n,r,o;try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;const i=z.getConfig();if(!(null!==(r=null===(n=null==i?void 0:i.customEventTrackingConfiguration)||void 0===n?void 0:n.enabled)&&void 0!==r?r:ee.customEventTrackingConfiguration.enabled))return;if(!e.name||"string"==typeof e.name&&""===e.name.trim())return void N.warn("custom event name is mandatory for trackCustomEvent API");let a=e.data;try{"string"!=typeof e.data&&(a=JSON.stringify(e.data))}catch(t){}const c=null===(o=null==i?void 0:i.customEventTrackingConfiguration)||void 0===o?void 0:o.blocklist;if(ht(e.name,c))return;z.track(Q({name:e.name,data:a}),e.context,e.timestamp)}catch(e){N.warn("Unable to track custom event",e)}},trackRevenueEvent(e){try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;if(null==e)return void N.warn("trackRevenueEvent: event is null or undefined. Event not sent.");if("object"!=typeof e||Array.isArray(e))return void N.warn("trackRevenueEvent: event must be a plain object. Event not sent.");const n=new Set(["totalOrderAmount","transactionId","currency","taxAmount","shippingCost","discount","cartSize","paymentMethod","paymentProvider","orderStatus","items","extraMetadata","context","timestamp"]),r=Object.keys(e).filter(t=>!n.has(t));r.length>0&&N.warn(`trackRevenueEvent: unrecognised field(s) [${r.join(", ")}] will be ignored.`);const{totalOrderAmount:o,transactionId:i,currency:a,context:c,timestamp:s}=e;if("number"!=typeof o||!Number.isFinite(o))return void N.warn("trackRevenueEvent: invalid totalOrderAmount. Must be a finite number. Event not sent.");if("string"!=typeof a||""===a.trim())return void N.warn("trackRevenueEvent: invalid currency. Must be a non-empty string. Event not sent.");if("string"!=typeof i||""===i.trim())return void N.warn("trackRevenueEvent: invalid transactionId. Must be a non-empty string. Event not sent.");const l={totalOrderAmount:o,transactionId:i,currency:a},{taxAmount:u,shippingCost:d,discount:v,cartSize:f}=e;void 0!==u&&("number"==typeof u?l.taxAmount=u:N.warn("trackRevenueEvent: invalid taxAmount. Must be a number. Ignoring.")),void 0!==d&&("number"==typeof d?l.shippingCost=d:N.warn("trackRevenueEvent: invalid shippingCost. Must be a number. Ignoring.")),void 0!==v&&("number"==typeof v?l.discount=v:N.warn("trackRevenueEvent: invalid discount. Must be a number. Ignoring.")),void 0!==f&&("number"==typeof f?l.cartSize=f:N.warn("trackRevenueEvent: invalid cartSize. Must be a number. Ignoring."));const{paymentMethod:g,paymentProvider:p,orderStatus:m}=e;void 0!==g&&("string"==typeof g?l.paymentMethod=g:N.warn("trackRevenueEvent: invalid paymentMethod. Must be a string. Ignoring.")),void 0!==p&&("string"==typeof p?l.paymentProvider=p:N.warn("trackRevenueEvent: invalid paymentProvider. Must be a string. Ignoring.")),void 0!==m&&("string"==typeof m?l.orderStatus=m:N.warn("trackRevenueEvent: invalid orderStatus. Must be a string. Ignoring."));const{items:h}=e;void 0!==h&&(Array.isArray(h)?l.items=h:N.warn("trackRevenueEvent: items must be an array. Ignoring."));const{extraMetadata:C}=e;void 0!==C&&((t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(C)?l.extraMetadata=C:N.warn("trackRevenueEvent: extraMetadata must be a plain object. Ignoring.")),Ct.trackCustomEvent({name:"conviva_revenue_event",data:l,context:c,timestamp:s})}catch(e){N.warn("Unable to track revenue event",e)}},trackNetworkRequest(e){var n,r,o,a,c,s,l,u,d,v,f,g,p;try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;const m=null==z?void 0:z.getConfig().networkRequestTrackingConfiguration;if(!m||!0!==m.enabled)return;let h=e.responseDetails.responseTimestamp-e.requestDetails.requestTimestamp;try{h=parseFloat(h.toFixed(3))}catch(e){N.warn("Conviva App Tracker:: exception while converting duration to 3 decimal",e)}try{let C={targetUrl:null===(n=null==e?void 0:e.requestDetails)||void 0===n?void 0:n.url,method:null===(r=null==e?void 0:e.requestDetails)||void 0===r?void 0:r.method,responseStatusCode:(null===(o=null==e?void 0:e.responseDetails)||void 0===o?void 0:o.status)?e.responseDetails.status:0,responseStatusText:(null===(a=null==e?void 0:e.responseDetails)||void 0===a?void 0:a.statusText)?e.responseDetails.statusText:"ok",[xt.request_headers]:null===(c=null==e?void 0:e.requestDetails)||void 0===c?void 0:c.headers,[xt.response_headers]:null===(s=null==e?void 0:e.responseDetails)||void 0===s?void 0:s.headers,duration:h};if(!pe(null==m?void 0:m.collect,null==m?void 0:m.block,null==m?void 0:m.blocklist,null===(u=null===(l=null==i?void 0:i.configs)||void 0===l?void 0:l.networkRequestTracking)||void 0===u?void 0:u.safelist,{status:null===(d=null==e?void 0:e.responseDetails)||void 0===d?void 0:d.status,responseTimestamp:null===(v=null==e?void 0:e.responseDetails)||void 0===v?void 0:v.responseTimestamp},null==e?void 0:e.requestDetails))return;const y=Gt(C,null==m?void 0:m.collectattr,e,null==m?void 0:m.maxQueryLength,null==m?void 0:m.rbl);if(null===(f=null==e?void 0:e.requestDetails)||void 0===f?void 0:f[t.ConvivaConstants.TRACEPARENT_HEADER_KEY]){const n={[t.ConvivaConstants.TRACEPARENT_HEADER_KEY]:null===(g=null==e?void 0:e.requestDetails)||void 0===g?void 0:g[t.ConvivaConstants.TRACEPARENT_HEADER_KEY]};y[xt.request_headers]?y[xt.request_headers]={...y[xt.request_headers],...n}:y[xt.request_headers]=n}null==z||z.track(J({event:{sc:"cv/nr/1-0-5",dt:X({targetUrl:(p=y).targetUrl,method:p.method,queryParameters:p.queryParameters,responseStatusCode:p.responseStatusCode,responseStatusText:p.responseStatusText,rqh:p.rqh,rsh:p.rsh,rqb:p.rqb,rsb:p.rsb,rqq:p.rqq,requestSize:p.requestSize,responseSize:p.responseSize,duration:p.duration,contentType:p.contentType,requestTimestamp:p.requestTimestamp,responseTimestamp:p.responseTimestamp})}}),e.context,e.timestamp)}catch(e){N.warn("Conviva App Tracker:: Network request could not be tracked due to an exception!!",e)}}catch(e){N.warn("Conviva App Tracker:: Network request could not be tracked due to an exception!!",e)}},trackClick(e){var n,r,o;try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;const i=z.getConfig();if(!0!==(null===(n=null==i?void 0:i.clickcc)||void 0===n?void 0:n.en))return;const a=t.ConvivaConstants.CLICK_KEY_MAX_LENGTH,c={};for(const t of Se){const n=e[t];"string"==typeof n&&n.length>0&&(c[t]=pt(n,a))}const s=null===(r=null==i?void 0:i.clickcc)||void 0===r?void 0:r.collectattr;if(Array.isArray(s))for(const t of s){if("string"!=typeof t||-1!==Se.indexOf(t))continue;const n=e[t];"string"==typeof n&&n.length>0&&(c[t]=pt(n,a))}const{collect:l,block:u}=null!==(o=null==i?void 0:i.clickcc)&&void 0!==o?o:{},d=function(t,e,n){const{collect:r,block:o}=t;let i=null;if(r&&(i=Ee(r,e,n)),o&&null===i){const t=Ee(o,e,n);"boolean"==typeof t&&(i=!t)}return null===i||i}({collect:l,block:u},c,ge.CUSTOM_EVENT);if("boolean"==typeof d&&!1===d)return;z.track(Q({name:"conviva_click",data:JSON.stringify(c)}),e.context,e.timestamp)}catch(e){N.warn("Exception in trackClick",e)}},trackButtonClick(t){try{t.elementType="button",Ct.trackClick(t)}catch(t){N.warn("Exception in trackButtonClick",t)}},trackLinkClick(t){try{t.elementType="link",Ct.trackClick(t)}catch(t){N.warn("Exception in trackLinkClick",t)}},trackError(e){try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;const{message:n,filename:r,lineno:o,colno:i,error:a,context:c,timestamp:s}=e,l=a&&a.stack?a.stack:void 0;if(void 0===n||null===n&&void 0===l||null===l&&void 0===o||null===o&&void 0===i||null===i&&void 0===r||null===r)return;const u=z.getConfig();if(!(null==u?void 0:u.exceptionAutotracking))return;if(!ot.isAllowedToSendEvent())return;z.track(J({event:{sc:"sp/ae/1-0-1",dt:{programmingLanguage:"JAVASCRIPT",message:n?pt(n,2048):"JS Exception.",stackTrace:l?pt(l,8192):"",lineNumber:o,lineColumn:i,fileName:r}}}),c,s)}catch(e){N.warn("trackError failed",e)}},trackVideoEvent(e){var n,r,o,i,a;try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;const c=z.getConfig();if(!(null!==(r=null===(n=null==c?void 0:c.customEventTrackingConfiguration)||void 0===n?void 0:n.enabled)&&void 0!==r?r:ee.customEventTrackingConfiguration.enabled))return;if(""===e.name||void 0===e.name)return void N.warn("Video event could not be tracked due to missing name property");e.ced=gt(e.ced),e.old=gt(e.old),e.new=gt(e.new),e.tags=gt(e.tags);let s=!1;e.cen&&(null===(o=t.ConvivaConstants.V2A_CUSTOM_EVENTS)||void 0===o?void 0:o.includes(e.name))&&(e.name=e.cen,s=!0);const l=null===(i=null==c?void 0:c.customEventTrackingConfiguration)||void 0===i?void 0:i.blocklist;if(ht(e.name,l))return;if(s){const{isTrusted:t,name:n,cen:r,new:o,old:i,...a}=e;z.track(Q({name:e.name,data:JSON.stringify(a)}),e.context,e.timestamp)}else z.track(J({event:{sc:"cv/ve/1-0-6",dt:X({name:(a={name:e.name,sid:e.sid,iid:e.iid,clid:e.clid,st:e.st,sst:e.sst,an:e.an,cl:e.cl,lv:e.lv,pn:e.pn,vid:e.vid,fw:e.fw,fwv:e.fwv,mn:e.mn,mv:e.mv,url:e.url,tags:e.tags,cen:e.cen,ced:e.ced,oldsc:e.old,newsc:e.new,err:e.err,br:e.br,ft:e.ft,avgbr:e.avgbr}).name,sid:a.sid,iid:a.iid,clid:a.clid,st:a.st,sst:a.sst,an:a.an,cl:a.cl,lv:a.lv,pn:a.pn,vid:a.vid,fw:a.fw,fwv:a.fwv,mn:a.mn,mv:a.mv,url:a.url,tags:a.tags,cen:a.cen,ced:a.ced,oldsc:a.oldsc,newsc:a.newsc,err:a.err,br:a.br,ft:a.ft,avgbr:a.avgbr})}}),e.context,e.timestamp)}catch(e){N.warn("Video event could not be tracked",e)}},trackAppBackground(e){try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;z.track(J({event:{sc:"sp/abg/1-0-0",dt:X({backgroundIndex:e.backgroundIndex})}}),e.context,e.timestamp)}catch(e){N.warn("trackAppBackground failed",e)}},trackAppForeground(e){try{if(tt()===t.ConvivaConstants.SAMPLING_MODES.NONE)return;z.track(J({event:{sc:"sp/afg/1-0-0",dt:X({foregroundIndex:e.foregroundIndex})}}),e.context,e.timestamp)}catch(e){N.warn("trackAppForeground failed",e)}},setUserId(t){try{z.addPayloadPair("uid",null!=t?t:"")}catch(t){}},setCustomTags(t){try{mt(JSON.stringify(t))?Object.keys(t).forEach(e=>{if(""!==e.trim()){let n=t[e];n&&""!==n&&(n="object"==typeof n?JSON.stringify(n):""+n,Object.defineProperty(x,e,{value:n,writable:!0,enumerable:!0,configurable:!0}))}}):N.warn("Invalid JSON Format for custom tags")}catch(t){N.warn("Invalid JSON Format for custom tags",t)}},unsetCustomTags(t){try{for(const e of t)delete x[e]}catch(t){}},getClientId(){try{return null!=P?P:""}catch(t){return""}},setClientId(e){try{if("string"!=typeof e)return void N.warn("setClientId: clientId must be a string");const n=e.split(".");if(4!==n.length||!n.every(t=>/^\d+$/.test(t)))return void N.warn("setClientId: invalid format. Must be x.x.x.x with numeric parts.");P=e;const r=_.getItem(t.ConvivaConstants.IDENTITY_STORAGE_KEY),o=r?JSON.parse(r):{};o.clId=e,Wt(_,o)}catch(t){}},setConversationId(t){try{z.setConversationId(t)}catch(t){}},setCustomUrl(t){try{G=t,ft()}catch(t){}},setDocumentTitle(t){try{q=t}catch(t){}},setReferrerUrl(t){try{F=t}catch(t){}},flushBuffer(t){try{lt.executeQueue(),null!=(null==t?void 0:t.newBufferSize)&<.setBufferSize(t.newBufferSize)}catch(t){}},setBufferSize(t){try{lt.setBufferSize(t)}catch(t){}},setCollectorUrl(t){try{lt.setCollectorUrl(it(t))}catch(t){}},enableAnonymousTracking(){try{lt.setAnonymousTracking(!0)}catch(t){}},disableAnonymousTracking(){try{lt.setAnonymousTracking(!1),lt.executeQueue()}catch(t){}},clearUserData(){try{z.addPayloadPair("uid",""),Object.keys(x).forEach(t=>delete x[t])}catch(t){}},getPageViewId(){try{return V||(V=ut()),V}catch(t){return""}},preservePageViewId(){try{j=!0}catch(t){}},getSamplingMode(){try{return tt()}catch(t){return""}},addPlugin(t){try{z.addPlugin(t)}catch(t){}},cleanup(){try{vt(),et.cleanup(),lt.cleanup(),Ae([r])}catch(t){}}};return Ct}catch(Et){return void N.warn("createCustomTracker failed",Et)}}const Re=[];let Oe=!1;function _e(t,e){Oe||Object.keys(Te).length>0?ke(t,e):Re.push({fn:e,trackers:t})}t.DeviceMetadataConstants=Yt,t.LOG=N,t.addPlugin=function(t,e){_e(e,e=>e.addPlugin(t))},t.cleanup=function(t){_e(t,t=>t.cleanup()),Ae(t),t||(Oe=!1,Re.length=0)},t.clearUserData=function(t){_e(t,t=>t.clearUserData())},t.convivaAppTracker=function(t){try{const e="CAT",n=Ie(e,e,t);return n?(function(t,e){Te.hasOwnProperty(t)||(Te[t]=e)}(e,n),function(){for(Oe=!0;Re.length>0;){const{fn:t,trackers:e}=Re.shift();try{ke(e,t)}catch(t){}}}(),n):void 0}catch(t){return}},t.disableAnonymousTracking=function(t){_e(t,t=>t.disableAnonymousTracking())},t.enableAnonymousTracking=function(t){_e(t,t=>t.enableAnonymousTracking())},t.flushBuffer=function(t,e){_e(e,e=>e.flushBuffer(t))},t.getClientId=function(t){let e="";return _e(t,t=>{e=t.getClientId()}),e},t.getPageViewId=function(t){let e="";return _e(t,t=>{e=t.getPageViewId()}),e},t.getSamplingMode=function(t){let e="";return _e(t,t=>{e=t.getSamplingMode()}),e},t.preservePageViewId=function(t){_e(t,t=>t.preservePageViewId())},t.setBufferSize=function(t,e){_e(e,e=>e.setBufferSize(t))},t.setClientId=function(t,e){_e(e,e=>e.setClientId(t))},t.setCollectorUrl=function(t,e){_e(e,e=>e.setCollectorUrl(t))},t.setConversationId=function(t,e){_e(e,e=>e.setConversationId(t))},t.setCustomTags=function(t,e){_e(e,e=>e.setCustomTags(t))},t.setCustomUrl=function(t,e){_e(e,e=>e.setCustomUrl(t))},t.setDocumentTitle=function(t,e){_e(e,e=>e.setDocumentTitle(t))},t.setReferrerUrl=function(t,e){_e(e,e=>e.setReferrerUrl(t))},t.setUserId=function(t,e){_e(e,e=>e.setUserId(t))},t.trackAppBackground=function(t,e){_e(e,e=>e.trackAppBackground(t))},t.trackAppForeground=function(t,e){_e(e,e=>e.trackAppForeground(t))},t.trackButtonClick=function(t,e){_e(e,e=>e.trackButtonClick(t))},t.trackClick=function(t,e){_e(e,e=>e.trackClick(t))},t.trackCustomEvent=function(t,e){_e(e,e=>e.trackCustomEvent(t))},t.trackError=function(t,e){_e(e,e=>e.trackError(t))},t.trackLinkClick=function(t,e){_e(e,e=>e.trackLinkClick(t))},t.trackNetworkRequest=function(t,e){_e(e,e=>e.trackNetworkRequest(t))},t.trackPageView=function(t,e){_e(e,e=>e.trackPageView(t))},t.trackRevenueEvent=function(t,e){_e(e,e=>e.trackRevenueEvent(t))},t.trackVideoEvent=function(t,e){_e(e,e=>e.trackVideoEvent(t))},t.unsetCustomTags=function(t,e){_e(e,e=>e.unsetCustomTags(t))},Object.defineProperty(t,"__esModule",{value:!0})});
|
|
8
|
+
//# sourceMappingURL=conviva-custom-tracker.umd.min.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@convivainc/conviva-js-custom-app-analytics-sdk",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Conviva Custom App Analytics SDK — DPI sensor for non-browser JavaScript runtimes (Taro mini-programs, VegaOS / Amazon Kepler, React Native, embedded JS)",
|
|
5
|
+
"main": "conviva-js-custom-app-analytics-sdk.umd.min.js",
|
|
6
|
+
"types": "conviva-js-custom-app-analytics-sdk.umd.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+github.com:Conviva/conviva-js-custom-app-analytics-sdk.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Conviva",
|
|
13
|
+
"Custom",
|
|
14
|
+
"Application",
|
|
15
|
+
"Analytics",
|
|
16
|
+
"Mini-program",
|
|
17
|
+
"Taro",
|
|
18
|
+
"VegaOS",
|
|
19
|
+
"Kepler",
|
|
20
|
+
"React Native"
|
|
21
|
+
],
|
|
22
|
+
"author": "Conviva Inc",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Conviva/conviva-js-custom-app-analytics-sdk/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Conviva/conviva-js-custom-app-analytics-sdk#readme"
|
|
28
|
+
}
|