avo-inspector 3.2.3-alpha.1 → 4.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/AvoInspector.d.ts +1 -0
- package/dist/AvoStorage.d.ts +3 -2
- package/dist/AvoStorage.js +21 -6
- package/dist/eventSpec/AvoEventSpecCache.d.ts +7 -3
- package/dist/eventSpec/AvoEventSpecFetchTypes.d.ts +0 -5
- package/dist/eventSpec/AvoEventSpecFetchTypes.js +0 -5
- package/dist/eventSpec/AvoEventSpecFetcher.d.ts +7 -8
- package/dist/index.js +1 -1
- package/dist/lite/AvoInspectorLite.d.ts +1 -0
- package/dist/lite/AvoInspectorLite.js +18 -4
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +5 -1
- package/package.json +1 -1
- package/dist/AvoBatcher.js +0 -87
- package/dist/AvoDeduplicator.js +0 -142
- package/dist/AvoEncryption.js +0 -176
- package/dist/AvoInspector.js +0 -435
- package/dist/AvoNetworkCallsHandler.js +0 -229
- package/dist/AvoSchemaParser.js +0 -95
- package/dist/AvoStreamId.js +0 -82
- package/dist/__mocks__/xhr.js +0 -14
- package/dist/__mocks__/xhrError.js +0 -14
- package/dist/__tests__/AvoEncryption.d.ts +0 -1
- package/dist/__tests__/AvoEncryption.js +0 -272
- package/dist/__tests__/AvoEncryptionIntegration.d.ts +0 -1
- package/dist/__tests__/AvoEncryptionIntegration.js +0 -191
- package/dist/__tests__/AvoEventSpecFetcher.d.ts +0 -1
- package/dist/__tests__/AvoEventSpecFetcher.js +0 -377
- package/dist/__tests__/AvoInspector.d.ts +0 -1
- package/dist/__tests__/AvoInspector.js +0 -335
- package/dist/__tests__/Batcher.d.ts +0 -1
- package/dist/__tests__/Batcher.js +0 -214
- package/dist/__tests__/BatcherPublic.d.ts +0 -1
- package/dist/__tests__/BatcherPublic.js +0 -139
- package/dist/__tests__/Deduplicator.d.ts +0 -1
- package/dist/__tests__/Deduplicator.js +0 -190
- package/dist/__tests__/EventSpecCache.d.ts +0 -1
- package/dist/__tests__/EventSpecCache.js +0 -143
- package/dist/__tests__/EventValidator.d.ts +0 -1
- package/dist/__tests__/EventValidator.js +0 -543
- package/dist/__tests__/InstallationId.d.ts +0 -1
- package/dist/__tests__/InstallationId.js +0 -60
- package/dist/__tests__/NetworkCallsHandler.d.ts +0 -1
- package/dist/__tests__/NetworkCallsHandler.js +0 -222
- package/dist/__tests__/NetworkCallsHandlerModelA.d.ts +0 -1
- package/dist/__tests__/NetworkCallsHandlerModelA.js +0 -206
- package/dist/__tests__/Parsing.d.ts +0 -1
- package/dist/__tests__/Parsing.js +0 -115
- package/dist/__tests__/Sessions.d.ts +0 -1
- package/dist/__tests__/Sessions.js +0 -10
- package/dist/__tests__/Storage.d.ts +0 -1
- package/dist/__tests__/Storage.js +0 -173
- package/dist/__tests__/StreamId.d.ts +0 -1
- package/dist/__tests__/StreamId.js +0 -153
- package/dist/__tests__/constants.js +0 -48
- package/dist/browser.js +0 -2
- package/dist/esm/AvoBatcher.js +0 -75
- package/dist/esm/AvoDeduplicator.js +0 -137
- package/dist/esm/AvoEncryption.js +0 -277
- package/dist/esm/AvoGuid.js +0 -9
- package/dist/esm/AvoInspector.js +0 -470
- package/dist/esm/AvoInspectorEnv.js +0 -5
- package/dist/esm/AvoNetworkCallsHandler.js +0 -181
- package/dist/esm/AvoSchemaParser.js +0 -128
- package/dist/esm/AvoStorage.js +0 -176
- package/dist/esm/AvoStreamId.js +0 -140
- package/dist/esm/eventSpec/AvoEventSpecCache.js +0 -165
- package/dist/esm/eventSpec/AvoEventSpecFetchTypes.js +0 -6
- package/dist/esm/eventSpec/AvoEventSpecFetcher.js +0 -203
- package/dist/esm/eventSpec/EventValidator.js +0 -687
- package/dist/esm/eventSpec/index.js +0 -4
- package/dist/esm/index.js +0 -3
- package/dist/esm/utils.js +0 -38
- package/dist/esm/version.js +0 -2
- package/dist/eventSpec/AvoEventSpecCache.js +0 -181
- package/dist/eventSpec/AvoEventSpecFetcher.js +0 -290
- package/dist/eventSpec/EventValidator.js +0 -846
- package/dist/eventSpec/index.js +0 -20
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -5
package/README.md
CHANGED
|
@@ -70,6 +70,8 @@ let inspector = new Inspector.AvoInspector({
|
|
|
70
70
|
|
|
71
71
|
Logs are enabled by default in the dev mode and disabled in prod mode.
|
|
72
72
|
|
|
73
|
+
Since 4.0.0 the setting is shared by every inspector created from the same copy of the SDK, and creating an inspector no longer resets it. Remove any leftover `enableLogging(true)` before upgrading, or production pages keep printing logs.
|
|
74
|
+
|
|
73
75
|
```javascript
|
|
74
76
|
inspector.enableLogging(true);
|
|
75
77
|
```
|
package/dist/AvoInspector.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class AvoInspector {
|
|
|
23
23
|
private static _batchFlushSeconds;
|
|
24
24
|
static get batchFlushSeconds(): number;
|
|
25
25
|
private static _shouldLog;
|
|
26
|
+
private static _shouldLogSetByUser;
|
|
26
27
|
static get shouldLog(): boolean;
|
|
27
28
|
static set shouldLog(enable: boolean);
|
|
28
29
|
private static _networkTimeout;
|
package/dist/AvoStorage.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type ShouldLogFlag } from "./utils";
|
|
1
2
|
declare abstract class PlatformAvoStorage {
|
|
2
|
-
abstract init(shouldLog:
|
|
3
|
+
abstract init(shouldLog: ShouldLogFlag, suffix: string): void;
|
|
3
4
|
abstract getItemAsync<T>(key: string): Promise<T | null>;
|
|
4
5
|
abstract getItem<T>(key: string): T | null;
|
|
5
6
|
abstract setItem<T>(key: string, value: T): void;
|
|
@@ -11,7 +12,7 @@ declare abstract class PlatformAvoStorage {
|
|
|
11
12
|
export declare class AvoStorage {
|
|
12
13
|
Platform: string | null;
|
|
13
14
|
storageImpl: PlatformAvoStorage;
|
|
14
|
-
constructor(shouldLog:
|
|
15
|
+
constructor(shouldLog: ShouldLogFlag, suffix?: string);
|
|
15
16
|
isInitialized(): boolean;
|
|
16
17
|
getItemAsync<T>(key: string): Promise<T | null>;
|
|
17
18
|
getItem<T>(key: string): T | null;
|
package/dist/AvoStorage.js
CHANGED
|
@@ -52,6 +52,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
};
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
exports.AvoStorage = void 0;
|
|
55
|
+
var utils_1 = require("./utils");
|
|
56
|
+
// A failed write means the persisted event queue (and stream id) won't survive
|
|
57
|
+
// a page unload — a data-delivery error — so the first write failure is printed
|
|
58
|
+
// regardless of the logging flag. Repeats are gated, since once storage is full
|
|
59
|
+
// every event's write fails and that would be per-event noise. Module-scoped so
|
|
60
|
+
// every BrowserAvoStorage in one loaded copy of the SDK shares the "first"
|
|
61
|
+
// (a page with two inspectors logs it once, not twice); a separately bundled
|
|
62
|
+
// copy, the lite build, or an iframe copy each load this module afresh and so
|
|
63
|
+
// keep their own flag. See AVO-3079 review.
|
|
64
|
+
var reportedWriteFailure = false;
|
|
55
65
|
var PlatformAvoStorage = /** @class */ (function () {
|
|
56
66
|
function PlatformAvoStorage() {
|
|
57
67
|
}
|
|
@@ -73,12 +83,14 @@ var BrowserAvoStorage = /** @class */ (function (_super) {
|
|
|
73
83
|
_this.fallbackStorage = {};
|
|
74
84
|
_this.storageInitialized = false;
|
|
75
85
|
_this.onStorageInitFuncs = [];
|
|
76
|
-
|
|
86
|
+
// Reads the current logging flag live so a later enableLogging() /
|
|
87
|
+
// AvoInspector.shouldLog change is reflected without re-pushing. See AVO-3079.
|
|
88
|
+
_this.shouldLog = function () { return false; };
|
|
77
89
|
_this.suffix = "";
|
|
78
90
|
return _this;
|
|
79
91
|
}
|
|
80
92
|
BrowserAvoStorage.prototype.init = function (shouldLog, suffix) {
|
|
81
|
-
this.shouldLog = shouldLog;
|
|
93
|
+
this.shouldLog = (0, utils_1.toShouldLogGetter)(shouldLog);
|
|
82
94
|
this.suffix = suffix;
|
|
83
95
|
this.initializeStorageWeb(this.isLocalStorageAvailable());
|
|
84
96
|
};
|
|
@@ -128,7 +140,7 @@ var BrowserAvoStorage = /** @class */ (function (_super) {
|
|
|
128
140
|
maybeItem = window.localStorage.getItem(key + _this.suffix);
|
|
129
141
|
}
|
|
130
142
|
catch (error) {
|
|
131
|
-
if (_this.shouldLog) {
|
|
143
|
+
if (_this.shouldLog()) {
|
|
132
144
|
console.error("Avo Inspector Storage getItemAsync error:", error);
|
|
133
145
|
}
|
|
134
146
|
resolve(null);
|
|
@@ -160,7 +172,7 @@ var BrowserAvoStorage = /** @class */ (function (_super) {
|
|
|
160
172
|
maybeItem = window.localStorage.getItem(key + this.suffix);
|
|
161
173
|
}
|
|
162
174
|
catch (error) {
|
|
163
|
-
if (this.shouldLog) {
|
|
175
|
+
if (this.shouldLog()) {
|
|
164
176
|
console.error("Avo Inspector Storage getItem error:", error);
|
|
165
177
|
}
|
|
166
178
|
}
|
|
@@ -180,7 +192,10 @@ var BrowserAvoStorage = /** @class */ (function (_super) {
|
|
|
180
192
|
window.localStorage.setItem(key + _this.suffix, JSON.stringify(value));
|
|
181
193
|
}
|
|
182
194
|
catch (error) {
|
|
183
|
-
|
|
195
|
+
// Print the first write failure unconditionally (it means the queue
|
|
196
|
+
// may not survive unload); gate the repeats. See AVO-3079 review.
|
|
197
|
+
if (!reportedWriteFailure || _this.shouldLog()) {
|
|
198
|
+
reportedWriteFailure = true;
|
|
184
199
|
console.error("Avo Inspector Storage setItem error:", error);
|
|
185
200
|
}
|
|
186
201
|
}
|
|
@@ -200,7 +215,7 @@ var BrowserAvoStorage = /** @class */ (function (_super) {
|
|
|
200
215
|
window.localStorage.removeItem(key + _this.suffix);
|
|
201
216
|
}
|
|
202
217
|
catch (error) {
|
|
203
|
-
if (_this.shouldLog) {
|
|
218
|
+
if (_this.shouldLog()) {
|
|
204
219
|
console.error("Avo Inspector Storage removeItem error:", error);
|
|
205
220
|
}
|
|
206
221
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EventSpecResponse, EventSpecCoordinates } from "./AvoEventSpecFetchTypes";
|
|
2
|
+
import { type ShouldLogFlag } from "../utils";
|
|
2
3
|
/**
|
|
3
4
|
* EventSpecCache implements a dual-condition cache with LRU eviction.
|
|
4
5
|
*
|
|
@@ -24,9 +25,12 @@ export declare class EventSpecCache {
|
|
|
24
25
|
private readonly MAX_EVENT_COUNT;
|
|
25
26
|
/** Global cache hit counter to track when to rotate cache */
|
|
26
27
|
private globalEventCount;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Reads the current logging flag live, so a later enableLogging() /
|
|
30
|
+
* AvoInspector.shouldLog change is reflected without re-pushing. See AVO-3079.
|
|
31
|
+
*/
|
|
32
|
+
private shouldLog;
|
|
33
|
+
constructor(shouldLog?: ShouldLogFlag);
|
|
30
34
|
/**
|
|
31
35
|
* Generates a cache key from the provided parameters.
|
|
32
36
|
*/
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is generated. Internal development changes should be made in the generator
|
|
3
|
-
* and the file should be re-generated. External contributions are welcome to submit
|
|
4
|
-
* changes directly to this file, and we'll apply them to the generator internally.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Wire format - Property constraints with short field names.
|
|
8
3
|
* At most one constraint type will be present per property.
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This file is generated. Internal development changes should be made in the generator
|
|
4
|
-
* and the file should be re-generated. External contributions are welcome to submit
|
|
5
|
-
* changes directly to this file, and we'll apply them to the generator internally.
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is generated. Internal development changes should be made in the generator
|
|
3
|
-
* and the file should be re-generated. External contributions are welcome to submit
|
|
4
|
-
* changes directly to this file, and we'll apply them to the generator internally.
|
|
5
|
-
*/
|
|
6
1
|
import type { EventSpecResponse, FetchEventSpecParams } from "./AvoEventSpecFetchTypes";
|
|
2
|
+
import { type ShouldLogFlag } from "../utils";
|
|
7
3
|
/**
|
|
8
4
|
* EventSpecFetcher handles fetching event specifications from the Avo API.
|
|
9
5
|
*
|
|
@@ -17,11 +13,14 @@ export declare class AvoEventSpecFetcher {
|
|
|
17
13
|
private readonly timeout;
|
|
18
14
|
/** In-flight requests to prevent duplicate fetches */
|
|
19
15
|
private inFlightRequests;
|
|
20
|
-
/**
|
|
21
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Reads the current logging flag live, so a later enableLogging() /
|
|
18
|
+
* AvoInspector.shouldLog change is reflected without re-pushing. See AVO-3079.
|
|
19
|
+
*/
|
|
20
|
+
private shouldLog;
|
|
22
21
|
/** Environment name */
|
|
23
22
|
private readonly env;
|
|
24
|
-
constructor(timeout: number | undefined, shouldLog:
|
|
23
|
+
constructor(timeout: number | undefined, shouldLog: ShouldLogFlag | undefined, env: string, baseUrl?: string);
|
|
25
24
|
/**
|
|
26
25
|
* Generates a unique key for tracking in-flight requests, matching the spec
|
|
27
26
|
* cache key. The API key tells gateways apart, and gateway coordinates are
|