avo-inspector 2.2.2-alpha → 2.2.2-alpha.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/.claude/settings.local.json +18 -0
- package/README.md +38 -3
- package/bin/avo-inspector.js +78 -26
- package/dist/AvoBatcher.d.ts +3 -12
- package/dist/AvoInspector.d.ts +13 -7
- package/dist/AvoNetworkCallsHandler.d.ts +28 -21
- package/dist/AvoSchemaParser.d.ts +2 -6
- package/dist/AvoStreamId.d.ts +58 -0
- package/dist/eventSpec/AvoEventSpecCache.d.ts +2 -1
- package/dist/eventSpec/AvoEventSpecFetchTypes.d.ts +103 -65
- package/dist/eventSpec/AvoEventSpecFetcher.d.ts +11 -5
- package/dist/eventSpec/EventValidator.d.ts +16 -72
- package/dist/eventSpec/fetcher.d.ts +52 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/browser.js.LICENSE.txt +0 -5
- package/dist-browser/AvoAnonymousId.d.ts +0 -26
- package/dist-browser/AvoBatcher.d.ts +0 -26
- package/dist-browser/AvoDeduplicator.d.ts +0 -20
- package/dist-browser/AvoEncryption.d.ts +0 -33
- package/dist-browser/AvoGuid.d.ts +0 -3
- package/dist-browser/AvoInspector.d.ts +0 -78
- package/dist-browser/AvoInspectorEnv.d.ts +0 -7
- package/dist-browser/AvoNetworkCallsHandler.d.ts +0 -74
- package/dist-browser/AvoSchemaParser.d.ts +0 -20
- package/dist-browser/AvoStorage.d.ts +0 -22
- package/dist-browser/__mocks__/xhr.d.ts +0 -12
- package/dist-browser/__mocks__/xhrError.d.ts +0 -12
- package/dist-browser/__tests__/AnonymousId_test.d.ts +0 -1
- package/dist-browser/__tests__/AvoEncryption_test.d.ts +0 -1
- package/dist-browser/__tests__/AvoInspectorEventSpec_test.d.ts +0 -1
- package/dist-browser/__tests__/AvoInspector_test.d.ts +0 -1
- package/dist-browser/__tests__/BatcherPublic_test.d.ts +0 -1
- package/dist-browser/__tests__/Batcher_test.d.ts +0 -1
- package/dist-browser/__tests__/Deduplicator_test.d.ts +0 -1
- package/dist-browser/__tests__/EncryptedPropertyTracking_test.d.ts +0 -1
- package/dist-browser/__tests__/EventSpecCache_test.d.ts +0 -1
- package/dist-browser/__tests__/EventSpecFetcher_test.d.ts +0 -1
- package/dist-browser/__tests__/EventValidator_test.d.ts +0 -1
- package/dist-browser/__tests__/NetworkCallsHandler_test.d.ts +0 -1
- package/dist-browser/__tests__/Parsing_test.d.ts +0 -1
- package/dist-browser/__tests__/Storage_test.d.ts +0 -1
- package/dist-browser/__tests__/ValidationIntegration_test.d.ts +0 -1
- package/dist-browser/__tests__/constants.d.ts +0 -36
- package/dist-browser/__tests__/helpers/encryptionHelpers.d.ts +0 -13
- package/dist-browser/__tests__/helpers/mockFactories.d.ts +0 -49
- package/dist-browser/eventSpec/AvoEventSpecCache.d.ts +0 -73
- package/dist-browser/eventSpec/AvoEventSpecFetchTypes.d.ts +0 -109
- package/dist-browser/eventSpec/AvoEventSpecFetcher.d.ts +0 -55
- package/dist-browser/eventSpec/EventValidator.d.ts +0 -90
- package/dist-browser/eventSpec/index.d.ts +0 -4
- package/dist-browser/index.d.ts +0 -2
- package/dist-browser/utils.d.ts +0 -3
- package/dist-native/AvoBatcher.d.ts +0 -24
- package/dist-native/AvoBatcher.js +0 -82
- package/dist-native/AvoDeduplicator.d.ts +0 -36
- package/dist-native/AvoDeduplicator.js +0 -142
- package/dist-native/AvoGuid.d.ts +0 -3
- package/dist-native/AvoGuid.js +0 -14
- package/dist-native/AvoInspector.d.ts +0 -52
- package/dist-native/AvoInspector.js +0 -220
- package/dist-native/AvoInspectorEnv.d.ts +0 -7
- package/dist-native/AvoInspectorEnv.js +0 -8
- package/dist-native/AvoInstallationId.d.ts +0 -5
- package/dist-native/AvoInstallationId.js +0 -36
- package/dist-native/AvoNetworkCallsHandler.d.ts +0 -48
- package/dist-native/AvoNetworkCallsHandler.js +0 -142
- package/dist-native/AvoSchemaParser.d.ts +0 -11
- package/dist-native/AvoSchemaParser.js +0 -95
- package/dist-native/AvoSessionTracker.d.ts +0 -15
- package/dist-native/AvoSessionTracker.js +0 -104
- package/dist-native/AvoStorage.d.ts +0 -22
- package/dist-native/AvoStorage.js +0 -336
- package/dist-native/__mocks__/xhr.d.ts +0 -12
- package/dist-native/__mocks__/xhr.js +0 -14
- package/dist-native/__mocks__/xhrError.d.ts +0 -12
- package/dist-native/__mocks__/xhrError.js +0 -14
- package/dist-native/__tests__/AvoInspector.d.ts +0 -1
- package/dist-native/__tests__/AvoInspector.js +0 -207
- package/dist-native/__tests__/Batcher.d.ts +0 -1
- package/dist-native/__tests__/Batcher.js +0 -280
- package/dist-native/__tests__/BatcherPublic.d.ts +0 -1
- package/dist-native/__tests__/BatcherPublic.js +0 -82
- package/dist-native/__tests__/Deduplicator.d.ts +0 -1
- package/dist-native/__tests__/Deduplicator.js +0 -111
- package/dist-native/__tests__/InstallationId.d.ts +0 -1
- package/dist-native/__tests__/InstallationId.js +0 -40
- package/dist-native/__tests__/NetworkCallsHandler.d.ts +0 -1
- package/dist-native/__tests__/NetworkCallsHandler.js +0 -132
- package/dist-native/__tests__/Parsing.d.ts +0 -1
- package/dist-native/__tests__/Parsing.js +0 -115
- package/dist-native/__tests__/Sessions.d.ts +0 -1
- package/dist-native/__tests__/Sessions.js +0 -179
- package/dist-native/__tests__/Storage.d.ts +0 -1
- package/dist-native/__tests__/Storage.js +0 -173
- package/dist-native/__tests__/constants.d.ts +0 -36
- package/dist-native/__tests__/constants.js +0 -47
- package/dist-native/index.d.ts +0 -2
- package/dist-native/index.js +0 -7
- package/dist-native/utils.d.ts +0 -3
- package/dist-native/utils.js +0 -42
package/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AvoAnonymousId manages a persistent anonymous user identifier.
|
|
3
|
-
*
|
|
4
|
-
* The anonymous ID is generated once and stored persistently across sessions.
|
|
5
|
-
* It remains the same until the storage is cleared or the user uninstalls the app.
|
|
6
|
-
*
|
|
7
|
-
* This class is designed to be standalone and reusable across different SDK platforms
|
|
8
|
-
* (Web, Node, React Native). Each platform should provide its own AvoStorage implementation.
|
|
9
|
-
*/
|
|
10
|
-
export declare class AvoAnonymousId {
|
|
11
|
-
private static _anonymousId;
|
|
12
|
-
/**
|
|
13
|
-
* Get the anonymous ID. If it doesn't exist, generates and persists a new one.
|
|
14
|
-
* Returns "unknown" if storage is not initialized.
|
|
15
|
-
*/
|
|
16
|
-
static get anonymousId(): string;
|
|
17
|
-
/**
|
|
18
|
-
* The storage key used to persist the anonymous ID.
|
|
19
|
-
*/
|
|
20
|
-
static get storageKey(): string;
|
|
21
|
-
/**
|
|
22
|
-
* Clear the cached anonymous ID. The next access will reload from storage.
|
|
23
|
-
* This is primarily useful for testing.
|
|
24
|
-
*/
|
|
25
|
-
static clearCache(): void;
|
|
26
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type AvoNetworkCallsHandler } from "./AvoNetworkCallsHandler";
|
|
2
|
-
import type { EventSpecMetadata } from "./eventSpec/AvoEventSpecFetchTypes";
|
|
3
|
-
import type { ValidationIssue } from "./eventSpec/EventValidator";
|
|
4
|
-
export interface AvoBatcherType {
|
|
5
|
-
handleSessionStarted: () => void;
|
|
6
|
-
handleTrackSchema: (eventName: string, schema: Array<{
|
|
7
|
-
propertyName: string;
|
|
8
|
-
propertyType: string;
|
|
9
|
-
children?: any;
|
|
10
|
-
}>, eventId: string | null, eventHash: string | null, variantId?: string | null, eventSpecMetadata?: EventSpecMetadata, validationErrors?: ValidationIssue[]) => void;
|
|
11
|
-
}
|
|
12
|
-
export declare class AvoBatcher implements AvoBatcherType {
|
|
13
|
-
private events;
|
|
14
|
-
private batchFlushAttemptTimestamp;
|
|
15
|
-
private readonly networkCallsHandler;
|
|
16
|
-
constructor(networkCallsHandler: AvoNetworkCallsHandler);
|
|
17
|
-
handleSessionStarted(): void;
|
|
18
|
-
handleTrackSchema(eventName: string, schema: Array<{
|
|
19
|
-
propertyName: string;
|
|
20
|
-
propertyType: string;
|
|
21
|
-
children?: any;
|
|
22
|
-
}>, eventId: string | null, eventHash: string | null, variantId?: string | null, eventSpecMetadata?: EventSpecMetadata, validationErrors?: ValidationIssue[]): void;
|
|
23
|
-
private checkIfBatchNeedsToBeSent;
|
|
24
|
-
private saveEvents;
|
|
25
|
-
static get cacheKey(): string;
|
|
26
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare class AvoDeduplicator {
|
|
2
|
-
avoFunctionsEvents: Record<number, string>;
|
|
3
|
-
manualEvents: Record<number, string>;
|
|
4
|
-
avoFunctionsEventsParams: Record<string, Record<string, any>>;
|
|
5
|
-
manualEventsParams: Record<string, Record<string, any>>;
|
|
6
|
-
shouldRegisterEvent(eventName: string, params: Record<string, any>, fromAvoFunction: boolean): boolean;
|
|
7
|
-
private hasSameEventAs;
|
|
8
|
-
private lookForEventIn;
|
|
9
|
-
hasSeenEventParams(params: Record<string, any>, checkInAvoFunctions: boolean): boolean;
|
|
10
|
-
private lookForEventParamsIn;
|
|
11
|
-
shouldRegisterSchemaFromManually(eventName: string, eventSchema: Array<{
|
|
12
|
-
propertyName: string;
|
|
13
|
-
propertyType: string;
|
|
14
|
-
children?: any;
|
|
15
|
-
}>): boolean;
|
|
16
|
-
private hasSameShapeInAvoFunctionsAs;
|
|
17
|
-
private lookForEventSchemaIn;
|
|
18
|
-
private clearOldEvents;
|
|
19
|
-
private _clearEvents;
|
|
20
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a new ECC key pair for encryption/decryption.
|
|
3
|
-
* Uses secp256k1 curve (P-256 family) which provides 128-bit security.
|
|
4
|
-
*
|
|
5
|
-
* @returns An object containing the private and public keys as hex strings
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateKeyPair(): {
|
|
8
|
-
privateKey: string;
|
|
9
|
-
publicKey: string;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Encrypts a value using ECC public key encryption (ECIES).
|
|
13
|
-
* The encrypted output can only be decrypted by the client using their private key.
|
|
14
|
-
* This ensures that Avo cannot decrypt the values on the backend.
|
|
15
|
-
*
|
|
16
|
-
* ECIES uses hybrid encryption (ECDH + AES-256-GCM) which provides:
|
|
17
|
-
* - No message size limitations
|
|
18
|
-
* - Fast encryption even for large values
|
|
19
|
-
* - Strong authentication via GCM
|
|
20
|
-
*
|
|
21
|
-
* @param value - The value to encrypt (any type - will be JSON stringified)
|
|
22
|
-
* @param publicKey - The ECC public key in hex format provided by the client
|
|
23
|
-
* @returns Base64-encoded encrypted string that can only be decrypted with the private key
|
|
24
|
-
*/
|
|
25
|
-
export declare function encryptValue(value: any, publicKey: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Decrypts a value that was encrypted with encryptValue.
|
|
28
|
-
*
|
|
29
|
-
* @param encryptedValue - The base64-encoded encrypted string
|
|
30
|
-
* @param privateKey - The ECC private key in hex format
|
|
31
|
-
* @returns The original decrypted value (parsed from JSON)
|
|
32
|
-
*/
|
|
33
|
-
export declare function decryptValue(encryptedValue: string, privateKey: string): any;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { type AvoInspectorEnvValueType } from "./AvoInspectorEnv";
|
|
2
|
-
import { AvoBatcher } from "./AvoBatcher";
|
|
3
|
-
import { AvoStorage } from "./AvoStorage";
|
|
4
|
-
import { AvoDeduplicator } from "./AvoDeduplicator";
|
|
5
|
-
export declare class AvoInspector {
|
|
6
|
-
environment: AvoInspectorEnvValueType;
|
|
7
|
-
avoBatcher: AvoBatcher;
|
|
8
|
-
avoDeduplicator: AvoDeduplicator;
|
|
9
|
-
apiKey: string;
|
|
10
|
-
version: string;
|
|
11
|
-
private avoNetworkCallsHandler;
|
|
12
|
-
private publicEncryptionKey?;
|
|
13
|
-
private streamId?;
|
|
14
|
-
private eventSpecCache?;
|
|
15
|
-
private eventSpecFetcher?;
|
|
16
|
-
static avoStorage: AvoStorage;
|
|
17
|
-
private static _batchSize;
|
|
18
|
-
static get batchSize(): number;
|
|
19
|
-
static set batchSize(newSize: number);
|
|
20
|
-
private static _batchFlushSeconds;
|
|
21
|
-
static get batchFlushSeconds(): number;
|
|
22
|
-
private static _shouldLog;
|
|
23
|
-
static get shouldLog(): boolean;
|
|
24
|
-
static set shouldLog(enable: boolean);
|
|
25
|
-
private static _networkTimeout;
|
|
26
|
-
static get networkTimeout(): number;
|
|
27
|
-
static set networkTimeout(timeout: number);
|
|
28
|
-
constructor(options: {
|
|
29
|
-
apiKey: string;
|
|
30
|
-
env: AvoInspectorEnvValueType;
|
|
31
|
-
version: string;
|
|
32
|
-
appName?: string;
|
|
33
|
-
suffix?: string;
|
|
34
|
-
publicEncryptionKey?: string;
|
|
35
|
-
});
|
|
36
|
-
trackSchemaFromEvent(eventName: string, eventProperties: Record<string, any>): Promise<Array<{
|
|
37
|
-
propertyName: string;
|
|
38
|
-
propertyType: string;
|
|
39
|
-
encryptedPropertyValue?: string;
|
|
40
|
-
children?: any;
|
|
41
|
-
}>>;
|
|
42
|
-
private _avoFunctionTrackSchemaFromEvent;
|
|
43
|
-
trackSchema(eventName: string, eventSchema: Array<{
|
|
44
|
-
propertyName: string;
|
|
45
|
-
propertyType: string;
|
|
46
|
-
encryptedPropertyValue?: string;
|
|
47
|
-
children?: any;
|
|
48
|
-
}>): Promise<void>;
|
|
49
|
-
private trackSchemaInternal;
|
|
50
|
-
enableLogging(enable: boolean): void;
|
|
51
|
-
extractSchema(eventProperties: Record<string, any>, shouldLogIfEnabled?: boolean): Array<{
|
|
52
|
-
propertyName: string;
|
|
53
|
-
propertyType: string;
|
|
54
|
-
encryptedPropertyValue?: string;
|
|
55
|
-
children?: any;
|
|
56
|
-
}>;
|
|
57
|
-
setBatchSize(newBatchSize: number): void;
|
|
58
|
-
setBatchFlushSeconds(newBatchFlushSeconds: number): void;
|
|
59
|
-
/**
|
|
60
|
-
* Fetches the event spec if spec fetching is enabled.
|
|
61
|
-
* Used by trackSchema when we don't have raw properties to validate.
|
|
62
|
-
*
|
|
63
|
-
* Note: EventSpec fetching only happens in dev/staging environments.
|
|
64
|
-
*/
|
|
65
|
-
private fetchEventSpecIfNeeded;
|
|
66
|
-
/**
|
|
67
|
-
* Fetches event spec and validates the event against it.
|
|
68
|
-
* Returns ValidationResult if spec is available, null otherwise.
|
|
69
|
-
*
|
|
70
|
-
* Note: EventSpec fetching and validation only happens in dev/staging environments.
|
|
71
|
-
*/
|
|
72
|
-
private fetchAndValidateEvent;
|
|
73
|
-
/**
|
|
74
|
-
* Sends an event immediately with validation data (bypasses batching).
|
|
75
|
-
* Logs validation errors if shouldLog is true.
|
|
76
|
-
*/
|
|
77
|
-
private sendEventWithValidation;
|
|
78
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const AvoInspectorEnv: {
|
|
2
|
-
readonly Prod: "prod";
|
|
3
|
-
readonly Dev: "dev";
|
|
4
|
-
readonly Staging: "staging";
|
|
5
|
-
};
|
|
6
|
-
export type AvoInspectorEnvType = typeof AvoInspectorEnv;
|
|
7
|
-
export type AvoInspectorEnvValueType = AvoInspectorEnvType[keyof AvoInspectorEnvType];
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { EventSpecMetadata } from "./eventSpec/AvoEventSpecFetchTypes";
|
|
2
|
-
import type { ValidationIssue } from "./eventSpec/EventValidator";
|
|
3
|
-
export interface BaseBody {
|
|
4
|
-
apiKey: string;
|
|
5
|
-
appName: string;
|
|
6
|
-
appVersion: string;
|
|
7
|
-
libVersion: string;
|
|
8
|
-
env: string;
|
|
9
|
-
libPlatform: "web";
|
|
10
|
-
messageId: string;
|
|
11
|
-
trackingId: string;
|
|
12
|
-
createdAt: string;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
anonymousId: string;
|
|
15
|
-
samplingRate: number;
|
|
16
|
-
}
|
|
17
|
-
export interface SessionStartedBody extends BaseBody {
|
|
18
|
-
type: "sessionStarted";
|
|
19
|
-
}
|
|
20
|
-
export interface EventSchemaBody extends BaseBody {
|
|
21
|
-
type: "event";
|
|
22
|
-
/** ID of the matched base event */
|
|
23
|
-
eventId: string | null;
|
|
24
|
-
/** ID of the matched variant (if any) */
|
|
25
|
-
variantId?: string | null;
|
|
26
|
-
/** Name seen in code */
|
|
27
|
-
eventName?: string;
|
|
28
|
-
/** Event spec metadata from EventSpecResponse */
|
|
29
|
-
eventSpecMetadata?: EventSpecMetadata;
|
|
30
|
-
/** Array of validation issues found during validation */
|
|
31
|
-
validationErrors?: ValidationIssue[];
|
|
32
|
-
eventProperties: Array<{
|
|
33
|
-
propertyName: string;
|
|
34
|
-
propertyType: string;
|
|
35
|
-
encryptedPropertyValue?: string;
|
|
36
|
-
children?: any;
|
|
37
|
-
}>;
|
|
38
|
-
avoFunction: boolean;
|
|
39
|
-
eventHash: string | null;
|
|
40
|
-
}
|
|
41
|
-
export declare class AvoNetworkCallsHandler {
|
|
42
|
-
private readonly apiKey;
|
|
43
|
-
private readonly envName;
|
|
44
|
-
private readonly appName;
|
|
45
|
-
private readonly appVersion;
|
|
46
|
-
private readonly libVersion;
|
|
47
|
-
private samplingRate;
|
|
48
|
-
private sending;
|
|
49
|
-
private static readonly trackingEndpoint;
|
|
50
|
-
constructor(apiKey: string, envName: string, appName: string, appVersion: string, libVersion: string);
|
|
51
|
-
callInspectorWithBatchBody(inEvents: Array<SessionStartedBody | EventSchemaBody>, onCompleted: (error: Error | null) => any): void;
|
|
52
|
-
private fixAnonymousIds;
|
|
53
|
-
bodyForSessionStartedCall(): SessionStartedBody;
|
|
54
|
-
bodyForEventSchemaCall(eventName: string, eventProperties: Array<{
|
|
55
|
-
propertyName: string;
|
|
56
|
-
propertyType: string;
|
|
57
|
-
children?: any;
|
|
58
|
-
}>, eventId: string | null, eventHash: string | null, variantId?: string | null, eventSpecMetadata?: EventSpecMetadata, validationErrors?: ValidationIssue[]): EventSchemaBody;
|
|
59
|
-
private createBaseCallBody;
|
|
60
|
-
/**
|
|
61
|
-
* Calls Inspector API immediately with a single event (bypasses batching).
|
|
62
|
-
* Used when event spec validation is available.
|
|
63
|
-
* Note: Does not drop due to sampling - validated events are always sent.
|
|
64
|
-
*/
|
|
65
|
-
callInspectorImmediately(eventBody: EventSchemaBody, onCompleted: (error: Error | null) => any): void;
|
|
66
|
-
/**
|
|
67
|
-
* Check if event should be dropped based on sampling rate.
|
|
68
|
-
*/
|
|
69
|
-
private shouldDropBySampling;
|
|
70
|
-
/**
|
|
71
|
-
* Core Inspector API call logic shared by batch and immediate calls.
|
|
72
|
-
*/
|
|
73
|
-
private callInspectorApi;
|
|
74
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare class AvoSchemaParser {
|
|
2
|
-
/**
|
|
3
|
-
* Returns true only if we have a valid encryption key and can send encrypted values.
|
|
4
|
-
* If no key is present, returns false and no property values will be sent.
|
|
5
|
-
*/
|
|
6
|
-
private static canSendEncryptedValues;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the encrypted property value if encryption is enabled, otherwise undefined.
|
|
9
|
-
* Never returns unencrypted values - only encrypted or nothing.
|
|
10
|
-
*/
|
|
11
|
-
private static getEncryptedPropertyValueIfEnabled;
|
|
12
|
-
static extractSchema(eventProperties: Record<string, any>, publicEncryptionKey?: string, env?: string): Array<{
|
|
13
|
-
propertyName: string;
|
|
14
|
-
propertyType: string;
|
|
15
|
-
encryptedPropertyValue?: string;
|
|
16
|
-
children?: any;
|
|
17
|
-
}>;
|
|
18
|
-
private static removeDuplicates;
|
|
19
|
-
private static getPropValueType;
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
declare abstract class PlatformAvoStorage {
|
|
2
|
-
abstract init(shouldLog: boolean, suffix: string): void;
|
|
3
|
-
abstract getItemAsync<T>(key: string): Promise<T | null>;
|
|
4
|
-
abstract getItem<T>(key: string): T | null;
|
|
5
|
-
abstract setItem<T>(key: string, value: T): void;
|
|
6
|
-
abstract removeItem(key: string): void;
|
|
7
|
-
abstract runAfterInit(func: () => void): void;
|
|
8
|
-
abstract isInitialized(): boolean;
|
|
9
|
-
parseJson<T>(maybeItem: string | null | undefined): T | null;
|
|
10
|
-
}
|
|
11
|
-
export declare class AvoStorage {
|
|
12
|
-
Platform: string | null;
|
|
13
|
-
storageImpl: PlatformAvoStorage;
|
|
14
|
-
constructor(shouldLog: boolean, suffix?: string);
|
|
15
|
-
isInitialized(): boolean;
|
|
16
|
-
getItemAsync<T>(key: string): Promise<T | null>;
|
|
17
|
-
getItem<T>(key: string): T | null;
|
|
18
|
-
setItem<T>(key: string, value: T): void;
|
|
19
|
-
removeItem(key: string): void;
|
|
20
|
-
runAfterInit(func: () => void): void;
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
declare const xhrMock: {
|
|
3
|
-
open: jest.Mock<any, any, any>;
|
|
4
|
-
send: jest.Mock<any, any, any>;
|
|
5
|
-
setRequestHeader: jest.Mock<any, any, any>;
|
|
6
|
-
onload: jest.Mock<any, any, any>;
|
|
7
|
-
onerror: jest.Mock<any, any, any>;
|
|
8
|
-
ontimeout: jest.Mock<any, any, any>;
|
|
9
|
-
status: number;
|
|
10
|
-
response: string;
|
|
11
|
-
};
|
|
12
|
-
export default xhrMock;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
declare const xhrErrorMock: {
|
|
3
|
-
open: jest.Mock<any, any, any>;
|
|
4
|
-
send: jest.Mock<any, any, any>;
|
|
5
|
-
setRequestHeader: jest.Mock<any, any, any>;
|
|
6
|
-
onload: jest.Mock<any, any, any>;
|
|
7
|
-
onerror: jest.Mock<any, any, any>;
|
|
8
|
-
ontimeout: jest.Mock<any, any, any>;
|
|
9
|
-
status: number;
|
|
10
|
-
statusText: string;
|
|
11
|
-
};
|
|
12
|
-
export default xhrErrorMock;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
declare const defaultOptions: {
|
|
2
|
-
apiKey: string;
|
|
3
|
-
env: "prod";
|
|
4
|
-
version: string;
|
|
5
|
-
shouldLog: boolean;
|
|
6
|
-
};
|
|
7
|
-
declare const error: {
|
|
8
|
-
API_KEY: string;
|
|
9
|
-
VERSION: string;
|
|
10
|
-
};
|
|
11
|
-
declare const mockedReturns: {
|
|
12
|
-
INSTALLATION_ID: string;
|
|
13
|
-
GUID: string;
|
|
14
|
-
SESSION_ID: string;
|
|
15
|
-
};
|
|
16
|
-
declare const networkCallType: {
|
|
17
|
-
EVENT: string;
|
|
18
|
-
SESSION_STARTED: string;
|
|
19
|
-
};
|
|
20
|
-
declare const requestMsg: {
|
|
21
|
-
ERROR: string;
|
|
22
|
-
TIMEOUT: string;
|
|
23
|
-
};
|
|
24
|
-
declare const trackingEndpoint = "https://api.avo.app/inspector/v1/track";
|
|
25
|
-
declare const sessionTimeMs: number;
|
|
26
|
-
declare const type: {
|
|
27
|
-
STRING: string;
|
|
28
|
-
INT: string;
|
|
29
|
-
OBJECT: string;
|
|
30
|
-
FLOAT: string;
|
|
31
|
-
LIST: string;
|
|
32
|
-
BOOL: string;
|
|
33
|
-
NULL: string;
|
|
34
|
-
UNKNOWN: string;
|
|
35
|
-
};
|
|
36
|
-
export { defaultOptions, error, mockedReturns, networkCallType, requestMsg, sessionTimeMs, type, trackingEndpoint };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test helper: Generates a new ECC key pair for testing encryption.
|
|
3
|
-
* This is also available in the CLI tool (bin/avo-inspector.js) for production use.
|
|
4
|
-
*/
|
|
5
|
-
export declare function generateKeyPair(): {
|
|
6
|
-
publicKey: string;
|
|
7
|
-
privateKey: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Test helper: Decrypts a value that was encrypted using encryptValue.
|
|
11
|
-
* Used for testing purposes only.
|
|
12
|
-
*/
|
|
13
|
-
export declare function decryptValue(encryptedValue: string, privateKey: string): any;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared mock factories for testing event spec related functionality.
|
|
3
|
-
* These helpers reduce duplication across test files.
|
|
4
|
-
*/
|
|
5
|
-
import type { PropertySpec, PropertyTypeSpec, VariantSpec, EventSpec, EventSpecResponse, EventSpecMetadata } from "../../eventSpec/AvoEventSpecFetchTypes";
|
|
6
|
-
/**
|
|
7
|
-
* Creates a PropertyTypeSpec with defaults.
|
|
8
|
-
*/
|
|
9
|
-
export declare function createPropertyTypeSpec(overrides?: Partial<PropertyTypeSpec>): PropertyTypeSpec;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a PropertySpec with sensible defaults.
|
|
12
|
-
*/
|
|
13
|
-
export declare function createPropertySpec(overrides?: Partial<PropertySpec>): PropertySpec;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a required string property.
|
|
16
|
-
*/
|
|
17
|
-
export declare function createRequiredStringProperty(id: string, extraOverrides?: Partial<PropertySpec>): PropertySpec;
|
|
18
|
-
/**
|
|
19
|
-
* Creates an optional number property.
|
|
20
|
-
*/
|
|
21
|
-
export declare function createNumberProperty(id: string, extraOverrides?: Partial<PropertySpec>): PropertySpec;
|
|
22
|
-
/**
|
|
23
|
-
* Creates an enum property with allowed values.
|
|
24
|
-
*/
|
|
25
|
-
export declare function createEnumProperty(id: string, allowedValues: string[], extraOverrides?: Partial<PropertySpec>): PropertySpec;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a VariantSpec with defaults.
|
|
28
|
-
*/
|
|
29
|
-
export declare function createVariantSpec(overrides?: Partial<VariantSpec>): VariantSpec;
|
|
30
|
-
/**
|
|
31
|
-
* Creates an EventSpec with defaults.
|
|
32
|
-
*/
|
|
33
|
-
export declare function createEventSpec(overrides?: Partial<EventSpec>): EventSpec;
|
|
34
|
-
/**
|
|
35
|
-
* Creates an EventSpec with common properties for testing.
|
|
36
|
-
*/
|
|
37
|
-
export declare function createUserLoginEventSpec(): EventSpec;
|
|
38
|
-
/**
|
|
39
|
-
* Creates EventSpecMetadata with defaults.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createEventSpecMetadata(overrides?: Partial<EventSpecMetadata>): EventSpecMetadata;
|
|
42
|
-
/**
|
|
43
|
-
* Creates an EventSpecResponse with defaults.
|
|
44
|
-
*/
|
|
45
|
-
export declare function createEventSpecResponse(events?: EventSpec[], metadataOverrides?: Partial<EventSpecMetadata>): EventSpecResponse;
|
|
46
|
-
/**
|
|
47
|
-
* Creates a simple EventSpecResponse with one event for basic testing.
|
|
48
|
-
*/
|
|
49
|
-
export declare function createSimpleEventSpecResponse(eventName?: string): EventSpecResponse;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { EventSpecResponse } from "./AvoEventSpecFetchTypes";
|
|
2
|
-
/**
|
|
3
|
-
* EventSpecCache implements a dual-condition cache with LRU eviction.
|
|
4
|
-
*
|
|
5
|
-
* Cache Policy:
|
|
6
|
-
* - Entries expire after 5 minutes OR 50 cache hits, whichever comes first
|
|
7
|
-
* - When 50 cache hits occur globally, the oldest cached entry is evicted
|
|
8
|
-
* - Each cache entry tracks: spec, timestamp, and hit count
|
|
9
|
-
*
|
|
10
|
-
* Cache Key Format: ${apiKey}:${streamId}:${eventName}
|
|
11
|
-
*
|
|
12
|
-
* Note: Event count only increments on cache hits, not on every tracked event.
|
|
13
|
-
* This ensures the cache evicts based on actual usage, not overall tracking volume.
|
|
14
|
-
*/
|
|
15
|
-
export declare class EventSpecCache {
|
|
16
|
-
/** Cache storage: key -> CacheEntry */
|
|
17
|
-
private cache;
|
|
18
|
-
/** Time-to-live in milliseconds (5 minutes) */
|
|
19
|
-
private readonly TTL_MS;
|
|
20
|
-
/** Maximum cache hit count before rotating cache (50 hits) */
|
|
21
|
-
private readonly MAX_EVENT_COUNT;
|
|
22
|
-
/** Global cache hit counter to track when to rotate cache */
|
|
23
|
-
private globalEventCount;
|
|
24
|
-
/** Whether to log debug information */
|
|
25
|
-
private readonly shouldLog;
|
|
26
|
-
constructor(shouldLog?: boolean);
|
|
27
|
-
/**
|
|
28
|
-
* Generates a cache key from the provided parameters.
|
|
29
|
-
*/
|
|
30
|
-
private generateKey;
|
|
31
|
-
/**
|
|
32
|
-
* Retrieves an event spec response from the cache if it exists and is valid.
|
|
33
|
-
* Returns null if the entry is missing, expired, or has exceeded event count.
|
|
34
|
-
*
|
|
35
|
-
* On cache hit, increments the hit count for this entry and the global counter.
|
|
36
|
-
*/
|
|
37
|
-
get(apiKey: string, streamId: string, eventName: string): EventSpecResponse | null;
|
|
38
|
-
/**
|
|
39
|
-
* Stores an event spec response in the cache.
|
|
40
|
-
*/
|
|
41
|
-
set(apiKey: string, streamId: string, eventName: string, spec: EventSpecResponse): void;
|
|
42
|
-
/**
|
|
43
|
-
* Determines if a cache entry should be evicted based on:
|
|
44
|
-
* - Age (older than 5 minutes)
|
|
45
|
-
* - Hit count (50 or more cache hits)
|
|
46
|
-
*/
|
|
47
|
-
private shouldEvict;
|
|
48
|
-
/**
|
|
49
|
-
* Evicts the oldest cache entry based on timestamp.
|
|
50
|
-
* This implements the LRU (Least Recently Used) eviction policy.
|
|
51
|
-
*/
|
|
52
|
-
private evictOldest;
|
|
53
|
-
/**
|
|
54
|
-
* Clears all cached entries. Useful for testing.
|
|
55
|
-
*/
|
|
56
|
-
clear(): void;
|
|
57
|
-
/**
|
|
58
|
-
* Returns the current size of the cache.
|
|
59
|
-
*/
|
|
60
|
-
size(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Returns cache statistics for debugging.
|
|
63
|
-
*/
|
|
64
|
-
getStats(): {
|
|
65
|
-
size: number;
|
|
66
|
-
globalEventCount: number;
|
|
67
|
-
entries: Array<{
|
|
68
|
-
key: string;
|
|
69
|
-
age: number;
|
|
70
|
-
eventCount: number;
|
|
71
|
-
}>;
|
|
72
|
-
};
|
|
73
|
-
}
|