@slicemachine/init 2.6.4-dev-next-hotfix.1 → 2.6.4-dev-next-hotfix.2
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/SliceMachineInitProcess.cjs +9 -3
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.js +9 -3
- package/dist/SliceMachineInitProcess.js.map +1 -1
- package/dist/lib/sentryErrorHandlers.cjs +5 -12
- package/dist/lib/sentryErrorHandlers.cjs.map +1 -1
- package/dist/lib/sentryErrorHandlers.js +5 -12
- package/dist/lib/sentryErrorHandlers.js.map +1 -1
- package/dist/lib/setupSentry.cjs +2 -19
- package/dist/lib/setupSentry.cjs.map +1 -1
- package/dist/lib/setupSentry.d.ts +1 -8
- package/dist/lib/setupSentry.js +2 -19
- package/dist/lib/setupSentry.js.map +1 -1
- package/dist/lib/updateSentryContext.cjs +45 -0
- package/dist/lib/updateSentryContext.cjs.map +1 -0
- package/dist/lib/updateSentryContext.d.ts +8 -0
- package/dist/lib/updateSentryContext.js +28 -0
- package/dist/lib/updateSentryContext.js.map +1 -0
- package/dist/packages/init/package.json.cjs +4 -4
- package/dist/packages/init/package.json.js +4 -4
- package/package.json +4 -4
- package/src/SliceMachineInitProcess.ts +8 -2
- package/src/lib/sentryErrorHandlers.ts +6 -20
- package/src/lib/setupSentry.ts +2 -35
- package/src/lib/updateSentryContext.ts +42 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const name = "@slicemachine/init";
|
|
4
|
-
const version = "2.6.4-dev-next-hotfix.
|
|
4
|
+
const version = "2.6.4-dev-next-hotfix.2";
|
|
5
5
|
const description = "Init Prismic Slice Machine in your project";
|
|
6
6
|
const keywords = [
|
|
7
7
|
"typescript",
|
|
@@ -55,7 +55,7 @@ const dependencies = {
|
|
|
55
55
|
"@antfu/ni": "^0.20.0",
|
|
56
56
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
57
57
|
"@sentry/node": "^7.70.0",
|
|
58
|
-
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.
|
|
58
|
+
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.2",
|
|
59
59
|
chalk: "^4.1.2",
|
|
60
60
|
giget: "^1.1.2",
|
|
61
61
|
globby: "^13.1.3",
|
|
@@ -68,7 +68,7 @@ const dependencies = {
|
|
|
68
68
|
};
|
|
69
69
|
const devDependencies = {
|
|
70
70
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
71
|
-
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.
|
|
71
|
+
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.2",
|
|
72
72
|
"@types/listr": "0.14.4",
|
|
73
73
|
"@types/prompts": "2.4.3",
|
|
74
74
|
"@types/semver": "7.3.13",
|
|
@@ -94,7 +94,7 @@ const devDependencies = {
|
|
|
94
94
|
"vite-plugin-sdk": "0.1.1",
|
|
95
95
|
vitest: "0.32.0"
|
|
96
96
|
};
|
|
97
|
-
const gitHead = "
|
|
97
|
+
const gitHead = "1b439215fb042d67972a9a7bdc8cae4d1c77859c";
|
|
98
98
|
const pkg = {
|
|
99
99
|
name,
|
|
100
100
|
version,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const name = "@slicemachine/init";
|
|
2
|
-
const version = "2.6.4-dev-next-hotfix.
|
|
2
|
+
const version = "2.6.4-dev-next-hotfix.2";
|
|
3
3
|
const description = "Init Prismic Slice Machine in your project";
|
|
4
4
|
const keywords = [
|
|
5
5
|
"typescript",
|
|
@@ -53,7 +53,7 @@ const dependencies = {
|
|
|
53
53
|
"@antfu/ni": "^0.20.0",
|
|
54
54
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
55
55
|
"@sentry/node": "^7.70.0",
|
|
56
|
-
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.
|
|
56
|
+
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.2",
|
|
57
57
|
chalk: "^4.1.2",
|
|
58
58
|
giget: "^1.1.2",
|
|
59
59
|
globby: "^13.1.3",
|
|
@@ -66,7 +66,7 @@ const dependencies = {
|
|
|
66
66
|
};
|
|
67
67
|
const devDependencies = {
|
|
68
68
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
69
|
-
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.
|
|
69
|
+
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.2",
|
|
70
70
|
"@types/listr": "0.14.4",
|
|
71
71
|
"@types/prompts": "2.4.3",
|
|
72
72
|
"@types/semver": "7.3.13",
|
|
@@ -92,7 +92,7 @@ const devDependencies = {
|
|
|
92
92
|
"vite-plugin-sdk": "0.1.1",
|
|
93
93
|
vitest: "0.32.0"
|
|
94
94
|
};
|
|
95
|
-
const gitHead = "
|
|
95
|
+
const gitHead = "1b439215fb042d67972a9a7bdc8cae4d1c77859c";
|
|
96
96
|
const pkg = {
|
|
97
97
|
name,
|
|
98
98
|
version,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/init",
|
|
3
|
-
"version": "2.6.4-dev-next-hotfix.
|
|
3
|
+
"version": "2.6.4-dev-next-hotfix.2",
|
|
4
4
|
"description": "Init Prismic Slice Machine in your project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@antfu/ni": "^0.20.0",
|
|
55
55
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
56
56
|
"@sentry/node": "^7.70.0",
|
|
57
|
-
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.
|
|
57
|
+
"@slicemachine/manager": "^0.11.3-dev-next-hotfix.2",
|
|
58
58
|
"chalk": "^4.1.2",
|
|
59
59
|
"giget": "^1.1.2",
|
|
60
60
|
"globby": "^13.1.3",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
70
|
-
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.
|
|
70
|
+
"@slicemachine/plugin-kit": "0.4.17-dev-next-hotfix.2",
|
|
71
71
|
"@types/listr": "0.14.4",
|
|
72
72
|
"@types/prompts": "2.4.3",
|
|
73
73
|
"@types/semver": "7.3.13",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"vite-plugin-sdk": "0.1.1",
|
|
94
94
|
"vitest": "0.32.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "1b439215fb042d67972a9a7bdc8cae4d1c77859c"
|
|
97
97
|
}
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
import { detectStarterId } from "./lib/starters";
|
|
44
44
|
import { setupSentry } from "./lib/setupSentry";
|
|
45
45
|
import { trackSentryError } from "./lib/sentryErrorHandlers";
|
|
46
|
+
import { updateSentryContext } from "./lib/updateSentryContext";
|
|
46
47
|
|
|
47
48
|
export type SliceMachineInitProcessOptions = {
|
|
48
49
|
repository?: string;
|
|
@@ -134,6 +135,7 @@ export class SliceMachineInitProcess {
|
|
|
134
135
|
appName: pkg.name,
|
|
135
136
|
appVersion: pkg.version,
|
|
136
137
|
});
|
|
138
|
+
await setupSentry();
|
|
137
139
|
await this.manager.telemetry.track({
|
|
138
140
|
event: "command:init:start",
|
|
139
141
|
repository: this.options.repository,
|
|
@@ -336,7 +338,11 @@ export class SliceMachineInitProcess {
|
|
|
336
338
|
const framework =
|
|
337
339
|
this.context.framework?.sliceMachineTelemetryID ?? "unknown";
|
|
338
340
|
|
|
339
|
-
await
|
|
341
|
+
await updateSentryContext({
|
|
342
|
+
manager: this.manager,
|
|
343
|
+
repositoryName,
|
|
344
|
+
framework,
|
|
345
|
+
});
|
|
340
346
|
trackSentryError(error);
|
|
341
347
|
|
|
342
348
|
// Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace
|
|
@@ -345,7 +351,7 @@ export class SliceMachineInitProcess {
|
|
|
345
351
|
).slice(0, 512);
|
|
346
352
|
await this.manager.telemetry.track({
|
|
347
353
|
event: "command:init:end",
|
|
348
|
-
framework:
|
|
354
|
+
framework: framework,
|
|
349
355
|
repository: repositoryName,
|
|
350
356
|
success: false,
|
|
351
357
|
error: safeError,
|
|
@@ -2,26 +2,12 @@ import * as Sentry from "@sentry/node";
|
|
|
2
2
|
|
|
3
3
|
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
4
4
|
|
|
5
|
-
type ErrorWithCause = Error & {
|
|
6
|
-
cause?: unknown;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
function hasCause(error: unknown): error is ErrorWithCause {
|
|
10
|
-
return error instanceof Error && "cause" in error;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
5
|
export function trackSentryError(error: unknown): void {
|
|
14
|
-
if (checkIsSentryEnabled()) {
|
|
15
|
-
|
|
16
|
-
scope.setTransactionName("init");
|
|
17
|
-
Sentry.captureException(error, {
|
|
18
|
-
extra: {
|
|
19
|
-
cause:
|
|
20
|
-
hasCause(error) && error.cause !== undefined
|
|
21
|
-
? (error.cause as string)
|
|
22
|
-
: "",
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
});
|
|
6
|
+
if (!checkIsSentryEnabled()) {
|
|
7
|
+
return;
|
|
26
8
|
}
|
|
9
|
+
|
|
10
|
+
Sentry.captureException(error, {
|
|
11
|
+
...(error instanceof Error ? { extra: { cause: error.cause } } : {}),
|
|
12
|
+
});
|
|
27
13
|
}
|
package/src/lib/setupSentry.ts
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import * as Sentry from "@sentry/node";
|
|
2
2
|
import semver from "semver";
|
|
3
3
|
|
|
4
|
-
import { PrismicUserProfile, SliceMachineManager } from "@slicemachine/manager";
|
|
5
4
|
import { SENTRY_EXPRESS_DSN } from "../constants";
|
|
6
5
|
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
7
6
|
import { version } from "../../package.json";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
manager: SliceMachineManager;
|
|
11
|
-
repositoryName: string;
|
|
12
|
-
framework: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const setupSentry = async ({
|
|
16
|
-
manager,
|
|
17
|
-
repositoryName,
|
|
18
|
-
framework,
|
|
19
|
-
}: SetupSentryArgs): Promise<void> => {
|
|
8
|
+
export function setupSentry(): void {
|
|
20
9
|
if (!checkIsSentryEnabled()) {
|
|
21
10
|
return;
|
|
22
11
|
}
|
|
23
12
|
|
|
24
|
-
let userProfile: PrismicUserProfile | undefined;
|
|
25
|
-
try {
|
|
26
|
-
userProfile = await manager.user.getProfile();
|
|
27
|
-
} catch {
|
|
28
|
-
// User is not logged in, it doesn't matter
|
|
29
|
-
}
|
|
30
|
-
|
|
31
13
|
const isStableVersion =
|
|
32
14
|
semver.prerelease(version) === null && semver.lte("0.1.0", version);
|
|
33
15
|
|
|
@@ -38,19 +20,4 @@ export const setupSentry = async ({
|
|
|
38
20
|
? import.meta.env.MODE || "production"
|
|
39
21
|
: "alpha",
|
|
40
22
|
});
|
|
41
|
-
|
|
42
|
-
if (userProfile) {
|
|
43
|
-
Sentry.setUser({ id: userProfile.shortId });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (repositoryName) {
|
|
47
|
-
Sentry.setTag("repository", repositoryName);
|
|
48
|
-
Sentry.setContext("Repository Data", {
|
|
49
|
-
name: repositoryName,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (framework) {
|
|
54
|
-
Sentry.setTag("framework", framework);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/node";
|
|
2
|
+
|
|
3
|
+
import { PrismicUserProfile, SliceMachineManager } from "@slicemachine/manager";
|
|
4
|
+
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
5
|
+
|
|
6
|
+
type UpdateSentryContextArgs = {
|
|
7
|
+
manager: SliceMachineManager;
|
|
8
|
+
repositoryName: string;
|
|
9
|
+
framework: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export async function updateSentryContext({
|
|
13
|
+
manager,
|
|
14
|
+
repositoryName,
|
|
15
|
+
framework,
|
|
16
|
+
}: UpdateSentryContextArgs): Promise<void> {
|
|
17
|
+
if (!checkIsSentryEnabled()) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let userProfile: PrismicUserProfile | undefined;
|
|
22
|
+
try {
|
|
23
|
+
userProfile = await manager.user.getProfile();
|
|
24
|
+
} catch {
|
|
25
|
+
// User is not logged in, it doesn't matter
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (userProfile) {
|
|
29
|
+
Sentry.setUser({ id: userProfile.shortId });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (repositoryName) {
|
|
33
|
+
Sentry.setTag("repository", repositoryName);
|
|
34
|
+
Sentry.setContext("Repository Data", {
|
|
35
|
+
name: repositoryName,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (framework) {
|
|
40
|
+
Sentry.setTag("framework", framework);
|
|
41
|
+
}
|
|
42
|
+
}
|