@sentry/browser 10.21.0-alpha.0 → 10.21.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/build/npm/cjs/index.js +0 -2
- package/build/npm/cjs/index.js.map +1 -1
- package/build/npm/cjs/integrations/httpcontext.js +0 -2
- package/build/npm/cjs/integrations/httpcontext.js.map +1 -1
- package/build/npm/cjs/profiling/integration.js +108 -46
- package/build/npm/cjs/profiling/integration.js.map +1 -1
- package/build/npm/cjs/profiling/lifecycleMode/traceLifecycleProfiler.js +343 -0
- package/build/npm/cjs/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
- package/build/npm/cjs/profiling/startProfileForSpan.js +16 -0
- package/build/npm/cjs/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/cjs/profiling/utils.js +251 -14
- package/build/npm/cjs/profiling/utils.js.map +1 -1
- package/build/npm/cjs/tracing/request.js +0 -1
- package/build/npm/cjs/tracing/request.js.map +1 -1
- package/build/npm/esm/index.js +0 -1
- package/build/npm/esm/index.js.map +1 -1
- package/build/npm/esm/integrations/httpcontext.js +0 -2
- package/build/npm/esm/integrations/httpcontext.js.map +1 -1
- package/build/npm/esm/package.json +1 -1
- package/build/npm/esm/profiling/integration.js +110 -48
- package/build/npm/esm/profiling/integration.js.map +1 -1
- package/build/npm/esm/profiling/lifecycleMode/traceLifecycleProfiler.js +341 -0
- package/build/npm/esm/profiling/lifecycleMode/traceLifecycleProfiler.js.map +1 -0
- package/build/npm/esm/profiling/startProfileForSpan.js +16 -0
- package/build/npm/esm/profiling/startProfileForSpan.js.map +1 -1
- package/build/npm/esm/profiling/utils.js +245 -15
- package/build/npm/esm/profiling/utils.js.map +1 -1
- package/build/npm/esm/tracing/request.js +0 -1
- package/build/npm/esm/tracing/request.js.map +1 -1
- package/build/npm/types/feedbackAsync.d.ts +3 -9
- package/build/npm/types/feedbackAsync.d.ts.map +1 -1
- package/build/npm/types/feedbackSync.d.ts +3 -9
- package/build/npm/types/feedbackSync.d.ts.map +1 -1
- package/build/npm/types/helpers.d.ts +2 -29
- package/build/npm/types/helpers.d.ts.map +1 -1
- package/build/npm/types/index.d.ts +0 -1
- package/build/npm/types/index.d.ts.map +1 -1
- package/build/npm/types/integrations/featureFlags/growthbook/integration.d.ts.map +1 -1
- package/build/npm/types/integrations/httpcontext.d.ts.map +1 -1
- package/build/npm/types/integrations/webWorker.d.ts.map +1 -1
- package/build/npm/types/profiling/integration.d.ts.map +1 -1
- package/build/npm/types/profiling/lifecycleMode/traceLifecycleProfiler.d.ts +70 -0
- package/build/npm/types/profiling/lifecycleMode/traceLifecycleProfiler.d.ts.map +1 -0
- package/build/npm/types/profiling/startProfileForSpan.d.ts.map +1 -1
- package/build/npm/types/profiling/utils.d.ts +32 -2
- package/build/npm/types/profiling/utils.d.ts.map +1 -1
- package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
- package/build/npm/types/tracing/request.d.ts.map +1 -1
- package/build/npm/types-ts3.8/feedbackAsync.d.ts +3 -9
- package/build/npm/types-ts3.8/feedbackSync.d.ts +3 -9
- package/build/npm/types-ts3.8/helpers.d.ts +2 -29
- package/build/npm/types-ts3.8/index.d.ts +0 -1
- package/build/npm/types-ts3.8/profiling/lifecycleMode/traceLifecycleProfiler.d.ts +70 -0
- package/build/npm/types-ts3.8/profiling/utils.d.ts +32 -2
- package/package.json +7 -7
- package/build/npm/cjs/integrations/spanstreaming.js +0 -252
- package/build/npm/cjs/integrations/spanstreaming.js.map +0 -1
- package/build/npm/esm/integrations/spanstreaming.js +0 -250
- package/build/npm/esm/integrations/spanstreaming.js.map +0 -1
- package/build/npm/types/integrations/spanstreaming.d.ts +0 -5
- package/build/npm/types/integrations/spanstreaming.d.ts.map +0 -1
- package/build/npm/types-ts3.8/integrations/spanstreaming.d.ts +0 -5
package/build/npm/cjs/index.js
CHANGED
|
@@ -39,7 +39,6 @@ const integration$4 = require('./integrations/featureFlags/growthbook/integratio
|
|
|
39
39
|
const integration$5 = require('./integrations/featureFlags/statsig/integration.js');
|
|
40
40
|
const diagnoseSdk = require('./diagnose-sdk.js');
|
|
41
41
|
const webWorker = require('./integrations/webWorker.js');
|
|
42
|
-
const spanstreaming = require('./integrations/spanstreaming.js');
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
|
|
@@ -177,5 +176,4 @@ exports.statsigIntegration = integration$5.statsigIntegration;
|
|
|
177
176
|
exports.diagnoseSdkConnectivity = diagnoseSdk.diagnoseSdkConnectivity;
|
|
178
177
|
exports.registerWebWorker = webWorker.registerWebWorker;
|
|
179
178
|
exports.webWorkerIntegration = webWorker.webWorkerIntegration;
|
|
180
|
-
exports.spanStreamingIntegration = spanstreaming.spanStreamingIntegration;
|
|
181
179
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -10,8 +10,6 @@ const helpers = require('../helpers.js');
|
|
|
10
10
|
const httpContextIntegration = core.defineIntegration(() => {
|
|
11
11
|
return {
|
|
12
12
|
name: 'HttpContext',
|
|
13
|
-
// TODO (span-streaming): probably fine to omit this in favour of us globally
|
|
14
|
-
// already adding request context data but should double-check this
|
|
15
13
|
preprocessEvent(event) {
|
|
16
14
|
// if none of the information we want exists, don't bother
|
|
17
15
|
if (!helpers.WINDOW.navigator && !helpers.WINDOW.location && !helpers.WINDOW.document) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpcontext.js","sources":["../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { getHttpRequestData, WINDOW } from '../helpers';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext',\n
|
|
1
|
+
{"version":3,"file":"httpcontext.js","sources":["../../../../src/integrations/httpcontext.ts"],"sourcesContent":["import { defineIntegration } from '@sentry/core';\nimport { getHttpRequestData, WINDOW } from '../helpers';\n\n/**\n * Collects information about HTTP request headers and\n * attaches them to the event.\n */\nexport const httpContextIntegration = defineIntegration(() => {\n return {\n name: 'HttpContext',\n preprocessEvent(event) {\n // if none of the information we want exists, don't bother\n if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {\n return;\n }\n\n const reqData = getHttpRequestData();\n const headers = {\n ...reqData.headers,\n ...event.request?.headers,\n };\n\n event.request = {\n ...reqData,\n ...event.request,\n headers,\n };\n },\n };\n});\n"],"names":["defineIntegration","WINDOW","getHttpRequestData"],"mappings":";;;;;AAGA;AACA;AACA;AACA;MACa,sBAAA,GAAyBA,sBAAiB,CAAC,MAAM;AAC9D,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,aAAa;AACvB,IAAI,eAAe,CAAC,KAAK,EAAE;AAC3B;AACA,MAAM,IAAI,CAACC,cAAM,CAAC,aAAa,CAACA,cAAM,CAAC,YAAY,CAACA,cAAM,CAAC,QAAQ,EAAE;AACrE,QAAQ;AACR;;AAEA,MAAM,MAAM,OAAA,GAAUC,0BAAkB,EAAE;AAC1C,MAAM,MAAM,UAAU;AACtB,QAAQ,GAAG,OAAO,CAAC,OAAO;AAC1B,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO;AACjC,OAAO;;AAEP,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,GAAG,OAAO;AAClB,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,QAAQ,OAAO;AACf,OAAO;AACP,KAAK;AACL,GAAG;AACH,CAAC;;;;"}
|
|
@@ -2,6 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
4
|
const debugBuild = require('../debug-build.js');
|
|
5
|
+
const helpers = require('../helpers.js');
|
|
6
|
+
const traceLifecycleProfiler = require('./lifecycleMode/traceLifecycleProfiler.js');
|
|
5
7
|
const startProfileForSpan = require('./startProfileForSpan.js');
|
|
6
8
|
const utils = require('./utils.js');
|
|
7
9
|
|
|
@@ -11,73 +13,133 @@ const _browserProfilingIntegration = (() => {
|
|
|
11
13
|
return {
|
|
12
14
|
name: INTEGRATION_NAME,
|
|
13
15
|
setup(client) {
|
|
16
|
+
const options = client.getOptions() ;
|
|
17
|
+
|
|
18
|
+
if (!utils.hasLegacyProfiling(options) && !options.profileLifecycle) {
|
|
19
|
+
// Set default lifecycle mode
|
|
20
|
+
options.profileLifecycle = 'manual';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (utils.hasLegacyProfiling(options) && !options.profilesSampleRate) {
|
|
24
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Profiling disabled, no profiling options found.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
const activeSpan = core.getActiveSpan();
|
|
15
29
|
const rootSpan = activeSpan && core.getRootSpan(activeSpan);
|
|
16
30
|
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
if (utils.hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {
|
|
32
|
+
debugBuild.DEBUG_BUILD &&
|
|
33
|
+
core.debug.warn(
|
|
34
|
+
'[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',
|
|
35
|
+
);
|
|
21
36
|
}
|
|
22
37
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
38
|
+
// UI PROFILING (Profiling V2)
|
|
39
|
+
if (!utils.hasLegacyProfiling(options)) {
|
|
40
|
+
const sessionSampled = utils.shouldProfileSession(options);
|
|
41
|
+
if (!sessionSampled) {
|
|
42
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');
|
|
26
43
|
}
|
|
27
|
-
});
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
// if not profiles are in queue, there is nothing to add to the envelope.
|
|
31
|
-
if (!utils.getActiveProfilesCount()) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
45
|
+
const lifecycleMode = options.profileLifecycle;
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
if (lifecycleMode === 'trace') {
|
|
48
|
+
if (!core.hasSpansEnabled(options)) {
|
|
49
|
+
debugBuild.DEBUG_BUILD &&
|
|
50
|
+
core.debug.warn(
|
|
51
|
+
"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.",
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
39
55
|
|
|
40
|
-
|
|
56
|
+
const traceLifecycleProfiler$1 = new traceLifecycleProfiler.BrowserTraceLifecycleProfiler();
|
|
57
|
+
traceLifecycleProfiler$1.initialize(client, sessionSampled);
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
// If there is an active, sampled root span already, notify the profiler
|
|
60
|
+
if (rootSpan) {
|
|
61
|
+
traceLifecycleProfiler$1.notifyRootSpanActive(rootSpan);
|
|
62
|
+
}
|
|
46
63
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
// In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.
|
|
65
|
+
helpers.WINDOW.setTimeout(() => {
|
|
66
|
+
const laterActiveSpan = core.getActiveSpan();
|
|
67
|
+
const laterRootSpan = laterActiveSpan && core.getRootSpan(laterActiveSpan);
|
|
68
|
+
if (laterRootSpan) {
|
|
69
|
+
traceLifecycleProfiler$1.notifyRootSpanActive(laterRootSpan);
|
|
70
|
+
}
|
|
71
|
+
}, 0);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
// LEGACY PROFILING (v1)
|
|
75
|
+
if (rootSpan && utils.isAutomatedPageLoadSpan(rootSpan)) {
|
|
76
|
+
if (utils.shouldProfileSpanLegacy(rootSpan)) {
|
|
77
|
+
startProfileForSpan.startProfileForSpan(rootSpan);
|
|
50
78
|
}
|
|
79
|
+
}
|
|
51
80
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
client.on('spanStart', (span) => {
|
|
82
|
+
if (span === core.getRootSpan(span) && utils.shouldProfileSpanLegacy(span)) {
|
|
83
|
+
startProfileForSpan.startProfileForSpan(span);
|
|
55
84
|
}
|
|
85
|
+
});
|
|
56
86
|
|
|
57
|
-
|
|
58
|
-
if
|
|
59
|
-
|
|
87
|
+
client.on('beforeEnvelope', (envelope) => {
|
|
88
|
+
// if not profiles are in queue, there is nothing to add to the envelope.
|
|
89
|
+
if (!utils.getActiveProfilesCount()) {
|
|
90
|
+
return;
|
|
60
91
|
}
|
|
61
92
|
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
|
|
65
|
-
continue;
|
|
93
|
+
const profiledTransactionEvents = utils.findProfiledTransactionsFromEnvelope(envelope);
|
|
94
|
+
if (!profiledTransactionEvents.length) {
|
|
95
|
+
return;
|
|
66
96
|
}
|
|
67
97
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
const profilesToAddToEnvelope = [];
|
|
99
|
+
|
|
100
|
+
for (const profiledTransaction of profiledTransactionEvents) {
|
|
101
|
+
const context = profiledTransaction?.contexts;
|
|
102
|
+
const profile_id = context?.profile?.['profile_id'];
|
|
103
|
+
const start_timestamp = context?.profile?.['start_timestamp'];
|
|
104
|
+
|
|
105
|
+
if (typeof profile_id !== 'string') {
|
|
106
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] cannot find profile for a span without a profile context');
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!profile_id) {
|
|
111
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] cannot find profile for a span without a profile context');
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Remove the profile from the span context before sending, relay will take care of the rest.
|
|
116
|
+
if (context?.profile) {
|
|
117
|
+
delete context.profile;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const profile = utils.takeProfileFromGlobalCache(profile_id);
|
|
121
|
+
if (!profile) {
|
|
122
|
+
debugBuild.DEBUG_BUILD && core.debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const profileEvent = utils.createProfilingEvent(
|
|
127
|
+
profile_id,
|
|
128
|
+
start_timestamp ,
|
|
129
|
+
profile,
|
|
130
|
+
profiledTransaction ,
|
|
131
|
+
);
|
|
132
|
+
if (profileEvent) {
|
|
133
|
+
profilesToAddToEnvelope.push(profileEvent);
|
|
134
|
+
}
|
|
76
135
|
}
|
|
77
|
-
}
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
|
|
137
|
+
utils.addProfilesToEnvelope(envelope , profilesToAddToEnvelope);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
processEvent(event) {
|
|
142
|
+
return utils.attachProfiledThreadToEvent(event);
|
|
81
143
|
},
|
|
82
144
|
};
|
|
83
145
|
}) ;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n isAutomatedPageLoadSpan,\n
|
|
1
|
+
{"version":3,"file":"integration.js","sources":["../../../../src/profiling/integration.ts"],"sourcesContent":["import type { EventEnvelope, IntegrationFn, Profile, Span } from '@sentry/core';\nimport { debug, defineIntegration, getActiveSpan, getRootSpan, hasSpansEnabled } from '@sentry/core';\nimport type { BrowserOptions } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { WINDOW } from '../helpers';\nimport { BrowserTraceLifecycleProfiler } from './lifecycleMode/traceLifecycleProfiler';\nimport { startProfileForSpan } from './startProfileForSpan';\nimport type { ProfiledEvent } from './utils';\nimport {\n addProfilesToEnvelope,\n attachProfiledThreadToEvent,\n createProfilingEvent,\n findProfiledTransactionsFromEnvelope,\n getActiveProfilesCount,\n hasLegacyProfiling,\n isAutomatedPageLoadSpan,\n shouldProfileSession,\n shouldProfileSpanLegacy,\n takeProfileFromGlobalCache,\n} from './utils';\n\nconst INTEGRATION_NAME = 'BrowserProfiling';\n\nconst _browserProfilingIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options = client.getOptions() as BrowserOptions;\n\n if (!hasLegacyProfiling(options) && !options.profileLifecycle) {\n // Set default lifecycle mode\n options.profileLifecycle = 'manual';\n }\n\n if (hasLegacyProfiling(options) && !options.profilesSampleRate) {\n DEBUG_BUILD && debug.log('[Profiling] Profiling disabled, no profiling options found.');\n return;\n }\n\n const activeSpan = getActiveSpan();\n const rootSpan = activeSpan && getRootSpan(activeSpan);\n\n if (hasLegacyProfiling(options) && options.profileSessionSampleRate !== undefined) {\n DEBUG_BUILD &&\n debug.warn(\n '[Profiling] Both legacy profiling (`profilesSampleRate`) and UI profiling settings are defined. `profileSessionSampleRate` has no effect when legacy profiling is enabled.',\n );\n }\n\n // UI PROFILING (Profiling V2)\n if (!hasLegacyProfiling(options)) {\n const sessionSampled = shouldProfileSession(options);\n if (!sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled. Skipping lifecycle profiler initialization.');\n }\n\n const lifecycleMode = options.profileLifecycle;\n\n if (lifecycleMode === 'trace') {\n if (!hasSpansEnabled(options)) {\n DEBUG_BUILD &&\n debug.warn(\n \"[Profiling] `profileLifecycle` is 'trace' but tracing is disabled. Set a `tracesSampleRate` or `tracesSampler` to enable span tracing.\",\n );\n return;\n }\n\n const traceLifecycleProfiler = new BrowserTraceLifecycleProfiler();\n traceLifecycleProfiler.initialize(client, sessionSampled);\n\n // If there is an active, sampled root span already, notify the profiler\n if (rootSpan) {\n traceLifecycleProfiler.notifyRootSpanActive(rootSpan);\n }\n\n // In case rootSpan is created slightly after setup -> schedule microtask to re-check and notify.\n WINDOW.setTimeout(() => {\n const laterActiveSpan = getActiveSpan();\n const laterRootSpan = laterActiveSpan && getRootSpan(laterActiveSpan);\n if (laterRootSpan) {\n traceLifecycleProfiler.notifyRootSpanActive(laterRootSpan);\n }\n }, 0);\n }\n } else {\n // LEGACY PROFILING (v1)\n if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {\n if (shouldProfileSpanLegacy(rootSpan)) {\n startProfileForSpan(rootSpan);\n }\n }\n\n client.on('spanStart', (span: Span) => {\n if (span === getRootSpan(span) && shouldProfileSpanLegacy(span)) {\n startProfileForSpan(span);\n }\n });\n\n client.on('beforeEnvelope', (envelope): void => {\n // if not profiles are in queue, there is nothing to add to the envelope.\n if (!getActiveProfilesCount()) {\n return;\n }\n\n const profiledTransactionEvents = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactionEvents.length) {\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n\n for (const profiledTransaction of profiledTransactionEvents) {\n const context = profiledTransaction?.contexts;\n const profile_id = context?.profile?.['profile_id'];\n const start_timestamp = context?.profile?.['start_timestamp'];\n\n if (typeof profile_id !== 'string') {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n if (!profile_id) {\n DEBUG_BUILD && debug.log('[Profiling] cannot find profile for a span without a profile context');\n continue;\n }\n\n // Remove the profile from the span context before sending, relay will take care of the rest.\n if (context?.profile) {\n delete context.profile;\n }\n\n const profile = takeProfileFromGlobalCache(profile_id);\n if (!profile) {\n DEBUG_BUILD && debug.log(`[Profiling] Could not retrieve profile for span: ${profile_id}`);\n continue;\n }\n\n const profileEvent = createProfilingEvent(\n profile_id,\n start_timestamp as number | undefined,\n profile,\n profiledTransaction as ProfiledEvent,\n );\n if (profileEvent) {\n profilesToAddToEnvelope.push(profileEvent);\n }\n }\n\n addProfilesToEnvelope(envelope as EventEnvelope, profilesToAddToEnvelope);\n });\n }\n },\n processEvent(event) {\n return attachProfiledThreadToEvent(event);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);\n"],"names":["hasLegacyProfiling","DEBUG_BUILD","debug","getActiveSpan","getRootSpan","shouldProfileSession","hasSpansEnabled","traceLifecycleProfiler","BrowserTraceLifecycleProfiler","WINDOW","isAutomatedPageLoadSpan","shouldProfileSpanLegacy","startProfileForSpan","getActiveProfilesCount","findProfiledTransactionsFromEnvelope","takeProfileFromGlobalCache","createProfilingEvent","addProfilesToEnvelope","attachProfiledThreadToEvent","defineIntegration"],"mappings":";;;;;;;;;AAqBA,MAAM,gBAAA,GAAmB,kBAAkB;;AAE3C,MAAM,4BAAA,IAAgC,MAAM;AAC5C,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,OAAA,GAAU,MAAM,CAAC,UAAU,EAAC;;AAExC,MAAM,IAAI,CAACA,wBAAkB,CAA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D,YAAY,MAAM,kBAAkB,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAAC;;AAEzE,YAAY,IAAI,OAAO,UAAA,KAAe,QAAQ,EAAE;AAChD,cAAcb,0BAAeC,UAAK,CAAC,GAAG,CAAC,sEAAsE,CAAC;AAC9G,cAAc;AACd;;AAEA,YAAY,IAAI,CAAC,UAAU,EAAE;AAC7B,cAAcD,0BAAeC,UAAK,CAAC,GAAG,CAAC,sEAAsE,CAAC;AAC9G,cAAc;AACd;;AAEA;AACA,YAAY,IAAI,OAAO,EAAE,OAAO,EAAE;AAClC,cAAc,OAAO,OAAO,CAAC,OAAO;AACpC;;AAEA,YAAY,MAAM,OAAA,GAAUa,gCAA0B,CAAC,UAAU,CAAC;AAClE,YAAY,IAAI,CAAC,OAAO,EAAE;AAC1B,cAAcd,sBAAA,IAAeC,UAAK,CAAC,GAAG,CAAC,CAAC,iDAAiD,EAAE,UAAU,CAAC,CAAA,CAAA;AACA,cAAA;AACA;;AAEA,YAAA,MAAA,YAAA,GAAAc,0BAAA;AACA,cAAA,UAAA;AACA,cAAA,eAAA;AACA,cAAA,OAAA;AACA,cAAA,mBAAA;AACA,aAAA;AACA,YAAA,IAAA,YAAA,EAAA;AACA,cAAA,uBAAA,CAAA,IAAA,CAAA,YAAA,CAAA;AACA;AACA;;AAEA,UAAAC,2BAAA,CAAA,QAAA,GAAA,uBAAA,CAAA;AACA,SAAA,CAAA;AACA;AACA,KAAA;AACA,IAAA,YAAA,CAAA,KAAA,EAAA;AACA,MAAA,OAAAC,iCAAA,CAAA,KAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,2BAAA,GAAAC,sBAAA,CAAA,4BAAA;;;;"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const debugBuild = require('../../debug-build.js');
|
|
5
|
+
const utils = require('../utils.js');
|
|
6
|
+
|
|
7
|
+
const CHUNK_INTERVAL_MS = 60000; // 1 minute
|
|
8
|
+
// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)
|
|
9
|
+
const MAX_ROOT_SPAN_PROFILE_MS = 300000; // 5 minutes
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Browser trace-lifecycle profiler (UI Profiling / Profiling V2):
|
|
13
|
+
* - Starts when the first sampled root span starts
|
|
14
|
+
* - Stops when the last sampled root span ends
|
|
15
|
+
* - While running, periodically stops and restarts the JS self-profiling API to collect chunks
|
|
16
|
+
*
|
|
17
|
+
* Profiles are emitted as standalone `profile_chunk` envelopes either when:
|
|
18
|
+
* - there are no more sampled root spans, or
|
|
19
|
+
* - the 60s chunk timer elapses while profiling is running.
|
|
20
|
+
*/
|
|
21
|
+
class BrowserTraceLifecycleProfiler {
|
|
22
|
+
|
|
23
|
+
// For keeping track of active root spans
|
|
24
|
+
|
|
25
|
+
// ID for Profiler session
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
this._client = undefined;
|
|
29
|
+
this._profiler = undefined;
|
|
30
|
+
this._chunkTimer = undefined;
|
|
31
|
+
this._activeRootSpanIds = new Set();
|
|
32
|
+
this._rootSpanTimeouts = new Map();
|
|
33
|
+
this._profilerId = undefined;
|
|
34
|
+
this._isRunning = false;
|
|
35
|
+
this._sessionSampled = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the profiler with client and session sampling decision computed by the integration.
|
|
40
|
+
*/
|
|
41
|
+
initialize(client, sessionSampled) {
|
|
42
|
+
// One Profiler ID per profiling session (user session)
|
|
43
|
+
this._profilerId = core.uuid4();
|
|
44
|
+
|
|
45
|
+
debugBuild.DEBUG_BUILD && core.debug.log("[Profiling] Initializing profiler (lifecycle='trace').");
|
|
46
|
+
|
|
47
|
+
this._client = client;
|
|
48
|
+
this._sessionSampled = sessionSampled;
|
|
49
|
+
|
|
50
|
+
client.on('spanStart', span => {
|
|
51
|
+
if (!this._sessionSampled) {
|
|
52
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Session not sampled because of negative sampling decision.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (span !== core.getRootSpan(span)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// Only count sampled root spans
|
|
59
|
+
if (!span.isRecording()) {
|
|
60
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Discarding profile because root span was not sampled.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Matching root spans with profiles
|
|
65
|
+
core.getGlobalScope().setContext('profile', {
|
|
66
|
+
profiler_id: this._profilerId,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const spanId = span.spanContext().spanId;
|
|
70
|
+
if (!spanId) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (this._activeRootSpanIds.has(spanId)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this._activeRootSpanIds.add(spanId);
|
|
78
|
+
const rootSpanCount = this._activeRootSpanIds.size;
|
|
79
|
+
|
|
80
|
+
const timeout = setTimeout(() => {
|
|
81
|
+
this._onRootSpanTimeout(spanId);
|
|
82
|
+
}, MAX_ROOT_SPAN_PROFILE_MS);
|
|
83
|
+
this._rootSpanTimeouts.set(spanId, timeout);
|
|
84
|
+
|
|
85
|
+
if (rootSpanCount === 1) {
|
|
86
|
+
debugBuild.DEBUG_BUILD &&
|
|
87
|
+
core.debug.log(
|
|
88
|
+
`[Profiling] Root span with ID ${spanId} started. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
this.start();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
client.on('spanEnd', span => {
|
|
96
|
+
if (!this._sessionSampled) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const spanId = span.spanContext().spanId;
|
|
101
|
+
if (!spanId || !this._activeRootSpanIds.has(spanId)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this._activeRootSpanIds.delete(spanId);
|
|
106
|
+
const rootSpanCount = this._activeRootSpanIds.size;
|
|
107
|
+
|
|
108
|
+
debugBuild.DEBUG_BUILD &&
|
|
109
|
+
core.debug.log(
|
|
110
|
+
`[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,
|
|
111
|
+
);
|
|
112
|
+
if (rootSpanCount === 0) {
|
|
113
|
+
this._collectCurrentChunk().catch(e => {
|
|
114
|
+
debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk on `spanEnd`:', e);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this.stop();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Handle an already-active root span at integration setup time.
|
|
124
|
+
*/
|
|
125
|
+
notifyRootSpanActive(rootSpan) {
|
|
126
|
+
if (!this._sessionSampled) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const spanId = rootSpan.spanContext().spanId;
|
|
131
|
+
if (!spanId || this._activeRootSpanIds.has(spanId)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._activeRootSpanIds.add(spanId);
|
|
136
|
+
|
|
137
|
+
const rootSpanCount = this._activeRootSpanIds.size;
|
|
138
|
+
|
|
139
|
+
if (rootSpanCount === 1) {
|
|
140
|
+
debugBuild.DEBUG_BUILD &&
|
|
141
|
+
core.debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);
|
|
142
|
+
|
|
143
|
+
this.start();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Start profiling if not already running.
|
|
149
|
+
*/
|
|
150
|
+
start() {
|
|
151
|
+
if (this._isRunning) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this._isRunning = true;
|
|
155
|
+
|
|
156
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Started profiling with profile ID:', this._profilerId);
|
|
157
|
+
|
|
158
|
+
this._startProfilerInstance();
|
|
159
|
+
|
|
160
|
+
if (!this._profiler) {
|
|
161
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Stopping trace lifecycle profiling.');
|
|
162
|
+
this._resetProfilerInfo();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this._startPeriodicChunking();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Stop profiling; final chunk will be collected and sent.
|
|
171
|
+
*/
|
|
172
|
+
stop() {
|
|
173
|
+
if (!this._isRunning) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this._isRunning = false;
|
|
178
|
+
if (this._chunkTimer) {
|
|
179
|
+
clearTimeout(this._chunkTimer);
|
|
180
|
+
this._chunkTimer = undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this._clearAllRootSpanTimeouts();
|
|
184
|
+
|
|
185
|
+
// Collect whatever was currently recording
|
|
186
|
+
this._collectCurrentChunk().catch(e => {
|
|
187
|
+
debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Resets profiling information from scope and resets running state
|
|
193
|
+
*/
|
|
194
|
+
_resetProfilerInfo() {
|
|
195
|
+
this._isRunning = false;
|
|
196
|
+
core.getGlobalScope().setContext('profile', {});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Clear and reset all per-root-span timeouts.
|
|
201
|
+
*/
|
|
202
|
+
_clearAllRootSpanTimeouts() {
|
|
203
|
+
this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));
|
|
204
|
+
this._rootSpanTimeouts.clear();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Start a profiler instance if needed.
|
|
209
|
+
*/
|
|
210
|
+
_startProfilerInstance() {
|
|
211
|
+
if (this._profiler?.stopped === false) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const profiler = utils.startJSSelfProfile();
|
|
215
|
+
if (!profiler) {
|
|
216
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Failed to start JS Profiler in trace lifecycle.');
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this._profiler = profiler;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Schedule the next 60s chunk while running.
|
|
224
|
+
* Each tick collects a chunk and restarts the profiler.
|
|
225
|
+
* A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.
|
|
226
|
+
*/
|
|
227
|
+
_startPeriodicChunking() {
|
|
228
|
+
if (!this._isRunning) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
this._chunkTimer = setTimeout(() => {
|
|
233
|
+
this._collectCurrentChunk().catch(e => {
|
|
234
|
+
debugBuild.DEBUG_BUILD && core.debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
if (this._isRunning) {
|
|
238
|
+
this._startProfilerInstance();
|
|
239
|
+
|
|
240
|
+
if (!this._profiler) {
|
|
241
|
+
// If restart failed, stop scheduling further chunks and reset context.
|
|
242
|
+
this._resetProfilerInfo();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this._startPeriodicChunking();
|
|
247
|
+
}
|
|
248
|
+
}, CHUNK_INTERVAL_MS);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.
|
|
253
|
+
* If this was the last active root span, collect the current chunk and stop profiling.
|
|
254
|
+
*/
|
|
255
|
+
_onRootSpanTimeout(rootSpanId) {
|
|
256
|
+
// If span already ended, ignore
|
|
257
|
+
if (!this._rootSpanTimeouts.has(rootSpanId)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
this._rootSpanTimeouts.delete(rootSpanId);
|
|
261
|
+
|
|
262
|
+
if (!this._activeRootSpanIds.has(rootSpanId)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
debugBuild.DEBUG_BUILD &&
|
|
267
|
+
core.debug.log(
|
|
268
|
+
`[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \`.end()\`.`,
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
this._activeRootSpanIds.delete(rootSpanId);
|
|
272
|
+
|
|
273
|
+
const rootSpanCount = this._activeRootSpanIds.size;
|
|
274
|
+
if (rootSpanCount === 0) {
|
|
275
|
+
this.stop();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Stop the current profiler, convert and send a profile chunk.
|
|
281
|
+
*/
|
|
282
|
+
async _collectCurrentChunk() {
|
|
283
|
+
const prevProfiler = this._profiler;
|
|
284
|
+
this._profiler = undefined;
|
|
285
|
+
|
|
286
|
+
if (!prevProfiler) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
const profile = await prevProfiler.stop();
|
|
292
|
+
|
|
293
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
294
|
+
const chunk = utils.createProfileChunkPayload(profile, this._client, this._profilerId);
|
|
295
|
+
|
|
296
|
+
// Validate chunk before sending
|
|
297
|
+
const validationReturn = utils.validateProfileChunk(chunk);
|
|
298
|
+
if ('reason' in validationReturn) {
|
|
299
|
+
debugBuild.DEBUG_BUILD &&
|
|
300
|
+
core.debug.log(
|
|
301
|
+
'[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',
|
|
302
|
+
validationReturn.reason,
|
|
303
|
+
);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
this._sendProfileChunk(chunk);
|
|
308
|
+
|
|
309
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Collected browser profile chunk.');
|
|
310
|
+
} catch (e) {
|
|
311
|
+
debugBuild.DEBUG_BUILD && core.debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Send a profile chunk as a standalone envelope.
|
|
317
|
+
*/
|
|
318
|
+
_sendProfileChunk(chunk) {
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
320
|
+
const client = this._client;
|
|
321
|
+
|
|
322
|
+
const sdkInfo = core.getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());
|
|
323
|
+
const dsn = client.getDsn();
|
|
324
|
+
const tunnel = client.getOptions().tunnel;
|
|
325
|
+
|
|
326
|
+
const envelope = core.createEnvelope(
|
|
327
|
+
{
|
|
328
|
+
event_id: core.uuid4(),
|
|
329
|
+
sent_at: new Date().toISOString(),
|
|
330
|
+
...(sdkInfo && { sdk: sdkInfo }),
|
|
331
|
+
...(!!tunnel && dsn && { dsn: core.dsnToString(dsn) }),
|
|
332
|
+
},
|
|
333
|
+
[[{ type: 'profile_chunk' }, chunk]],
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
client.sendEnvelope(envelope).then(null, reason => {
|
|
337
|
+
debugBuild.DEBUG_BUILD && core.debug.error('Error while sending profile chunk envelope:', reason);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
exports.BrowserTraceLifecycleProfiler = BrowserTraceLifecycleProfiler;
|
|
343
|
+
//# sourceMappingURL=traceLifecycleProfiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceLifecycleProfiler.js","sources":["../../../../../src/profiling/lifecycleMode/traceLifecycleProfiler.ts"],"sourcesContent":["import type { Client, ProfileChunk, Span } from '@sentry/core';\nimport {\n type ProfileChunkEnvelope,\n createEnvelope,\n debug,\n dsnToString,\n getGlobalScope,\n getRootSpan,\n getSdkMetadataForEnvelopeHeader,\n uuid4,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type { JSSelfProfiler } from '../jsSelfProfiling';\nimport { createProfileChunkPayload, startJSSelfProfile, validateProfileChunk } from '../utils';\n\nconst CHUNK_INTERVAL_MS = 60_000; // 1 minute\n// Maximum length for trace lifecycle profiling per root span (e.g. if spanEnd never fires)\nconst MAX_ROOT_SPAN_PROFILE_MS = 300_000; // 5 minutes\n\n/**\n * Browser trace-lifecycle profiler (UI Profiling / Profiling V2):\n * - Starts when the first sampled root span starts\n * - Stops when the last sampled root span ends\n * - While running, periodically stops and restarts the JS self-profiling API to collect chunks\n *\n * Profiles are emitted as standalone `profile_chunk` envelopes either when:\n * - there are no more sampled root spans, or\n * - the 60s chunk timer elapses while profiling is running.\n */\nexport class BrowserTraceLifecycleProfiler {\n private _client: Client | undefined;\n private _profiler: JSSelfProfiler | undefined;\n private _chunkTimer: ReturnType<typeof setTimeout> | undefined;\n // For keeping track of active root spans\n private _activeRootSpanIds: Set<string>;\n private _rootSpanTimeouts: Map<string, ReturnType<typeof setTimeout>>;\n // ID for Profiler session\n private _profilerId: string | undefined;\n private _isRunning: boolean;\n private _sessionSampled: boolean;\n\n public constructor() {\n this._client = undefined;\n this._profiler = undefined;\n this._chunkTimer = undefined;\n this._activeRootSpanIds = new Set<string>();\n this._rootSpanTimeouts = new Map<string, ReturnType<typeof setTimeout>>();\n this._profilerId = undefined;\n this._isRunning = false;\n this._sessionSampled = false;\n }\n\n /**\n * Initialize the profiler with client and session sampling decision computed by the integration.\n */\n public initialize(client: Client, sessionSampled: boolean): void {\n // One Profiler ID per profiling session (user session)\n this._profilerId = uuid4();\n\n DEBUG_BUILD && debug.log(\"[Profiling] Initializing profiler (lifecycle='trace').\");\n\n this._client = client;\n this._sessionSampled = sessionSampled;\n\n client.on('spanStart', span => {\n if (!this._sessionSampled) {\n DEBUG_BUILD && debug.log('[Profiling] Session not sampled because of negative sampling decision.');\n return;\n }\n if (span !== getRootSpan(span)) {\n return;\n }\n // Only count sampled root spans\n if (!span.isRecording()) {\n DEBUG_BUILD && debug.log('[Profiling] Discarding profile because root span was not sampled.');\n return;\n }\n\n // Matching root spans with profiles\n getGlobalScope().setContext('profile', {\n profiler_id: this._profilerId,\n });\n\n const spanId = span.spanContext().spanId;\n if (!spanId) {\n return;\n }\n if (this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._activeRootSpanIds.add(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n const timeout = setTimeout(() => {\n this._onRootSpanTimeout(spanId);\n }, MAX_ROOT_SPAN_PROFILE_MS);\n this._rootSpanTimeouts.set(spanId, timeout);\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} started. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n\n this.start();\n }\n });\n\n client.on('spanEnd', span => {\n if (!this._sessionSampled) {\n return;\n }\n\n const spanId = span.spanContext().spanId;\n if (!spanId || !this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._activeRootSpanIds.delete(spanId);\n const rootSpanCount = this._activeRootSpanIds.size;\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Root span with ID ${spanId} ended. Will continue profiling for as long as there are active root spans (currently: ${rootSpanCount}).`,\n );\n if (rootSpanCount === 0) {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `spanEnd`:', e);\n });\n\n this.stop();\n }\n });\n }\n\n /**\n * Handle an already-active root span at integration setup time.\n */\n public notifyRootSpanActive(rootSpan: Span): void {\n if (!this._sessionSampled) {\n return;\n }\n\n const spanId = rootSpan.spanContext().spanId;\n if (!spanId || this._activeRootSpanIds.has(spanId)) {\n return;\n }\n\n this._activeRootSpanIds.add(spanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n\n if (rootSpanCount === 1) {\n DEBUG_BUILD &&\n debug.log('[Profiling] Detected already active root span during setup. Active root spans now:', rootSpanCount);\n\n this.start();\n }\n }\n\n /**\n * Start profiling if not already running.\n */\n public start(): void {\n if (this._isRunning) {\n return;\n }\n this._isRunning = true;\n\n DEBUG_BUILD && debug.log('[Profiling] Started profiling with profile ID:', this._profilerId);\n\n this._startProfilerInstance();\n\n if (!this._profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Stopping trace lifecycle profiling.');\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n\n /**\n * Stop profiling; final chunk will be collected and sent.\n */\n public stop(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._isRunning = false;\n if (this._chunkTimer) {\n clearTimeout(this._chunkTimer);\n this._chunkTimer = undefined;\n }\n\n this._clearAllRootSpanTimeouts();\n\n // Collect whatever was currently recording\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk on `stop()`:', e);\n });\n }\n\n /**\n * Resets profiling information from scope and resets running state\n */\n private _resetProfilerInfo(): void {\n this._isRunning = false;\n getGlobalScope().setContext('profile', {});\n }\n\n /**\n * Clear and reset all per-root-span timeouts.\n */\n private _clearAllRootSpanTimeouts(): void {\n this._rootSpanTimeouts.forEach(timeout => clearTimeout(timeout));\n this._rootSpanTimeouts.clear();\n }\n\n /**\n * Start a profiler instance if needed.\n */\n private _startProfilerInstance(): void {\n if (this._profiler?.stopped === false) {\n return;\n }\n const profiler = startJSSelfProfile();\n if (!profiler) {\n DEBUG_BUILD && debug.log('[Profiling] Failed to start JS Profiler in trace lifecycle.');\n return;\n }\n this._profiler = profiler;\n }\n\n /**\n * Schedule the next 60s chunk while running.\n * Each tick collects a chunk and restarts the profiler.\n * A chunk should be closed when there are no active root spans anymore OR when the maximum chunk interval is reached.\n */\n private _startPeriodicChunking(): void {\n if (!this._isRunning) {\n return;\n }\n\n this._chunkTimer = setTimeout(() => {\n this._collectCurrentChunk().catch(e => {\n DEBUG_BUILD && debug.error('[Profiling] Failed to collect current profile chunk during periodic chunking:', e);\n });\n\n if (this._isRunning) {\n this._startProfilerInstance();\n\n if (!this._profiler) {\n // If restart failed, stop scheduling further chunks and reset context.\n this._resetProfilerInfo();\n return;\n }\n\n this._startPeriodicChunking();\n }\n }, CHUNK_INTERVAL_MS);\n }\n\n /**\n * Handle timeout for a specific root span ID to avoid indefinitely running profiler if `spanEnd` never fires.\n * If this was the last active root span, collect the current chunk and stop profiling.\n */\n private _onRootSpanTimeout(rootSpanId: string): void {\n // If span already ended, ignore\n if (!this._rootSpanTimeouts.has(rootSpanId)) {\n return;\n }\n this._rootSpanTimeouts.delete(rootSpanId);\n\n if (!this._activeRootSpanIds.has(rootSpanId)) {\n return;\n }\n\n DEBUG_BUILD &&\n debug.log(\n `[Profiling] Reached 5-minute timeout for root span ${rootSpanId}. You likely started a manual root span that never called \\`.end()\\`.`,\n );\n\n this._activeRootSpanIds.delete(rootSpanId);\n\n const rootSpanCount = this._activeRootSpanIds.size;\n if (rootSpanCount === 0) {\n this.stop();\n }\n }\n\n /**\n * Stop the current profiler, convert and send a profile chunk.\n */\n private async _collectCurrentChunk(): Promise<void> {\n const prevProfiler = this._profiler;\n this._profiler = undefined;\n\n if (!prevProfiler) {\n return;\n }\n\n try {\n const profile = await prevProfiler.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const chunk = createProfileChunkPayload(profile, this._client!, this._profilerId);\n\n // Validate chunk before sending\n const validationReturn = validateProfileChunk(chunk);\n if ('reason' in validationReturn) {\n DEBUG_BUILD &&\n debug.log(\n '[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):',\n validationReturn.reason,\n );\n return;\n }\n\n this._sendProfileChunk(chunk);\n\n DEBUG_BUILD && debug.log('[Profiling] Collected browser profile chunk.');\n } catch (e) {\n DEBUG_BUILD && debug.log('[Profiling] Error while stopping JS Profiler for chunk:', e);\n }\n }\n\n /**\n * Send a profile chunk as a standalone envelope.\n */\n private _sendProfileChunk(chunk: ProfileChunk): void {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const client = this._client!;\n\n const sdkInfo = getSdkMetadataForEnvelopeHeader(client.getSdkMetadata?.());\n const dsn = client.getDsn();\n const tunnel = client.getOptions().tunnel;\n\n const envelope = createEnvelope<ProfileChunkEnvelope>(\n {\n event_id: uuid4(),\n sent_at: new Date().toISOString(),\n ...(sdkInfo && { sdk: sdkInfo }),\n ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),\n },\n [[{ type: 'profile_chunk' }, chunk]],\n );\n\n client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending profile chunk envelope:', reason);\n });\n }\n}\n"],"names":["uuid4","DEBUG_BUILD","debug","getRootSpan","getGlobalScope","startJSSelfProfile","createProfileChunkPayload","validateProfileChunk","getSdkMetadataForEnvelopeHeader","createEnvelope","dsnToString"],"mappings":";;;;;;AAeA,MAAM,iBAAA,GAAoB,KAAM,CAAA;AAChC;AACA,MAAM,wBAAA,GAA2B,MAAO,CAAA;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,6BAAA,CAA8B;;AAI3C;;AAGA;;AAKA,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,OAAA,GAAU,SAAS;AAC5B,IAAI,IAAI,CAAC,SAAA,GAAY,SAAS;AAC9B,IAAI,IAAI,CAAC,WAA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