@tracelog/lib 2.1.2-rc.78.4 → 2.1.2
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 +4 -97
- package/dist/browser/tracelog.esm.js +441 -570
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +1 -1
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/public-api.cjs +6 -171
- package/dist/public-api.cjs.map +1 -1
- package/dist/public-api.d.mts +2 -45
- package/dist/public-api.d.ts +2 -45
- package/dist/public-api.js +6 -171
- package/dist/public-api.js.map +1 -1
- package/package.json +1 -1
package/dist/public-api.d.mts
CHANGED
|
@@ -443,12 +443,6 @@ interface Config {
|
|
|
443
443
|
collectApiUrl: string;
|
|
444
444
|
/** Allow HTTP URLs (not recommended for production). @default false */
|
|
445
445
|
allowHttp?: boolean;
|
|
446
|
-
/**
|
|
447
|
-
* Static HTTP headers to include in every request.
|
|
448
|
-
* For dynamic headers, use `setCustomHeaders()` instead.
|
|
449
|
-
* @example { 'X-Brand': 'my-brand', 'X-Tenant-Id': 'tenant-123' }
|
|
450
|
-
*/
|
|
451
|
-
headers?: Record<string, string>;
|
|
452
446
|
};
|
|
453
447
|
};
|
|
454
448
|
}
|
|
@@ -1244,10 +1238,8 @@ declare class EventManager extends StateManager {
|
|
|
1244
1238
|
* @param storeManager - Storage manager for persistence
|
|
1245
1239
|
* @param emitter - Optional event emitter for local event consumption
|
|
1246
1240
|
* @param transformers - Optional event transformation hooks
|
|
1247
|
-
* @param staticHeaders - Optional static HTTP headers for custom backend (from config)
|
|
1248
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1249
1241
|
*/
|
|
1250
|
-
constructor(storeManager: StorageManager, emitter?: Emitter | null, transformers?: TransformerMap
|
|
1242
|
+
constructor(storeManager: StorageManager, emitter?: Emitter | null, transformers?: TransformerMap);
|
|
1251
1243
|
/**
|
|
1252
1244
|
* Recovers persisted events from localStorage after a crash or page reload.
|
|
1253
1245
|
*
|
|
@@ -1438,17 +1430,6 @@ declare class EventManager extends StateManager {
|
|
|
1438
1430
|
* @see src/managers/README.md (lines 5-75) for flush details
|
|
1439
1431
|
*/
|
|
1440
1432
|
flushImmediatelySync(): boolean;
|
|
1441
|
-
/**
|
|
1442
|
-
* Sets the custom headers provider callback for the custom integration.
|
|
1443
|
-
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
1444
|
-
*
|
|
1445
|
-
* @param provider - Callback function that returns custom headers
|
|
1446
|
-
*/
|
|
1447
|
-
setCustomHeadersProvider(provider: CustomHeadersProvider): void;
|
|
1448
|
-
/**
|
|
1449
|
-
* Removes the custom headers provider callback from the custom integration.
|
|
1450
|
-
*/
|
|
1451
|
-
removeCustomHeadersProvider(): void;
|
|
1452
1433
|
/**
|
|
1453
1434
|
* Returns the current number of events in the main queue.
|
|
1454
1435
|
*
|
|
@@ -2255,26 +2236,6 @@ interface TransformerMap {
|
|
|
2255
2236
|
beforeSend?: BeforeSendTransformer;
|
|
2256
2237
|
beforeBatch?: BeforeBatchTransformer;
|
|
2257
2238
|
}
|
|
2258
|
-
/**
|
|
2259
|
-
* Callback function for providing dynamic HTTP headers.
|
|
2260
|
-
*
|
|
2261
|
-
* Called synchronously before each fetch request to custom backends.
|
|
2262
|
-
* Return empty object {} to send no custom headers.
|
|
2263
|
-
*
|
|
2264
|
-
* **Note**: Only applies to `custom` integration (not TraceLog SaaS).
|
|
2265
|
-
* Headers are NOT applied to sendBeacon requests (page unload).
|
|
2266
|
-
*
|
|
2267
|
-
* @returns Record of header names to values
|
|
2268
|
-
*
|
|
2269
|
-
* @example
|
|
2270
|
-
* ```typescript
|
|
2271
|
-
* tracelog.setCustomHeaders(() => ({
|
|
2272
|
-
* 'Authorization': `Bearer ${getAuthToken()}`,
|
|
2273
|
-
* 'X-Request-ID': crypto.randomUUID()
|
|
2274
|
-
* }));
|
|
2275
|
-
* ```
|
|
2276
|
-
*/
|
|
2277
|
-
type CustomHeadersProvider = () => Record<string, string>;
|
|
2278
2239
|
|
|
2279
2240
|
/**
|
|
2280
2241
|
* Testing bridge interface for E2E and integration tests
|
|
@@ -2306,8 +2267,6 @@ interface TraceLogTestBridge {
|
|
|
2306
2267
|
setTransformer(hook: 'beforeBatch', fn: BeforeBatchTransformer): void;
|
|
2307
2268
|
setTransformer(hook: TransformerHook, fn: BeforeSendTransformer | BeforeBatchTransformer): void;
|
|
2308
2269
|
removeTransformer(hook: TransformerHook): void;
|
|
2309
|
-
setCustomHeaders(provider: CustomHeadersProvider): void;
|
|
2310
|
-
removeCustomHeaders(): void;
|
|
2311
2270
|
getEventManager(): EventManager | undefined;
|
|
2312
2271
|
getStorageManager(): StorageManager | null;
|
|
2313
2272
|
getPerformanceHandler(): PerformanceHandler | null;
|
|
@@ -2481,8 +2440,6 @@ declare const tracelog: {
|
|
|
2481
2440
|
off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
|
|
2482
2441
|
setTransformer: typeof setTransformer;
|
|
2483
2442
|
removeTransformer: (hook: TransformerHook) => void;
|
|
2484
|
-
setCustomHeaders: (provider: CustomHeadersProvider) => void;
|
|
2485
|
-
removeCustomHeaders: () => void;
|
|
2486
2443
|
isInitialized: () => boolean;
|
|
2487
2444
|
destroy: () => void;
|
|
2488
2445
|
setQaMode: (enabled: boolean) => void;
|
|
@@ -2490,4 +2447,4 @@ declare const tracelog: {
|
|
|
2490
2447
|
mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
|
|
2491
2448
|
};
|
|
2492
2449
|
|
|
2493
|
-
export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData,
|
|
2450
|
+
export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
|
package/dist/public-api.d.ts
CHANGED
|
@@ -443,12 +443,6 @@ interface Config {
|
|
|
443
443
|
collectApiUrl: string;
|
|
444
444
|
/** Allow HTTP URLs (not recommended for production). @default false */
|
|
445
445
|
allowHttp?: boolean;
|
|
446
|
-
/**
|
|
447
|
-
* Static HTTP headers to include in every request.
|
|
448
|
-
* For dynamic headers, use `setCustomHeaders()` instead.
|
|
449
|
-
* @example { 'X-Brand': 'my-brand', 'X-Tenant-Id': 'tenant-123' }
|
|
450
|
-
*/
|
|
451
|
-
headers?: Record<string, string>;
|
|
452
446
|
};
|
|
453
447
|
};
|
|
454
448
|
}
|
|
@@ -1244,10 +1238,8 @@ declare class EventManager extends StateManager {
|
|
|
1244
1238
|
* @param storeManager - Storage manager for persistence
|
|
1245
1239
|
* @param emitter - Optional event emitter for local event consumption
|
|
1246
1240
|
* @param transformers - Optional event transformation hooks
|
|
1247
|
-
* @param staticHeaders - Optional static HTTP headers for custom backend (from config)
|
|
1248
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1249
1241
|
*/
|
|
1250
|
-
constructor(storeManager: StorageManager, emitter?: Emitter | null, transformers?: TransformerMap
|
|
1242
|
+
constructor(storeManager: StorageManager, emitter?: Emitter | null, transformers?: TransformerMap);
|
|
1251
1243
|
/**
|
|
1252
1244
|
* Recovers persisted events from localStorage after a crash or page reload.
|
|
1253
1245
|
*
|
|
@@ -1438,17 +1430,6 @@ declare class EventManager extends StateManager {
|
|
|
1438
1430
|
* @see src/managers/README.md (lines 5-75) for flush details
|
|
1439
1431
|
*/
|
|
1440
1432
|
flushImmediatelySync(): boolean;
|
|
1441
|
-
/**
|
|
1442
|
-
* Sets the custom headers provider callback for the custom integration.
|
|
1443
|
-
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
1444
|
-
*
|
|
1445
|
-
* @param provider - Callback function that returns custom headers
|
|
1446
|
-
*/
|
|
1447
|
-
setCustomHeadersProvider(provider: CustomHeadersProvider): void;
|
|
1448
|
-
/**
|
|
1449
|
-
* Removes the custom headers provider callback from the custom integration.
|
|
1450
|
-
*/
|
|
1451
|
-
removeCustomHeadersProvider(): void;
|
|
1452
1433
|
/**
|
|
1453
1434
|
* Returns the current number of events in the main queue.
|
|
1454
1435
|
*
|
|
@@ -2255,26 +2236,6 @@ interface TransformerMap {
|
|
|
2255
2236
|
beforeSend?: BeforeSendTransformer;
|
|
2256
2237
|
beforeBatch?: BeforeBatchTransformer;
|
|
2257
2238
|
}
|
|
2258
|
-
/**
|
|
2259
|
-
* Callback function for providing dynamic HTTP headers.
|
|
2260
|
-
*
|
|
2261
|
-
* Called synchronously before each fetch request to custom backends.
|
|
2262
|
-
* Return empty object {} to send no custom headers.
|
|
2263
|
-
*
|
|
2264
|
-
* **Note**: Only applies to `custom` integration (not TraceLog SaaS).
|
|
2265
|
-
* Headers are NOT applied to sendBeacon requests (page unload).
|
|
2266
|
-
*
|
|
2267
|
-
* @returns Record of header names to values
|
|
2268
|
-
*
|
|
2269
|
-
* @example
|
|
2270
|
-
* ```typescript
|
|
2271
|
-
* tracelog.setCustomHeaders(() => ({
|
|
2272
|
-
* 'Authorization': `Bearer ${getAuthToken()}`,
|
|
2273
|
-
* 'X-Request-ID': crypto.randomUUID()
|
|
2274
|
-
* }));
|
|
2275
|
-
* ```
|
|
2276
|
-
*/
|
|
2277
|
-
type CustomHeadersProvider = () => Record<string, string>;
|
|
2278
2239
|
|
|
2279
2240
|
/**
|
|
2280
2241
|
* Testing bridge interface for E2E and integration tests
|
|
@@ -2306,8 +2267,6 @@ interface TraceLogTestBridge {
|
|
|
2306
2267
|
setTransformer(hook: 'beforeBatch', fn: BeforeBatchTransformer): void;
|
|
2307
2268
|
setTransformer(hook: TransformerHook, fn: BeforeSendTransformer | BeforeBatchTransformer): void;
|
|
2308
2269
|
removeTransformer(hook: TransformerHook): void;
|
|
2309
|
-
setCustomHeaders(provider: CustomHeadersProvider): void;
|
|
2310
|
-
removeCustomHeaders(): void;
|
|
2311
2270
|
getEventManager(): EventManager | undefined;
|
|
2312
2271
|
getStorageManager(): StorageManager | null;
|
|
2313
2272
|
getPerformanceHandler(): PerformanceHandler | null;
|
|
@@ -2481,8 +2440,6 @@ declare const tracelog: {
|
|
|
2481
2440
|
off: <K extends keyof EmitterMap>(event: K, callback: EmitterCallback<EmitterMap[K]>) => void;
|
|
2482
2441
|
setTransformer: typeof setTransformer;
|
|
2483
2442
|
removeTransformer: (hook: TransformerHook) => void;
|
|
2484
|
-
setCustomHeaders: (provider: CustomHeadersProvider) => void;
|
|
2485
|
-
removeCustomHeaders: () => void;
|
|
2486
2443
|
isInitialized: () => boolean;
|
|
2487
2444
|
destroy: () => void;
|
|
2488
2445
|
setQaMode: (enabled: boolean) => void;
|
|
@@ -2490,4 +2447,4 @@ declare const tracelog: {
|
|
|
2490
2447
|
mergeGlobalMetadata: (metadata: Record<string, MetadataType>) => void;
|
|
2491
2448
|
};
|
|
2492
2449
|
|
|
2493
|
-
export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData,
|
|
2450
|
+
export { AppConfigValidationError, type BeforeBatchTransformer, type BeforeSendTransformer, type ClickCoordinates, type ClickData, type ClickTrackingElementData, type Config, type CustomEventData, DEFAULT_SESSION_TIMEOUT, DEFAULT_WEB_VITALS_MODE, type DeviceInfo, DeviceType, type EmitterCallback, EmitterEvent, type EmitterMap, type ErrorData, ErrorType, type EventData, EventType, type EventTypeName, type EventsQueue, InitializationTimeoutError, IntegrationValidationError, MAX_ARRAY_LENGTH, MAX_CUSTOM_EVENT_ARRAY_SIZE, MAX_CUSTOM_EVENT_KEYS, MAX_CUSTOM_EVENT_NAME_LENGTH, MAX_CUSTOM_EVENT_STRING_SIZE, MAX_METADATA_NESTING_DEPTH, MAX_NESTED_OBJECT_KEYS, MAX_STRING_LENGTH, MAX_STRING_LENGTH_IN_ARRAY, type MetadataType, Mode, PII_PATTERNS, type PageViewData, PermanentError, type PersistedEventsQueue, type PrimaryScrollEvent, SamplingRateValidationError, type ScrollData, ScrollDirection, type SecondaryScrollEvent, type SessionEventCounts, SessionTimeoutValidationError, SpecialApiUrl, type State, type TraceLogTestBridge, TraceLogValidationError, type TransformerHook, type TransformerMap, type UTM, type ViewportConfig, type ViewportElement, type ViewportEventData, WEB_VITALS_GOOD_THRESHOLDS, WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS, WEB_VITALS_POOR_THRESHOLDS, type WebVitalType, type WebVitalsData, type WebVitalsMode, getWebVitalsThresholds, isPrimaryScrollEvent, isSecondaryScrollEvent, tracelog };
|
package/dist/public-api.js
CHANGED
|
@@ -556,7 +556,7 @@ var LONG_TASK_THROTTLE_MS = 1e3;
|
|
|
556
556
|
var MAX_NAVIGATION_HISTORY = 50;
|
|
557
557
|
|
|
558
558
|
// package.json
|
|
559
|
-
var version = "2.1.
|
|
559
|
+
var version = "2.1.1";
|
|
560
560
|
|
|
561
561
|
// src/constants/version.constants.ts
|
|
562
562
|
var LIB_VERSION = version;
|
|
@@ -1585,8 +1585,6 @@ var SenderManager = class extends StateManager {
|
|
|
1585
1585
|
integrationId;
|
|
1586
1586
|
apiUrl;
|
|
1587
1587
|
transformers;
|
|
1588
|
-
staticHeaders;
|
|
1589
|
-
customHeadersProvider;
|
|
1590
1588
|
lastPermanentErrorLog = null;
|
|
1591
1589
|
recoveryInProgress = false;
|
|
1592
1590
|
lastMetadataTimestamp = 0;
|
|
@@ -1601,11 +1599,9 @@ var SenderManager = class extends StateManager {
|
|
|
1601
1599
|
* @param integrationId - Optional integration identifier ('saas' or 'custom')
|
|
1602
1600
|
* @param apiUrl - Optional API endpoint URL
|
|
1603
1601
|
* @param transformers - Optional event transformation hooks
|
|
1604
|
-
* @param staticHeaders - Optional static HTTP headers (from config)
|
|
1605
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
1606
1602
|
* @throws Error if integrationId and apiUrl are not both provided or both undefined
|
|
1607
1603
|
*/
|
|
1608
|
-
constructor(storeManager, integrationId, apiUrl, transformers = {}
|
|
1604
|
+
constructor(storeManager, integrationId, apiUrl, transformers = {}) {
|
|
1609
1605
|
super();
|
|
1610
1606
|
if (integrationId && !apiUrl || !integrationId && apiUrl) {
|
|
1611
1607
|
throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
|
|
@@ -1614,8 +1610,6 @@ var SenderManager = class extends StateManager {
|
|
|
1614
1610
|
this.integrationId = integrationId;
|
|
1615
1611
|
this.apiUrl = apiUrl;
|
|
1616
1612
|
this.transformers = transformers;
|
|
1617
|
-
this.staticHeaders = staticHeaders;
|
|
1618
|
-
this.customHeadersProvider = customHeadersProvider;
|
|
1619
1613
|
}
|
|
1620
1614
|
/**
|
|
1621
1615
|
* Get the integration ID for this sender
|
|
@@ -1624,49 +1618,6 @@ var SenderManager = class extends StateManager {
|
|
|
1624
1618
|
getIntegrationId() {
|
|
1625
1619
|
return this.integrationId;
|
|
1626
1620
|
}
|
|
1627
|
-
/**
|
|
1628
|
-
* Sets the custom headers provider callback.
|
|
1629
|
-
* Only applies to 'custom' integration (ignored for 'saas').
|
|
1630
|
-
*
|
|
1631
|
-
* @param provider - Callback function that returns custom headers
|
|
1632
|
-
*/
|
|
1633
|
-
setCustomHeadersProvider(provider) {
|
|
1634
|
-
this.customHeadersProvider = provider;
|
|
1635
|
-
}
|
|
1636
|
-
/**
|
|
1637
|
-
* Removes the custom headers provider callback.
|
|
1638
|
-
*/
|
|
1639
|
-
removeCustomHeadersProvider() {
|
|
1640
|
-
this.customHeadersProvider = void 0;
|
|
1641
|
-
}
|
|
1642
|
-
/**
|
|
1643
|
-
* Builds custom headers by merging static headers with dynamic headers from provider.
|
|
1644
|
-
* Only applies to 'custom' integration (returns empty object for 'saas').
|
|
1645
|
-
*
|
|
1646
|
-
* @returns Merged custom headers object (dynamic headers override static)
|
|
1647
|
-
* @private
|
|
1648
|
-
*/
|
|
1649
|
-
getCustomHeaders() {
|
|
1650
|
-
if (this.integrationId !== "custom") {
|
|
1651
|
-
return {};
|
|
1652
|
-
}
|
|
1653
|
-
let dynamicHeaders = {};
|
|
1654
|
-
if (this.customHeadersProvider) {
|
|
1655
|
-
try {
|
|
1656
|
-
const result = this.customHeadersProvider();
|
|
1657
|
-
if (typeof result === "object" && result !== null && !Array.isArray(result)) {
|
|
1658
|
-
dynamicHeaders = result;
|
|
1659
|
-
} else {
|
|
1660
|
-
log("warn", "Custom headers provider returned invalid value, expected object", {
|
|
1661
|
-
data: { received: typeof result }
|
|
1662
|
-
});
|
|
1663
|
-
}
|
|
1664
|
-
} catch (error) {
|
|
1665
|
-
log("warn", "Custom headers provider threw an error, using static headers only", { error });
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
return { ...this.staticHeaders, ...dynamicHeaders };
|
|
1669
|
-
}
|
|
1670
1621
|
getQueueStorageKey() {
|
|
1671
1622
|
const userId = this.get("userId") || "anonymous";
|
|
1672
1623
|
const baseKey = QUEUE_KEY(userId);
|
|
@@ -1694,11 +1645,6 @@ var SenderManager = class extends StateManager {
|
|
|
1694
1645
|
*
|
|
1695
1646
|
* **Important**: No retry mechanism for failures. Events are NOT persisted.
|
|
1696
1647
|
*
|
|
1697
|
-
* **Custom Headers Limitation**: Custom headers set via `setCustomHeaders()` are NOT applied
|
|
1698
|
-
* to sendBeacon requests due to browser API limitations. The sendBeacon API only supports
|
|
1699
|
-
* Content-Type header via Blob. For scenarios requiring custom headers, ensure async
|
|
1700
|
-
* sends complete before page unload.
|
|
1701
|
-
*
|
|
1702
1648
|
* @param body - Event queue to send
|
|
1703
1649
|
* @returns `true` if send succeeded or was skipped, `false` if failed
|
|
1704
1650
|
*
|
|
@@ -2121,7 +2067,6 @@ var SenderManager = class extends StateManager {
|
|
|
2121
2067
|
controller.abort();
|
|
2122
2068
|
}, REQUEST_TIMEOUT_MS);
|
|
2123
2069
|
try {
|
|
2124
|
-
const customHeaders = this.getCustomHeaders();
|
|
2125
2070
|
const response = await fetch(url, {
|
|
2126
2071
|
method: "POST",
|
|
2127
2072
|
body: payload,
|
|
@@ -2129,8 +2074,7 @@ var SenderManager = class extends StateManager {
|
|
|
2129
2074
|
credentials: "include",
|
|
2130
2075
|
signal: controller.signal,
|
|
2131
2076
|
headers: {
|
|
2132
|
-
"Content-Type": "application/json"
|
|
2133
|
-
...customHeaders
|
|
2077
|
+
"Content-Type": "application/json"
|
|
2134
2078
|
}
|
|
2135
2079
|
});
|
|
2136
2080
|
if (!response.ok) {
|
|
@@ -2592,10 +2536,8 @@ var EventManager = class extends StateManager {
|
|
|
2592
2536
|
* @param storeManager - Storage manager for persistence
|
|
2593
2537
|
* @param emitter - Optional event emitter for local event consumption
|
|
2594
2538
|
* @param transformers - Optional event transformation hooks
|
|
2595
|
-
* @param staticHeaders - Optional static HTTP headers for custom backend (from config)
|
|
2596
|
-
* @param customHeadersProvider - Optional callback for dynamic headers
|
|
2597
2539
|
*/
|
|
2598
|
-
constructor(storeManager, emitter = null, transformers = {}
|
|
2540
|
+
constructor(storeManager, emitter = null, transformers = {}) {
|
|
2599
2541
|
super();
|
|
2600
2542
|
this.emitter = emitter;
|
|
2601
2543
|
this.transformers = transformers;
|
|
@@ -2606,16 +2548,7 @@ var EventManager = class extends StateManager {
|
|
|
2606
2548
|
this.dataSenders.push(new SenderManager(storeManager, "saas", collectApiUrls.saas, transformers));
|
|
2607
2549
|
}
|
|
2608
2550
|
if (collectApiUrls?.custom) {
|
|
2609
|
-
this.dataSenders.push(
|
|
2610
|
-
new SenderManager(
|
|
2611
|
-
storeManager,
|
|
2612
|
-
"custom",
|
|
2613
|
-
collectApiUrls.custom,
|
|
2614
|
-
transformers,
|
|
2615
|
-
staticHeaders,
|
|
2616
|
-
customHeadersProvider
|
|
2617
|
-
)
|
|
2618
|
-
);
|
|
2551
|
+
this.dataSenders.push(new SenderManager(storeManager, "custom", collectApiUrls.custom, transformers));
|
|
2619
2552
|
}
|
|
2620
2553
|
this.saveSessionCountsDebounced = this.debounce((sessionId) => {
|
|
2621
2554
|
this.saveSessionCounts(sessionId);
|
|
@@ -3022,29 +2955,6 @@ var EventManager = class extends StateManager {
|
|
|
3022
2955
|
flushImmediatelySync() {
|
|
3023
2956
|
return this.flushEvents(true);
|
|
3024
2957
|
}
|
|
3025
|
-
/**
|
|
3026
|
-
* Sets the custom headers provider callback for the custom integration.
|
|
3027
|
-
* Only affects requests to custom backend (not TraceLog SaaS).
|
|
3028
|
-
*
|
|
3029
|
-
* @param provider - Callback function that returns custom headers
|
|
3030
|
-
*/
|
|
3031
|
-
setCustomHeadersProvider(provider) {
|
|
3032
|
-
for (const sender of this.dataSenders) {
|
|
3033
|
-
if (sender.getIntegrationId() === "custom") {
|
|
3034
|
-
sender.setCustomHeadersProvider(provider);
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
/**
|
|
3039
|
-
* Removes the custom headers provider callback from the custom integration.
|
|
3040
|
-
*/
|
|
3041
|
-
removeCustomHeadersProvider() {
|
|
3042
|
-
for (const sender of this.dataSenders) {
|
|
3043
|
-
if (sender.getIntegrationId() === "custom") {
|
|
3044
|
-
sender.removeCustomHeadersProvider();
|
|
3045
|
-
}
|
|
3046
|
-
}
|
|
3047
|
-
}
|
|
3048
2958
|
/**
|
|
3049
2959
|
* Returns the current number of events in the main queue.
|
|
3050
2960
|
*
|
|
@@ -6141,7 +6051,6 @@ var App = class extends StateManager {
|
|
|
6141
6051
|
suppressNextScrollTimer = null;
|
|
6142
6052
|
emitter = new Emitter();
|
|
6143
6053
|
transformers = {};
|
|
6144
|
-
customHeadersProvider;
|
|
6145
6054
|
managers = {};
|
|
6146
6055
|
handlers = {};
|
|
6147
6056
|
get initialized() {
|
|
@@ -6161,14 +6070,7 @@ var App = class extends StateManager {
|
|
|
6161
6070
|
this.managers.storage = new StorageManager();
|
|
6162
6071
|
try {
|
|
6163
6072
|
this.setupState(config);
|
|
6164
|
-
|
|
6165
|
-
this.managers.event = new EventManager(
|
|
6166
|
-
this.managers.storage,
|
|
6167
|
-
this.emitter,
|
|
6168
|
-
this.transformers,
|
|
6169
|
-
staticHeaders,
|
|
6170
|
-
this.customHeadersProvider
|
|
6171
|
-
);
|
|
6073
|
+
this.managers.event = new EventManager(this.managers.storage, this.emitter, this.transformers);
|
|
6172
6074
|
this.initializeHandlers();
|
|
6173
6075
|
await this.managers.event.recoverPersistedEvents().catch((error) => {
|
|
6174
6076
|
log("warn", "Failed to recover persisted events", { error });
|
|
@@ -6231,34 +6133,6 @@ var App = class extends StateManager {
|
|
|
6231
6133
|
getTransformer(hook) {
|
|
6232
6134
|
return this.transformers[hook];
|
|
6233
6135
|
}
|
|
6234
|
-
/**
|
|
6235
|
-
* Sets a callback to provide custom HTTP headers for requests to custom backends.
|
|
6236
|
-
* Only applies to custom backend integration (not TraceLog SaaS).
|
|
6237
|
-
*
|
|
6238
|
-
* @param provider - Callback function that returns custom headers
|
|
6239
|
-
* @throws {Error} If provider is not a function
|
|
6240
|
-
* @internal Called from api.setCustomHeaders()
|
|
6241
|
-
*/
|
|
6242
|
-
setCustomHeaders(provider) {
|
|
6243
|
-
if (typeof provider !== "function") {
|
|
6244
|
-
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof provider}`);
|
|
6245
|
-
}
|
|
6246
|
-
this.customHeadersProvider = provider;
|
|
6247
|
-
if (this.managers.event) {
|
|
6248
|
-
this.managers.event.setCustomHeadersProvider(provider);
|
|
6249
|
-
}
|
|
6250
|
-
}
|
|
6251
|
-
/**
|
|
6252
|
-
* Removes the custom headers provider callback.
|
|
6253
|
-
*
|
|
6254
|
-
* @internal Called from api.removeCustomHeaders()
|
|
6255
|
-
*/
|
|
6256
|
-
removeCustomHeaders() {
|
|
6257
|
-
this.customHeadersProvider = void 0;
|
|
6258
|
-
if (this.managers.event) {
|
|
6259
|
-
this.managers.event.removeCustomHeadersProvider();
|
|
6260
|
-
}
|
|
6261
|
-
}
|
|
6262
6136
|
/**
|
|
6263
6137
|
* Destroys the TraceLog instance and cleans up all resources.
|
|
6264
6138
|
*
|
|
@@ -6284,7 +6158,6 @@ var App = class extends StateManager {
|
|
|
6284
6158
|
this.emitter.removeAllListeners();
|
|
6285
6159
|
this.transformers.beforeSend = void 0;
|
|
6286
6160
|
this.transformers.beforeBatch = void 0;
|
|
6287
|
-
this.customHeadersProvider = void 0;
|
|
6288
6161
|
this.set("suppressNextScroll", false);
|
|
6289
6162
|
this.set("sessionId", null);
|
|
6290
6163
|
this.isInitialized = false;
|
|
@@ -6439,7 +6312,6 @@ var App = class extends StateManager {
|
|
|
6439
6312
|
// src/api.ts
|
|
6440
6313
|
var pendingListeners = [];
|
|
6441
6314
|
var pendingTransformers = [];
|
|
6442
|
-
var pendingCustomHeadersProvider = null;
|
|
6443
6315
|
var app = null;
|
|
6444
6316
|
var isInitializing = false;
|
|
6445
6317
|
var isDestroying = false;
|
|
@@ -6474,10 +6346,6 @@ var init = async (config) => {
|
|
|
6474
6346
|
}
|
|
6475
6347
|
});
|
|
6476
6348
|
pendingTransformers.length = 0;
|
|
6477
|
-
if (pendingCustomHeadersProvider) {
|
|
6478
|
-
instance.setCustomHeaders(pendingCustomHeadersProvider);
|
|
6479
|
-
pendingCustomHeadersProvider = null;
|
|
6480
|
-
}
|
|
6481
6349
|
const initPromise = instance.init(validatedConfig);
|
|
6482
6350
|
const timeoutPromise = new Promise((_, reject) => {
|
|
6483
6351
|
setTimeout(() => {
|
|
@@ -6576,35 +6444,6 @@ var removeTransformer = (hook) => {
|
|
|
6576
6444
|
}
|
|
6577
6445
|
app.removeTransformer(hook);
|
|
6578
6446
|
};
|
|
6579
|
-
var setCustomHeaders = (provider) => {
|
|
6580
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
6581
|
-
return;
|
|
6582
|
-
}
|
|
6583
|
-
if (typeof provider !== "function") {
|
|
6584
|
-
throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof provider}`);
|
|
6585
|
-
}
|
|
6586
|
-
if (!app || isInitializing) {
|
|
6587
|
-
pendingCustomHeadersProvider = provider;
|
|
6588
|
-
return;
|
|
6589
|
-
}
|
|
6590
|
-
if (isDestroying) {
|
|
6591
|
-
throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
|
|
6592
|
-
}
|
|
6593
|
-
app.setCustomHeaders(provider);
|
|
6594
|
-
};
|
|
6595
|
-
var removeCustomHeaders = () => {
|
|
6596
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
6597
|
-
return;
|
|
6598
|
-
}
|
|
6599
|
-
if (!app) {
|
|
6600
|
-
pendingCustomHeadersProvider = null;
|
|
6601
|
-
return;
|
|
6602
|
-
}
|
|
6603
|
-
if (isDestroying) {
|
|
6604
|
-
throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
|
|
6605
|
-
}
|
|
6606
|
-
app.removeCustomHeaders();
|
|
6607
|
-
};
|
|
6608
6447
|
var isInitialized = () => {
|
|
6609
6448
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
6610
6449
|
return false;
|
|
@@ -6629,7 +6468,6 @@ var destroy = () => {
|
|
|
6629
6468
|
isInitializing = false;
|
|
6630
6469
|
pendingListeners.length = 0;
|
|
6631
6470
|
pendingTransformers.length = 0;
|
|
6632
|
-
pendingCustomHeadersProvider = null;
|
|
6633
6471
|
if (false) ;
|
|
6634
6472
|
isDestroying = false;
|
|
6635
6473
|
} catch (error) {
|
|
@@ -6637,7 +6475,6 @@ var destroy = () => {
|
|
|
6637
6475
|
isInitializing = false;
|
|
6638
6476
|
pendingListeners.length = 0;
|
|
6639
6477
|
pendingTransformers.length = 0;
|
|
6640
|
-
pendingCustomHeadersProvider = null;
|
|
6641
6478
|
isDestroying = false;
|
|
6642
6479
|
log("warn", "Error during destroy, forced cleanup completed", { error });
|
|
6643
6480
|
}
|
|
@@ -6681,8 +6518,6 @@ var tracelog = {
|
|
|
6681
6518
|
off,
|
|
6682
6519
|
setTransformer,
|
|
6683
6520
|
removeTransformer,
|
|
6684
|
-
setCustomHeaders,
|
|
6685
|
-
removeCustomHeaders,
|
|
6686
6521
|
isInitialized,
|
|
6687
6522
|
destroy,
|
|
6688
6523
|
setQaMode: setQaMode2,
|