avo-inspector 3.2.3-alpha.1 → 3.2.3

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.
Files changed (71) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/dist/AvoBatcher.js +0 -87
  4. package/dist/AvoDeduplicator.js +0 -142
  5. package/dist/AvoEncryption.js +0 -176
  6. package/dist/AvoInspector.js +0 -435
  7. package/dist/AvoNetworkCallsHandler.js +0 -229
  8. package/dist/AvoSchemaParser.js +0 -95
  9. package/dist/AvoStreamId.js +0 -82
  10. package/dist/__mocks__/xhr.js +0 -14
  11. package/dist/__mocks__/xhrError.js +0 -14
  12. package/dist/__tests__/AvoEncryption.d.ts +0 -1
  13. package/dist/__tests__/AvoEncryption.js +0 -272
  14. package/dist/__tests__/AvoEncryptionIntegration.d.ts +0 -1
  15. package/dist/__tests__/AvoEncryptionIntegration.js +0 -191
  16. package/dist/__tests__/AvoEventSpecFetcher.d.ts +0 -1
  17. package/dist/__tests__/AvoEventSpecFetcher.js +0 -377
  18. package/dist/__tests__/AvoInspector.d.ts +0 -1
  19. package/dist/__tests__/AvoInspector.js +0 -335
  20. package/dist/__tests__/Batcher.d.ts +0 -1
  21. package/dist/__tests__/Batcher.js +0 -214
  22. package/dist/__tests__/BatcherPublic.d.ts +0 -1
  23. package/dist/__tests__/BatcherPublic.js +0 -139
  24. package/dist/__tests__/Deduplicator.d.ts +0 -1
  25. package/dist/__tests__/Deduplicator.js +0 -190
  26. package/dist/__tests__/EnableLoggingLite_test.d.ts +0 -1
  27. package/dist/__tests__/EnableLogging_test.d.ts +0 -1
  28. package/dist/__tests__/EventSpecCache.d.ts +0 -1
  29. package/dist/__tests__/EventSpecCache.js +0 -143
  30. package/dist/__tests__/EventValidator.d.ts +0 -1
  31. package/dist/__tests__/EventValidator.js +0 -543
  32. package/dist/__tests__/InstallationId.d.ts +0 -1
  33. package/dist/__tests__/InstallationId.js +0 -60
  34. package/dist/__tests__/NetworkCallsHandler.d.ts +0 -1
  35. package/dist/__tests__/NetworkCallsHandler.js +0 -222
  36. package/dist/__tests__/NetworkCallsHandlerModelA.d.ts +0 -1
  37. package/dist/__tests__/NetworkCallsHandlerModelA.js +0 -206
  38. package/dist/__tests__/Parsing.d.ts +0 -1
  39. package/dist/__tests__/Parsing.js +0 -115
  40. package/dist/__tests__/Sessions.d.ts +0 -1
  41. package/dist/__tests__/Sessions.js +0 -10
  42. package/dist/__tests__/Storage.d.ts +0 -1
  43. package/dist/__tests__/Storage.js +0 -173
  44. package/dist/__tests__/StreamId.d.ts +0 -1
  45. package/dist/__tests__/StreamId.js +0 -153
  46. package/dist/__tests__/constants.js +0 -48
  47. package/dist/browser.js +0 -2
  48. package/dist/esm/AvoBatcher.js +0 -75
  49. package/dist/esm/AvoDeduplicator.js +0 -137
  50. package/dist/esm/AvoEncryption.js +0 -277
  51. package/dist/esm/AvoGuid.js +0 -9
  52. package/dist/esm/AvoInspector.js +0 -470
  53. package/dist/esm/AvoInspectorEnv.js +0 -5
  54. package/dist/esm/AvoNetworkCallsHandler.js +0 -181
  55. package/dist/esm/AvoSchemaParser.js +0 -128
  56. package/dist/esm/AvoStorage.js +0 -176
  57. package/dist/esm/AvoStreamId.js +0 -140
  58. package/dist/esm/eventSpec/AvoEventSpecCache.js +0 -165
  59. package/dist/esm/eventSpec/AvoEventSpecFetchTypes.js +0 -6
  60. package/dist/esm/eventSpec/AvoEventSpecFetcher.js +0 -203
  61. package/dist/esm/eventSpec/EventValidator.js +0 -687
  62. package/dist/esm/eventSpec/index.js +0 -4
  63. package/dist/esm/index.js +0 -3
  64. package/dist/esm/utils.js +0 -38
  65. package/dist/esm/version.js +0 -2
  66. package/dist/eventSpec/AvoEventSpecCache.js +0 -181
  67. package/dist/eventSpec/AvoEventSpecFetcher.js +0 -290
  68. package/dist/eventSpec/EventValidator.js +0 -846
  69. package/dist/eventSpec/index.js +0 -20
  70. package/dist/version.d.ts +0 -1
  71. package/dist/version.js +0 -5
@@ -1,173 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- var AvoStorage_1 = require("../AvoStorage");
51
- var constants_1 = require("../__tests__/constants");
52
- var originalWindow = __assign({}, window);
53
- beforeEach(function () {
54
- window = originalWindow;
55
- });
56
- describe("Avo Storage", function () {
57
- var storage = new AvoStorage_1.AvoStorage(constants_1.defaultOptions.shouldLog);
58
- var key = "avoKey";
59
- var value = "avoValue";
60
- test("Sets and gets item with shouldLog on", function () {
61
- var storage = new AvoStorage_1.AvoStorage(true);
62
- storage.setItem(key, value);
63
- var item = storage.getItem(key);
64
- expect(item).toBe(value);
65
- });
66
- test("Sets and gets item with shouldLog off", function () {
67
- var storage = new AvoStorage_1.AvoStorage(false);
68
- storage.setItem(key, value);
69
- var item = storage.getItem(key);
70
- expect(item).toBe(value);
71
- });
72
- test("Gets item asynchronously", function () { return __awaiter(void 0, void 0, void 0, function () {
73
- var item;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- storage.removeItem(key);
78
- storage.setItem(key, value);
79
- return [4 /*yield*/, storage.getItemAsync(key)];
80
- case 1:
81
- item = _a.sent();
82
- expect(item).toBe(value);
83
- return [2 /*return*/];
84
- }
85
- });
86
- }); });
87
- test("Returns null if key does not exist", function () {
88
- storage.removeItem(key);
89
- var item = storage.getItem(key);
90
- expect(item).toBeNull();
91
- });
92
- test("Deletes item with shouldLog on", function () {
93
- var storage = new AvoStorage_1.AvoStorage(true);
94
- storage.removeItem(key);
95
- var item = storage.getItem(key);
96
- expect(item).toBeNull();
97
- });
98
- test("Deletes item with shouldLog off", function () {
99
- var storage = new AvoStorage_1.AvoStorage(false);
100
- storage.removeItem(key);
101
- var item = storage.getItem(key);
102
- expect(item).toBeNull();
103
- });
104
- test("storage writes are delayed until the storage is initialized on web", function () {
105
- var storageWebImpl = storage.storageImpl;
106
- storageWebImpl.storageInitialized = false;
107
- storage.setItem(key, "OnStorageInitFuncs on web");
108
- var itemBeforeInit = storage.getItem(key);
109
- expect(itemBeforeInit).toBeNull();
110
- storageWebImpl.init(true);
111
- var itemAfterInit = storage.getItem(key);
112
- expect(itemAfterInit).toEqual("OnStorageInitFuncs on web");
113
- });
114
- });
115
- describe("Avo Storage unavailable", function () {
116
- var key = "avoKey";
117
- var value = "avoValue";
118
- beforeEach(function () {
119
- Object.defineProperty(window, "localStorage", {});
120
- });
121
- test("Fallback mode enabled", function () {
122
- var storage = new AvoStorage_1.AvoStorage(false);
123
- var storageImpl = storage.storageImpl;
124
- expect(storageImpl.useFallbackStorage).toBe(true);
125
- expect(storageImpl.storageInitialized).toBe(true);
126
- });
127
- test("Sets and gets item with shouldLog on", function () {
128
- var storage = new AvoStorage_1.AvoStorage(true);
129
- storage.setItem(key, value);
130
- var item = storage.getItem(key);
131
- expect(item).toBe(value);
132
- });
133
- test("Sets and gets item with shouldLog off", function () {
134
- var storage = new AvoStorage_1.AvoStorage(false);
135
- storage.setItem(key, value);
136
- var item = storage.getItem(key);
137
- expect(item).toBe(value);
138
- });
139
- test("Gets item asynchronously", function () { return __awaiter(void 0, void 0, void 0, function () {
140
- var storage, item;
141
- return __generator(this, function (_a) {
142
- switch (_a.label) {
143
- case 0:
144
- storage = new AvoStorage_1.AvoStorage(false);
145
- storage.removeItem(key);
146
- storage.setItem(key, value);
147
- return [4 /*yield*/, storage.getItemAsync(key)];
148
- case 1:
149
- item = _a.sent();
150
- expect(item).toBe(value);
151
- return [2 /*return*/];
152
- }
153
- });
154
- }); });
155
- test("Returns null if key does not exist", function () {
156
- var storage = new AvoStorage_1.AvoStorage(false);
157
- storage.removeItem(key);
158
- var item = storage.getItem(key);
159
- expect(item).toBeNull();
160
- });
161
- test("Deletes item with shouldLog on", function () {
162
- var storage = new AvoStorage_1.AvoStorage(true);
163
- storage.removeItem(key);
164
- var item = storage.getItem(key);
165
- expect(item).toBeNull();
166
- });
167
- test("Deletes item with shouldLog off", function () {
168
- var storage = new AvoStorage_1.AvoStorage(false);
169
- storage.removeItem(key);
170
- var item = storage.getItem(key);
171
- expect(item).toBeNull();
172
- });
173
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,153 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var AvoStreamId_1 = require("../AvoStreamId");
40
- var AvoStorage_1 = require("../AvoStorage");
41
- var AvoInspector_1 = require("../AvoInspector");
42
- var constants_1 = require("../__tests__/constants");
43
- describe("StreamId", function () {
44
- var storage = new AvoStorage_1.AvoStorage(constants_1.defaultOptions.shouldLog);
45
- beforeAll(function () {
46
- new AvoInspector_1.AvoInspector(constants_1.defaultOptions);
47
- });
48
- beforeEach(function () {
49
- // Reset the cached anonymousId between tests
50
- AvoStreamId_1.AvoStreamId._anonymousId = null;
51
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
52
- });
53
- afterEach(function () {
54
- storage.removeItem(AvoStreamId_1.AvoStreamId.cacheKey);
55
- AvoStreamId_1.AvoStreamId._anonymousId = null;
56
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
57
- });
58
- test("cacheKey equal to \"AvoInspectorAnonymousId\"", function () {
59
- expect(AvoStreamId_1.AvoStreamId.cacheKey).toEqual("AvoInspectorAnonymousId");
60
- });
61
- test("Returns a UUID after initialize()", function () { return __awaiter(void 0, void 0, void 0, function () {
62
- var id;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0: return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
66
- case 1:
67
- id = _a.sent();
68
- expect(id).not.toBeNull();
69
- expect(typeof id).toBe("string");
70
- expect(id.length).toBeGreaterThan(0);
71
- return [2 /*return*/];
72
- }
73
- });
74
- }); });
75
- test("Persists the same UUID across multiple initialize() calls", function () { return __awaiter(void 0, void 0, void 0, function () {
76
- var id1, id2;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0: return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
80
- case 1:
81
- id1 = _a.sent();
82
- // Reset in-memory cache to force re-read from storage
83
- AvoStreamId_1.AvoStreamId._anonymousId = null;
84
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
85
- return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
86
- case 2:
87
- id2 = _a.sent();
88
- expect(id1).toBe(id2);
89
- return [2 /*return*/];
90
- }
91
- });
92
- }); });
93
- test("Returns cached value on second call without re-reading storage", function () { return __awaiter(void 0, void 0, void 0, function () {
94
- var id1, id2;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0: return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
98
- case 1:
99
- id1 = _a.sent();
100
- return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
101
- case 2:
102
- id2 = _a.sent();
103
- expect(id1).toBe(id2);
104
- return [2 /*return*/];
105
- }
106
- });
107
- }); });
108
- test("Concurrent calls before cache populated all return same UUID (promise lock)", function () { return __awaiter(void 0, void 0, void 0, function () {
109
- var _a, id1, id2, id3;
110
- return __generator(this, function (_b) {
111
- switch (_b.label) {
112
- case 0:
113
- // Reset cache to force concurrent initialization
114
- AvoStreamId_1.AvoStreamId._anonymousId = null;
115
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
116
- return [4 /*yield*/, Promise.all([
117
- AvoStreamId_1.AvoStreamId.initialize(),
118
- AvoStreamId_1.AvoStreamId.initialize(),
119
- AvoStreamId_1.AvoStreamId.initialize(),
120
- ])];
121
- case 1:
122
- _a = _b.sent(), id1 = _a[0], id2 = _a[1], id3 = _a[2];
123
- expect(id1).toBe(id2);
124
- expect(id2).toBe(id3);
125
- return [2 /*return*/];
126
- }
127
- });
128
- }); });
129
- test("UUID never resets - calling initialize again returns same value", function () { return __awaiter(void 0, void 0, void 0, function () {
130
- var id1, id2, id3;
131
- return __generator(this, function (_a) {
132
- switch (_a.label) {
133
- case 0: return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
134
- case 1:
135
- id1 = _a.sent();
136
- // Simulate time passing / multiple app restarts by clearing memory cache
137
- AvoStreamId_1.AvoStreamId._anonymousId = null;
138
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
139
- return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
140
- case 2:
141
- id2 = _a.sent();
142
- AvoStreamId_1.AvoStreamId._anonymousId = null;
143
- AvoStreamId_1.AvoStreamId._initializationPromise = null;
144
- return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
145
- case 3:
146
- id3 = _a.sent();
147
- expect(id1).toBe(id2);
148
- expect(id2).toBe(id3);
149
- return [2 /*return*/];
150
- }
151
- });
152
- }); });
153
- });
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trackingEndpoint = exports.type = exports.sessionTimeMs = exports.requestMsg = exports.networkCallType = exports.mockedReturns = exports.error = exports.defaultOptions = void 0;
4
- var AvoInspectorEnv_1 = require("../AvoInspectorEnv");
5
- var defaultOptions = {
6
- apiKey: "api-key-xxx",
7
- env: AvoInspectorEnv_1.AvoInspectorEnv.Prod,
8
- version: "1",
9
- shouldLog: true
10
- };
11
- exports.defaultOptions = defaultOptions;
12
- var error = {
13
- API_KEY: "[Avo Inspector] No API key provided. Inspector can't operate without API key.",
14
- VERSION: "[Avo Inspector] No version provided. Many features of Inspector rely on versioning. Please provide comparable string version, i.e. integer or semantic.",
15
- };
16
- exports.error = error;
17
- var mockedReturns = {
18
- INSTALLATION_ID: "avo-instalation-id",
19
- GUID: "generated-guid",
20
- SESSION_ID: "session-id",
21
- ANONYMOUS_ID: "avo-anonymous-id",
22
- };
23
- exports.mockedReturns = mockedReturns;
24
- var networkCallType = {
25
- EVENT: "event",
26
- SESSION_STARTED: "sessionStarted",
27
- };
28
- exports.networkCallType = networkCallType;
29
- var requestMsg = {
30
- ERROR: "Request failed",
31
- TIMEOUT: "Request timed out",
32
- };
33
- exports.requestMsg = requestMsg;
34
- var trackingEndpoint = "https://api.avo.app/inspector/v1/track";
35
- exports.trackingEndpoint = trackingEndpoint;
36
- var sessionTimeMs = 5 * 60 * 1000;
37
- exports.sessionTimeMs = sessionTimeMs;
38
- var type = {
39
- STRING: "string",
40
- INT: "int",
41
- OBJECT: "object",
42
- FLOAT: "float",
43
- LIST: "list",
44
- BOOL: "boolean",
45
- NULL: "null",
46
- UNKNOWN: "unknown",
47
- };
48
- exports.type = type;