@hot-updater/sentry-plugin 0.19.2 → 0.19.4

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/index.cjs CHANGED
@@ -27,15 +27,20 @@ const __hot_updater_plugin_core = __toESM(require("@hot-updater/plugin-core"));
27
27
  const __sentry_cli = __toESM(require("@sentry/cli"));
28
28
 
29
29
  //#region src/withSentry.ts
30
- const injectDebugIdToHbcMap = (jsMapPath, hbcMapPath) => {
30
+ const injectDebugIdToHbcMap = (jsCodePath, jsMapPath, hbcMapPath) => {
31
31
  if (!hbcMapPath) return jsMapPath;
32
32
  const jsMap = JSON.parse(fs.default.readFileSync(jsMapPath, "utf8"));
33
- const debugId = jsMap.debug_id || jsMap.debugId;
34
- if (!debugId) throw new Error("debugId from Source map not found. It seems hot-updater doesn't support Sentry plugin with this bundle framework. Please pile issue on Github.");
33
+ let debugId = jsMap.debug_id || jsMap.debugId;
34
+ if (!debugId) {
35
+ const jsCode = fs.default.readFileSync(jsCodePath, "utf8");
36
+ const debugIdMatch = jsCode.match(/\/\/# debugId=([a-f0-9-]+)/);
37
+ debugId = debugIdMatch ? debugIdMatch[1] : void 0;
38
+ if (!debugId) throw new Error("debugId from Source map not found. It seems hot-updater doesn't support Sentry plugin with this bundle framework. Please pile issue on Github.");
39
+ }
35
40
  const hbcMap = JSON.parse(fs.default.readFileSync(hbcMapPath, "utf8"));
36
41
  hbcMap.debug_id = debugId;
37
42
  hbcMap.debugId = debugId;
38
- fs.default.writeFileSync(hbcMapPath, JSON.stringify(hbcMap, null, 2));
43
+ fs.default.writeFileSync(hbcMapPath, JSON.stringify(hbcMap, null, 0));
39
44
  fs.default.unlinkSync(jsMapPath);
40
45
  fs.default.renameSync(hbcMapPath, jsMapPath);
41
46
  return jsMapPath;
@@ -57,7 +62,7 @@ const withSentry = (buildFn, config) => (args) => {
57
62
  const hbcMapFile = ensureFilePath(files, result.buildPath, ".hbc.map");
58
63
  const bundleFile = ensureFilePath(files, result.buildPath, ".bundle");
59
64
  if (!bundleMapFile || !bundleFile) throw new Error("Source map not found. Please enable sourcemap in your build plugin. e.g build: bare({ sourcemap: true })");
60
- const sourcemapFile = injectDebugIdToHbcMap(bundleMapFile, hbcMapFile);
65
+ const sourcemapFile = injectDebugIdToHbcMap(bundleFile, bundleMapFile, hbcMapFile);
61
66
  await sentry.execute([
62
67
  "sourcemaps",
63
68
  "upload",
package/dist/index.js CHANGED
@@ -4,15 +4,20 @@ import { getCwd } from "@hot-updater/plugin-core";
4
4
  import SentryCli from "@sentry/cli";
5
5
 
6
6
  //#region src/withSentry.ts
7
- const injectDebugIdToHbcMap = (jsMapPath, hbcMapPath) => {
7
+ const injectDebugIdToHbcMap = (jsCodePath, jsMapPath, hbcMapPath) => {
8
8
  if (!hbcMapPath) return jsMapPath;
9
9
  const jsMap = JSON.parse(fs.readFileSync(jsMapPath, "utf8"));
10
- const debugId = jsMap.debug_id || jsMap.debugId;
11
- if (!debugId) throw new Error("debugId from Source map not found. It seems hot-updater doesn't support Sentry plugin with this bundle framework. Please pile issue on Github.");
10
+ let debugId = jsMap.debug_id || jsMap.debugId;
11
+ if (!debugId) {
12
+ const jsCode = fs.readFileSync(jsCodePath, "utf8");
13
+ const debugIdMatch = jsCode.match(/\/\/# debugId=([a-f0-9-]+)/);
14
+ debugId = debugIdMatch ? debugIdMatch[1] : void 0;
15
+ if (!debugId) throw new Error("debugId from Source map not found. It seems hot-updater doesn't support Sentry plugin with this bundle framework. Please pile issue on Github.");
16
+ }
12
17
  const hbcMap = JSON.parse(fs.readFileSync(hbcMapPath, "utf8"));
13
18
  hbcMap.debug_id = debugId;
14
19
  hbcMap.debugId = debugId;
15
- fs.writeFileSync(hbcMapPath, JSON.stringify(hbcMap, null, 2));
20
+ fs.writeFileSync(hbcMapPath, JSON.stringify(hbcMap, null, 0));
16
21
  fs.unlinkSync(jsMapPath);
17
22
  fs.renameSync(hbcMapPath, jsMapPath);
18
23
  return jsMapPath;
@@ -34,7 +39,7 @@ const withSentry = (buildFn, config) => (args) => {
34
39
  const hbcMapFile = ensureFilePath(files, result.buildPath, ".hbc.map");
35
40
  const bundleFile = ensureFilePath(files, result.buildPath, ".bundle");
36
41
  if (!bundleMapFile || !bundleFile) throw new Error("Source map not found. Please enable sourcemap in your build plugin. e.g build: bare({ sourcemap: true })");
37
- const sourcemapFile = injectDebugIdToHbcMap(bundleMapFile, hbcMapFile);
42
+ const sourcemapFile = injectDebugIdToHbcMap(bundleFile, bundleMapFile, hbcMapFile);
38
43
  await sentry.execute([
39
44
  "sourcemaps",
40
45
  "upload",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/sentry-plugin",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@sentry/cli": "2.46.0",
42
- "@hot-updater/core": "0.19.2",
43
- "@hot-updater/plugin-core": "0.19.2"
42
+ "@hot-updater/core": "0.19.4",
43
+ "@hot-updater/plugin-core": "0.19.4"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^20.9.4"