-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.ts
More file actions
48 lines (42 loc) · 1.57 KB
/
Copy pathindex.ts
File metadata and controls
48 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
import type { Logger } from '@dd/core/types';
import type { ErrorTrackingOptionsWithSourcemaps } from '../types';
import type { SourcemapsFilesContext } from './files';
import { getSourcemapsFiles } from './files';
import type { SourcemapsSenderContext } from './sender';
import { sendSourcemaps } from './sender';
export type UploadSourcemapsContext = SourcemapsSenderContext & SourcemapsFilesContext;
export const uploadSourcemaps = async (
options: ErrorTrackingOptionsWithSourcemaps,
context: UploadSourcemapsContext,
log: Logger,
) => {
// Gather the sourcemaps files.
const sourcemapsTime = log.time('get sourcemaps files');
const sourcemaps = getSourcemapsFiles(options.sourcemaps, {
outDir: context.outDir,
outputs: context.outputs,
});
sourcemapsTime.end();
// Send everything.
const sendTime = log.time('send sourcemaps');
await sendSourcemaps(
sourcemaps,
options.sourcemaps,
{
addMetric: context.addMetric,
apiKey: context.apiKey,
bundlerName: context.bundlerName,
debugIds: context.debugIds,
git: context.git,
outDir: context.outDir,
sendMetrics: context.sendMetrics,
site: context.site,
version: context.version,
},
log,
);
sendTime.end();
};