@tracelog/lib 0.0.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/LICENSE +21 -0
- package/README.md +217 -0
- package/dist/browser/tracelog.js +4040 -0
- package/dist/browser/web-vitals-CCnqwnC8.mjs +198 -0
- package/dist/cjs/api.d.ts +46 -0
- package/dist/cjs/api.js +224 -0
- package/dist/cjs/app.constants.d.ts +1 -0
- package/dist/cjs/app.constants.js +5 -0
- package/dist/cjs/app.d.ts +59 -0
- package/dist/cjs/app.js +272 -0
- package/dist/cjs/app.types.d.ts +6 -0
- package/dist/cjs/app.types.js +22 -0
- package/dist/cjs/constants/api.constants.d.ts +4 -0
- package/dist/cjs/constants/api.constants.js +18 -0
- package/dist/cjs/constants/browser.constants.d.ts +3 -0
- package/dist/cjs/constants/browser.constants.js +41 -0
- package/dist/cjs/constants/index.d.ts +8 -0
- package/dist/cjs/constants/index.js +24 -0
- package/dist/cjs/constants/initialization.constants.d.ts +40 -0
- package/dist/cjs/constants/initialization.constants.js +48 -0
- package/dist/cjs/constants/limits.constants.d.ts +25 -0
- package/dist/cjs/constants/limits.constants.js +40 -0
- package/dist/cjs/constants/security.constants.d.ts +1 -0
- package/dist/cjs/constants/security.constants.js +12 -0
- package/dist/cjs/constants/storage.constants.d.ts +9 -0
- package/dist/cjs/constants/storage.constants.js +22 -0
- package/dist/cjs/constants/timing.constants.d.ts +22 -0
- package/dist/cjs/constants/timing.constants.js +34 -0
- package/dist/cjs/constants/validation.constants.d.ts +13 -0
- package/dist/cjs/constants/validation.constants.js +31 -0
- package/dist/cjs/handlers/click.handler.d.ts +17 -0
- package/dist/cjs/handlers/click.handler.js +199 -0
- package/dist/cjs/handlers/error.handler.d.ts +15 -0
- package/dist/cjs/handlers/error.handler.js +97 -0
- package/dist/cjs/handlers/network.handler.d.ts +16 -0
- package/dist/cjs/handlers/network.handler.js +136 -0
- package/dist/cjs/handlers/page-view.handler.d.ts +15 -0
- package/dist/cjs/handlers/page-view.handler.js +83 -0
- package/dist/cjs/handlers/performance.handler.d.ts +19 -0
- package/dist/cjs/handlers/performance.handler.js +255 -0
- package/dist/cjs/handlers/scroll.handler.d.ts +16 -0
- package/dist/cjs/handlers/scroll.handler.js +138 -0
- package/dist/cjs/handlers/session.handler.d.ts +29 -0
- package/dist/cjs/handlers/session.handler.js +357 -0
- package/dist/cjs/integrations/google-analytics.integration.d.ts +18 -0
- package/dist/cjs/integrations/google-analytics.integration.js +159 -0
- package/dist/cjs/listeners/activity-listener-manager.d.ts +8 -0
- package/dist/cjs/listeners/activity-listener-manager.js +32 -0
- package/dist/cjs/listeners/index.d.ts +6 -0
- package/dist/cjs/listeners/index.js +14 -0
- package/dist/cjs/listeners/input-listener-managers.d.ts +15 -0
- package/dist/cjs/listeners/input-listener-managers.js +58 -0
- package/dist/cjs/listeners/listeners.types.d.ts +4 -0
- package/dist/cjs/listeners/listeners.types.js +2 -0
- package/dist/cjs/listeners/touch-listener-manager.d.ts +10 -0
- package/dist/cjs/listeners/touch-listener-manager.js +56 -0
- package/dist/cjs/listeners/unload-listener-manager.d.ts +8 -0
- package/dist/cjs/listeners/unload-listener-manager.js +30 -0
- package/dist/cjs/listeners/visibility-listener-manager.d.ts +12 -0
- package/dist/cjs/listeners/visibility-listener-manager.js +83 -0
- package/dist/cjs/managers/api.manager.d.ts +3 -0
- package/dist/cjs/managers/api.manager.js +14 -0
- package/dist/cjs/managers/config.manager.d.ts +7 -0
- package/dist/cjs/managers/config.manager.js +94 -0
- package/dist/cjs/managers/cross-tab-session.manager.d.ts +170 -0
- package/dist/cjs/managers/cross-tab-session.manager.js +730 -0
- package/dist/cjs/managers/event.manager.d.ts +61 -0
- package/dist/cjs/managers/event.manager.js +508 -0
- package/dist/cjs/managers/sampling.manager.d.ts +8 -0
- package/dist/cjs/managers/sampling.manager.js +53 -0
- package/dist/cjs/managers/sender.manager.d.ts +46 -0
- package/dist/cjs/managers/sender.manager.js +304 -0
- package/dist/cjs/managers/session-recovery.manager.d.ts +65 -0
- package/dist/cjs/managers/session-recovery.manager.js +237 -0
- package/dist/cjs/managers/session.manager.d.ts +72 -0
- package/dist/cjs/managers/session.manager.js +587 -0
- package/dist/cjs/managers/state.manager.d.ts +5 -0
- package/dist/cjs/managers/state.manager.js +23 -0
- package/dist/cjs/managers/storage.manager.d.ts +10 -0
- package/dist/cjs/managers/storage.manager.js +81 -0
- package/dist/cjs/managers/tags.manager.d.ts +12 -0
- package/dist/cjs/managers/tags.manager.js +289 -0
- package/dist/cjs/managers/user.manager.d.ts +7 -0
- package/dist/cjs/managers/user.manager.js +22 -0
- package/dist/cjs/public-api.d.ts +1 -0
- package/dist/cjs/public-api.js +37 -0
- package/dist/cjs/types/api.types.d.ts +21 -0
- package/dist/cjs/types/api.types.js +25 -0
- package/dist/cjs/types/common.types.d.ts +1 -0
- package/dist/cjs/types/common.types.js +2 -0
- package/dist/cjs/types/config.types.d.ts +104 -0
- package/dist/cjs/types/config.types.js +2 -0
- package/dist/cjs/types/device.types.d.ts +6 -0
- package/dist/cjs/types/device.types.js +10 -0
- package/dist/cjs/types/event.types.d.ts +104 -0
- package/dist/cjs/types/event.types.js +25 -0
- package/dist/cjs/types/index.d.ts +13 -0
- package/dist/cjs/types/index.js +29 -0
- package/dist/cjs/types/log.types.d.ts +4 -0
- package/dist/cjs/types/log.types.js +2 -0
- package/dist/cjs/types/mode.types.d.ts +7 -0
- package/dist/cjs/types/mode.types.js +11 -0
- package/dist/cjs/types/queue.types.d.ts +23 -0
- package/dist/cjs/types/queue.types.js +2 -0
- package/dist/cjs/types/session.types.d.ts +65 -0
- package/dist/cjs/types/session.types.js +2 -0
- package/dist/cjs/types/state.types.d.ts +12 -0
- package/dist/cjs/types/state.types.js +2 -0
- package/dist/cjs/types/tag.types.d.ts +43 -0
- package/dist/cjs/types/tag.types.js +31 -0
- package/dist/cjs/types/validation-error.types.d.ts +42 -0
- package/dist/cjs/types/validation-error.types.js +68 -0
- package/dist/cjs/types/web-vitals.types.d.ts +6 -0
- package/dist/cjs/types/web-vitals.types.js +2 -0
- package/dist/cjs/types/window.types.d.ts +17 -0
- package/dist/cjs/types/window.types.js +2 -0
- package/dist/cjs/utils/browser/device-detector.utils.d.ts +6 -0
- package/dist/cjs/utils/browser/device-detector.utils.js +71 -0
- package/dist/cjs/utils/browser/index.d.ts +2 -0
- package/dist/cjs/utils/browser/index.js +18 -0
- package/dist/cjs/utils/browser/utm-params.utils.d.ts +6 -0
- package/dist/cjs/utils/browser/utm-params.utils.js +37 -0
- package/dist/cjs/utils/data/index.d.ts +1 -0
- package/dist/cjs/utils/data/index.js +17 -0
- package/dist/cjs/utils/data/uuid.utils.d.ts +5 -0
- package/dist/cjs/utils/data/uuid.utils.js +18 -0
- package/dist/cjs/utils/index.d.ts +6 -0
- package/dist/cjs/utils/index.js +22 -0
- package/dist/cjs/utils/logging/debug-logger.utils.d.ts +56 -0
- package/dist/cjs/utils/logging/debug-logger.utils.js +139 -0
- package/dist/cjs/utils/logging/index.d.ts +1 -0
- package/dist/cjs/utils/logging/index.js +5 -0
- package/dist/cjs/utils/network/index.d.ts +1 -0
- package/dist/cjs/utils/network/index.js +17 -0
- package/dist/cjs/utils/network/url.utils.d.ts +20 -0
- package/dist/cjs/utils/network/url.utils.js +172 -0
- package/dist/cjs/utils/security/index.d.ts +1 -0
- package/dist/cjs/utils/security/index.js +17 -0
- package/dist/cjs/utils/security/sanitize.utils.d.ts +32 -0
- package/dist/cjs/utils/security/sanitize.utils.js +319 -0
- package/dist/cjs/utils/validations/config-validations.utils.d.ts +42 -0
- package/dist/cjs/utils/validations/config-validations.utils.js +297 -0
- package/dist/cjs/utils/validations/event-validations.utils.d.ts +12 -0
- package/dist/cjs/utils/validations/event-validations.utils.js +30 -0
- package/dist/cjs/utils/validations/index.d.ts +5 -0
- package/dist/cjs/utils/validations/index.js +21 -0
- package/dist/cjs/utils/validations/metadata-validations.utils.d.ts +22 -0
- package/dist/cjs/utils/validations/metadata-validations.utils.js +115 -0
- package/dist/cjs/utils/validations/type-guards.utils.d.ts +6 -0
- package/dist/cjs/utils/validations/type-guards.utils.js +31 -0
- package/dist/cjs/utils/validations/url-validations.utils.d.ts +15 -0
- package/dist/cjs/utils/validations/url-validations.utils.js +47 -0
- package/dist/esm/api.d.ts +46 -0
- package/dist/esm/api.js +183 -0
- package/dist/esm/app.constants.d.ts +1 -0
- package/dist/esm/app.constants.js +1 -0
- package/dist/esm/app.d.ts +59 -0
- package/dist/esm/app.js +268 -0
- package/dist/esm/app.types.d.ts +6 -0
- package/dist/esm/app.types.js +6 -0
- package/dist/esm/constants/api.constants.d.ts +4 -0
- package/dist/esm/constants/api.constants.js +14 -0
- package/dist/esm/constants/browser.constants.d.ts +3 -0
- package/dist/esm/constants/browser.constants.js +38 -0
- package/dist/esm/constants/index.d.ts +8 -0
- package/dist/esm/constants/index.js +8 -0
- package/dist/esm/constants/initialization.constants.d.ts +40 -0
- package/dist/esm/constants/initialization.constants.js +45 -0
- package/dist/esm/constants/limits.constants.d.ts +25 -0
- package/dist/esm/constants/limits.constants.js +37 -0
- package/dist/esm/constants/security.constants.d.ts +1 -0
- package/dist/esm/constants/security.constants.js +9 -0
- package/dist/esm/constants/storage.constants.d.ts +9 -0
- package/dist/esm/constants/storage.constants.js +11 -0
- package/dist/esm/constants/timing.constants.d.ts +22 -0
- package/dist/esm/constants/timing.constants.js +31 -0
- package/dist/esm/constants/validation.constants.d.ts +13 -0
- package/dist/esm/constants/validation.constants.js +28 -0
- package/dist/esm/handlers/click.handler.d.ts +17 -0
- package/dist/esm/handlers/click.handler.js +195 -0
- package/dist/esm/handlers/error.handler.d.ts +15 -0
- package/dist/esm/handlers/error.handler.js +93 -0
- package/dist/esm/handlers/network.handler.d.ts +16 -0
- package/dist/esm/handlers/network.handler.js +132 -0
- package/dist/esm/handlers/page-view.handler.d.ts +15 -0
- package/dist/esm/handlers/page-view.handler.js +79 -0
- package/dist/esm/handlers/performance.handler.d.ts +19 -0
- package/dist/esm/handlers/performance.handler.js +218 -0
- package/dist/esm/handlers/scroll.handler.d.ts +16 -0
- package/dist/esm/handlers/scroll.handler.js +134 -0
- package/dist/esm/handlers/session.handler.d.ts +29 -0
- package/dist/esm/handlers/session.handler.js +353 -0
- package/dist/esm/integrations/google-analytics.integration.d.ts +18 -0
- package/dist/esm/integrations/google-analytics.integration.js +155 -0
- package/dist/esm/listeners/activity-listener-manager.d.ts +8 -0
- package/dist/esm/listeners/activity-listener-manager.js +28 -0
- package/dist/esm/listeners/index.d.ts +6 -0
- package/dist/esm/listeners/index.js +5 -0
- package/dist/esm/listeners/input-listener-managers.d.ts +15 -0
- package/dist/esm/listeners/input-listener-managers.js +53 -0
- package/dist/esm/listeners/listeners.types.d.ts +4 -0
- package/dist/esm/listeners/listeners.types.js +1 -0
- package/dist/esm/listeners/touch-listener-manager.d.ts +10 -0
- package/dist/esm/listeners/touch-listener-manager.js +52 -0
- package/dist/esm/listeners/unload-listener-manager.d.ts +8 -0
- package/dist/esm/listeners/unload-listener-manager.js +26 -0
- package/dist/esm/listeners/visibility-listener-manager.d.ts +12 -0
- package/dist/esm/listeners/visibility-listener-manager.js +79 -0
- package/dist/esm/managers/api.manager.d.ts +3 -0
- package/dist/esm/managers/api.manager.js +10 -0
- package/dist/esm/managers/config.manager.d.ts +7 -0
- package/dist/esm/managers/config.manager.js +90 -0
- package/dist/esm/managers/cross-tab-session.manager.d.ts +170 -0
- package/dist/esm/managers/cross-tab-session.manager.js +726 -0
- package/dist/esm/managers/event.manager.d.ts +61 -0
- package/dist/esm/managers/event.manager.js +504 -0
- package/dist/esm/managers/sampling.manager.d.ts +8 -0
- package/dist/esm/managers/sampling.manager.js +49 -0
- package/dist/esm/managers/sender.manager.d.ts +46 -0
- package/dist/esm/managers/sender.manager.js +300 -0
- package/dist/esm/managers/session-recovery.manager.d.ts +65 -0
- package/dist/esm/managers/session-recovery.manager.js +233 -0
- package/dist/esm/managers/session.manager.d.ts +72 -0
- package/dist/esm/managers/session.manager.js +583 -0
- package/dist/esm/managers/state.manager.d.ts +5 -0
- package/dist/esm/managers/state.manager.js +19 -0
- package/dist/esm/managers/storage.manager.d.ts +10 -0
- package/dist/esm/managers/storage.manager.js +77 -0
- package/dist/esm/managers/tags.manager.d.ts +12 -0
- package/dist/esm/managers/tags.manager.js +285 -0
- package/dist/esm/managers/user.manager.d.ts +7 -0
- package/dist/esm/managers/user.manager.js +18 -0
- package/dist/esm/public-api.d.ts +1 -0
- package/dist/esm/public-api.js +1 -0
- package/dist/esm/types/api.types.d.ts +21 -0
- package/dist/esm/types/api.types.js +22 -0
- package/dist/esm/types/common.types.d.ts +1 -0
- package/dist/esm/types/common.types.js +1 -0
- package/dist/esm/types/config.types.d.ts +104 -0
- package/dist/esm/types/config.types.js +1 -0
- package/dist/esm/types/device.types.d.ts +6 -0
- package/dist/esm/types/device.types.js +7 -0
- package/dist/esm/types/event.types.d.ts +104 -0
- package/dist/esm/types/event.types.js +22 -0
- package/dist/esm/types/index.d.ts +13 -0
- package/dist/esm/types/index.js +13 -0
- package/dist/esm/types/log.types.d.ts +4 -0
- package/dist/esm/types/log.types.js +1 -0
- package/dist/esm/types/mode.types.d.ts +7 -0
- package/dist/esm/types/mode.types.js +8 -0
- package/dist/esm/types/queue.types.d.ts +23 -0
- package/dist/esm/types/queue.types.js +1 -0
- package/dist/esm/types/session.types.d.ts +65 -0
- package/dist/esm/types/session.types.js +1 -0
- package/dist/esm/types/state.types.d.ts +12 -0
- package/dist/esm/types/state.types.js +1 -0
- package/dist/esm/types/tag.types.d.ts +43 -0
- package/dist/esm/types/tag.types.js +28 -0
- package/dist/esm/types/validation-error.types.d.ts +42 -0
- package/dist/esm/types/validation-error.types.js +59 -0
- package/dist/esm/types/web-vitals.types.d.ts +6 -0
- package/dist/esm/types/web-vitals.types.js +1 -0
- package/dist/esm/types/window.types.d.ts +17 -0
- package/dist/esm/types/window.types.js +1 -0
- package/dist/esm/utils/browser/device-detector.utils.d.ts +6 -0
- package/dist/esm/utils/browser/device-detector.utils.js +67 -0
- package/dist/esm/utils/browser/index.d.ts +2 -0
- package/dist/esm/utils/browser/index.js +2 -0
- package/dist/esm/utils/browser/utm-params.utils.d.ts +6 -0
- package/dist/esm/utils/browser/utm-params.utils.js +33 -0
- package/dist/esm/utils/data/index.d.ts +1 -0
- package/dist/esm/utils/data/index.js +1 -0
- package/dist/esm/utils/data/uuid.utils.d.ts +5 -0
- package/dist/esm/utils/data/uuid.utils.js +14 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.js +6 -0
- package/dist/esm/utils/logging/debug-logger.utils.d.ts +56 -0
- package/dist/esm/utils/logging/debug-logger.utils.js +136 -0
- package/dist/esm/utils/logging/index.d.ts +1 -0
- package/dist/esm/utils/logging/index.js +1 -0
- package/dist/esm/utils/network/index.d.ts +1 -0
- package/dist/esm/utils/network/index.js +1 -0
- package/dist/esm/utils/network/url.utils.d.ts +20 -0
- package/dist/esm/utils/network/url.utils.js +166 -0
- package/dist/esm/utils/security/index.d.ts +1 -0
- package/dist/esm/utils/security/index.js +1 -0
- package/dist/esm/utils/security/sanitize.utils.d.ts +32 -0
- package/dist/esm/utils/security/sanitize.utils.js +311 -0
- package/dist/esm/utils/validations/config-validations.utils.d.ts +42 -0
- package/dist/esm/utils/validations/config-validations.utils.js +289 -0
- package/dist/esm/utils/validations/event-validations.utils.d.ts +12 -0
- package/dist/esm/utils/validations/event-validations.utils.js +26 -0
- package/dist/esm/utils/validations/index.d.ts +5 -0
- package/dist/esm/utils/validations/index.js +5 -0
- package/dist/esm/utils/validations/metadata-validations.utils.d.ts +22 -0
- package/dist/esm/utils/validations/metadata-validations.utils.js +110 -0
- package/dist/esm/utils/validations/type-guards.utils.d.ts +6 -0
- package/dist/esm/utils/validations/type-guards.utils.js +27 -0
- package/dist/esm/utils/validations/url-validations.utils.d.ts +15 -0
- package/dist/esm/utils/validations/url-validations.utils.js +42 -0
- package/package.json +80 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEventValid = void 0;
|
|
4
|
+
const metadata_validations_utils_1 = require("./metadata-validations.utils");
|
|
5
|
+
const logging_1 = require("../logging");
|
|
6
|
+
/**
|
|
7
|
+
* Validates a complete event with name and optional metadata
|
|
8
|
+
* @param eventName - The event name to validate
|
|
9
|
+
* @param metadata - Optional metadata to validate
|
|
10
|
+
* @returns Validation result with sanitized metadata if valid
|
|
11
|
+
*/
|
|
12
|
+
const isEventValid = (eventName, metadata) => {
|
|
13
|
+
const nameValidation = (0, metadata_validations_utils_1.isValidEventName)(eventName);
|
|
14
|
+
if (!nameValidation.valid) {
|
|
15
|
+
logging_1.debugLog.clientError('EventValidation', 'Event name validation failed', { eventName, error: nameValidation.error });
|
|
16
|
+
return nameValidation;
|
|
17
|
+
}
|
|
18
|
+
if (!metadata) {
|
|
19
|
+
return { valid: true };
|
|
20
|
+
}
|
|
21
|
+
const metadataValidation = (0, metadata_validations_utils_1.isValidMetadata)(eventName, metadata, 'customEvent');
|
|
22
|
+
if (!metadataValidation.valid) {
|
|
23
|
+
logging_1.debugLog.clientError('EventValidation', 'Event metadata validation failed', {
|
|
24
|
+
eventName,
|
|
25
|
+
error: metadataValidation.error,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return metadataValidation;
|
|
29
|
+
};
|
|
30
|
+
exports.isEventValid = isEventValid;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./config-validations.utils"), exports);
|
|
18
|
+
__exportStar(require("./event-validations.utils"), exports);
|
|
19
|
+
__exportStar(require("./metadata-validations.utils"), exports);
|
|
20
|
+
__exportStar(require("./type-guards.utils"), exports);
|
|
21
|
+
__exportStar(require("./url-validations.utils"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MetadataType } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Validates an event name
|
|
4
|
+
* @param eventName - The event name to validate
|
|
5
|
+
* @returns Validation result with error message if invalid
|
|
6
|
+
*/
|
|
7
|
+
export declare const isValidEventName: (eventName: string) => {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Validates metadata for events
|
|
13
|
+
* @param eventName - The event name (for error messages)
|
|
14
|
+
* @param metadata - The metadata to validate
|
|
15
|
+
* @param type - Type of metadata (globalMetadata or customEvent)
|
|
16
|
+
* @returns Validation result with sanitized metadata if valid
|
|
17
|
+
*/
|
|
18
|
+
export declare const isValidMetadata: (eventName: string, metadata: Record<string, unknown>, type?: "globalMetadata" | "customEvent") => {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
error?: string;
|
|
21
|
+
sanitizedMetadata?: Record<string, MetadataType>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidMetadata = exports.isValidEventName = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const sanitize_utils_1 = require("../security/sanitize.utils");
|
|
6
|
+
const type_guards_utils_1 = require("./type-guards.utils");
|
|
7
|
+
/**
|
|
8
|
+
* Validates an event name
|
|
9
|
+
* @param eventName - The event name to validate
|
|
10
|
+
* @returns Validation result with error message if invalid
|
|
11
|
+
*/
|
|
12
|
+
const isValidEventName = (eventName) => {
|
|
13
|
+
if (typeof eventName !== 'string') {
|
|
14
|
+
return {
|
|
15
|
+
valid: false,
|
|
16
|
+
error: 'Event name must be a string',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (eventName.length === 0) {
|
|
20
|
+
return {
|
|
21
|
+
valid: false,
|
|
22
|
+
error: 'Event name cannot be empty',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (eventName.length > constants_1.MAX_CUSTOM_EVENT_NAME_LENGTH) {
|
|
26
|
+
return {
|
|
27
|
+
valid: false,
|
|
28
|
+
error: `Event name is too long (max ${constants_1.MAX_CUSTOM_EVENT_NAME_LENGTH} characters)`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (eventName.includes('<') || eventName.includes('>') || eventName.includes('&')) {
|
|
32
|
+
return {
|
|
33
|
+
valid: false,
|
|
34
|
+
error: 'Event name contains invalid characters',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const reservedWords = ['constructor', 'prototype', '__proto__', 'eval', 'function', 'var', 'let', 'const'];
|
|
38
|
+
if (reservedWords.includes(eventName.toLowerCase())) {
|
|
39
|
+
return {
|
|
40
|
+
valid: false,
|
|
41
|
+
error: 'Event name cannot be a reserved word',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return { valid: true };
|
|
45
|
+
};
|
|
46
|
+
exports.isValidEventName = isValidEventName;
|
|
47
|
+
/**
|
|
48
|
+
* Validates metadata for events
|
|
49
|
+
* @param eventName - The event name (for error messages)
|
|
50
|
+
* @param metadata - The metadata to validate
|
|
51
|
+
* @param type - Type of metadata (globalMetadata or customEvent)
|
|
52
|
+
* @returns Validation result with sanitized metadata if valid
|
|
53
|
+
*/
|
|
54
|
+
const isValidMetadata = (eventName, metadata, type) => {
|
|
55
|
+
const sanitizedMetadata = (0, sanitize_utils_1.sanitizeMetadata)(metadata);
|
|
56
|
+
const intro = type && type === 'customEvent' ? `${type} "${eventName}" metadata error` : `${eventName} metadata error`;
|
|
57
|
+
if (!(0, type_guards_utils_1.isOnlyPrimitiveFields)(sanitizedMetadata)) {
|
|
58
|
+
return {
|
|
59
|
+
valid: false,
|
|
60
|
+
error: `${intro}: object has invalid types. Valid types are string, number, boolean or string arrays.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
let jsonString;
|
|
64
|
+
try {
|
|
65
|
+
jsonString = JSON.stringify(sanitizedMetadata);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return {
|
|
69
|
+
valid: false,
|
|
70
|
+
error: `${intro}: object contains circular references or cannot be serialized.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (jsonString.length > constants_1.MAX_CUSTOM_EVENT_STRING_SIZE) {
|
|
74
|
+
return {
|
|
75
|
+
valid: false,
|
|
76
|
+
error: `${intro}: object is too large (max ${constants_1.MAX_CUSTOM_EVENT_STRING_SIZE / 1024} KB).`,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const keyCount = Object.keys(sanitizedMetadata).length;
|
|
80
|
+
if (keyCount > constants_1.MAX_CUSTOM_EVENT_KEYS) {
|
|
81
|
+
return {
|
|
82
|
+
valid: false,
|
|
83
|
+
error: `${intro}: object has too many keys (max ${constants_1.MAX_CUSTOM_EVENT_KEYS} keys).`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
for (const [key, value] of Object.entries(sanitizedMetadata)) {
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
if (value.length > constants_1.MAX_CUSTOM_EVENT_ARRAY_SIZE) {
|
|
89
|
+
return {
|
|
90
|
+
valid: false,
|
|
91
|
+
error: `${intro}: array property "${key}" is too large (max ${constants_1.MAX_CUSTOM_EVENT_ARRAY_SIZE} items).`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
for (const item of value) {
|
|
95
|
+
if (typeof item === 'string' && item.length > 500) {
|
|
96
|
+
return {
|
|
97
|
+
valid: false,
|
|
98
|
+
error: `${intro}: array property "${key}" contains strings that are too long (max 500 characters).`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (typeof value === 'string' && value.length > constants_1.MAX_STRING_LENGTH) {
|
|
104
|
+
return {
|
|
105
|
+
valid: false,
|
|
106
|
+
error: `${intro}: property "${key}" is too long (max ${constants_1.MAX_STRING_LENGTH} characters).`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
valid: true,
|
|
112
|
+
sanitizedMetadata,
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.isValidMetadata = isValidMetadata;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if an object contains only primitive fields (string, number, boolean, or string arrays)
|
|
3
|
+
* @param object - The object to check
|
|
4
|
+
* @returns True if the object contains only primitive fields
|
|
5
|
+
*/
|
|
6
|
+
export declare const isOnlyPrimitiveFields: (object: Record<string, unknown>) => boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOnlyPrimitiveFields = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an object contains only primitive fields (string, number, boolean, or string arrays)
|
|
6
|
+
* @param object - The object to check
|
|
7
|
+
* @returns True if the object contains only primitive fields
|
|
8
|
+
*/
|
|
9
|
+
const isOnlyPrimitiveFields = (object) => {
|
|
10
|
+
if (typeof object !== 'object' || object === null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
for (const value of Object.values(object)) {
|
|
14
|
+
if (value === null || value === undefined) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const type = typeof value;
|
|
18
|
+
if (type === 'string' || type === 'number' || type === 'boolean') {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
if (!value.every((item) => typeof item === 'string')) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
exports.isOnlyPrimitiveFields = isOnlyPrimitiveFields;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates if a URL is valid and optionally allows HTTP URLs
|
|
3
|
+
* @param url - The URL to validate
|
|
4
|
+
* @param allowHttp - Whether to allow HTTP URLs (default: false)
|
|
5
|
+
* @returns True if the URL is valid, false otherwise
|
|
6
|
+
*/
|
|
7
|
+
export declare const isValidUrl: (url: string, allowHttp?: boolean) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Validates a URL field in configuration
|
|
10
|
+
* @param url - The URL to validate
|
|
11
|
+
* @param allowHttp - Whether to allow HTTP URLs
|
|
12
|
+
* @param fieldName - The name of the field being validated
|
|
13
|
+
* @param errors - Array to push errors to
|
|
14
|
+
*/
|
|
15
|
+
export declare const validateUrl: (url: unknown, allowHttp: boolean | undefined, fieldName: string, errors: string[]) => void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateUrl = exports.isValidUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validates if a URL is valid and optionally allows HTTP URLs
|
|
6
|
+
* @param url - The URL to validate
|
|
7
|
+
* @param allowHttp - Whether to allow HTTP URLs (default: false)
|
|
8
|
+
* @returns True if the URL is valid, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
const isValidUrl = (url, allowHttp = false) => {
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(url);
|
|
13
|
+
const isHttps = parsed.protocol === 'https:';
|
|
14
|
+
const isHttp = parsed.protocol === 'http:';
|
|
15
|
+
return isHttps || (allowHttp && isHttp);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.isValidUrl = isValidUrl;
|
|
22
|
+
/**
|
|
23
|
+
* Validates a URL field in configuration
|
|
24
|
+
* @param url - The URL to validate
|
|
25
|
+
* @param allowHttp - Whether to allow HTTP URLs
|
|
26
|
+
* @param fieldName - The name of the field being validated
|
|
27
|
+
* @param errors - Array to push errors to
|
|
28
|
+
*/
|
|
29
|
+
const validateUrl = (url, allowHttp, fieldName, errors) => {
|
|
30
|
+
if (url !== undefined) {
|
|
31
|
+
if (typeof url === 'string') {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = new URL(url);
|
|
34
|
+
if (parsed.protocol === 'http:' && !allowHttp) {
|
|
35
|
+
errors.push(`${fieldName} using http requires allowHttp=true`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
errors.push(`${fieldName} must be a valid URL`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
errors.push(`${fieldName} must be a string`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.validateUrl = validateUrl;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MetadataType } from './types/common.types';
|
|
2
|
+
import { AppConfig } from './types/config.types';
|
|
3
|
+
import './types/window.types';
|
|
4
|
+
export * as Types from './app.types';
|
|
5
|
+
export * as Constants from './app.constants';
|
|
6
|
+
/**
|
|
7
|
+
* Initializes the tracelog app with the provided configuration.
|
|
8
|
+
* If already initialized, this function returns early without error.
|
|
9
|
+
* @param appConfig - The configuration object for the app
|
|
10
|
+
* @throws {Error} If initialization is currently in progress
|
|
11
|
+
* @example
|
|
12
|
+
* await init({ id: 'my-project-id' });
|
|
13
|
+
*/
|
|
14
|
+
export declare const init: (appConfig: AppConfig) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Sends a custom event with the specified name and metadata.
|
|
17
|
+
* @param name - The name of the custom event.
|
|
18
|
+
* @param metadata - Optional metadata to attach to the event.
|
|
19
|
+
* @example
|
|
20
|
+
* // Send a custom event with metadata
|
|
21
|
+
* event('user_signup', { method: 'email', plan: 'premium' });
|
|
22
|
+
* @example
|
|
23
|
+
* // Send a custom event without metadata
|
|
24
|
+
* event('user_login');
|
|
25
|
+
* @remarks
|
|
26
|
+
* This function should be called after the app has been initialized using the `init` function.
|
|
27
|
+
*/
|
|
28
|
+
export declare const event: (name: string, metadata?: Record<string, MetadataType>) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the app has been initialized.
|
|
31
|
+
* @returns true if the app is initialized, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
export declare const isInitialized: () => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the current initialization status for debugging purposes.
|
|
36
|
+
* @returns Object with detailed initialization state
|
|
37
|
+
*/
|
|
38
|
+
export declare const getInitializationStatus: () => {
|
|
39
|
+
isInitialized: boolean;
|
|
40
|
+
isInitializing: boolean;
|
|
41
|
+
hasInstance: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Destroys the current app instance and cleans up resources.
|
|
45
|
+
*/
|
|
46
|
+
export declare const destroy: () => void;
|
package/dist/esm/api.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { App } from './app';
|
|
2
|
+
import { debugLog } from './utils/logging';
|
|
3
|
+
import { validateAndNormalizeConfig } from './utils/validations';
|
|
4
|
+
import { INITIALIZATION_CONSTANTS } from './constants';
|
|
5
|
+
import './types/window.types';
|
|
6
|
+
export * as Types from './app.types';
|
|
7
|
+
export * as Constants from './app.constants';
|
|
8
|
+
let app = null;
|
|
9
|
+
let isInitializing = false;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes the tracelog app with the provided configuration.
|
|
12
|
+
* If already initialized, this function returns early without error.
|
|
13
|
+
* @param appConfig - The configuration object for the app
|
|
14
|
+
* @throws {Error} If initialization is currently in progress
|
|
15
|
+
* @example
|
|
16
|
+
* await init({ id: 'my-project-id' });
|
|
17
|
+
*/
|
|
18
|
+
export const init = async (appConfig) => {
|
|
19
|
+
try {
|
|
20
|
+
debugLog.info('API', 'Library initialization started', { id: appConfig.id });
|
|
21
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
22
|
+
debugLog.clientError('API', 'Browser environment required - this library can only be used in a browser environment', {
|
|
23
|
+
hasWindow: typeof window !== 'undefined',
|
|
24
|
+
hasDocument: typeof document !== 'undefined',
|
|
25
|
+
});
|
|
26
|
+
throw new Error('This library can only be used in a browser environment');
|
|
27
|
+
}
|
|
28
|
+
if (app) {
|
|
29
|
+
debugLog.debug('API', 'Library already initialized, skipping duplicate initialization', {
|
|
30
|
+
projectId: appConfig.id,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (isInitializing) {
|
|
35
|
+
debugLog.debug('API', 'Concurrent initialization detected, waiting for completion', { projectId: appConfig.id });
|
|
36
|
+
let retries = 0;
|
|
37
|
+
const maxRetries = INITIALIZATION_CONSTANTS.MAX_CONCURRENT_RETRIES;
|
|
38
|
+
const retryDelay = INITIALIZATION_CONSTANTS.CONCURRENT_RETRY_DELAY_MS;
|
|
39
|
+
while (isInitializing && retries < maxRetries) {
|
|
40
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
|
41
|
+
retries++;
|
|
42
|
+
}
|
|
43
|
+
if (app) {
|
|
44
|
+
debugLog.debug('API', 'Concurrent initialization completed successfully', {
|
|
45
|
+
projectId: appConfig.id,
|
|
46
|
+
retriesUsed: retries,
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (isInitializing) {
|
|
51
|
+
debugLog.error('API', 'Initialization timeout - concurrent initialization took too long', {
|
|
52
|
+
projectId: appConfig.id,
|
|
53
|
+
retriesUsed: retries,
|
|
54
|
+
maxRetries,
|
|
55
|
+
});
|
|
56
|
+
throw new Error('App initialization timeout - concurrent initialization took too long');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
isInitializing = true;
|
|
60
|
+
debugLog.debug('API', 'Validating and normalizing configuration', { projectId: appConfig.id });
|
|
61
|
+
const validatedConfig = validateAndNormalizeConfig(appConfig);
|
|
62
|
+
debugLog.debug('API', 'Creating App instance', { projectId: validatedConfig.id });
|
|
63
|
+
const instance = new App();
|
|
64
|
+
await instance.init(validatedConfig);
|
|
65
|
+
app = instance;
|
|
66
|
+
debugLog.info('API', 'Library initialization completed successfully', {
|
|
67
|
+
projectId: validatedConfig.id,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Ensure complete cleanup on initialization failure
|
|
72
|
+
if (app && !app.initialized) {
|
|
73
|
+
// Clean up partially initialized app instance
|
|
74
|
+
try {
|
|
75
|
+
app.destroy();
|
|
76
|
+
}
|
|
77
|
+
catch (cleanupError) {
|
|
78
|
+
debugLog.warn('API', 'Failed to cleanup partially initialized app', { cleanupError });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
app = null;
|
|
82
|
+
debugLog.error('API', 'Initialization failed', { error });
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
isInitializing = false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Sends a custom event with the specified name and metadata.
|
|
91
|
+
* @param name - The name of the custom event.
|
|
92
|
+
* @param metadata - Optional metadata to attach to the event.
|
|
93
|
+
* @example
|
|
94
|
+
* // Send a custom event with metadata
|
|
95
|
+
* event('user_signup', { method: 'email', plan: 'premium' });
|
|
96
|
+
* @example
|
|
97
|
+
* // Send a custom event without metadata
|
|
98
|
+
* event('user_login');
|
|
99
|
+
* @remarks
|
|
100
|
+
* This function should be called after the app has been initialized using the `init` function.
|
|
101
|
+
*/
|
|
102
|
+
export const event = (name, metadata) => {
|
|
103
|
+
try {
|
|
104
|
+
if (!app) {
|
|
105
|
+
debugLog.clientError('API', 'Custom event failed - Library not initialized. Please call TraceLog.init() first', {
|
|
106
|
+
eventName: name,
|
|
107
|
+
hasMetadata: !!metadata,
|
|
108
|
+
});
|
|
109
|
+
throw new Error('App not initialized');
|
|
110
|
+
}
|
|
111
|
+
debugLog.debug('API', 'Sending custom event', {
|
|
112
|
+
eventName: name,
|
|
113
|
+
hasMetadata: !!metadata,
|
|
114
|
+
metadataKeys: metadata ? Object.keys(metadata) : [],
|
|
115
|
+
});
|
|
116
|
+
app.sendCustomEvent(name, metadata);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
debugLog.error('API', 'Event tracking failed', { eventName: name, error, hasMetadata: !!metadata });
|
|
120
|
+
if (error instanceof Error &&
|
|
121
|
+
(error.message === 'App not initialized' || error.message.includes('validation failed'))) {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Checks if the app has been initialized.
|
|
128
|
+
* @returns true if the app is initialized, false otherwise
|
|
129
|
+
*/
|
|
130
|
+
export const isInitialized = () => {
|
|
131
|
+
return app !== null;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Gets the current initialization status for debugging purposes.
|
|
135
|
+
* @returns Object with detailed initialization state
|
|
136
|
+
*/
|
|
137
|
+
export const getInitializationStatus = () => {
|
|
138
|
+
return {
|
|
139
|
+
isInitialized: app !== null,
|
|
140
|
+
isInitializing: isInitializing,
|
|
141
|
+
hasInstance: app !== null,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Destroys the current app instance and cleans up resources.
|
|
146
|
+
*/
|
|
147
|
+
export const destroy = () => {
|
|
148
|
+
try {
|
|
149
|
+
debugLog.info('API', 'Library cleanup initiated');
|
|
150
|
+
if (!app) {
|
|
151
|
+
debugLog.warn('API', 'Cleanup called but Library was not initialized');
|
|
152
|
+
throw new Error('App not initialized');
|
|
153
|
+
}
|
|
154
|
+
app.destroy();
|
|
155
|
+
app = null;
|
|
156
|
+
isInitializing = false;
|
|
157
|
+
debugLog.info('API', 'Library cleanup completed successfully');
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
debugLog.error('API', 'Cleanup failed', { error, hadApp: !!app, wasInitializing: isInitializing });
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
class TestBridge extends App {
|
|
164
|
+
isInitializing() {
|
|
165
|
+
return isInitializing;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Auto-inject testing bridge only in development/testing environments
|
|
169
|
+
if (process.env.NODE_ENV === 'dev') {
|
|
170
|
+
if (typeof window !== 'undefined') {
|
|
171
|
+
// Wait for DOM to be ready before injecting
|
|
172
|
+
const injectTestingBridge = () => {
|
|
173
|
+
window.__traceLogBridge = new TestBridge();
|
|
174
|
+
};
|
|
175
|
+
// Inject immediately if DOM is ready, otherwise wait
|
|
176
|
+
if (document.readyState === 'loading') {
|
|
177
|
+
document.addEventListener('DOMContentLoaded', injectTestingBridge);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
injectTestingBridge();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_SESSION_TIMEOUT_MS } from './constants';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_SESSION_TIMEOUT_MS } from './constants';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EventManager } from './managers/event.manager';
|
|
2
|
+
import { AppConfig } from './types/config.types';
|
|
3
|
+
import { StateManager } from './managers/state.manager';
|
|
4
|
+
import { SessionHandler } from './handlers/session.handler';
|
|
5
|
+
import { PageViewHandler } from './handlers/page-view.handler';
|
|
6
|
+
import { ClickHandler } from './handlers/click.handler';
|
|
7
|
+
import { ScrollHandler } from './handlers/scroll.handler';
|
|
8
|
+
import { GoogleAnalyticsIntegration } from './integrations/google-analytics.integration';
|
|
9
|
+
import { StorageManager } from './managers/storage.manager';
|
|
10
|
+
import { PerformanceHandler } from './handlers/performance.handler';
|
|
11
|
+
import { ErrorHandler } from './handlers/error.handler';
|
|
12
|
+
import { NetworkHandler } from './handlers/network.handler';
|
|
13
|
+
export declare class App extends StateManager {
|
|
14
|
+
protected isInitialized: boolean;
|
|
15
|
+
protected googleAnalytics: GoogleAnalyticsIntegration | null;
|
|
16
|
+
protected storageManager: StorageManager;
|
|
17
|
+
protected eventManager: EventManager;
|
|
18
|
+
protected sessionHandler: SessionHandler;
|
|
19
|
+
protected pageViewHandler: PageViewHandler;
|
|
20
|
+
protected clickHandler: ClickHandler;
|
|
21
|
+
protected scrollHandler: ScrollHandler;
|
|
22
|
+
protected performanceHandler: PerformanceHandler;
|
|
23
|
+
protected errorHandler: ErrorHandler;
|
|
24
|
+
protected networkHandler: NetworkHandler;
|
|
25
|
+
protected suppressNextScrollTimer: number | null;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the initialization status of the app
|
|
28
|
+
* @returns true if the app is fully initialized, false otherwise
|
|
29
|
+
*/
|
|
30
|
+
get initialized(): boolean;
|
|
31
|
+
init(appConfig: AppConfig): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Validates that the app is ready to initialize with the provided config
|
|
34
|
+
* This is a lightweight runtime validation layer that ensures the app receives proper config
|
|
35
|
+
* @param appConfig - The validated and normalized configuration
|
|
36
|
+
* @throws {ProjectIdValidationError} If project ID is invalid at runtime
|
|
37
|
+
*/
|
|
38
|
+
private validateAppReadiness;
|
|
39
|
+
sendCustomEvent(name: string, metadata?: Record<string, unknown>): void;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private setState;
|
|
42
|
+
private setApiUrl;
|
|
43
|
+
private setConfig;
|
|
44
|
+
private setUserId;
|
|
45
|
+
private setDevice;
|
|
46
|
+
private setPageUrl;
|
|
47
|
+
private setIntegrations;
|
|
48
|
+
private initHandlers;
|
|
49
|
+
private initStorage;
|
|
50
|
+
private setEventManager;
|
|
51
|
+
private initSessionHandler;
|
|
52
|
+
private initPageViewHandler;
|
|
53
|
+
private onPageViewTrack;
|
|
54
|
+
private initClickHandler;
|
|
55
|
+
private initScrollHandler;
|
|
56
|
+
private initPerformanceHandler;
|
|
57
|
+
private initErrorHandler;
|
|
58
|
+
private initNetworkHandler;
|
|
59
|
+
}
|