avo-inspector 3.2.0 → 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.
- package/README.md +10 -0
- package/dist/AvoBatcher.d.ts +9 -3
- package/dist/AvoInspector.d.ts +4 -0
- package/dist/AvoNetworkCallsHandler.d.ts +80 -5
- package/dist/__tests__/UnboundPublicMethods_test.d.ts +1 -0
- package/dist/__tests__/constants.d.ts +2 -1
- package/dist/__tests__/helpers/internalGateway.d.ts +23 -0
- package/dist/eventSpec/AvoEventSpecCache.d.ts +7 -4
- package/dist/eventSpec/AvoEventSpecFetchTypes.d.ts +12 -1
- package/dist/eventSpec/AvoEventSpecFetcher.d.ts +6 -1
- package/dist/index.js +1 -1
- package/dist/lite/AvoBatcherLite.d.ts +9 -3
- package/dist/lite/AvoBatcherLite.js +46 -7
- package/dist/lite/AvoInspectorLite.d.ts +2 -0
- package/dist/lite/AvoInspectorLite.js +95 -15
- package/dist/lite/AvoNetworkCallsHandlerLite.d.ts +79 -5
- package/dist/lite/AvoNetworkCallsHandlerLite.js +300 -20
- package/package.json +10 -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.js +0 -272
- package/dist/__tests__/AvoEncryptionIntegration.js +0 -191
- package/dist/__tests__/AvoEventSpecFetcher.js +0 -377
- package/dist/__tests__/AvoInspector.js +0 -335
- package/dist/__tests__/Batcher.js +0 -214
- package/dist/__tests__/BatcherPublic.js +0 -139
- package/dist/__tests__/Deduplicator.js +0 -190
- package/dist/__tests__/EventSpecCache.js +0 -143
- package/dist/__tests__/EventValidator.js +0 -543
- package/dist/__tests__/InstallationId.js +0 -60
- package/dist/__tests__/NetworkCallsHandler.js +0 -222
- package/dist/__tests__/NetworkCallsHandlerModelA.js +0 -206
- 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/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/dist/__tests__/{AvoEncryption.d.ts → ApiKeyHeaderInjection_test.d.ts} +0 -0
- /package/dist/__tests__/{AvoEncryptionIntegration.d.ts → BrowserBootstrap_test.d.ts} +0 -0
- /package/dist/__tests__/{AvoEventSpecFetcher.d.ts → EventSpecGatewayCoordinates_test.d.ts} +0 -0
- /package/dist/__tests__/{AvoInspector.d.ts → InFlightQueueGaps_test.d.ts} +0 -0
- /package/dist/__tests__/{Batcher.d.ts → InFlightQueue_test.d.ts} +0 -0
- /package/dist/__tests__/{BatcherPublic.d.ts → NetworkCallsHandlerLite_test.d.ts} +0 -0
- /package/dist/__tests__/{Deduplicator.d.ts → PublicSurface_test.d.ts} +0 -0
- /package/dist/__tests__/{EventSpecCache.d.ts → TrackOptionsIntegration_test.d.ts} +0 -0
- /package/dist/__tests__/{EventValidator.d.ts → TrackOptionsTransport_test.d.ts} +0 -0
- /package/dist/__tests__/{InstallationId.d.ts → TrackingHeaders_test.d.ts} +0 -0
- /package/dist/__tests__/{NetworkCallsHandler.d.ts → V1WireBaseline_test.d.ts} +0 -0
- /package/dist/__tests__/{NetworkCallsHandlerModelA.d.ts → V2QueuedAttribution_test.d.ts} +0 -0
- /package/dist/__tests__/{Parsing.d.ts → V2StopSending_test.d.ts} +0 -0
|
@@ -1,229 +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
|
-
exports.AvoNetworkCallsHandler = void 0;
|
|
40
|
-
var AvoGuid_1 = require("./AvoGuid");
|
|
41
|
-
var AvoInspector_1 = require("./AvoInspector");
|
|
42
|
-
var AvoStreamId_1 = require("./AvoStreamId");
|
|
43
|
-
var AvoEncryption_1 = require("./AvoEncryption");
|
|
44
|
-
var AvoNetworkCallsHandler = /** @class */ (function () {
|
|
45
|
-
function AvoNetworkCallsHandler(apiKey, envName, appName, appVersion, libVersion, publicEncryptionKey) {
|
|
46
|
-
this.samplingRate = 1.0;
|
|
47
|
-
this.sending = false;
|
|
48
|
-
this.apiKey = apiKey;
|
|
49
|
-
this.envName = envName;
|
|
50
|
-
this.appName = appName;
|
|
51
|
-
this.appVersion = appVersion;
|
|
52
|
-
this.libVersion = libVersion;
|
|
53
|
-
this.publicEncryptionKey = publicEncryptionKey;
|
|
54
|
-
}
|
|
55
|
-
AvoNetworkCallsHandler.prototype.callInspectorWithBatchBody = function (inEvents, onCompleted) {
|
|
56
|
-
var _this = this;
|
|
57
|
-
if (this.sending) {
|
|
58
|
-
onCompleted("Batch sending cancelled because another batch sending is in progress. Your events will be sent with next batch.");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
var events = inEvents.filter(function (x) { return x != null; });
|
|
62
|
-
if (events.length === 0) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (Math.random() > this.samplingRate) {
|
|
66
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
67
|
-
console.log("Avo Inspector: last event schema dropped due to sampling rate.");
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
72
|
-
console.log("Avo Inspector: events", events);
|
|
73
|
-
events.forEach(function (event) {
|
|
74
|
-
if (event.type === "event") {
|
|
75
|
-
var schemaEvent = event;
|
|
76
|
-
console.log("Avo Inspector: sending event " + schemaEvent.eventName + " with schema " + JSON.stringify(schemaEvent.eventProperties));
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
this.sending = true;
|
|
81
|
-
var xmlhttp = new XMLHttpRequest();
|
|
82
|
-
xmlhttp.open("POST", AvoNetworkCallsHandler.trackingEndpoint, true);
|
|
83
|
-
xmlhttp.setRequestHeader("Content-Type", "application/json");
|
|
84
|
-
xmlhttp.setRequestHeader("Accept", "application/json");
|
|
85
|
-
xmlhttp.timeout = 10000;
|
|
86
|
-
xmlhttp.onload = function () {
|
|
87
|
-
_this.sending = false;
|
|
88
|
-
if (xmlhttp.status != 200) {
|
|
89
|
-
onCompleted("Error ".concat(xmlhttp.status, ": ").concat(xmlhttp.statusText));
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
try {
|
|
93
|
-
var samplingRate = JSON.parse(xmlhttp.response).samplingRate;
|
|
94
|
-
if (samplingRate !== undefined) {
|
|
95
|
-
_this.samplingRate = samplingRate;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (_) {
|
|
99
|
-
// Ignore malformed response — sampling rate stays unchanged
|
|
100
|
-
}
|
|
101
|
-
onCompleted(null);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
xmlhttp.onerror = function () {
|
|
105
|
-
_this.sending = false;
|
|
106
|
-
onCompleted("Request failed");
|
|
107
|
-
};
|
|
108
|
-
xmlhttp.ontimeout = function () {
|
|
109
|
-
_this.sending = false;
|
|
110
|
-
onCompleted("Request timed out");
|
|
111
|
-
};
|
|
112
|
-
xmlhttp.send(JSON.stringify(events));
|
|
113
|
-
};
|
|
114
|
-
AvoNetworkCallsHandler.prototype.bodyForEventSchemaCall = function (eventName, eventProperties, eventId, eventHash, eventProps, metadata) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var anonymousId, eventSchemaBody;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
switch (_a.label) {
|
|
119
|
-
case 0: return [4 /*yield*/, AvoStreamId_1.AvoStreamId.initialize()];
|
|
120
|
-
case 1:
|
|
121
|
-
anonymousId = _a.sent();
|
|
122
|
-
eventSchemaBody = this.createBaseCallBody(anonymousId);
|
|
123
|
-
eventSchemaBody.type = "event";
|
|
124
|
-
eventSchemaBody.eventName = eventName;
|
|
125
|
-
// Encrypt property values when encryption is enabled
|
|
126
|
-
if ((0, AvoEncryption_1.shouldEncrypt)(this.envName, this.publicEncryptionKey) &&
|
|
127
|
-
eventProps) {
|
|
128
|
-
eventSchemaBody.eventProperties = (0, AvoEncryption_1.encryptEventProperties)(eventProperties, eventProps, this.publicEncryptionKey);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
eventSchemaBody.eventProperties = eventProperties;
|
|
132
|
-
}
|
|
133
|
-
if (eventId != null) {
|
|
134
|
-
eventSchemaBody.avoFunction = true;
|
|
135
|
-
eventSchemaBody.eventId = eventId;
|
|
136
|
-
eventSchemaBody.eventHash = eventHash;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
eventSchemaBody.avoFunction = false;
|
|
140
|
-
eventSchemaBody.eventId = null;
|
|
141
|
-
eventSchemaBody.eventHash = null;
|
|
142
|
-
}
|
|
143
|
-
// Add streamId and event spec metadata for validated events
|
|
144
|
-
if (metadata) {
|
|
145
|
-
eventSchemaBody.streamId = anonymousId;
|
|
146
|
-
eventSchemaBody.eventSpecMetadata = {};
|
|
147
|
-
if (metadata.schemaId) {
|
|
148
|
-
eventSchemaBody.eventSpecMetadata.schemaId = metadata.schemaId;
|
|
149
|
-
}
|
|
150
|
-
if (metadata.branchId) {
|
|
151
|
-
eventSchemaBody.eventSpecMetadata.branchId = metadata.branchId;
|
|
152
|
-
}
|
|
153
|
-
if (metadata.latestActionId) {
|
|
154
|
-
eventSchemaBody.eventSpecMetadata.latestActionId = metadata.latestActionId;
|
|
155
|
-
}
|
|
156
|
-
if (metadata.sourceId) {
|
|
157
|
-
eventSchemaBody.eventSpecMetadata.sourceId = metadata.sourceId;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return [2 /*return*/, eventSchemaBody];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Sends a validated event immediately, bypassing the batcher.
|
|
167
|
-
* Matches Android SDK's reportValidatedEvent behavior.
|
|
168
|
-
*/
|
|
169
|
-
AvoNetworkCallsHandler.prototype.reportValidatedEvent = function (eventBody) {
|
|
170
|
-
if (Math.random() > this.samplingRate) {
|
|
171
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
172
|
-
console.log("Avo Inspector: validated event dropped due to sampling rate.");
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
177
|
-
console.log("Avo Inspector: sending validated event " +
|
|
178
|
-
eventBody.eventName +
|
|
179
|
-
" with schema " +
|
|
180
|
-
JSON.stringify(eventBody.eventProperties));
|
|
181
|
-
}
|
|
182
|
-
var xmlhttp = new XMLHttpRequest();
|
|
183
|
-
xmlhttp.open("POST", AvoNetworkCallsHandler.trackingEndpoint, true);
|
|
184
|
-
xmlhttp.setRequestHeader("Content-Type", "application/json");
|
|
185
|
-
xmlhttp.setRequestHeader("Accept", "application/json");
|
|
186
|
-
xmlhttp.timeout = 10000;
|
|
187
|
-
xmlhttp.onload = function () {
|
|
188
|
-
if (xmlhttp.status !== 200 && AvoInspector_1.AvoInspector.shouldLog) {
|
|
189
|
-
console.warn("Avo Inspector: validated event response status ".concat(xmlhttp.status));
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
xmlhttp.onerror = function () {
|
|
193
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
194
|
-
console.warn("Avo Inspector: failed to send validated event");
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
xmlhttp.ontimeout = function () {
|
|
198
|
-
if (AvoInspector_1.AvoInspector.shouldLog) {
|
|
199
|
-
console.warn("Avo Inspector: validated event report timed out");
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
xmlhttp.send(JSON.stringify([eventBody]));
|
|
203
|
-
};
|
|
204
|
-
AvoNetworkCallsHandler.prototype.createBaseCallBody = function (anonymousId) {
|
|
205
|
-
var body = {
|
|
206
|
-
apiKey: this.apiKey,
|
|
207
|
-
appName: this.appName,
|
|
208
|
-
appVersion: this.appVersion,
|
|
209
|
-
libVersion: this.libVersion,
|
|
210
|
-
env: this.envName,
|
|
211
|
-
libPlatform: "react-native",
|
|
212
|
-
messageId: AvoGuid_1.default.newGuid(),
|
|
213
|
-
trackingId: "",
|
|
214
|
-
sessionId: "",
|
|
215
|
-
anonymousId: anonymousId,
|
|
216
|
-
createdAt: new Date().toISOString(),
|
|
217
|
-
samplingRate: this.samplingRate,
|
|
218
|
-
};
|
|
219
|
-
if (this.publicEncryptionKey !== null &&
|
|
220
|
-
this.publicEncryptionKey !== undefined &&
|
|
221
|
-
this.publicEncryptionKey.trim().length > 0) {
|
|
222
|
-
body.publicEncryptionKey = this.publicEncryptionKey;
|
|
223
|
-
}
|
|
224
|
-
return body;
|
|
225
|
-
};
|
|
226
|
-
AvoNetworkCallsHandler.trackingEndpoint = "https://api.avo.app/inspector/v1/track";
|
|
227
|
-
return AvoNetworkCallsHandler;
|
|
228
|
-
}());
|
|
229
|
-
exports.AvoNetworkCallsHandler = AvoNetworkCallsHandler;
|
package/dist/AvoSchemaParser.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AvoSchemaParser = void 0;
|
|
4
|
-
var isArray = function (obj) {
|
|
5
|
-
return Object.prototype.toString.call(obj) === "[object Array]";
|
|
6
|
-
};
|
|
7
|
-
var AvoSchemaParser = /** @class */ (function () {
|
|
8
|
-
function AvoSchemaParser() {
|
|
9
|
-
}
|
|
10
|
-
AvoSchemaParser.extractSchema = function (eventProperties) {
|
|
11
|
-
var _this = this;
|
|
12
|
-
if (eventProperties === null || eventProperties === undefined) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
var mapping = function (object) {
|
|
16
|
-
if (isArray(object)) {
|
|
17
|
-
var list = object.map(function (x) {
|
|
18
|
-
return mapping(x);
|
|
19
|
-
});
|
|
20
|
-
return _this.removeDuplicates(list);
|
|
21
|
-
}
|
|
22
|
-
else if (typeof object === "object") {
|
|
23
|
-
var mappedResult = [];
|
|
24
|
-
for (var key in object) {
|
|
25
|
-
if (object.hasOwnProperty(key)) {
|
|
26
|
-
var val = object[key];
|
|
27
|
-
var mappedEntry = {
|
|
28
|
-
propertyName: key,
|
|
29
|
-
propertyType: _this.getPropValueType(val),
|
|
30
|
-
};
|
|
31
|
-
if (typeof val === "object" && val != null) {
|
|
32
|
-
mappedEntry["children"] = mapping(val);
|
|
33
|
-
}
|
|
34
|
-
mappedResult.push(mappedEntry);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return mappedResult;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return _this.getPropValueType(object);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var mappedEventProps = mapping(eventProperties);
|
|
44
|
-
return mappedEventProps;
|
|
45
|
-
};
|
|
46
|
-
AvoSchemaParser.removeDuplicates = function (array) {
|
|
47
|
-
// XXX TODO fix any types
|
|
48
|
-
var primitives = { boolean: {}, number: {}, string: {} };
|
|
49
|
-
var objects = [];
|
|
50
|
-
return array.filter(function (item) {
|
|
51
|
-
var type = typeof item;
|
|
52
|
-
if (type in primitives) {
|
|
53
|
-
return primitives[type].hasOwnProperty(item)
|
|
54
|
-
? false
|
|
55
|
-
: (primitives[type][item] = true);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return objects.indexOf(item) >= 0 ? false : objects.push(item);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
AvoSchemaParser.getPropValueType = function (propValue) {
|
|
63
|
-
var propType = typeof propValue;
|
|
64
|
-
if (propValue == null) {
|
|
65
|
-
return "null";
|
|
66
|
-
}
|
|
67
|
-
else if (propType === "string") {
|
|
68
|
-
return "string";
|
|
69
|
-
}
|
|
70
|
-
else if (propType === "number" || propType === "bigint") {
|
|
71
|
-
if ((propValue + "").indexOf(".") >= 0) {
|
|
72
|
-
return "float";
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return "int";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (propType === "boolean") {
|
|
79
|
-
return "boolean";
|
|
80
|
-
}
|
|
81
|
-
else if (propType === "object") {
|
|
82
|
-
if (isArray(propValue)) {
|
|
83
|
-
return "list";
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
return "object";
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
return "unknown";
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return AvoSchemaParser;
|
|
94
|
-
}());
|
|
95
|
-
exports.AvoSchemaParser = AvoSchemaParser;
|
package/dist/AvoStreamId.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AvoStreamId = void 0;
|
|
4
|
-
var AvoGuid_1 = require("./AvoGuid");
|
|
5
|
-
var AvoInspector_1 = require("./AvoInspector");
|
|
6
|
-
var AvoStreamId = /** @class */ (function () {
|
|
7
|
-
function AvoStreamId() {
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Returns the persistent anonymous ID (Model A).
|
|
11
|
-
* Generates a UUID once and persists it via AsyncStorage.
|
|
12
|
-
* Never resets based on time.
|
|
13
|
-
* Concurrent calls before cache is populated all return the same UUID.
|
|
14
|
-
*/
|
|
15
|
-
AvoStreamId.initialize = function () {
|
|
16
|
-
// Return cached value immediately if available
|
|
17
|
-
if (AvoStreamId._anonymousId !== null) {
|
|
18
|
-
return Promise.resolve(AvoStreamId._anonymousId);
|
|
19
|
-
}
|
|
20
|
-
// Return the in-flight promise if initialization is already underway
|
|
21
|
-
if (AvoStreamId._initializationPromise !== null) {
|
|
22
|
-
return AvoStreamId._initializationPromise;
|
|
23
|
-
}
|
|
24
|
-
// Guard: if storage isn't initialized yet, fall back to a fresh GUID
|
|
25
|
-
if (!AvoInspector_1.AvoInspector.avoStorage) {
|
|
26
|
-
var fallbackId = AvoGuid_1.default.newGuid();
|
|
27
|
-
AvoStreamId._anonymousId = fallbackId;
|
|
28
|
-
return Promise.resolve(fallbackId);
|
|
29
|
-
}
|
|
30
|
-
// Start initialization and cache the promise to handle concurrent calls
|
|
31
|
-
var storagePromise = AvoInspector_1.AvoInspector.avoStorage.getItemAsync(AvoStreamId.cacheKey);
|
|
32
|
-
var resolvedPromise = storagePromise && typeof storagePromise.then === "function"
|
|
33
|
-
? storagePromise
|
|
34
|
-
: Promise.resolve(null);
|
|
35
|
-
AvoStreamId._initializationPromise = resolvedPromise.then(function (maybeId) {
|
|
36
|
-
if (maybeId !== null && maybeId !== undefined) {
|
|
37
|
-
AvoStreamId._anonymousId = maybeId;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
AvoStreamId._anonymousId = AvoGuid_1.default.newGuid();
|
|
41
|
-
AvoInspector_1.AvoInspector.avoStorage.setItem(AvoStreamId.cacheKey, AvoStreamId._anonymousId);
|
|
42
|
-
}
|
|
43
|
-
return AvoStreamId._anonymousId;
|
|
44
|
-
}).catch(function (error) {
|
|
45
|
-
// Reset so callers can retry on next call
|
|
46
|
-
AvoStreamId._initializationPromise = null;
|
|
47
|
-
// Fall back to a fresh GUID
|
|
48
|
-
var fallbackId = AvoGuid_1.default.newGuid();
|
|
49
|
-
AvoStreamId._anonymousId = fallbackId;
|
|
50
|
-
return fallbackId;
|
|
51
|
-
});
|
|
52
|
-
return AvoStreamId._initializationPromise;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Sets a custom anonymous ID. Persists to storage.
|
|
56
|
-
*/
|
|
57
|
-
AvoStreamId.setAnonymousId = function (id) {
|
|
58
|
-
AvoStreamId._anonymousId = id;
|
|
59
|
-
AvoStreamId._initializationPromise = null;
|
|
60
|
-
if (AvoInspector_1.AvoInspector.avoStorage) {
|
|
61
|
-
AvoInspector_1.AvoInspector.avoStorage.setItem(AvoStreamId.cacheKey, id);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* Clears the cached anonymous ID. The next access will reload from storage.
|
|
66
|
-
*/
|
|
67
|
-
AvoStreamId.clearCache = function () {
|
|
68
|
-
AvoStreamId._anonymousId = null;
|
|
69
|
-
AvoStreamId._initializationPromise = null;
|
|
70
|
-
};
|
|
71
|
-
Object.defineProperty(AvoStreamId, "cacheKey", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return "AvoInspectorAnonymousId";
|
|
74
|
-
},
|
|
75
|
-
enumerable: false,
|
|
76
|
-
configurable: true
|
|
77
|
-
});
|
|
78
|
-
AvoStreamId._anonymousId = null;
|
|
79
|
-
AvoStreamId._initializationPromise = null;
|
|
80
|
-
return AvoStreamId;
|
|
81
|
-
}());
|
|
82
|
-
exports.AvoStreamId = AvoStreamId;
|
package/dist/__mocks__/xhr.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var xhrMock = {
|
|
4
|
-
open: jest.fn(),
|
|
5
|
-
send: jest.fn(),
|
|
6
|
-
setRequestHeader: jest.fn(),
|
|
7
|
-
onload: jest.fn(),
|
|
8
|
-
onerror: jest.fn(),
|
|
9
|
-
ontimeout: jest.fn(),
|
|
10
|
-
status: 200,
|
|
11
|
-
response: "{}",
|
|
12
|
-
};
|
|
13
|
-
window.XMLHttpRequest = jest.fn(function () { return xhrMock; });
|
|
14
|
-
exports.default = xhrMock;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var xhrErrorMock = {
|
|
4
|
-
open: jest.fn(),
|
|
5
|
-
send: jest.fn(),
|
|
6
|
-
setRequestHeader: jest.fn(),
|
|
7
|
-
onload: jest.fn(),
|
|
8
|
-
onerror: jest.fn(),
|
|
9
|
-
ontimeout: jest.fn(),
|
|
10
|
-
status: 400,
|
|
11
|
-
statusText: "Bad Request",
|
|
12
|
-
};
|
|
13
|
-
window.XMLHttpRequest = jest.fn(function () { return xhrErrorMock; });
|
|
14
|
-
exports.default = xhrErrorMock;
|