@descope/sdk-mixins 0.24.1 → 0.25.0
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/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mixins/flowIdMixin.js +17 -0
- package/dist/cjs/mixins/flowIdMixin.js.map +1 -0
- package/dist/cjs/mixins/telemetryMixin/constants.js +14 -0
- package/dist/cjs/mixins/telemetryMixin/constants.js.map +1 -0
- package/dist/cjs/mixins/telemetryMixin/index.js +8 -0
- package/dist/cjs/mixins/telemetryMixin/index.js.map +1 -0
- package/dist/cjs/mixins/telemetryMixin/telemetryMixin.js +246 -0
- package/dist/cjs/mixins/telemetryMixin/telemetryMixin.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mixins/flowIdMixin.js +15 -0
- package/dist/esm/mixins/flowIdMixin.js.map +1 -0
- package/dist/esm/mixins/telemetryMixin/constants.js +9 -0
- package/dist/esm/mixins/telemetryMixin/constants.js.map +1 -0
- package/dist/esm/mixins/telemetryMixin/index.js +2 -0
- package/dist/esm/mixins/telemetryMixin/index.js.map +1 -0
- package/dist/esm/mixins/telemetryMixin/telemetryMixin.js +244 -0
- package/dist/esm/mixins/telemetryMixin/telemetryMixin.js.map +1 -0
- package/dist/index.d.ts +714 -256
- package/dist/types/index.d.ts +2 -0
- package/dist/types/mixins/baseUrlMixin.d.ts +1 -0
- package/dist/types/mixins/configMixin/configMixin.d.ts +15 -14
- package/dist/types/mixins/configMixin/types.d.ts +27 -0
- package/dist/types/mixins/cookieConfigMixin.d.ts +1 -0
- package/dist/types/mixins/createStateManagementMixin.d.ts +3 -2
- package/dist/types/mixins/createValidateAttributesMixin/createValidateAttributesMixin.d.ts +6 -5
- package/dist/types/mixins/cspNonceMixin.d.ts +6 -5
- package/dist/types/mixins/debuggerMixin/debugger-wc.d.ts +6 -5
- package/dist/types/mixins/debuggerMixin/debuggerMixin.d.ts +9 -8
- package/dist/types/mixins/descopeUiMixin/descopeUiMixin.d.ts +20 -19
- package/dist/types/mixins/fetchWidgetPagesMixin/createFetchWidgetPagesMixin.d.ts +16 -15
- package/dist/types/mixins/flowIdMixin.d.ts +343 -0
- package/dist/types/mixins/flowInputMixin/flowInputMixin.d.ts +42 -41
- package/dist/types/mixins/formMixin.d.ts +3 -2
- package/dist/types/mixins/initElementMixin.d.ts +6 -5
- package/dist/types/mixins/initLifecycleMixin.d.ts +2 -1
- package/dist/types/mixins/injectNpmLibMixin/injectNpmLibMixin.d.ts +3 -2
- package/dist/types/mixins/injectStyleMixin.d.ts +6 -5
- package/dist/types/mixins/localeMixin/localeMixin.d.ts +1 -0
- package/dist/types/mixins/loggerMixin/loggerMixin.d.ts +3 -2
- package/dist/types/mixins/modalMixin/modalMixin.d.ts +24 -23
- package/dist/types/mixins/notificationsMixin/notificationsMixin.d.ts +24 -23
- package/dist/types/mixins/observeAttributesMixin/observeAttributesMixin.d.ts +5 -4
- package/dist/types/mixins/projectIdMixin.d.ts +6 -5
- package/dist/types/mixins/resetMixin.d.ts +7 -6
- package/dist/types/mixins/staticResourcesMixin/staticResourcesMixin.d.ts +11 -10
- package/dist/types/mixins/telemetryMixin/constants.d.ts +4 -0
- package/dist/types/mixins/telemetryMixin/index.d.ts +1 -0
- package/dist/types/mixins/telemetryMixin/telemetryMixin.d.ts +411 -0
- package/dist/types/mixins/tenantIdMixin.d.ts +6 -5
- package/dist/types/mixins/themeMixin/themeMixin.d.ts +41 -40
- package/dist/types/mixins/widgetConfigMixin/widgetConfigMixin.d.ts +15 -14
- package/dist/types/mixins/widgetIdMixin.d.ts +6 -5
- package/package.json +13 -3
package/dist/cjs/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var cookieConfigMixin = require('./mixins/cookieConfigMixin.js');
|
|
|
26
26
|
var injectNpmLibMixin = require('./mixins/injectNpmLibMixin/injectNpmLibMixin.js');
|
|
27
27
|
var injectStyleMixin = require('./mixins/injectStyleMixin.js');
|
|
28
28
|
var cspNonceMixin = require('./mixins/cspNonceMixin.js');
|
|
29
|
+
var telemetryMixin = require('./mixins/telemetryMixin/telemetryMixin.js');
|
|
29
30
|
var flowInputMixin = require('./mixins/flowInputMixin/flowInputMixin.js');
|
|
30
31
|
|
|
31
32
|
|
|
@@ -57,5 +58,6 @@ exports.cookieConfigMixin = cookieConfigMixin.cookieConfigMixin;
|
|
|
57
58
|
exports.injectNpmLibMixin = injectNpmLibMixin.injectNpmLibMixin;
|
|
58
59
|
exports.injectStyleMixin = injectStyleMixin.injectStyleMixin;
|
|
59
60
|
exports.cspNonceMixin = cspNonceMixin.cspNonceMixin;
|
|
61
|
+
exports.telemetryMixin = telemetryMixin.telemetryMixin;
|
|
60
62
|
exports.flowInputMixin = flowInputMixin.flowInputMixin;
|
|
61
63
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sdkHelpers = require('@descope/sdk-helpers');
|
|
4
|
+
var commonValidators = require('./createValidateAttributesMixin/commonValidators.js');
|
|
5
|
+
var createValidateAttributesMixin = require('./createValidateAttributesMixin/createValidateAttributesMixin.js');
|
|
6
|
+
|
|
7
|
+
const flowIdMixin = sdkHelpers.createSingletonMixin((superclass) => {
|
|
8
|
+
const BaseClass = sdkHelpers.compose(createValidateAttributesMixin.createValidateAttributesMixin({ 'flow-id': commonValidators.missingAttrValidator }))(superclass);
|
|
9
|
+
return class FlowIdMixinClass extends BaseClass {
|
|
10
|
+
get flowId() {
|
|
11
|
+
return this.getAttribute('flow-id');
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
exports.flowIdMixin = flowIdMixin;
|
|
17
|
+
//# sourceMappingURL=flowIdMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowIdMixin.js","sources":["../../../src/mixins/flowIdMixin.ts"],"sourcesContent":["import { createSingletonMixin, compose } from '@descope/sdk-helpers';\nimport { missingAttrValidator } from './createValidateAttributesMixin/commonValidators';\nimport { createValidateAttributesMixin } from './createValidateAttributesMixin';\n\nexport const flowIdMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) => {\n const BaseClass = compose(\n createValidateAttributesMixin({ 'flow-id': missingAttrValidator }),\n )(superclass);\n\n return class FlowIdMixinClass extends BaseClass {\n get flowId() {\n return this.getAttribute('flow-id');\n }\n };\n },\n);\n"],"names":["createSingletonMixin","compose","createValidateAttributesMixin","missingAttrValidator"],"mappings":";;;;;;MAIa,WAAW,GAAGA,+BAAoB,CAC7C,CAAqC,UAAa,KAAI;AACpD,IAAA,MAAM,SAAS,GAAGC,kBAAO,CACvBC,2DAA6B,CAAC,EAAE,SAAS,EAAEC,qCAAoB,EAAE,CAAC,CACnE,CAAC,UAAU,CAAC,CAAC;IAEd,OAAO,MAAM,gBAAiB,SAAQ,SAAS,CAAA;AAC7C,QAAA,IAAI,MAAM,GAAA;AACR,YAAA,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;SACrC;KACF,CAAC;AACJ,CAAC;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('../../constants.js');
|
|
4
|
+
|
|
5
|
+
const DEBUG_LOGS_URL_KEY = 'base.debug.logs.url';
|
|
6
|
+
const LOCAL_STORAGE_OVERRIDE = constants.IS_LOCAL_STORAGE && localStorage.getItem(DEBUG_LOGS_URL_KEY);
|
|
7
|
+
const JS_FILE_PATH = 'dist/index.js';
|
|
8
|
+
const DEBUG_LOGS_LIB_NAME = '@descope/debug-logs';
|
|
9
|
+
|
|
10
|
+
exports.DEBUG_LOGS_LIB_NAME = DEBUG_LOGS_LIB_NAME;
|
|
11
|
+
exports.DEBUG_LOGS_URL_KEY = DEBUG_LOGS_URL_KEY;
|
|
12
|
+
exports.JS_FILE_PATH = JS_FILE_PATH;
|
|
13
|
+
exports.LOCAL_STORAGE_OVERRIDE = LOCAL_STORAGE_OVERRIDE;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/mixins/telemetryMixin/constants.ts"],"sourcesContent":["import { IS_LOCAL_STORAGE } from '../../constants';\n\nexport const DEBUG_LOGS_URL_KEY = 'base.debug.logs.url';\nexport const LOCAL_STORAGE_OVERRIDE =\n IS_LOCAL_STORAGE && localStorage.getItem(DEBUG_LOGS_URL_KEY);\nexport const JS_FILE_PATH = 'dist/index.js';\nexport const DEBUG_LOGS_LIB_NAME = '@descope/debug-logs';\n"],"names":["IS_LOCAL_STORAGE"],"mappings":";;;;AAEO,MAAM,kBAAkB,GAAG,sBAAsB;AACjD,MAAM,sBAAsB,GACjCA,0BAAgB,IAAI,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE;AACxD,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,mBAAmB,GAAG;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var sdkHelpers = require('@descope/sdk-helpers');
|
|
5
|
+
var injectNpmLibMixin = require('../injectNpmLibMixin/injectNpmLibMixin.js');
|
|
6
|
+
var loggerMixin = require('../loggerMixin/loggerMixin.js');
|
|
7
|
+
var constants = require('./constants.js');
|
|
8
|
+
var initLifecycleMixin = require('../initLifecycleMixin.js');
|
|
9
|
+
var configMixin = require('../configMixin/configMixin.js');
|
|
10
|
+
var projectIdMixin = require('../projectIdMixin.js');
|
|
11
|
+
var flowIdMixin = require('../flowIdMixin.js');
|
|
12
|
+
|
|
13
|
+
// Human-readable delay formatter. Picks the largest unit that fits so logs
|
|
14
|
+
// read as "30 minutes" / "2 days" instead of "1800 seconds" / "172800 seconds".
|
|
15
|
+
function formatDelay(ms) {
|
|
16
|
+
const s = Math.floor(ms / 1000);
|
|
17
|
+
if (s < 60)
|
|
18
|
+
return `${s} seconds`;
|
|
19
|
+
const m = Math.floor(s / 60);
|
|
20
|
+
if (m < 60)
|
|
21
|
+
return `${m} minutes`;
|
|
22
|
+
const h = Math.floor(m / 60);
|
|
23
|
+
if (h < 24)
|
|
24
|
+
return `${h} hours`;
|
|
25
|
+
return `${Math.floor(h / 24)} days`;
|
|
26
|
+
}
|
|
27
|
+
const telemetryMixin = sdkHelpers.createSingletonMixin((superclass) => {
|
|
28
|
+
var _TelemetryMixinClass_instances, _TelemetryMixinClass_telemetryManager, _TelemetryMixinClass_telemetryInitialized, _TelemetryMixinClass_expirationTimeoutId, _TelemetryMixinClass_initializeTelemetry, _TelemetryMixinClass_scheduleExpirationShutdown, _TelemetryMixinClass_shutdownTelemetry, _TelemetryMixinClass_isRumConfigComplete, _TelemetryMixinClass_getTelemetryConfig, _TelemetryMixinClass_resolveCapture, _TelemetryMixinClass_telemetryReady, _a;
|
|
29
|
+
const BaseClass = sdkHelpers.compose(injectNpmLibMixin.injectNpmLibMixin, loggerMixin.loggerMixin, initLifecycleMixin.initLifecycleMixin, configMixin.configMixin, projectIdMixin.projectIdMixin, flowIdMixin.flowIdMixin)(superclass);
|
|
30
|
+
return _a = class TelemetryMixinClass extends BaseClass {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
_TelemetryMixinClass_instances.add(this);
|
|
34
|
+
_TelemetryMixinClass_telemetryManager.set(this, null);
|
|
35
|
+
_TelemetryMixinClass_telemetryInitialized.set(this, false);
|
|
36
|
+
_TelemetryMixinClass_expirationTimeoutId.set(this, null);
|
|
37
|
+
_TelemetryMixinClass_telemetryReady.set(this, null);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the telemetry manager instance (for advanced usage)
|
|
41
|
+
*/
|
|
42
|
+
get telemetryManager() {
|
|
43
|
+
return tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f");
|
|
44
|
+
}
|
|
45
|
+
updateTelemetryContext(context) {
|
|
46
|
+
if (tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f")) {
|
|
47
|
+
try {
|
|
48
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f").updateContext(context);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
// Fail silently - telemetry errors should never break the web-component
|
|
52
|
+
this.logger.error('Error updating telemetry context:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async init() {
|
|
57
|
+
var _b;
|
|
58
|
+
// super.init() FIRST so downstream mixins finish setup and the
|
|
59
|
+
// SDK's user-facing paint isn't blocked on our CDN load or the
|
|
60
|
+
// `this.config` fetch. Kick off telemetry as its OWN promise chain
|
|
61
|
+
// stored on the instance. NOT awaited here — tests using
|
|
62
|
+
// jest.useFakeTimers can't advance the fetch chain, and blocking on
|
|
63
|
+
// it would freeze the render. Failures are caught so telemetry
|
|
64
|
+
// errors can never break the SDK's boot.
|
|
65
|
+
await ((_b = super.init) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
66
|
+
const sdkVersion = this.sdkVersion || '1.0.0';
|
|
67
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryReady, tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_getTelemetryConfig).call(this)
|
|
68
|
+
.then((config) => tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_initializeTelemetry).call(this, config, {
|
|
69
|
+
projectId: this.projectId,
|
|
70
|
+
flowId: this.flowId,
|
|
71
|
+
sdkVersion,
|
|
72
|
+
}))
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
this.logger.error('Failed to start telemetry:', error);
|
|
75
|
+
}), "f");
|
|
76
|
+
}
|
|
77
|
+
// Test hook: resolves once telemetry init has settled (success or
|
|
78
|
+
// caught error). Not part of the public SDK contract.
|
|
79
|
+
get telemetryReady() {
|
|
80
|
+
var _b;
|
|
81
|
+
return (_b = tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryReady, "f")) !== null && _b !== void 0 ? _b : Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
disconnectedCallback() {
|
|
84
|
+
var _b;
|
|
85
|
+
(_b = super.disconnectedCallback) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
86
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_shutdownTelemetry).call(this);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
_TelemetryMixinClass_telemetryManager = new WeakMap(),
|
|
90
|
+
_TelemetryMixinClass_telemetryInitialized = new WeakMap(),
|
|
91
|
+
_TelemetryMixinClass_expirationTimeoutId = new WeakMap(),
|
|
92
|
+
_TelemetryMixinClass_telemetryReady = new WeakMap(),
|
|
93
|
+
_TelemetryMixinClass_instances = new WeakSet(),
|
|
94
|
+
_TelemetryMixinClass_initializeTelemetry = async function _TelemetryMixinClass_initializeTelemetry(config, context) {
|
|
95
|
+
if (!(config === null || config === void 0 ? void 0 : config.enabled)) {
|
|
96
|
+
this.logger.debug('Telemetry is disabled, skipping initialization');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryInitialized, "f")) {
|
|
100
|
+
this.logger.debug('Telemetry already initialized');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (config.expiration && Date.now() >= config.expiration) {
|
|
104
|
+
this.logger.info(`Telemetry expiration time has passed (${new Date(config.expiration).toISOString()}), skipping initialization`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
this.logger.debug('Initializing telemetry...');
|
|
109
|
+
const version = config.version || 'latest';
|
|
110
|
+
await this.injectNpmLib(constants.DEBUG_LOGS_LIB_NAME, version, constants.JS_FILE_PATH, [
|
|
111
|
+
constants.LOCAL_STORAGE_OVERRIDE,
|
|
112
|
+
]);
|
|
113
|
+
const TelemetryManager = window.DescopeDebugLogs;
|
|
114
|
+
if (!TelemetryManager) {
|
|
115
|
+
throw new Error('DescopeDebugLogs not found after loading @descope/debug-logs. ' +
|
|
116
|
+
'This likely means the UMD build failed to load from CDN.');
|
|
117
|
+
}
|
|
118
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryManager, new TelemetryManager({
|
|
119
|
+
enabled: true,
|
|
120
|
+
rumConfig: config.rumConfig,
|
|
121
|
+
capture: config.capture,
|
|
122
|
+
}, {
|
|
123
|
+
projectId: context.projectId,
|
|
124
|
+
flowId: context.flowId,
|
|
125
|
+
version: context.sdkVersion || '1.0.0',
|
|
126
|
+
}, this.logger), "f");
|
|
127
|
+
// The TelemetryManager constructor swallows RUM-client init errors
|
|
128
|
+
// (it sets an internal failure flag instead of throwing). Confirm it
|
|
129
|
+
// actually came up before flagging success - otherwise we'd log
|
|
130
|
+
// "initialized" and, because #initializeTelemetry early-returns once
|
|
131
|
+
// #telemetryInitialized is true, permanently block any retry.
|
|
132
|
+
if (!tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f").isReady()) {
|
|
133
|
+
this.logger.error('Telemetry manager failed to initialize (RUM client not ready)');
|
|
134
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryManager, null, "f");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryInitialized, true, "f");
|
|
138
|
+
this.logger.info('Telemetry initialized successfully');
|
|
139
|
+
if (config.expiration) {
|
|
140
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_scheduleExpirationShutdown).call(this, config.expiration);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.logger.error('Failed to initialize telemetry:', error);
|
|
145
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryInitialized, false, "f");
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
_TelemetryMixinClass_scheduleExpirationShutdown = function _TelemetryMixinClass_scheduleExpirationShutdown(expirationMs) {
|
|
149
|
+
const now = Date.now();
|
|
150
|
+
const timeUntilExpiration = expirationMs - now;
|
|
151
|
+
if (timeUntilExpiration <= 0) {
|
|
152
|
+
this.logger.info('Telemetry expiration time reached, shutting down');
|
|
153
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_shutdownTelemetry).call(this);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// setTimeout's max safe delay is ~24.8 days; cap at 1 day so a
|
|
157
|
+
// mis-set expiration far in the future doesn't underflow to 0.
|
|
158
|
+
const MAX_TIMEOUT = 86400000;
|
|
159
|
+
const delay = Math.min(timeUntilExpiration, MAX_TIMEOUT);
|
|
160
|
+
if (timeUntilExpiration > MAX_TIMEOUT) {
|
|
161
|
+
this.logger.warn(`Telemetry expiration is beyond maximum timeout (${formatDelay(timeUntilExpiration)}). Setting to maximum.`);
|
|
162
|
+
}
|
|
163
|
+
this.logger.info(`Telemetry will expire at ${new Date(expirationMs).toISOString()} (in ${formatDelay(delay)})`);
|
|
164
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_expirationTimeoutId, setTimeout(() => {
|
|
165
|
+
this.logger.info('Telemetry expiration time reached, shutting down');
|
|
166
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_shutdownTelemetry).call(this);
|
|
167
|
+
}, delay), "f");
|
|
168
|
+
},
|
|
169
|
+
_TelemetryMixinClass_shutdownTelemetry = function _TelemetryMixinClass_shutdownTelemetry() {
|
|
170
|
+
if (tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_expirationTimeoutId, "f")) {
|
|
171
|
+
clearTimeout(tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_expirationTimeoutId, "f"));
|
|
172
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_expirationTimeoutId, null, "f");
|
|
173
|
+
}
|
|
174
|
+
if (tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f")) {
|
|
175
|
+
try {
|
|
176
|
+
this.logger.debug('Shutting down telemetry...');
|
|
177
|
+
tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_telemetryManager, "f").shutdown();
|
|
178
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryManager, null, "f");
|
|
179
|
+
tslib.__classPrivateFieldSet(this, _TelemetryMixinClass_telemetryInitialized, false, "f");
|
|
180
|
+
this.logger.info('Telemetry shutdown complete');
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
this.logger.error('Error shutting down telemetry:', error);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
_TelemetryMixinClass_isRumConfigComplete = function _TelemetryMixinClass_isRumConfigComplete(rumConfig) {
|
|
188
|
+
return Boolean((rumConfig === null || rumConfig === void 0 ? void 0 : rumConfig.applicationId) &&
|
|
189
|
+
(rumConfig === null || rumConfig === void 0 ? void 0 : rumConfig.identityPoolId) &&
|
|
190
|
+
(rumConfig === null || rumConfig === void 0 ? void 0 : rumConfig.region));
|
|
191
|
+
},
|
|
192
|
+
_TelemetryMixinClass_getTelemetryConfig = async function _TelemetryMixinClass_getTelemetryConfig() {
|
|
193
|
+
var _b;
|
|
194
|
+
// Prefer telemetry config shipped by the backend in the project's
|
|
195
|
+
// config.json. Otherwise, fall back to values from
|
|
196
|
+
// packages/sdks/web-component/.env (DESCOPE_TELEMETRY_* — substituted
|
|
197
|
+
// at WC build time via rollup.config.app.mjs). We MERGE rather than
|
|
198
|
+
// replace so the backend can override individual fields (e.g. just
|
|
199
|
+
// expiration) without re-stating every credential.
|
|
200
|
+
// The backend ships telemetry nested under `projectConfig` in config.json.
|
|
201
|
+
const resolvedConfig = await this.config;
|
|
202
|
+
const beTelemetry = (_b = resolvedConfig === null || resolvedConfig === void 0 ? void 0 : resolvedConfig.projectConfig) === null || _b === void 0 ? void 0 : _b.telemetry;
|
|
203
|
+
const sampleRate = Number(process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE);
|
|
204
|
+
const fallback = {
|
|
205
|
+
enabled: (process.env.DESCOPE_TELEMETRY_ENABLED || '').toLowerCase() ===
|
|
206
|
+
'true',
|
|
207
|
+
rumConfig: Object.assign({ applicationId: process.env.DESCOPE_TELEMETRY_APPLICATION_ID || '', identityPoolId: process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID || '', region: process.env.DESCOPE_TELEMETRY_REGION || '', sessionSampleRate: Number.isFinite(sampleRate) && sampleRate > 0 ? sampleRate : 1 }, (process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN && {
|
|
208
|
+
guestRoleArn: process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN,
|
|
209
|
+
})),
|
|
210
|
+
};
|
|
211
|
+
const cfg = Object.assign(Object.assign(Object.assign({}, fallback), beTelemetry), { rumConfig: Object.assign(Object.assign({}, fallback.rumConfig), beTelemetry === null || beTelemetry === void 0 ? void 0 : beTelemetry.rumConfig), capture: tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_resolveCapture).call(this, beTelemetry === null || beTelemetry === void 0 ? void 0 : beTelemetry.capture) });
|
|
212
|
+
// If enabled but a required RUM credential is missing (empty from both
|
|
213
|
+
// the BE block and the .env fallback), disable rather than hand AwsRum
|
|
214
|
+
// an empty applicationId/identityPoolId/region — that would either
|
|
215
|
+
// throw at construction or silently no-op with no session recorded.
|
|
216
|
+
if (cfg.enabled && !tslib.__classPrivateFieldGet(this, _TelemetryMixinClass_instances, "m", _TelemetryMixinClass_isRumConfigComplete).call(this, cfg.rumConfig)) {
|
|
217
|
+
this.logger.warn('Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization.');
|
|
218
|
+
cfg.enabled = false;
|
|
219
|
+
}
|
|
220
|
+
// Safety cap: when no backend telemetry config is present at all,
|
|
221
|
+
// end the session after 5 minutes so dev sessions don't leak. Once
|
|
222
|
+
// the backend owns the config it controls expiration explicitly.
|
|
223
|
+
if (!beTelemetry) {
|
|
224
|
+
cfg.expiration = Date.now() + 5 * 60 * 1000;
|
|
225
|
+
this.logger.debug('No backend telemetry config present; applying a 5-minute safety cap on the session.');
|
|
226
|
+
}
|
|
227
|
+
return cfg;
|
|
228
|
+
},
|
|
229
|
+
_TelemetryMixinClass_resolveCapture = function _TelemetryMixinClass_resolveCapture(beCapture) {
|
|
230
|
+
// `network: true` = capture ALL network traffic. We used to default to
|
|
231
|
+
// `{ urlFilter: [] }` but the two network paths had inverted semantics
|
|
232
|
+
// for the empty array: the custom NetworkPlugin treated it as
|
|
233
|
+
// "capture everything", while AWS RUM's built-in HTTP telemetry
|
|
234
|
+
// treated it as "capture nothing". `true` is consistent — both paths
|
|
235
|
+
// capture all by default. BE can override with a narrow filter later.
|
|
236
|
+
const domSetting = beCapture === null || beCapture === void 0 ? void 0 : beCapture.dom;
|
|
237
|
+
if (domSetting === false) {
|
|
238
|
+
return Object.assign(Object.assign({ console: true, network: true, navigation: true }, beCapture), { dom: false });
|
|
239
|
+
}
|
|
240
|
+
return Object.assign(Object.assign({ console: true, network: true, navigation: true }, beCapture), { dom: Object.assign(Object.assign({ throttleMs: 2000 }, (typeof domSetting === 'object' ? domSetting : {})), { rootElement: this.shadowRoot }) });
|
|
241
|
+
},
|
|
242
|
+
_a;
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
exports.telemetryMixin = telemetryMixin;
|
|
246
|
+
//# sourceMappingURL=telemetryMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetryMixin.js","sources":["../../../../src/mixins/telemetryMixin/telemetryMixin.ts"],"sourcesContent":["import { compose, createSingletonMixin } from '@descope/sdk-helpers';\nimport { injectNpmLibMixin } from '../injectNpmLibMixin';\nimport { loggerMixin } from '../loggerMixin';\nimport { TelemetryConfig } from '../configMixin/types';\nimport {\n DEBUG_LOGS_LIB_NAME,\n JS_FILE_PATH,\n LOCAL_STORAGE_OVERRIDE,\n} from './constants';\nimport { initLifecycleMixin } from '../initLifecycleMixin';\nimport { configMixin } from '../configMixin';\nimport { projectIdMixin } from '../projectIdMixin';\nimport { flowIdMixin } from '../flowIdMixin';\n\n// Human-readable delay formatter. Picks the largest unit that fits so logs\n// read as \"30 minutes\" / \"2 days\" instead of \"1800 seconds\" / \"172800 seconds\".\nfunction formatDelay(ms: number): string {\n const s = Math.floor(ms / 1000);\n if (s < 60) return `${s} seconds`;\n const m = Math.floor(s / 60);\n if (m < 60) return `${m} minutes`;\n const h = Math.floor(m / 60);\n if (h < 24) return `${h} hours`;\n return `${Math.floor(h / 24)} days`;\n}\n\n// Extend global window to include DescopeDebugLogs (UMD global)\ndeclare global {\n interface Window {\n DescopeDebugLogs?: new (config: any, context: any, logger?: any) => any;\n }\n}\n\nexport const telemetryMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) => {\n const BaseClass = compose(\n injectNpmLibMixin,\n loggerMixin,\n initLifecycleMixin,\n configMixin,\n projectIdMixin,\n flowIdMixin,\n )(superclass);\n\n return class TelemetryMixinClass extends BaseClass {\n #telemetryManager: any = null;\n #telemetryInitialized = false;\n #expirationTimeoutId: NodeJS.Timeout | null = null;\n\n async #initializeTelemetry(\n config: TelemetryConfig,\n context: {\n projectId: string;\n flowId?: string;\n sdkVersion?: string;\n },\n ) {\n if (!config?.enabled) {\n this.logger.debug('Telemetry is disabled, skipping initialization');\n return;\n }\n\n if (this.#telemetryInitialized) {\n this.logger.debug('Telemetry already initialized');\n return;\n }\n\n if (config.expiration && Date.now() >= config.expiration) {\n this.logger.info(\n `Telemetry expiration time has passed (${new Date(\n config.expiration,\n ).toISOString()}), skipping initialization`,\n );\n return;\n }\n\n try {\n this.logger.debug('Initializing telemetry...');\n const version = config.version || 'latest';\n\n await this.injectNpmLib(DEBUG_LOGS_LIB_NAME, version, JS_FILE_PATH, [\n LOCAL_STORAGE_OVERRIDE,\n ]);\n\n const TelemetryManager = window.DescopeDebugLogs;\n if (!TelemetryManager) {\n throw new Error(\n 'DescopeDebugLogs not found after loading @descope/debug-logs. ' +\n 'This likely means the UMD build failed to load from CDN.',\n );\n }\n\n this.#telemetryManager = new TelemetryManager(\n {\n enabled: true,\n rumConfig: config.rumConfig,\n capture: config.capture,\n },\n {\n projectId: context.projectId,\n flowId: context.flowId,\n version: context.sdkVersion || '1.0.0',\n },\n this.logger,\n );\n\n // The TelemetryManager constructor swallows RUM-client init errors\n // (it sets an internal failure flag instead of throwing). Confirm it\n // actually came up before flagging success - otherwise we'd log\n // \"initialized\" and, because #initializeTelemetry early-returns once\n // #telemetryInitialized is true, permanently block any retry.\n if (!this.#telemetryManager.isReady()) {\n this.logger.error(\n 'Telemetry manager failed to initialize (RUM client not ready)',\n );\n this.#telemetryManager = null;\n return;\n }\n\n this.#telemetryInitialized = true;\n\n this.logger.info('Telemetry initialized successfully');\n\n if (config.expiration) {\n this.#scheduleExpirationShutdown(config.expiration);\n }\n } catch (error) {\n this.logger.error('Failed to initialize telemetry:', error);\n this.#telemetryInitialized = false;\n }\n }\n\n /**\n * Schedule automatic telemetry shutdown at expiration time\n * @param expirationMs - Unix timestamp in milliseconds when telemetry should expire\n */\n #scheduleExpirationShutdown(expirationMs: number) {\n const now = Date.now();\n const timeUntilExpiration = expirationMs - now;\n\n if (timeUntilExpiration <= 0) {\n this.logger.info('Telemetry expiration time reached, shutting down');\n this.#shutdownTelemetry();\n return;\n }\n\n // setTimeout's max safe delay is ~24.8 days; cap at 1 day so a\n // mis-set expiration far in the future doesn't underflow to 0.\n const MAX_TIMEOUT = 86400000;\n const delay = Math.min(timeUntilExpiration, MAX_TIMEOUT);\n\n if (timeUntilExpiration > MAX_TIMEOUT) {\n this.logger.warn(\n `Telemetry expiration is beyond maximum timeout (${formatDelay(\n timeUntilExpiration,\n )}). Setting to maximum.`,\n );\n }\n\n this.logger.info(\n `Telemetry will expire at ${new Date(\n expirationMs,\n ).toISOString()} (in ${formatDelay(delay)})`,\n );\n\n this.#expirationTimeoutId = setTimeout(() => {\n this.logger.info('Telemetry expiration time reached, shutting down');\n this.#shutdownTelemetry();\n }, delay);\n }\n\n #shutdownTelemetry() {\n if (this.#expirationTimeoutId) {\n clearTimeout(this.#expirationTimeoutId);\n this.#expirationTimeoutId = null;\n }\n\n if (this.#telemetryManager) {\n try {\n this.logger.debug('Shutting down telemetry...');\n this.#telemetryManager.shutdown();\n this.#telemetryManager = null;\n this.#telemetryInitialized = false;\n this.logger.info('Telemetry shutdown complete');\n } catch (error) {\n this.logger.error('Error shutting down telemetry:', error);\n }\n }\n }\n\n /**\n * Get the telemetry manager instance (for advanced usage)\n */\n get telemetryManager() {\n return this.#telemetryManager;\n }\n\n // A RUM client needs applicationId, identityPoolId and region. If any is\n // missing, AwsRum either throws at construction or silently records\n // nothing, so we treat the config as unusable.\n #isRumConfigComplete(rumConfig?: TelemetryConfig['rumConfig']): boolean {\n return Boolean(\n rumConfig?.applicationId &&\n rumConfig?.identityPoolId &&\n rumConfig?.region,\n );\n }\n\n async #getTelemetryConfig(): Promise<TelemetryConfig> {\n // Prefer telemetry config shipped by the backend in the project's\n // config.json. Otherwise, fall back to values from\n // packages/sdks/web-component/.env (DESCOPE_TELEMETRY_* — substituted\n // at WC build time via rollup.config.app.mjs). We MERGE rather than\n // replace so the backend can override individual fields (e.g. just\n // expiration) without re-stating every credential.\n // The backend ships telemetry nested under `projectConfig` in config.json.\n const resolvedConfig = await this.config;\n const beTelemetry = resolvedConfig?.projectConfig?.telemetry;\n\n const sampleRate = Number(\n process.env.DESCOPE_TELEMETRY_SESSION_SAMPLE_RATE,\n );\n\n const fallback: NonNullable<TelemetryConfig> = {\n enabled:\n (process.env.DESCOPE_TELEMETRY_ENABLED || '').toLowerCase() ===\n 'true',\n rumConfig: {\n applicationId: process.env.DESCOPE_TELEMETRY_APPLICATION_ID || '',\n identityPoolId:\n process.env.DESCOPE_TELEMETRY_IDENTITY_POOL_ID || '',\n region: process.env.DESCOPE_TELEMETRY_REGION || '',\n sessionSampleRate:\n Number.isFinite(sampleRate) && sampleRate > 0 ? sampleRate : 1,\n ...(process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN && {\n guestRoleArn: process.env.DESCOPE_TELEMETRY_GUEST_ROLE_ARN,\n }),\n },\n };\n\n const cfg: NonNullable<TelemetryConfig> = {\n ...fallback,\n ...beTelemetry,\n rumConfig: {\n ...fallback.rumConfig,\n ...beTelemetry?.rumConfig,\n },\n capture: this.#resolveCapture(beTelemetry?.capture),\n };\n\n // If enabled but a required RUM credential is missing (empty from both\n // the BE block and the .env fallback), disable rather than hand AwsRum\n // an empty applicationId/identityPoolId/region — that would either\n // throw at construction or silently no-op with no session recorded.\n if (cfg.enabled && !this.#isRumConfigComplete(cfg.rumConfig)) {\n this.logger.warn(\n 'Telemetry enabled but rumConfig is incomplete (applicationId/identityPoolId/region required). Skipping initialization.',\n );\n cfg.enabled = false;\n }\n\n // Safety cap: when no backend telemetry config is present at all,\n // end the session after 5 minutes so dev sessions don't leak. Once\n // the backend owns the config it controls expiration explicitly.\n if (!beTelemetry) {\n cfg.expiration = Date.now() + 5 * 60 * 1000;\n this.logger.debug(\n 'No backend telemetry config present; applying a 5-minute safety cap on the session.',\n );\n }\n\n return cfg;\n }\n\n /**\n * The backend can't serialize a DOM element reference, so we always\n * inject this.shadowRoot here. Respect an explicit `dom: false`.\n */\n #resolveCapture(\n beCapture: NonNullable<TelemetryConfig>['capture'],\n ): NonNullable<TelemetryConfig>['capture'] {\n // `network: true` = capture ALL network traffic. We used to default to\n // `{ urlFilter: [] }` but the two network paths had inverted semantics\n // for the empty array: the custom NetworkPlugin treated it as\n // \"capture everything\", while AWS RUM's built-in HTTP telemetry\n // treated it as \"capture nothing\". `true` is consistent — both paths\n // capture all by default. BE can override with a narrow filter later.\n const domSetting = beCapture?.dom;\n if (domSetting === false) {\n return {\n console: true,\n network: true,\n navigation: true,\n ...beCapture,\n dom: false,\n };\n }\n return {\n console: true,\n network: true,\n navigation: true,\n ...beCapture,\n dom: {\n throttleMs: 2000,\n ...(typeof domSetting === 'object' ? domSetting : {}),\n rootElement: this.shadowRoot as any,\n },\n };\n }\n\n updateTelemetryContext(context: Record<string, any>) {\n if (this.#telemetryManager) {\n try {\n this.#telemetryManager.updateContext(context);\n } catch (error) {\n // Fail silently - telemetry errors should never break the web-component\n this.logger.error('Error updating telemetry context:', error);\n }\n }\n }\n\n #telemetryReady: Promise<void> | null = null;\n\n async init() {\n // super.init() FIRST so downstream mixins finish setup and the\n // SDK's user-facing paint isn't blocked on our CDN load or the\n // `this.config` fetch. Kick off telemetry as its OWN promise chain\n // stored on the instance. NOT awaited here — tests using\n // jest.useFakeTimers can't advance the fetch chain, and blocking on\n // it would freeze the render. Failures are caught so telemetry\n // errors can never break the SDK's boot.\n await super.init?.();\n const sdkVersion = (this as any).sdkVersion || '1.0.0';\n this.#telemetryReady = this.#getTelemetryConfig()\n .then((config) =>\n this.#initializeTelemetry(config as any, {\n projectId: this.projectId,\n flowId: this.flowId,\n sdkVersion,\n }),\n )\n .catch((error) => {\n this.logger.error('Failed to start telemetry:', error);\n });\n }\n\n // Test hook: resolves once telemetry init has settled (success or\n // caught error). Not part of the public SDK contract.\n get telemetryReady(): Promise<void> {\n return this.#telemetryReady ?? Promise.resolve();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback?.();\n this.#shutdownTelemetry();\n }\n };\n },\n);\n"],"names":["createSingletonMixin","compose","injectNpmLibMixin","loggerMixin","initLifecycleMixin","configMixin","projectIdMixin","flowIdMixin","__classPrivateFieldGet","__classPrivateFieldSet","DEBUG_LOGS_LIB_NAME","JS_FILE_PATH","LOCAL_STORAGE_OVERRIDE"],"mappings":";;;;;;;;;;;;AAcA;AACA;AACA,SAAS,WAAW,CAAC,EAAU,EAAA;IAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,CAAA,EAAG,CAAC,CAAA,QAAA,CAAU,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,CAAA,EAAG,CAAC,CAAA,QAAA,CAAU,CAAC;IAClC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,CAAA,EAAG,CAAC,CAAA,MAAA,CAAQ,CAAC;IAChC,OAAO,CAAA,EAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAA,KAAA,CAAO,CAAC;AACtC,CAAC;MASY,cAAc,GAAGA,+BAAoB,CAChD,CAAqC,UAAa,KAAI;;AACpD,IAAA,MAAM,SAAS,GAAGC,kBAAO,CACvBC,mCAAiB,EACjBC,uBAAW,EACXC,qCAAkB,EAClBC,uBAAW,EACXC,6BAAc,EACdC,uBAAW,CACZ,CAAC,UAAU,CAAC,CAAC;IAEd,OAAO,EAAA,GAAA,MAAM,mBAAoB,SAAQ,S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|
|
24
24
|
export { injectNpmLibMixin } from './mixins/injectNpmLibMixin/injectNpmLibMixin.js';
|
|
25
25
|
export { injectStyleMixin } from './mixins/injectStyleMixin.js';
|
|
26
26
|
export { cspNonceMixin } from './mixins/cspNonceMixin.js';
|
|
27
|
+
export { telemetryMixin } from './mixins/telemetryMixin/telemetryMixin.js';
|
|
27
28
|
export { flowInputMixin } from './mixins/flowInputMixin/flowInputMixin.js';
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createSingletonMixin, compose } from '@descope/sdk-helpers';
|
|
2
|
+
import { missingAttrValidator } from './createValidateAttributesMixin/commonValidators.js';
|
|
3
|
+
import { createValidateAttributesMixin } from './createValidateAttributesMixin/createValidateAttributesMixin.js';
|
|
4
|
+
|
|
5
|
+
const flowIdMixin = createSingletonMixin((superclass) => {
|
|
6
|
+
const BaseClass = compose(createValidateAttributesMixin({ 'flow-id': missingAttrValidator }))(superclass);
|
|
7
|
+
return class FlowIdMixinClass extends BaseClass {
|
|
8
|
+
get flowId() {
|
|
9
|
+
return this.getAttribute('flow-id');
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { flowIdMixin };
|
|
15
|
+
//# sourceMappingURL=flowIdMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowIdMixin.js","sources":["../../../src/mixins/flowIdMixin.ts"],"sourcesContent":["import { createSingletonMixin, compose } from '@descope/sdk-helpers';\nimport { missingAttrValidator } from './createValidateAttributesMixin/commonValidators';\nimport { createValidateAttributesMixin } from './createValidateAttributesMixin';\n\nexport const flowIdMixin = createSingletonMixin(\n <T extends CustomElementConstructor>(superclass: T) => {\n const BaseClass = compose(\n createValidateAttributesMixin({ 'flow-id': missingAttrValidator }),\n )(superclass);\n\n return class FlowIdMixinClass extends BaseClass {\n get flowId() {\n return this.getAttribute('flow-id');\n }\n };\n },\n);\n"],"names":[],"mappings":";;;;MAIa,WAAW,GAAG,oBAAoB,CAC7C,CAAqC,UAAa,KAAI;AACpD,IAAA,MAAM,SAAS,GAAG,OAAO,CACvB,6BAA6B,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC,CACnE,CAAC,UAAU,CAAC,CAAC;IAEd,OAAO,MAAM,gBAAiB,SAAQ,SAAS,CAAA;AAC7C,QAAA,IAAI,MAAM,GAAA;AACR,YAAA,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;SACrC;KACF,CAAC;AACJ,CAAC;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IS_LOCAL_STORAGE } from '../../constants.js';
|
|
2
|
+
|
|
3
|
+
const DEBUG_LOGS_URL_KEY = 'base.debug.logs.url';
|
|
4
|
+
const LOCAL_STORAGE_OVERRIDE = IS_LOCAL_STORAGE && localStorage.getItem(DEBUG_LOGS_URL_KEY);
|
|
5
|
+
const JS_FILE_PATH = 'dist/index.js';
|
|
6
|
+
const DEBUG_LOGS_LIB_NAME = '@descope/debug-logs';
|
|
7
|
+
|
|
8
|
+
export { DEBUG_LOGS_LIB_NAME, DEBUG_LOGS_URL_KEY, JS_FILE_PATH, LOCAL_STORAGE_OVERRIDE };
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/mixins/telemetryMixin/constants.ts"],"sourcesContent":["import { IS_LOCAL_STORAGE } from '../../constants';\n\nexport const DEBUG_LOGS_URL_KEY = 'base.debug.logs.url';\nexport const LOCAL_STORAGE_OVERRIDE =\n IS_LOCAL_STORAGE && localStorage.getItem(DEBUG_LOGS_URL_KEY);\nexport const JS_FILE_PATH = 'dist/index.js';\nexport const DEBUG_LOGS_LIB_NAME = '@descope/debug-logs';\n"],"names":[],"mappings":";;AAEO,MAAM,kBAAkB,GAAG,sBAAsB;AACjD,MAAM,sBAAsB,GACjC,gBAAgB,IAAI,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE;AACxD,MAAM,YAAY,GAAG,gBAAgB;AACrC,MAAM,mBAAmB,GAAG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|