@slicemachine/init 2.6.4-dev-next-hotfix.2 → 2.6.4-dev-upgrade-legacy.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.
Files changed (41) hide show
  1. package/dist/SliceMachineInitProcess.cjs +32 -26
  2. package/dist/SliceMachineInitProcess.cjs.map +1 -1
  3. package/dist/SliceMachineInitProcess.d.ts +1 -1
  4. package/dist/SliceMachineInitProcess.js +32 -26
  5. package/dist/SliceMachineInitProcess.js.map +1 -1
  6. package/dist/constants.cjs +0 -2
  7. package/dist/constants.cjs.map +1 -1
  8. package/dist/constants.d.ts +0 -1
  9. package/dist/constants.js +0 -2
  10. package/dist/constants.js.map +1 -1
  11. package/dist/packages/init/package.json.cjs +4 -5
  12. package/dist/packages/init/package.json.cjs.map +1 -1
  13. package/dist/packages/init/package.json.js +4 -5
  14. package/dist/packages/init/package.json.js.map +1 -1
  15. package/package.json +4 -5
  16. package/src/SliceMachineInitProcess.ts +53 -29
  17. package/src/constants.ts +0 -3
  18. package/dist/lib/checkIsSentryEnabled.cjs +0 -5
  19. package/dist/lib/checkIsSentryEnabled.cjs.map +0 -1
  20. package/dist/lib/checkIsSentryEnabled.d.ts +0 -9
  21. package/dist/lib/checkIsSentryEnabled.js +0 -5
  22. package/dist/lib/checkIsSentryEnabled.js.map +0 -1
  23. package/dist/lib/sentryErrorHandlers.cjs +0 -31
  24. package/dist/lib/sentryErrorHandlers.cjs.map +0 -1
  25. package/dist/lib/sentryErrorHandlers.d.ts +0 -1
  26. package/dist/lib/sentryErrorHandlers.js +0 -14
  27. package/dist/lib/sentryErrorHandlers.js.map +0 -1
  28. package/dist/lib/setupSentry.cjs +0 -37
  29. package/dist/lib/setupSentry.cjs.map +0 -1
  30. package/dist/lib/setupSentry.d.ts +0 -1
  31. package/dist/lib/setupSentry.js +0 -20
  32. package/dist/lib/setupSentry.js.map +0 -1
  33. package/dist/lib/updateSentryContext.cjs +0 -45
  34. package/dist/lib/updateSentryContext.cjs.map +0 -1
  35. package/dist/lib/updateSentryContext.d.ts +0 -8
  36. package/dist/lib/updateSentryContext.js +0 -28
  37. package/dist/lib/updateSentryContext.js.map +0 -1
  38. package/src/lib/checkIsSentryEnabled.ts +0 -12
  39. package/src/lib/sentryErrorHandlers.ts +0 -13
  40. package/src/lib/setupSentry.ts +0 -23
  41. package/src/lib/updateSentryContext.ts +0 -42
@@ -41,9 +41,6 @@ import {
41
41
  START_SCRIPT_VALUE,
42
42
  } from "./constants";
43
43
  import { detectStarterId } from "./lib/starters";
44
- import { setupSentry } from "./lib/setupSentry";
45
- import { trackSentryError } from "./lib/sentryErrorHandlers";
46
- import { updateSentryContext } from "./lib/updateSentryContext";
47
44
 
48
45
  export type SliceMachineInitProcessOptions = {
49
46
  repository?: string;
@@ -135,7 +132,6 @@ export class SliceMachineInitProcess {
135
132
  appName: pkg.name,
136
133
  appVersion: pkg.version,
137
134
  });
138
- await setupSentry();
139
135
  await this.manager.telemetry.track({
140
136
  event: "command:init:start",
141
137
  repository: this.options.repository,
@@ -176,7 +172,7 @@ export class SliceMachineInitProcess {
176
172
  await this.createNewRepository();
177
173
  }
178
174
 
179
- await this.pushDataToPrismic();
175
+ await this.syncDataWithPrismic();
180
176
  await this.initializeProject();
181
177
  await this.initializePlugins();
182
178
  } catch (error) {
@@ -303,8 +299,8 @@ export class SliceMachineInitProcess {
303
299
  }
304
300
  }
305
301
  }
306
- } catch (error) {
307
- await this.trackError(error);
302
+ } catch {
303
+ // Noop, it's only the final convenience messsage
308
304
  }
309
305
  }
310
306
 
@@ -319,6 +315,8 @@ export class SliceMachineInitProcess {
319
315
  this.manager.customTypes.readCustomTypeLibrary(),
320
316
  this.readDocuments(),
321
317
  ]);
318
+
319
+ // If repository exists, and there's anything to push
322
320
  if (
323
321
  slices.length > 0 ||
324
322
  ctLibrary.ids.length > 0 ||
@@ -326,6 +324,11 @@ export class SliceMachineInitProcess {
326
324
  ) {
327
325
  return true;
328
326
  }
327
+
328
+ // If repository exists, and there might be things to pull
329
+ if (ctLibrary.ids.length === 0) {
330
+ return true;
331
+ }
329
332
  } catch (e) {
330
333
  return true;
331
334
  }
@@ -333,26 +336,16 @@ export class SliceMachineInitProcess {
333
336
  return false;
334
337
  }
335
338
 
336
- protected trackError = async (error: unknown): Promise<void> => {
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
-
339
+ protected trackError = (error: unknown): Promise<void> => {
348
340
  // Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace
349
341
  const safeError = (
350
342
  error instanceof Error ? error.message : `${error}`
351
343
  ).slice(0, 512);
352
- await this.manager.telemetry.track({
344
+
345
+ return this.manager.telemetry.track({
353
346
  event: "command:init:end",
354
- framework: framework,
355
- repository: repositoryName,
347
+ framework: this.context.framework?.sliceMachineTelemetryID ?? "unknown",
348
+ repository: this.context.repository?.domain || "",
356
349
  success: false,
357
350
  error: safeError,
358
351
  });
@@ -1106,10 +1099,10 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1106
1099
  return { signature, documents, directoryPath: documentsDirectoryPath };
1107
1100
  }
1108
1101
 
1109
- protected pushDataToPrismic(): Promise<void> {
1102
+ protected syncDataWithPrismic(): Promise<void> {
1110
1103
  return listrRun([
1111
1104
  {
1112
- title: "Pushing data to Prismic...",
1105
+ title: "Syncing data with Prismic...",
1113
1106
  task: (_, parentTask) =>
1114
1107
  listr([
1115
1108
  {
@@ -1205,7 +1198,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1205
1198
  task: async (_, task) => {
1206
1199
  assertExists(
1207
1200
  this.context.repository,
1208
- "Repository selection must be available through context to run `pushDataToPrismic`",
1201
+ "Repository selection must be available through context to run `syncDataWithPrismic`",
1209
1202
  );
1210
1203
 
1211
1204
  try {
@@ -1215,7 +1208,6 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1215
1208
  documentsRead === undefined ||
1216
1209
  documentsRead.documents.length === 0
1217
1210
  ) {
1218
- parentTask.title = "Pushed data to Prismic";
1219
1211
  task.skip("No document to push");
1220
1212
 
1221
1213
  return;
@@ -1257,9 +1249,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1257
1249
  });
1258
1250
 
1259
1251
  task.title = "Pushed all documents";
1260
- parentTask.title = "Pushed data to Prismic";
1261
1252
  } catch {
1262
- parentTask.title = "Pushed data to Prismic";
1263
1253
  task.skip("No document to push");
1264
1254
 
1265
1255
  return;
@@ -1281,7 +1271,41 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1281
1271
  }
1282
1272
 
1283
1273
  task.title = "Cleaned up data push artifacts";
1284
- parentTask.title = "Pushed data to Prismic";
1274
+ },
1275
+ },
1276
+ {
1277
+ title: "Pulling existing types...",
1278
+ task: async (_, task) => {
1279
+ const { ids, errors } =
1280
+ await this.manager.customTypes.readCustomTypeLibrary();
1281
+
1282
+ if (errors.length > 0) {
1283
+ // TODO: Provide better error message.
1284
+ throw new Error(
1285
+ `Failed to read custom type libraries: ${errors.join(
1286
+ ", ",
1287
+ )}`,
1288
+ );
1289
+ }
1290
+
1291
+ if (ids && ids.length > 0) {
1292
+ task.skip("Types already exists");
1293
+ parentTask.title = "Synced data with Prismic";
1294
+
1295
+ return;
1296
+ }
1297
+
1298
+ const remoteTypes =
1299
+ await this.manager.customTypes.fetchRemoteCustomTypes();
1300
+
1301
+ await Promise.all(
1302
+ remoteTypes.map(async (model) => {
1303
+ await this.manager.customTypes.createCustomType({ model });
1304
+ }),
1305
+ );
1306
+
1307
+ task.title = "Pulled existing types";
1308
+ parentTask.title = "Synced data with Prismic";
1285
1309
  },
1286
1310
  },
1287
1311
  ]),
package/src/constants.ts CHANGED
@@ -4,6 +4,3 @@ export const START_SCRIPT_VALUE = "start-slicemachine";
4
4
  export const GIGET_PROVIDER = "github";
5
5
  export const GIGET_ORGANIZATION = "prismicio-community";
6
6
  export const SLICE_MACHINE_INIT_USER_AGENT = "slice-machine-init";
7
- export const SENTRY_EXPRESS_DSN =
8
- import.meta.env.VITE_SENTRY_EXPRESS_DSN ||
9
- "https://d3e69d5189266d8d7f60f71ccc9353fc@o146123.ingest.sentry.io/4505917981982720";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const checkIsSentryEnabled = () => ({}).VITE_ENABLE_SENTRY === void 0 ? true : {}.VITE_ENABLE_SENTRY === "true";
4
- exports.checkIsSentryEnabled = checkIsSentryEnabled;
5
- //# sourceMappingURL=checkIsSentryEnabled.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkIsSentryEnabled.cjs","sources":["../../../src/lib/checkIsSentryEnabled.ts"],"sourcesContent":["/**\n * Checks whether or not Sentry is enabled.\n *\n * Sentry is enabled automatically in production but can be disabled by setting\n * `VITE_ENABLE_SENTRY` to `false`.\n *\n * @returns Whether or not Sentry is enabled.\n */\nexport const checkIsSentryEnabled = (): boolean =>\n\timport.meta.env.VITE_ENABLE_SENTRY === undefined\n\t\t? import.meta.env.PROD\n\t\t: import.meta.env.VITE_ENABLE_SENTRY === \"true\";\n"],"names":[],"mappings":";;AAQa,MAAA,uBAAuB,OACnB,CAAA,GAAA,uBAAuB,SACpC,OACgB,CAAA,EAAA,uBAAuB;;"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Checks whether or not Sentry is enabled.
3
- *
4
- * Sentry is enabled automatically in production but can be disabled by setting
5
- * `VITE_ENABLE_SENTRY` to `false`.
6
- *
7
- * @returns Whether or not Sentry is enabled.
8
- */
9
- export declare const checkIsSentryEnabled: () => boolean;
@@ -1,5 +0,0 @@
1
- const checkIsSentryEnabled = () => ({}).VITE_ENABLE_SENTRY === void 0 ? true : {}.VITE_ENABLE_SENTRY === "true";
2
- export {
3
- checkIsSentryEnabled
4
- };
5
- //# sourceMappingURL=checkIsSentryEnabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkIsSentryEnabled.js","sources":["../../../src/lib/checkIsSentryEnabled.ts"],"sourcesContent":["/**\n * Checks whether or not Sentry is enabled.\n *\n * Sentry is enabled automatically in production but can be disabled by setting\n * `VITE_ENABLE_SENTRY` to `false`.\n *\n * @returns Whether or not Sentry is enabled.\n */\nexport const checkIsSentryEnabled = (): boolean =>\n\timport.meta.env.VITE_ENABLE_SENTRY === undefined\n\t\t? import.meta.env.PROD\n\t\t: import.meta.env.VITE_ENABLE_SENTRY === \"true\";\n"],"names":[],"mappings":"AAQa,MAAA,uBAAuB,OACnB,CAAA,GAAA,uBAAuB,SACpC,OACgB,CAAA,EAAA,uBAAuB;"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Sentry = require("@sentry/node");
4
- const checkIsSentryEnabled = require("./checkIsSentryEnabled.cjs");
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const Sentry__namespace = /* @__PURE__ */ _interopNamespaceDefault(Sentry);
22
- function trackSentryError(error) {
23
- if (!checkIsSentryEnabled.checkIsSentryEnabled()) {
24
- return;
25
- }
26
- Sentry__namespace.captureException(error, {
27
- ...error instanceof Error ? { extra: { cause: error.cause } } : {}
28
- });
29
- }
30
- exports.trackSentryError = trackSentryError;
31
- //# sourceMappingURL=sentryErrorHandlers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentryErrorHandlers.cjs","sources":["../../../src/lib/sentryErrorHandlers.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\n\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\n\nexport function trackSentryError(error: unknown): void {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tSentry.captureException(error, {\n\t\t...(error instanceof Error ? { extra: { cause: error.cause } } : {}),\n\t});\n}\n"],"names":["checkIsSentryEnabled","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIM,SAAU,iBAAiB,OAAc;AAC1C,MAAA,CAACA,6CAAwB;AAC5B;AAAA,EACA;AAEDC,oBAAO,iBAAiB,OAAO;AAAA,IAC9B,GAAI,iBAAiB,QAAQ,EAAE,OAAO,EAAE,OAAO,MAAM,YAAY,CAAA;AAAA,EAAA,CACjE;AACF;;"}
@@ -1 +0,0 @@
1
- export declare function trackSentryError(error: unknown): void;
@@ -1,14 +0,0 @@
1
- import * as Sentry from "@sentry/node";
2
- import { checkIsSentryEnabled } from "./checkIsSentryEnabled.js";
3
- function trackSentryError(error) {
4
- if (!checkIsSentryEnabled()) {
5
- return;
6
- }
7
- Sentry.captureException(error, {
8
- ...error instanceof Error ? { extra: { cause: error.cause } } : {}
9
- });
10
- }
11
- export {
12
- trackSentryError
13
- };
14
- //# sourceMappingURL=sentryErrorHandlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sentryErrorHandlers.js","sources":["../../../src/lib/sentryErrorHandlers.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\n\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\n\nexport function trackSentryError(error: unknown): void {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tSentry.captureException(error, {\n\t\t...(error instanceof Error ? { extra: { cause: error.cause } } : {}),\n\t});\n}\n"],"names":[],"mappings":";;AAIM,SAAU,iBAAiB,OAAc;AAC1C,MAAA,CAAC,wBAAwB;AAC5B;AAAA,EACA;AAED,SAAO,iBAAiB,OAAO;AAAA,IAC9B,GAAI,iBAAiB,QAAQ,EAAE,OAAO,EAAE,OAAO,MAAM,YAAY,CAAA;AAAA,EAAA,CACjE;AACF;"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Sentry = require("@sentry/node");
4
- const semver = require("semver");
5
- const constants = require("../constants.cjs");
6
- const checkIsSentryEnabled = require("./checkIsSentryEnabled.cjs");
7
- const _package = require("../packages/init/package.json.cjs");
8
- function _interopNamespaceDefault(e) {
9
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
- if (e) {
11
- for (const k in e) {
12
- if (k !== "default") {
13
- const d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: () => e[k]
17
- });
18
- }
19
- }
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
- const Sentry__namespace = /* @__PURE__ */ _interopNamespaceDefault(Sentry);
25
- function setupSentry() {
26
- if (!checkIsSentryEnabled.checkIsSentryEnabled()) {
27
- return;
28
- }
29
- const isStableVersion = semver.prerelease(_package.version) === null && semver.lte("0.1.0", _package.version);
30
- Sentry__namespace.init({
31
- dsn: constants.SENTRY_EXPRESS_DSN,
32
- release: _package.version,
33
- environment: isStableVersion ? "production" : "alpha"
34
- });
35
- }
36
- exports.setupSentry = setupSentry;
37
- //# sourceMappingURL=setupSentry.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupSentry.cjs","sources":["../../../src/lib/setupSentry.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\nimport semver from \"semver\";\n\nimport { SENTRY_EXPRESS_DSN } from \"../constants\";\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\nimport { version } from \"../../package.json\";\n\nexport function setupSentry(): void {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tconst isStableVersion =\n\t\tsemver.prerelease(version) === null && semver.lte(\"0.1.0\", version);\n\n\tSentry.init({\n\t\tdsn: SENTRY_EXPRESS_DSN,\n\t\trelease: version,\n\t\tenvironment: isStableVersion\n\t\t\t? import.meta.env.MODE || \"production\"\n\t\t\t: \"alpha\",\n\t});\n}\n"],"names":["checkIsSentryEnabled","version","Sentry","SENTRY_EXPRESS_DSN"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;SAOgB,cAAW;AACtB,MAAA,CAACA,6CAAwB;AAC5B;AAAA,EACA;AAEK,QAAA,kBACL,OAAO,WAAWC,gBAAO,MAAM,QAAQ,OAAO,IAAI,SAASA,SAAAA,OAAO;AAEnEC,oBAAO,KAAK;AAAA,IACX,KAAKC,UAAA;AAAA,IACL,SAASF,SAAA;AAAA,IACT,aAAa,kBACV,eACA;AAAA,EAAA,CACH;AACF;;"}
@@ -1 +0,0 @@
1
- export declare function setupSentry(): void;
@@ -1,20 +0,0 @@
1
- import * as Sentry from "@sentry/node";
2
- import semver from "semver";
3
- import { SENTRY_EXPRESS_DSN } from "../constants.js";
4
- import { checkIsSentryEnabled } from "./checkIsSentryEnabled.js";
5
- import { version } from "../packages/init/package.json.js";
6
- function setupSentry() {
7
- if (!checkIsSentryEnabled()) {
8
- return;
9
- }
10
- const isStableVersion = semver.prerelease(version) === null && semver.lte("0.1.0", version);
11
- Sentry.init({
12
- dsn: SENTRY_EXPRESS_DSN,
13
- release: version,
14
- environment: isStableVersion ? "production" : "alpha"
15
- });
16
- }
17
- export {
18
- setupSentry
19
- };
20
- //# sourceMappingURL=setupSentry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupSentry.js","sources":["../../../src/lib/setupSentry.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\nimport semver from \"semver\";\n\nimport { SENTRY_EXPRESS_DSN } from \"../constants\";\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\nimport { version } from \"../../package.json\";\n\nexport function setupSentry(): void {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tconst isStableVersion =\n\t\tsemver.prerelease(version) === null && semver.lte(\"0.1.0\", version);\n\n\tSentry.init({\n\t\tdsn: SENTRY_EXPRESS_DSN,\n\t\trelease: version,\n\t\tenvironment: isStableVersion\n\t\t\t? import.meta.env.MODE || \"production\"\n\t\t\t: \"alpha\",\n\t});\n}\n"],"names":[],"mappings":";;;;;SAOgB,cAAW;AACtB,MAAA,CAAC,wBAAwB;AAC5B;AAAA,EACA;AAEK,QAAA,kBACL,OAAO,WAAW,OAAO,MAAM,QAAQ,OAAO,IAAI,SAAS,OAAO;AAEnE,SAAO,KAAK;AAAA,IACX,KAAK;AAAA,IACL,SAAS;AAAA,IACT,aAAa,kBACV,eACA;AAAA,EAAA,CACH;AACF;"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Sentry = require("@sentry/node");
4
- const checkIsSentryEnabled = require("./checkIsSentryEnabled.cjs");
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const Sentry__namespace = /* @__PURE__ */ _interopNamespaceDefault(Sentry);
22
- async function updateSentryContext({ manager, repositoryName, framework }) {
23
- if (!checkIsSentryEnabled.checkIsSentryEnabled()) {
24
- return;
25
- }
26
- let userProfile;
27
- try {
28
- userProfile = await manager.user.getProfile();
29
- } catch {
30
- }
31
- if (userProfile) {
32
- Sentry__namespace.setUser({ id: userProfile.shortId });
33
- }
34
- if (repositoryName) {
35
- Sentry__namespace.setTag("repository", repositoryName);
36
- Sentry__namespace.setContext("Repository Data", {
37
- name: repositoryName
38
- });
39
- }
40
- if (framework) {
41
- Sentry__namespace.setTag("framework", framework);
42
- }
43
- }
44
- exports.updateSentryContext = updateSentryContext;
45
- //# sourceMappingURL=updateSentryContext.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateSentryContext.cjs","sources":["../../../src/lib/updateSentryContext.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\n\nimport { PrismicUserProfile, SliceMachineManager } from \"@slicemachine/manager\";\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\n\ntype UpdateSentryContextArgs = {\n\tmanager: SliceMachineManager;\n\trepositoryName: string;\n\tframework: string;\n};\n\nexport async function updateSentryContext({\n\tmanager,\n\trepositoryName,\n\tframework,\n}: UpdateSentryContextArgs): Promise<void> {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tlet userProfile: PrismicUserProfile | undefined;\n\ttry {\n\t\tuserProfile = await manager.user.getProfile();\n\t} catch {\n\t\t// User is not logged in, it doesn't matter\n\t}\n\n\tif (userProfile) {\n\t\tSentry.setUser({ id: userProfile.shortId });\n\t}\n\n\tif (repositoryName) {\n\t\tSentry.setTag(\"repository\", repositoryName);\n\t\tSentry.setContext(\"Repository Data\", {\n\t\t\tname: repositoryName,\n\t\t});\n\t}\n\n\tif (framework) {\n\t\tSentry.setTag(\"framework\", framework);\n\t}\n}\n"],"names":["checkIsSentryEnabled","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,eAAsB,oBAAoB,EACzC,SACA,gBACA,aACyB;AACrB,MAAA,CAACA,6CAAwB;AAC5B;AAAA,EACA;AAEG,MAAA;AACA,MAAA;AACW,kBAAA,MAAM,QAAQ,KAAK;UAChC;AAAA,EAED;AAED,MAAI,aAAa;AAChBC,sBAAO,QAAQ,EAAE,IAAI,YAAY,QAAS,CAAA;AAAA,EAC1C;AAED,MAAI,gBAAgB;AACZA,sBAAA,OAAO,cAAc,cAAc;AAC1CA,sBAAO,WAAW,mBAAmB;AAAA,MACpC,MAAM;AAAA,IAAA,CACN;AAAA,EACD;AAED,MAAI,WAAW;AACPA,sBAAA,OAAO,aAAa,SAAS;AAAA,EACpC;AACF;;"}
@@ -1,8 +0,0 @@
1
- import { SliceMachineManager } from "@slicemachine/manager";
2
- type UpdateSentryContextArgs = {
3
- manager: SliceMachineManager;
4
- repositoryName: string;
5
- framework: string;
6
- };
7
- export declare function updateSentryContext({ manager, repositoryName, framework, }: UpdateSentryContextArgs): Promise<void>;
8
- export {};
@@ -1,28 +0,0 @@
1
- import * as Sentry from "@sentry/node";
2
- import { checkIsSentryEnabled } from "./checkIsSentryEnabled.js";
3
- async function updateSentryContext({ manager, repositoryName, framework }) {
4
- if (!checkIsSentryEnabled()) {
5
- return;
6
- }
7
- let userProfile;
8
- try {
9
- userProfile = await manager.user.getProfile();
10
- } catch {
11
- }
12
- if (userProfile) {
13
- Sentry.setUser({ id: userProfile.shortId });
14
- }
15
- if (repositoryName) {
16
- Sentry.setTag("repository", repositoryName);
17
- Sentry.setContext("Repository Data", {
18
- name: repositoryName
19
- });
20
- }
21
- if (framework) {
22
- Sentry.setTag("framework", framework);
23
- }
24
- }
25
- export {
26
- updateSentryContext
27
- };
28
- //# sourceMappingURL=updateSentryContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"updateSentryContext.js","sources":["../../../src/lib/updateSentryContext.ts"],"sourcesContent":["import * as Sentry from \"@sentry/node\";\n\nimport { PrismicUserProfile, SliceMachineManager } from \"@slicemachine/manager\";\nimport { checkIsSentryEnabled } from \"./checkIsSentryEnabled\";\n\ntype UpdateSentryContextArgs = {\n\tmanager: SliceMachineManager;\n\trepositoryName: string;\n\tframework: string;\n};\n\nexport async function updateSentryContext({\n\tmanager,\n\trepositoryName,\n\tframework,\n}: UpdateSentryContextArgs): Promise<void> {\n\tif (!checkIsSentryEnabled()) {\n\t\treturn;\n\t}\n\n\tlet userProfile: PrismicUserProfile | undefined;\n\ttry {\n\t\tuserProfile = await manager.user.getProfile();\n\t} catch {\n\t\t// User is not logged in, it doesn't matter\n\t}\n\n\tif (userProfile) {\n\t\tSentry.setUser({ id: userProfile.shortId });\n\t}\n\n\tif (repositoryName) {\n\t\tSentry.setTag(\"repository\", repositoryName);\n\t\tSentry.setContext(\"Repository Data\", {\n\t\t\tname: repositoryName,\n\t\t});\n\t}\n\n\tif (framework) {\n\t\tSentry.setTag(\"framework\", framework);\n\t}\n}\n"],"names":[],"mappings":";;AAWA,eAAsB,oBAAoB,EACzC,SACA,gBACA,aACyB;AACrB,MAAA,CAAC,wBAAwB;AAC5B;AAAA,EACA;AAEG,MAAA;AACA,MAAA;AACW,kBAAA,MAAM,QAAQ,KAAK;UAChC;AAAA,EAED;AAED,MAAI,aAAa;AAChB,WAAO,QAAQ,EAAE,IAAI,YAAY,QAAS,CAAA;AAAA,EAC1C;AAED,MAAI,gBAAgB;AACZ,WAAA,OAAO,cAAc,cAAc;AAC1C,WAAO,WAAW,mBAAmB;AAAA,MACpC,MAAM;AAAA,IAAA,CACN;AAAA,EACD;AAED,MAAI,WAAW;AACP,WAAA,OAAO,aAAa,SAAS;AAAA,EACpC;AACF;"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Checks whether or not Sentry is enabled.
3
- *
4
- * Sentry is enabled automatically in production but can be disabled by setting
5
- * `VITE_ENABLE_SENTRY` to `false`.
6
- *
7
- * @returns Whether or not Sentry is enabled.
8
- */
9
- export const checkIsSentryEnabled = (): boolean =>
10
- import.meta.env.VITE_ENABLE_SENTRY === undefined
11
- ? import.meta.env.PROD
12
- : import.meta.env.VITE_ENABLE_SENTRY === "true";
@@ -1,13 +0,0 @@
1
- import * as Sentry from "@sentry/node";
2
-
3
- import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
4
-
5
- export function trackSentryError(error: unknown): void {
6
- if (!checkIsSentryEnabled()) {
7
- return;
8
- }
9
-
10
- Sentry.captureException(error, {
11
- ...(error instanceof Error ? { extra: { cause: error.cause } } : {}),
12
- });
13
- }
@@ -1,23 +0,0 @@
1
- import * as Sentry from "@sentry/node";
2
- import semver from "semver";
3
-
4
- import { SENTRY_EXPRESS_DSN } from "../constants";
5
- import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
6
- import { version } from "../../package.json";
7
-
8
- export function setupSentry(): void {
9
- if (!checkIsSentryEnabled()) {
10
- return;
11
- }
12
-
13
- const isStableVersion =
14
- semver.prerelease(version) === null && semver.lte("0.1.0", version);
15
-
16
- Sentry.init({
17
- dsn: SENTRY_EXPRESS_DSN,
18
- release: version,
19
- environment: isStableVersion
20
- ? import.meta.env.MODE || "production"
21
- : "alpha",
22
- });
23
- }
@@ -1,42 +0,0 @@
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
- }