@tracelog/lib 0.6.1 → 0.6.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 +8 -8
- package/dist/browser/tracelog.esm.js +483 -478
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +2 -2
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/cjs/api.d.ts +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/app.d.ts +1 -1
- package/dist/cjs/app.js +4 -4
- package/dist/cjs/handlers/click.handler.js +2 -2
- package/dist/cjs/handlers/scroll.handler.js +1 -1
- package/dist/cjs/handlers/session.handler.js +1 -1
- package/dist/cjs/managers/sender.manager.js +4 -5
- package/dist/cjs/public-api.d.ts +1 -1
- package/dist/cjs/test-bridge.d.ts +1 -1
- package/dist/cjs/test-bridge.js +1 -1
- package/dist/cjs/types/config.types.d.ts +2 -2
- package/dist/cjs/types/state.types.d.ts +1 -1
- package/dist/cjs/types/test-bridge.types.d.ts +1 -1
- package/dist/cjs/utils/network/url.utils.d.ts +1 -1
- package/dist/cjs/utils/network/url.utils.js +10 -10
- package/dist/cjs/utils/validations/config-validations.utils.d.ts +2 -2
- package/dist/cjs/utils/validations/config-validations.utils.js +16 -13
- package/dist/esm/api.d.ts +1 -1
- package/dist/esm/api.js +1 -1
- package/dist/esm/app.d.ts +1 -1
- package/dist/esm/app.js +5 -5
- package/dist/esm/handlers/click.handler.js +2 -2
- package/dist/esm/handlers/scroll.handler.js +1 -1
- package/dist/esm/handlers/session.handler.js +1 -1
- package/dist/esm/managers/sender.manager.js +4 -5
- package/dist/esm/public-api.d.ts +1 -1
- package/dist/esm/test-bridge.d.ts +1 -1
- package/dist/esm/test-bridge.js +1 -1
- package/dist/esm/types/config.types.d.ts +2 -2
- package/dist/esm/types/state.types.d.ts +1 -1
- package/dist/esm/types/test-bridge.types.d.ts +1 -1
- package/dist/esm/utils/network/url.utils.d.ts +1 -1
- package/dist/esm/utils/network/url.utils.js +8 -8
- package/dist/esm/utils/validations/config-validations.utils.d.ts +2 -2
- package/dist/esm/utils/validations/config-validations.utils.js +16 -13
- package/package.json +6 -6
|
@@ -9,9 +9,12 @@ import { log } from '../logging.utils';
|
|
|
9
9
|
* @throws {AppConfigValidationError} If other configuration validation fails
|
|
10
10
|
*/
|
|
11
11
|
export const validateAppConfig = (config) => {
|
|
12
|
-
if (
|
|
12
|
+
if (config !== undefined && (config === null || typeof config !== 'object')) {
|
|
13
13
|
throw new AppConfigValidationError('Configuration must be an object', 'config');
|
|
14
14
|
}
|
|
15
|
+
if (!config) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
15
18
|
if (config.sessionTimeout !== undefined) {
|
|
16
19
|
if (typeof config.sessionTimeout !== 'number' ||
|
|
17
20
|
config.sessionTimeout < MIN_SESSION_TIMEOUT_MS ||
|
|
@@ -140,20 +143,20 @@ const validateIntegrations = (integrations) => {
|
|
|
140
143
|
}
|
|
141
144
|
}
|
|
142
145
|
if (integrations.custom) {
|
|
143
|
-
if (!integrations.custom.
|
|
144
|
-
typeof integrations.custom.
|
|
145
|
-
integrations.custom.
|
|
146
|
+
if (!integrations.custom.collectApiUrl ||
|
|
147
|
+
typeof integrations.custom.collectApiUrl !== 'string' ||
|
|
148
|
+
integrations.custom.collectApiUrl.trim() === '') {
|
|
146
149
|
throw new IntegrationValidationError(VALIDATION_MESSAGES.INVALID_CUSTOM_API_URL, 'config');
|
|
147
150
|
}
|
|
148
151
|
if (integrations.custom.allowHttp !== undefined && typeof integrations.custom.allowHttp !== 'boolean') {
|
|
149
152
|
throw new IntegrationValidationError('allowHttp must be a boolean', 'config');
|
|
150
153
|
}
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
154
|
+
const collectApiUrl = integrations.custom.collectApiUrl.trim();
|
|
155
|
+
if (!collectApiUrl.startsWith('http://') && !collectApiUrl.startsWith('https://')) {
|
|
153
156
|
throw new IntegrationValidationError('Custom API URL must start with "http://" or "https://"', 'config');
|
|
154
157
|
}
|
|
155
158
|
const allowHttp = integrations.custom.allowHttp ?? false;
|
|
156
|
-
if (!allowHttp &&
|
|
159
|
+
if (!allowHttp && collectApiUrl.startsWith('http://')) {
|
|
157
160
|
throw new IntegrationValidationError('Custom API URL must use HTTPS in production. Set allowHttp: true in integration config to allow HTTP (not recommended)', 'config');
|
|
158
161
|
}
|
|
159
162
|
}
|
|
@@ -180,12 +183,12 @@ const validateIntegrations = (integrations) => {
|
|
|
180
183
|
export const validateAndNormalizeConfig = (config) => {
|
|
181
184
|
validateAppConfig(config);
|
|
182
185
|
const normalizedConfig = {
|
|
183
|
-
...config,
|
|
184
|
-
sessionTimeout: config
|
|
185
|
-
globalMetadata: config
|
|
186
|
-
sensitiveQueryParams: config
|
|
187
|
-
errorSampling: config
|
|
188
|
-
samplingRate: config
|
|
186
|
+
...(config ?? {}),
|
|
187
|
+
sessionTimeout: config?.sessionTimeout ?? DEFAULT_SESSION_TIMEOUT,
|
|
188
|
+
globalMetadata: config?.globalMetadata ?? {},
|
|
189
|
+
sensitiveQueryParams: config?.sensitiveQueryParams ?? [],
|
|
190
|
+
errorSampling: config?.errorSampling ?? 1,
|
|
191
|
+
samplingRate: config?.samplingRate ?? 1,
|
|
189
192
|
};
|
|
190
193
|
// Normalize integrations
|
|
191
194
|
if (normalizedConfig.integrations?.custom) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tracelog/lib",
|
|
3
3
|
"description": "JavaScript library for web analytics and real-time event tracking",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.6.
|
|
5
|
+
"version": "0.6.3",
|
|
6
6
|
"main": "./dist/cjs/public-api.js",
|
|
7
7
|
"module": "./dist/esm/public-api.js",
|
|
8
8
|
"types": "./dist/esm/public-api.d.ts",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"test:unit:watch": "vitest",
|
|
41
41
|
"test:coverage": "vitest run --coverage",
|
|
42
42
|
"test:integration": "vitest run --config vitest.integration.config.mjs",
|
|
43
|
-
"serve": "http-server
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"test:e2e": "npm run
|
|
43
|
+
"serve": "http-server docs -p 3000 --cors",
|
|
44
|
+
"docs:setup": "npm run build:browser:dev && cp dist/browser/tracelog.esm.js docs/tracelog.js",
|
|
45
|
+
"docs:dev": "npm run docs:setup && npm run serve",
|
|
46
|
+
"docs:gh-pages": "npm run build:browser && cp dist/browser/tracelog.esm.js docs/tracelog.js",
|
|
47
|
+
"test:e2e": "npm run docs:setup && NODE_ENV=dev playwright test",
|
|
48
48
|
"ci:build": "npm run build:all",
|
|
49
49
|
"prepare": "husky",
|
|
50
50
|
"release": "node scripts/release.js",
|