@slicemachine/init 2.6.4-dev-next-hotfix.0 → 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.
@@ -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.0";
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",
@@ -42,7 +42,7 @@ const scripts = {
42
42
  dev: "vite build --watch",
43
43
  format: "prettier --write .",
44
44
  lint: "eslint --max-warnings 0 --ext .js,.ts .",
45
- prepack: "npm run build",
45
+ prepack: "$npm_execpath run build",
46
46
  size: "size-limit",
47
47
  test: "yarn lint && yarn types && yarn unit && yarn build && yarn size",
48
48
  types: "tsc --noEmit",
@@ -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.0",
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.0",
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 = "01f71118f1d7c2b422f527dad5949368f7c816ce";
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.0";
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",
@@ -40,7 +40,7 @@ const scripts = {
40
40
  dev: "vite build --watch",
41
41
  format: "prettier --write .",
42
42
  lint: "eslint --max-warnings 0 --ext .js,.ts .",
43
- prepack: "npm run build",
43
+ prepack: "$npm_execpath run build",
44
44
  size: "size-limit",
45
45
  test: "yarn lint && yarn types && yarn unit && yarn build && yarn size",
46
46
  types: "tsc --noEmit",
@@ -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.0",
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.0",
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 = "01f71118f1d7c2b422f527dad5949368f7c816ce";
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.0",
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",
@@ -41,7 +41,7 @@
41
41
  "dev": "vite build --watch",
42
42
  "format": "prettier --write .",
43
43
  "lint": "eslint --max-warnings 0 --ext .js,.ts .",
44
- "prepack": "npm run build",
44
+ "prepack": "$npm_execpath run build",
45
45
  "size": "size-limit",
46
46
  "test": "yarn lint && yarn types && yarn unit && yarn build && yarn size",
47
47
  "types": "tsc --noEmit",
@@ -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.0",
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.0",
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": "01f71118f1d7c2b422f527dad5949368f7c816ce"
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,
@@ -332,26 +334,28 @@ export class SliceMachineInitProcess {
332
334
  }
333
335
 
334
336
  protected trackError = async (error: unknown): Promise<void> => {
335
- if (await this.manager.telemetry.checkIsTelemetryEnabled()) {
336
- const repositoryName = this.context.repository?.domain || "";
337
- const framework =
338
- this.context.framework?.sliceMachineTelemetryID ?? "unknown";
339
-
340
- await setupSentry({ manager: this.manager, repositoryName, framework });
341
- trackSentryError(error);
342
-
343
- // Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace
344
- const safeError = (
345
- error instanceof Error ? error.message : `${error}`
346
- ).slice(0, 512);
347
- await this.manager.telemetry.track({
348
- event: "command:init:end",
349
- framework: this.context.framework?.sliceMachineTelemetryID ?? "unknown",
350
- repository: repositoryName,
351
- success: false,
352
- error: safeError,
353
- });
354
- }
337
+ const repositoryName = this.context.repository?.domain || "";
338
+ const framework =
339
+ this.context.framework?.sliceMachineTelemetryID ?? "unknown";
340
+
341
+ await updateSentryContext({
342
+ manager: this.manager,
343
+ repositoryName,
344
+ framework,
345
+ });
346
+ trackSentryError(error);
347
+
348
+ // Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace
349
+ const safeError = (
350
+ error instanceof Error ? error.message : `${error}`
351
+ ).slice(0, 512);
352
+ await this.manager.telemetry.track({
353
+ event: "command:init:end",
354
+ framework: framework,
355
+ repository: repositoryName,
356
+ success: false,
357
+ error: safeError,
358
+ });
355
359
  };
356
360
 
357
361
  protected async copyStarter(): Promise<void> {
@@ -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
- Sentry.withScope(function (scope) {
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
  }
@@ -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
- type SetupSentryArgs = {
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,12 +20,4 @@ export const setupSentry = async ({
38
20
  ? import.meta.env.MODE || "production"
39
21
  : "alpha",
40
22
  });
41
- if (userProfile) {
42
- Sentry.setUser({ id: userProfile.shortId });
43
- }
44
- Sentry.setTag("repository", repositoryName);
45
- Sentry.setContext("Repository Data", {
46
- name: repositoryName,
47
- });
48
- Sentry.setTag("framework", framework);
49
- };
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
+ }