@datadog/datadog-ci 3.9.1 → 3.11.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.
Files changed (31) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/aas/cli.js +2 -1
  5. package/dist/commands/aas/cli.js.map +1 -1
  6. package/dist/commands/aas/common.d.ts +25 -7
  7. package/dist/commands/aas/common.js +97 -35
  8. package/dist/commands/aas/common.js.map +1 -1
  9. package/dist/commands/aas/instrument.d.ts +13 -0
  10. package/dist/commands/aas/instrument.js +63 -30
  11. package/dist/commands/aas/instrument.js.map +1 -1
  12. package/dist/commands/aas/interfaces.d.ts +10 -11
  13. package/dist/commands/aas/uninstrument.d.ts +16 -0
  14. package/dist/commands/aas/uninstrument.js +99 -0
  15. package/dist/commands/aas/uninstrument.js.map +1 -0
  16. package/dist/commands/deployment/cli.js +2 -1
  17. package/dist/commands/deployment/cli.js.map +1 -1
  18. package/dist/commands/deployment/correlate-image.d.ts +15 -0
  19. package/dist/commands/deployment/correlate-image.js +121 -0
  20. package/dist/commands/deployment/correlate-image.js.map +1 -0
  21. package/dist/commands/react-native/cli.js +2 -1
  22. package/dist/commands/react-native/cli.js.map +1 -1
  23. package/dist/commands/react-native/injectDebugId.d.ts +42 -0
  24. package/dist/commands/react-native/injectDebugId.js +251 -0
  25. package/dist/commands/react-native/injectDebugId.js.map +1 -0
  26. package/dist/commands/react-native/interfaces.d.ts +3 -1
  27. package/dist/commands/react-native/interfaces.js +26 -3
  28. package/dist/commands/react-native/interfaces.js.map +1 -1
  29. package/dist/commands/react-native/upload.js +1 -1
  30. package/dist/commands/react-native/upload.js.map +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.UninstrumentCommand = void 0;
16
+ const arm_appservice_1 = require("@azure/arm-appservice");
17
+ const identity_1 = require("@azure/identity");
18
+ const chalk_1 = __importDefault(require("chalk"));
19
+ const clipanion_1 = require("clipanion");
20
+ const renderer_1 = require("../../helpers/renderer");
21
+ const common_1 = require("./common");
22
+ class UninstrumentCommand extends common_1.AasCommand {
23
+ execute() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ this.enableFips();
26
+ const [appServicesToUninstrument, config, errors] = yield this.ensureConfig();
27
+ if (errors.length > 0) {
28
+ for (const error of errors) {
29
+ this.context.stdout.write((0, renderer_1.renderError)(error));
30
+ }
31
+ return 1;
32
+ }
33
+ const cred = new identity_1.DefaultAzureCredential();
34
+ if (!(yield this.ensureAzureAuth(cred))) {
35
+ return 1;
36
+ }
37
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Beginning uninstrumentation of Azure App Service(s)\n`);
38
+ const results = yield Promise.all(Object.entries(appServicesToUninstrument).map(([subscriptionId, resourceGroupToNames]) => this.processSubscription(cred, subscriptionId, resourceGroupToNames, config)));
39
+ const success = results.every((result) => result);
40
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Uninstrumentation completed ${success ? 'successfully!' : 'with errors, see above for details.'}\n`);
41
+ return success ? 0 : 1;
42
+ });
43
+ }
44
+ processSubscription(cred, subscriptionId, resourceGroupToNames, config) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const client = new arm_appservice_1.WebSiteManagementClient(cred, subscriptionId, { apiVersion: '2024-11-01' });
47
+ const results = yield Promise.all(Object.entries(resourceGroupToNames).flatMap(([resourceGroup, aasNames]) => aasNames.map((aasName) => this.processAas(client, config, resourceGroup, aasName))));
48
+ return results.every((result) => result);
49
+ });
50
+ }
51
+ /**
52
+ * Process an Azure App Service for uninstrumentation.
53
+ * @returns A promise that resolves to a boolean indicating success or failure.
54
+ */
55
+ processAas(client, config, resourceGroup, aasName) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ try {
58
+ const site = yield client.webApps.get(resourceGroup, aasName);
59
+ if (!this.ensureLinux(site)) {
60
+ return false;
61
+ }
62
+ yield this.uninstrumentSidecar(client, Object.assign(Object.assign({}, config), { isDotnet: config.isDotnet || (0, common_1.isDotnet)(site) }), resourceGroup, aasName);
63
+ }
64
+ catch (error) {
65
+ this.context.stdout.write((0, renderer_1.renderError)(`Failed to uninstrument ${chalk_1.default.bold(aasName)}: ${(0, common_1.formatError)(error)}`));
66
+ return false;
67
+ }
68
+ return true;
69
+ });
70
+ }
71
+ uninstrumentSidecar(client, config, resourceGroup, aasName) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ this.context.stdout.write(`${this.dryRunPrefix}Removing sidecar container ${chalk_1.default.bold(common_1.SIDECAR_CONTAINER_NAME)} from ${chalk_1.default.bold(aasName)} (if it exists)\n`);
74
+ if (!this.dryRun) {
75
+ yield client.webApps.deleteSiteContainer(resourceGroup, aasName, common_1.SIDECAR_CONTAINER_NAME);
76
+ }
77
+ this.context.stdout.write(`${this.dryRunPrefix}Checking Application Settings on ${chalk_1.default.bold(aasName)}\n`);
78
+ const currentEnvVars = (yield client.webApps.listApplicationSettings(resourceGroup, aasName)).properties;
79
+ if (currentEnvVars !== undefined && common_1.AAS_DD_SETTING_NAMES.some((key) => key in currentEnvVars)) {
80
+ this.context.stdout.write(`${this.dryRunPrefix}Updating Application Settings for ${chalk_1.default.bold(aasName)}\n`);
81
+ if (!this.dryRun) {
82
+ yield client.webApps.updateApplicationSettings(resourceGroup, aasName, {
83
+ properties: Object.fromEntries(Object.entries(currentEnvVars).filter(([key]) => !common_1.AAS_DD_SETTING_NAMES.includes(key))),
84
+ });
85
+ }
86
+ }
87
+ else {
88
+ this.context.stdout.write(`${this.dryRunPrefix}No Application Settings changes needed for ${chalk_1.default.bold(aasName)}.\n`);
89
+ }
90
+ });
91
+ }
92
+ }
93
+ exports.UninstrumentCommand = UninstrumentCommand;
94
+ UninstrumentCommand.paths = [['aas', 'uninstrument']];
95
+ UninstrumentCommand.usage = clipanion_1.Command.Usage({
96
+ category: 'Serverless',
97
+ description: 'Remove Datadog instrumentation from an Azure App Service.',
98
+ });
99
+ //# sourceMappingURL=uninstrument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstrument.js","sourceRoot":"","sources":["../../../src/commands/aas/uninstrument.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA6D;AAC7D,8CAAsD;AACtD,kDAAyB;AACzB,yCAAiC;AAEjC,qDAAkD;AAElD,qCAAwG;AAGxG,MAAa,mBAAoB,SAAQ,mBAAU;IAOpC,OAAO;;YAClB,IAAI,CAAC,UAAU,EAAE,CAAA;YACjB,MAAM,CAAC,yBAAyB,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;YAC7E,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;oBAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAA;iBAC9C;gBAED,OAAO,CAAC,CAAA;aACT;YAED,MAAM,IAAI,GAAG,IAAI,iCAAsB,EAAE,CAAA;YACzC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EA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AA2D;CACzE,CAAC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const correlate_1 = require("./correlate");
4
+ const correlate_image_1 = require("./correlate-image");
4
5
  const mark_1 = require("./mark");
5
- module.exports = [mark_1.DeploymentMarkCommand, correlate_1.DeploymentCorrelateCommand];
6
+ module.exports = [mark_1.DeploymentMarkCommand, correlate_1.DeploymentCorrelateCommand, correlate_image_1.DeploymentCorrelateImageCommand];
6
7
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/deployment/cli.ts"],"names":[],"mappings":";;AAAA,2CAAsD;AACtD,iCAA4C;AAE5C,MAAM,CAAC,OAAO,GAAG,CAAC,4BAAqB,EAAE,sCAA0B,CAAC,CAAA"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/deployment/cli.ts"],"names":[],"mappings":";;AAAA,2CAAsD;AACtD,uDAAiE;AACjE,iCAA4C;AAE5C,MAAM,CAAC,OAAO,GAAG,CAAC,4BAAqB,EAAE,sCAA0B,EAAE,iDAA+B,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Command } from 'clipanion';
2
+ export declare class DeploymentCorrelateImageCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ private commitSha;
6
+ private repositoryUrl;
7
+ private image;
8
+ private fips;
9
+ private fipsIgnoreError;
10
+ private dryRun;
11
+ private logger;
12
+ private config;
13
+ execute(): Promise<number>;
14
+ private handleError;
15
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DeploymentCorrelateImageCommand = void 0;
16
+ const axios_1 = require("axios");
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const clipanion_1 = require("clipanion");
19
+ const constants_1 = require("../../constants");
20
+ const env_1 = require("../../helpers/env");
21
+ const fips_1 = require("../../helpers/fips");
22
+ const logger_1 = require("../../helpers/logger");
23
+ const retry_1 = require("../../helpers/retry");
24
+ const utils_1 = require("../../helpers/utils");
25
+ class DeploymentCorrelateImageCommand extends clipanion_1.Command {
26
+ constructor() {
27
+ var _a, _b;
28
+ super(...arguments);
29
+ this.commitSha = clipanion_1.Option.String('--commit-sha');
30
+ this.repositoryUrl = clipanion_1.Option.String('--repository-url');
31
+ this.image = clipanion_1.Option.String('--image');
32
+ this.fips = clipanion_1.Option.Boolean('--fips', false);
33
+ this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
34
+ this.dryRun = clipanion_1.Option.Boolean('--dry-run', false);
35
+ this.logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO);
36
+ this.config = {
37
+ apiKey: process.env.DD_API_KEY,
38
+ appKey: process.env.DD_APP_KEY,
39
+ fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
40
+ fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
41
+ };
42
+ }
43
+ execute() {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ (0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
46
+ if (!this.config.apiKey) {
47
+ this.logger.error(`Missing ${chalk_1.default.red.bold('DD_API_KEY')} in your environment.`);
48
+ return 1;
49
+ }
50
+ if (!this.config.appKey) {
51
+ this.logger.error(`Missing ${chalk_1.default.red.bold('DD_APP_KEY')} in your environment.`);
52
+ return 1;
53
+ }
54
+ if (!this.commitSha) {
55
+ this.logger.error('Missing commit SHA. It must be provided with --commit-sha');
56
+ return 1;
57
+ }
58
+ if (!this.repositoryUrl) {
59
+ this.logger.error('Missing repository URL. It must be provided with --repository-url');
60
+ return 1;
61
+ }
62
+ if (!this.image) {
63
+ this.logger.error('Missing image. It must be provided with --image');
64
+ return 1;
65
+ }
66
+ const site = process.env.DD_SITE || 'datadoghq.com';
67
+ const baseAPIURL = `https://${(0, utils_1.getApiHostForSite)(site)}`;
68
+ const request = (0, utils_1.getRequestBuilder)({ baseUrl: baseAPIURL, apiKey: this.config.apiKey, appKey: this.config.appKey });
69
+ const correlateEvent = {
70
+ type: 'ci_deployment_correlate_image',
71
+ attributes: {
72
+ commit_sha: this.commitSha,
73
+ repository_url: this.repositoryUrl,
74
+ image: this.image,
75
+ },
76
+ };
77
+ if (this.dryRun) {
78
+ this.logger.info(`[DRYRUN] Sending correlation event\n data: ` + JSON.stringify(correlateEvent, undefined, 2));
79
+ return 0;
80
+ }
81
+ const doRequest = () => request({
82
+ data: {
83
+ data: correlateEvent,
84
+ },
85
+ method: 'post',
86
+ url: '/api/v2/ci/deployments/correlate-image',
87
+ });
88
+ try {
89
+ yield (0, retry_1.retryRequest)(doRequest, {
90
+ maxTimeout: 30000,
91
+ minTimeout: 5000,
92
+ onRetry: (e, attempt) => {
93
+ this.logger.warn(`[attempt ${attempt}] Could not send correlation event. Retrying...: ${e.message}\n`);
94
+ },
95
+ retries: 5,
96
+ });
97
+ }
98
+ catch (error) {
99
+ this.handleError(error);
100
+ }
101
+ return 0;
102
+ });
103
+ }
104
+ handleError(error) {
105
+ var _a, _b;
106
+ this.context.stderr.write(`${chalk_1.default.red.bold('[ERROR]')} Could not send deployment correlation data: ${(0, axios_1.isAxiosError)(error)
107
+ ? JSON.stringify({
108
+ status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
109
+ response: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
110
+ }, undefined, 2)
111
+ : error.message}\n`);
112
+ }
113
+ }
114
+ exports.DeploymentCorrelateImageCommand = DeploymentCorrelateImageCommand;
115
+ DeploymentCorrelateImageCommand.paths = [['deployment', 'correlate-image']];
116
+ DeploymentCorrelateImageCommand.usage = clipanion_1.Command.Usage({
117
+ category: 'CI Visibility',
118
+ description: 'Correlate images with their source commit.',
119
+ details: 'This command will correlate the image with a commit of the application repository.',
120
+ });
121
+ //# sourceMappingURL=correlate-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlate-image.js","sourceRoot":"","sources":["../../../src/commands/deployment/correlate-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,kDAAyB;AACzB,yCAAyC;AAEzC,+CAAuE;AACvE,2CAA2C;AAC3C,6CAA6C;AAC7C,iDAAqD;AACrD,+CAAgD;AAChD,+CAAwE;AAExE,MAAa,+BAAgC,SAAQ,mBAAO;IAA5D;;;QASU,cAAS,GAAG,kBAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACzC,kBAAa,GAAG,kBAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACjD,UAAK,GAAG,kBAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAChC,SAAI,GAAG,kBAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACtC,oBAAe,GAAG,kBAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC9D,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAE3C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oBACjB,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;wBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,OAAO,oDAAoD,CAAC,CAAC,OAAO,IAAI,CAAC,CAAA;oBACxG,CAAC;oBACD,OAAO,EAAE,CAAC;iBACX,CAAC,CAAA;aACH;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,CAAC,WAAW,CAAC,KAAc,CAAC,CAAA;aACjC;YAED,OAAO,CAAC,CAAA;QACV,CAAC;KAAA;IAEO,WAAW,CAAC,KAAY;;QAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACvB,GAAG,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,gDAC1B,IAAA,oBAAY,EAAC,KAAK,CAAC;YACjB,CAAC,CAAC,IAAI,CAAC,SAAS,CACZ;gBACE,MAAM,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM;gBAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAe;aAC1C,EACD,SAAS,EACT,CAAC,CACF;YACH,CAAC,CAAC,KAAK,CAAC,OACZ,IAAI,CACL,CAAA;IACH,CAAC;;AArHH,0EAsHC;AArHe,qCAAK,GAAG,CAAC,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,AAAtC,CAAsC;AAE3C,qCAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,4CAA4C;IACzD,OAAO,EAAE,oFAAoF;CAC9F,CAAC,AAJiB,CAIjB"}
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const codepush_1 = require("./codepush");
4
+ const injectDebugId_1 = require("./injectDebugId");
4
5
  const upload_1 = require("./upload");
5
6
  const xcode_1 = require("./xcode");
6
- module.exports = [codepush_1.CodepushCommand, upload_1.UploadCommand, xcode_1.XCodeCommand];
7
+ module.exports = [codepush_1.CodepushCommand, upload_1.UploadCommand, xcode_1.XCodeCommand, injectDebugId_1.InjectDebugIdCommand];
7
8
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/react-native/cli.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAC1C,qCAAsC;AACtC,mCAAoC;AAEpC,MAAM,CAAC,OAAO,GAAG,CAAC,0BAAe,EAAE,sBAAa,EAAE,oBAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/react-native/cli.ts"],"names":[],"mappings":";;AAAA,yCAA0C;AAC1C,mDAAoD;AACpD,qCAAsC;AACtC,mCAAoC;AAEpC,MAAM,CAAC,OAAO,GAAG,CAAC,0BAAe,EAAE,sBAAa,EAAE,oBAAY,EAAE,oCAAoB,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { Command } from 'clipanion';
2
+ export declare class InjectDebugIdCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ private assetsPath;
6
+ private dryRun;
7
+ private fips;
8
+ private fipsIgnoreError;
9
+ private fipsConfig;
10
+ execute(): Promise<number>;
11
+ /**
12
+ * Scans the directory for bundles and sourcemaps, then injects Debug IDs.
13
+ *
14
+ * @param directory - The directory containing JavaScript bundles and sourcemaps.
15
+ * @param dryRun - If true, does not modify files.
16
+ */
17
+ private injectDebugIds;
18
+ /**
19
+ * Modifies the JS bundle by injecting a minified code snippet to allow runtime consumption of the given Debug ID,
20
+ * and it appends it to the end of the file, while preserving mappings.
21
+ *
22
+ * - Appends a **code snippet** containing the Debug ID.
23
+ * - Adds a **comment** with `//# debugId=<debug_id>`.
24
+ * - Moves the last `//# sourceMappingURL=` or `//@ sourceMappingURL=` comment to the end.
25
+ *
26
+ * @param filePath - The path to the JavaScript file.
27
+ * @param debugId - The Debug ID to inject.
28
+ */
29
+ private injectDebugIdIntoBundle;
30
+ /**
31
+ * Injects a Debug ID into a sourcemap JSON file.
32
+ */
33
+ private injectDebugIdIntoSourceMap;
34
+ /**
35
+ * Reads the Debug ID from a JavaScript bundle, if present.
36
+ */
37
+ private extractDebugIdFromBundle;
38
+ /**
39
+ * Reads the Debug ID from a sourcemap file.
40
+ */
41
+ private extractDebugIdFromSourceMap;
42
+ }
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InjectDebugIdCommand = void 0;
16
+ const crypto_1 = require("crypto");
17
+ const fs_1 = require("fs");
18
+ const clipanion_1 = require("clipanion");
19
+ const upath_1 = __importDefault(require("upath"));
20
+ const constants_1 = require("../../constants");
21
+ const env_1 = require("../../helpers/env");
22
+ const fips_1 = require("../../helpers/fips");
23
+ /**
24
+ * The Debug ID is injected in the bundle as a plain string, using this prefix.
25
+ */
26
+ const DEBUG_ID_METADATA_PREFIX = 'datadog-debug-id-';
27
+ class InjectDebugIdCommand extends clipanion_1.Command {
28
+ constructor() {
29
+ var _a, _b;
30
+ super(...arguments);
31
+ this.assetsPath = clipanion_1.Option.String({ required: false });
32
+ this.dryRun = clipanion_1.Option.Boolean('--dry-run', false);
33
+ this.fips = clipanion_1.Option.Boolean('--fips', false);
34
+ this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
35
+ this.fipsConfig = {
36
+ fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
37
+ fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
38
+ };
39
+ }
40
+ execute() {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ (0, fips_1.enableFips)(this.fips || this.fipsConfig.fips, this.fipsIgnoreError || this.fipsConfig.fipsIgnoreError);
43
+ if (!this.assetsPath) {
44
+ this.context.stderr.write('[ERROR] No path specified for JS bundle and sourcemap.\n');
45
+ return 1;
46
+ }
47
+ if (!(0, fs_1.existsSync)(this.assetsPath)) {
48
+ this.context.stderr.write('[ERROR] The given path does not exist.\n');
49
+ return 1;
50
+ }
51
+ return this.injectDebugIds(this.assetsPath, this.dryRun);
52
+ });
53
+ }
54
+ /**
55
+ * Scans the directory for bundles and sourcemaps, then injects Debug IDs.
56
+ *
57
+ * @param directory - The directory containing JavaScript bundles and sourcemaps.
58
+ * @param dryRun - If true, does not modify files.
59
+ */
60
+ injectDebugIds(directory, dryRun) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ this.context.stdout.write(`Scanning directory: ${directory}\n`);
63
+ const files = yield fs_1.promises.readdir(directory);
64
+ const bundles = files.filter((file) => file.endsWith('.bundle'));
65
+ if (bundles.length === 0) {
66
+ this.context.stderr.write(`[ERROR] JS bundle not found in "${directory}". Ensure your files follow the "*.bundle" and "*.bundle.map" naming convention.\n`);
67
+ return 1;
68
+ }
69
+ for (const bundle of bundles) {
70
+ const bundlePath = upath_1.default.join(directory, bundle);
71
+ const sourcemapPath = upath_1.default.join(directory, `${bundle}.map`);
72
+ let debugId = (yield this.extractDebugIdFromBundle(bundlePath)) || (yield this.extractDebugIdFromSourceMap(sourcemapPath));
73
+ if (!debugId) {
74
+ const bundleData = yield fs_1.promises.readFile(bundlePath, 'utf-8');
75
+ debugId = generateDebugId(bundleData);
76
+ this.context.stdout.write(`Generated Debug ID for ${bundle}: ${debugId}\n`);
77
+ }
78
+ else {
79
+ this.context.stdout.write(`Found existing Debug ID for ${bundle}: ${debugId}\n`);
80
+ }
81
+ if (!dryRun) {
82
+ if (!(yield this.injectDebugIdIntoBundle(bundlePath, debugId))) {
83
+ return 1;
84
+ }
85
+ if ((0, fs_1.existsSync)(sourcemapPath)) {
86
+ if (!(yield this.injectDebugIdIntoSourceMap(sourcemapPath, debugId))) {
87
+ return 1;
88
+ }
89
+ this.context.stdout.write(`Updated Debug ID in ${bundle} and its sourcemap.\n`);
90
+ }
91
+ }
92
+ else {
93
+ this.context.stdout.write(`Dry run: No files modified.\n`);
94
+ }
95
+ }
96
+ return 0;
97
+ });
98
+ }
99
+ /**
100
+ * Modifies the JS bundle by injecting a minified code snippet to allow runtime consumption of the given Debug ID,
101
+ * and it appends it to the end of the file, while preserving mappings.
102
+ *
103
+ * - Appends a **code snippet** containing the Debug ID.
104
+ * - Adds a **comment** with `//# debugId=<debug_id>`.
105
+ * - Moves the last `//# sourceMappingURL=` or `//@ sourceMappingURL=` comment to the end.
106
+ *
107
+ * @param filePath - The path to the JavaScript file.
108
+ * @param debugId - The Debug ID to inject.
109
+ */
110
+ injectDebugIdIntoBundle(filePath, debugId) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ try {
113
+ const jsContents = yield fs_1.promises.readFile(filePath, 'utf-8');
114
+ const lines = jsContents.split('\n');
115
+ // Find the last source mapping comment (`//# sourceMappingURL=...` or `//@ sourceMappingURL=...`)
116
+ const sourcemapIndex = lines
117
+ .map((line, index) => ({ line, index }))
118
+ .reverse()
119
+ .find(({ line }) => line.startsWith('//# sourceMappingURL=') || line.startsWith('//@ sourceMappingURL='));
120
+ let sourcemapComment = '';
121
+ if (sourcemapIndex) {
122
+ // Remove the sourcemap comment so we can place it at the very end later
123
+ sourcemapComment = lines.splice(sourcemapIndex.index, 1)[0];
124
+ }
125
+ // Inject Debug ID snippet (modify as needed)
126
+ const snippet = createDebugIdSnippet(debugId);
127
+ // Append minified snippet to the bundle
128
+ lines.push(snippet);
129
+ // Re-add the sourcemap comment at the end (if it was found)
130
+ if (sourcemapComment) {
131
+ lines.push(sourcemapComment);
132
+ }
133
+ // Append Debug ID comment
134
+ lines.push(`//# debugId=${debugId}`);
135
+ // Write back the modified contents
136
+ yield fs_1.promises.writeFile(filePath, lines.join('\n'), 'utf-8');
137
+ this.context.stdout.write(`✅ Debug ID injected into ${filePath}\n`);
138
+ }
139
+ catch (error) {
140
+ const errorMsg = error instanceof Error ? error.message : String(error);
141
+ this.context.stderr.write(`❌ Failed to inject Debug ID into ${filePath}:${errorMsg}\n`);
142
+ return false;
143
+ }
144
+ return true;
145
+ });
146
+ }
147
+ /**
148
+ * Injects a Debug ID into a sourcemap JSON file.
149
+ */
150
+ injectDebugIdIntoSourceMap(sourceMapPath, debugId) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ let sourcemapData;
153
+ try {
154
+ sourcemapData = yield fs_1.promises.readFile(sourceMapPath, 'utf-8');
155
+ }
156
+ catch (error) {
157
+ this.context.stderr.write(`[ERROR] Cannot read sourcemap from ${sourceMapPath}: ${String(error)}\n`);
158
+ return false;
159
+ }
160
+ let content;
161
+ try {
162
+ content = JSON.parse(sourcemapData);
163
+ }
164
+ catch (error) {
165
+ this.context.stderr.write(`[ERROR] Cannot parse JSON from sourcemap at ${sourceMapPath}: ${String(error)}\n`);
166
+ return false;
167
+ }
168
+ content.debugId = debugId;
169
+ try {
170
+ yield fs_1.promises.writeFile(sourceMapPath, JSON.stringify(content, undefined, 2));
171
+ }
172
+ catch (error) {
173
+ this.context.stderr.write(`[ERROR] Cannot write sourcemap file at ${sourceMapPath}: ${String(error)}\n`);
174
+ return false;
175
+ }
176
+ return true;
177
+ });
178
+ }
179
+ /**
180
+ * Reads the Debug ID from a JavaScript bundle, if present.
181
+ */
182
+ extractDebugIdFromBundle(bundlePath) {
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ const content = yield fs_1.promises.readFile(bundlePath, 'utf-8');
185
+ const match = content.match(/\/\/# debugId=([a-f0-9-]+)/);
186
+ return match ? match[1] : undefined;
187
+ });
188
+ }
189
+ /**
190
+ * Reads the Debug ID from a sourcemap file.
191
+ */
192
+ extractDebugIdFromSourceMap(sourceMapPath) {
193
+ return __awaiter(this, void 0, void 0, function* () {
194
+ let sourcemapData;
195
+ try {
196
+ sourcemapData = yield fs_1.promises.readFile(sourceMapPath, 'utf-8');
197
+ }
198
+ catch (error) {
199
+ throw new Error(`Cannot read sourcemap from ${sourceMapPath}: ${String(error)}`);
200
+ }
201
+ let content;
202
+ try {
203
+ content = JSON.parse(sourcemapData);
204
+ }
205
+ catch (error) {
206
+ throw new Error(`Cannot parse JSON from sourcemap at ${sourceMapPath}: ${String(error)}`);
207
+ }
208
+ return content.debugId || undefined;
209
+ });
210
+ }
211
+ }
212
+ exports.InjectDebugIdCommand = InjectDebugIdCommand;
213
+ InjectDebugIdCommand.paths = [['react-native', 'inject-debug-id']];
214
+ InjectDebugIdCommand.usage = clipanion_1.Command.Usage({
215
+ category: 'RUM',
216
+ description: 'Inject Debug ID into JavaScript bundles and sourcemaps.',
217
+ details: `
218
+ This command scans the specified directory for minified JavaScript bundles (.bundle) and their associated source maps (.map),
219
+ injecting a unique Debug ID into each file. These Debug IDs enable precise source map resolution in Datadog, ensuring accurate
220
+ stack traces and error symbolication.
221
+ `,
222
+ examples: [
223
+ ['Inject Debug ID', 'datadog-ci react-native inject-debug-id ./dist'],
224
+ ['Inject Debug ID (dry run)', 'datadog-ci react-native inject-debug-id ./dist --dry-run'],
225
+ ],
226
+ });
227
+ /**
228
+ * Creates a minified JavaScript snippet that exposes the provided Debug ID
229
+ * on the global scope at runtime.
230
+ *
231
+ * @param debugId - The Debug ID to be injected into the global scope.
232
+ * @returns A minified JavaScript string that performs the injection.
233
+ */
234
+ const createDebugIdSnippet = (debugId) => {
235
+ return `var _datadogDebugIds,_datadogDebugIdMeta;void 0===_datadogDebugIds&&(_datadogDebugIds={});try{var stack=(new Error).stack;stack&&(_datadogDebugIds[stack]="${debugId}",_datadogDebugIdMeta="${DEBUG_ID_METADATA_PREFIX}${debugId}")}catch(e){}`;
236
+ };
237
+ /**
238
+ * Converts a string into a UUID (Version 4 format) based on its MD5 hash.
239
+ *
240
+ * @param str - The input string to convert into a UUID.
241
+ * @returns A UUIDv4 string derived from the MD5 hash of the input.
242
+ */
243
+ const generateDebugId = (str) => {
244
+ const md5sum = (0, crypto_1.createHash)('md5');
245
+ md5sum.update(str);
246
+ const md5Hash = md5sum.digest('hex');
247
+ // Select a variant character (RFC 4122) - '8', '9', 'a', or 'b'
248
+ const v4variant = ['8', '9', 'a', 'b'][md5Hash.charCodeAt(16) % 4];
249
+ return `${md5Hash.substring(0, 8)}-${md5Hash.substring(8, 12)}-4${md5Hash.substring(13, 16)}-${v4variant}${md5Hash.substring(17, 20)}-${md5Hash.substring(20)}`.toLowerCase();
250
+ };
251
+ //# sourceMappingURL=injectDebugId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectDebugId.js","sourceRoot":"","sources":["../../../src/commands/react-native/injectDebugId.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,2BAAuC;AAEvC,yCAAyC;AACzC,kDAAyB;AAEzB,+CAAuE;AACvE,2CAA2C;AAC3C,6CAA6C;AAE7C;;GAEG;AACH,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAEpD,MAAa,oBAAqB,SAAQ,mBAAO;IAAjD;;;QAgBU,eAAU,GAAG,kBAAM,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAA;QAC7C,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAC3C,SAAI,GAAG,kBAAM,CAAC,O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,EACF,EAAE,CACH,IAAI,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAA;AACrF,CAAC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { CommandContext } from '../../helpers/interfaces';
1
2
  import { MultipartPayload } from '../../helpers/upload';
2
3
  export declare class RNSourcemap {
3
4
  bundleName: string;
@@ -5,8 +6,9 @@ export declare class RNSourcemap {
5
6
  sourcemapPath: string;
6
7
  constructor(bundleName: string, sourcemapPath: string);
7
8
  addRepositoryData(gitData: GitData): void;
8
- asMultipartPayload(cliVersion: string, service: string, version: string, projectPath: string, platform: RNPlatform, build: string): MultipartPayload;
9
+ asMultipartPayload(cliVersion: string, service: string, version: string, projectPath: string, platform: RNPlatform, build: string, context: CommandContext): MultipartPayload;
9
10
  removeSourcesContentFromSourceMap: () => void;
11
+ private extractDebugId;
10
12
  private getMetadataPayload;
11
13
  }
12
14
  export interface GitData {