@slicemachine/manager 0.20.8-beta.1 → 0.21.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 (53) hide show
  1. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.cjs +1 -1
  2. package/dist/_node_modules/@amplitude/experiment-node-server/dist/src/local/client.js +1 -1
  3. package/dist/_node_modules/cross-spawn/index.cjs +1 -1
  4. package/dist/_node_modules/cross-spawn/index.js +1 -1
  5. package/dist/_node_modules/zod/lib/index.cjs +4030 -0
  6. package/dist/_node_modules/zod/lib/index.cjs.map +1 -0
  7. package/dist/_node_modules/zod/lib/index.js +4033 -0
  8. package/dist/_node_modules/zod/lib/index.js.map +1 -0
  9. package/dist/_virtual/index2.cjs +3 -4
  10. package/dist/_virtual/index2.cjs.map +1 -1
  11. package/dist/_virtual/index2.js +2 -4
  12. package/dist/_virtual/index2.js.map +1 -1
  13. package/dist/_virtual/index3.cjs +4 -3
  14. package/dist/_virtual/index3.cjs.map +1 -1
  15. package/dist/_virtual/index3.js +4 -2
  16. package/dist/_virtual/index3.js.map +1 -1
  17. package/dist/constants/API_ENDPOINTS.cjs +6 -3
  18. package/dist/constants/API_ENDPOINTS.cjs.map +1 -1
  19. package/dist/constants/API_ENDPOINTS.d.ts +1 -0
  20. package/dist/constants/API_ENDPOINTS.js +6 -3
  21. package/dist/constants/API_ENDPOINTS.js.map +1 -1
  22. package/dist/lib/DecodeError.cjs +15 -1
  23. package/dist/lib/DecodeError.cjs.map +1 -1
  24. package/dist/lib/DecodeError.d.ts +2 -1
  25. package/dist/lib/DecodeError.js +15 -1
  26. package/dist/lib/DecodeError.js.map +1 -1
  27. package/dist/lib/decode.cjs +13 -2
  28. package/dist/lib/decode.cjs.map +1 -1
  29. package/dist/lib/decode.d.ts +3 -1
  30. package/dist/lib/decode.js +13 -2
  31. package/dist/lib/decode.js.map +1 -1
  32. package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs +76 -0
  33. package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs.map +1 -1
  34. package/dist/managers/prismicRepository/PrismicRepositoryManager.d.ts +8 -1
  35. package/dist/managers/prismicRepository/PrismicRepositoryManager.js +77 -1
  36. package/dist/managers/prismicRepository/PrismicRepositoryManager.js.map +1 -1
  37. package/dist/managers/prismicRepository/types.cjs +26 -0
  38. package/dist/managers/prismicRepository/types.cjs.map +1 -1
  39. package/dist/managers/prismicRepository/types.d.ts +33 -0
  40. package/dist/managers/prismicRepository/types.js +27 -1
  41. package/dist/managers/prismicRepository/types.js.map +1 -1
  42. package/dist/managers/telemetry/types.cjs +14 -8
  43. package/dist/managers/telemetry/types.cjs.map +1 -1
  44. package/dist/managers/telemetry/types.d.ts +23 -13
  45. package/dist/managers/telemetry/types.js +14 -8
  46. package/dist/managers/telemetry/types.js.map +1 -1
  47. package/package.json +3 -4
  48. package/src/constants/API_ENDPOINTS.ts +6 -0
  49. package/src/lib/DecodeError.ts +21 -2
  50. package/src/lib/decode.ts +30 -4
  51. package/src/managers/prismicRepository/PrismicRepositoryManager.ts +112 -1
  52. package/src/managers/prismicRepository/types.ts +38 -0
  53. package/src/managers/telemetry/types.ts +41 -18
@@ -32,13 +32,16 @@ export declare const SegmentEventType: {
32
32
  readonly sliceMachine_start: "slice-machine:start";
33
33
  readonly sliceLibrary_beta_modalOpened: "slice-library:beta:modal-opened";
34
34
  readonly sliceLibrary_beta_codeOpened: "slice-library:beta:code-opened";
35
- readonly onboarding_step_opened: "onboarding:step-opened";
36
- readonly onboarding_step_completed: "onboarding:step-completed";
37
- readonly onboarding_completed: "onboarding:completed";
38
35
  readonly postPush_emptyStateCtaClicked: "post-push:empty-state-cta-clicked";
39
36
  readonly postPush_toastCtaClicked: "post-push:toast-cta-clicked";
40
37
  readonly experiment_exposure: "experiment:exposure";
41
38
  readonly sliceName_pascalCaseError: "slice-name-error:pascal-case";
39
+ readonly onboarding_step_opened: "onboarding:step-opened";
40
+ readonly onboarding_step_completed: "onboarding:step-completed";
41
+ readonly onboarding_completed: "onboarding:completed";
42
+ readonly sharedOnboarding_step_opened: "shared-onboarding:step-opened";
43
+ readonly sharedOnboarding_step_completed: "shared-onboarding:step-completed";
44
+ readonly sharedOnboarding_completed: "shared-onboarding:completed";
42
45
  };
43
46
  type SegmentEventTypes = (typeof SegmentEventType)[keyof typeof SegmentEventType];
44
47
  export declare const HumanSegmentEventType: {
@@ -71,13 +74,16 @@ export declare const HumanSegmentEventType: {
71
74
  readonly "slice-machine:start": "SliceMachine Start";
72
75
  readonly "slice-library:beta:modal-opened": "SliceMachine Slice Library [BETA] CTA modal displayed";
73
76
  readonly "slice-library:beta:code-opened": "SliceMachine Slice Library [BETA] CTA example code opened";
74
- readonly "onboarding:step-opened": "SliceMachine Onboarding Step Opened";
75
- readonly "onboarding:step-completed": "SliceMachine Onboarding Step Completed";
76
- readonly "onboarding:completed": "SliceMachine Onboarding Completed";
77
77
  readonly "post-push:empty-state-cta-clicked": "SliceMachine Post Push Empty State CTA Clicked";
78
78
  readonly "post-push:toast-cta-clicked": "SliceMachine Post Push Toast CTA Clicked";
79
79
  readonly "experiment:exposure": "$exposure";
80
80
  readonly "slice-name-error:pascal-case": "SliceMachine Slice Name Pascal Case Error";
81
+ readonly "onboarding:step-opened": "SliceMachine Onboarding Step Opened";
82
+ readonly "onboarding:step-completed": "SliceMachine Onboarding Step Completed";
83
+ readonly "onboarding:completed": "SliceMachine Onboarding Completed";
84
+ readonly "shared-onboarding:step-completed": "Prismic Onboarding Guide Step Completed";
85
+ readonly "shared-onboarding:step-opened": "Prismic Onboarding Guide Step Open";
86
+ readonly "shared-onboarding:completed": "Prismic Onboarding Guide Completed";
81
87
  };
82
88
  export type HumanSegmentEventTypes = (typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];
83
89
  type SegmentEvent<TType extends SegmentEventTypes, TProperties extends Record<string, unknown> | void = void> = TProperties extends void ? {
@@ -216,15 +222,19 @@ type SliceMachineStart = SegmentEvent<typeof SegmentEventType.sliceMachine_start
216
222
  }>;
217
223
  type SliceLibraryBetaModalOpened = SegmentEvent<typeof SegmentEventType.sliceLibrary_beta_modalOpened>;
218
224
  type SliceLibraryBetaCodeOpened = SegmentEvent<typeof SegmentEventType.sliceLibrary_beta_codeOpened>;
219
- type SliceMachineOnboardingStepOpened = SegmentEvent<typeof SegmentEventType.onboarding_step_opened, {
225
+ type OnboardingCommonPayload = {
220
226
  stepId: string;
221
227
  stepTitle: string;
222
- }>;
223
- type SliceMachineOnboardingStepCompleted = SegmentEvent<typeof SegmentEventType.onboarding_step_completed, {
224
- stepId: string;
225
- stepTitle: string;
226
- }>;
228
+ };
229
+ type SharedOnboardingProperties<T = Record<string, string>> = T & {
230
+ source: "SliceMachine";
231
+ };
232
+ type SliceMachineOnboardingStepOpened = SegmentEvent<typeof SegmentEventType.onboarding_step_opened, OnboardingCommonPayload>;
233
+ type SliceMachineOnboardingStepCompleted = SegmentEvent<typeof SegmentEventType.onboarding_step_completed, OnboardingCommonPayload>;
227
234
  type SliceMachineOnboardingCompleted = SegmentEvent<typeof SegmentEventType.onboarding_completed>;
235
+ type SliceMachineSharedOnboardingStepOpened = SegmentEvent<typeof SegmentEventType.sharedOnboarding_step_opened, SharedOnboardingProperties<OnboardingCommonPayload>>;
236
+ type SliceMachineSharedOnboardingStepCompleted = SegmentEvent<typeof SegmentEventType.sharedOnboarding_step_completed, SharedOnboardingProperties<OnboardingCommonPayload>>;
237
+ type SliceMachineSharedOnboardingCompleted = SegmentEvent<typeof SegmentEventType.sharedOnboarding_completed, SharedOnboardingProperties>;
228
238
  type SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<typeof SegmentEventType.postPush_emptyStateCtaClicked>;
229
239
  type SliceMachinePostPushToastCtaClicked = SegmentEvent<typeof SegmentEventType.postPush_toastCtaClicked>;
230
240
  type SliceMachineExperimentExposure = SegmentEvent<typeof SegmentEventType.experiment_exposure, {
@@ -234,4 +244,4 @@ type SliceMachineExperimentExposure = SegmentEvent<typeof SegmentEventType.exper
234
244
  type SliceMachineSliceNamePascalCase = SegmentEvent<typeof SegmentEventType.sliceName_pascalCaseError, {
235
245
  errorType: "create" | "update";
236
246
  }>;
237
- export type SegmentEvents = CommandInitStartSegmentEvent | CommandInitIdentifySegmentEvent | CommandInitEndSegmentEvent | ReviewSegmentEvent | SliceSimulatorOpenSegmentEvent | SliceSimulatorIsNotRunningSegmentEvent | PageViewSegmentEvent | OpenVideoTutorialsSegmentEvent | FieldAddedSegmentEvent | FieldSettingsOpenedSegmentEvent | CustomTypeCreatedSegmentEvent | CustomTypeSliceZoneUpdatedSegmentEvent | CustomTypeOpenAddFromTemplatesEvent | CustomTypeSavedSegmentEvent | SliceCreatedSegmentEvent | LegacySliceConvertedSegmentEvent | ScreenshotTakenSegmentEvent | ChangesPushedSegmentEvent | ChangesLimitReachSegmentEvent | EditorWidgetUsedSegmentEvent | OpenPageSnippetSegmentEvent | CopyPageSnippetSegmentEvent | SwitchEnvironmentSegmentEvent | DevCollabJoinBetaClicked | DevCollabSetUpWorkflowOpened | DevCollabWorkflowStubDisplayed | SliceMachineStart | SliceLibraryBetaModalOpened | SliceLibraryBetaCodeOpened | SliceMachineOnboardingStepOpened | SliceMachineOnboardingStepCompleted | SliceMachineOnboardingCompleted | SliceMachinePostPushEmptyStateCtaClicked | SliceMachinePostPushToastCtaClicked | SliceMachineExperimentExposure | SliceMachineSliceNamePascalCase;
247
+ export type SegmentEvents = CommandInitStartSegmentEvent | CommandInitIdentifySegmentEvent | CommandInitEndSegmentEvent | ReviewSegmentEvent | SliceSimulatorOpenSegmentEvent | SliceSimulatorIsNotRunningSegmentEvent | PageViewSegmentEvent | OpenVideoTutorialsSegmentEvent | FieldAddedSegmentEvent | FieldSettingsOpenedSegmentEvent | CustomTypeCreatedSegmentEvent | CustomTypeSliceZoneUpdatedSegmentEvent | CustomTypeOpenAddFromTemplatesEvent | CustomTypeSavedSegmentEvent | SliceCreatedSegmentEvent | LegacySliceConvertedSegmentEvent | ScreenshotTakenSegmentEvent | ChangesPushedSegmentEvent | ChangesLimitReachSegmentEvent | EditorWidgetUsedSegmentEvent | OpenPageSnippetSegmentEvent | CopyPageSnippetSegmentEvent | SwitchEnvironmentSegmentEvent | DevCollabJoinBetaClicked | DevCollabSetUpWorkflowOpened | DevCollabWorkflowStubDisplayed | SliceMachineStart | SliceLibraryBetaModalOpened | SliceLibraryBetaCodeOpened | SliceMachineOnboardingStepOpened | SliceMachineOnboardingStepCompleted | SliceMachineOnboardingCompleted | SliceMachineSharedOnboardingStepOpened | SliceMachineSharedOnboardingStepCompleted | SliceMachineSharedOnboardingCompleted | SliceMachinePostPushEmptyStateCtaClicked | SliceMachinePostPushToastCtaClicked | SliceMachineExperimentExposure | SliceMachineSliceNamePascalCase;
@@ -28,13 +28,16 @@ const SegmentEventType = {
28
28
  sliceMachine_start: "slice-machine:start",
29
29
  sliceLibrary_beta_modalOpened: "slice-library:beta:modal-opened",
30
30
  sliceLibrary_beta_codeOpened: "slice-library:beta:code-opened",
31
- onboarding_step_opened: "onboarding:step-opened",
32
- onboarding_step_completed: "onboarding:step-completed",
33
- onboarding_completed: "onboarding:completed",
34
31
  postPush_emptyStateCtaClicked: "post-push:empty-state-cta-clicked",
35
32
  postPush_toastCtaClicked: "post-push:toast-cta-clicked",
36
33
  experiment_exposure: "experiment:exposure",
37
- sliceName_pascalCaseError: "slice-name-error:pascal-case"
34
+ sliceName_pascalCaseError: "slice-name-error:pascal-case",
35
+ onboarding_step_opened: "onboarding:step-opened",
36
+ onboarding_step_completed: "onboarding:step-completed",
37
+ onboarding_completed: "onboarding:completed",
38
+ sharedOnboarding_step_opened: "shared-onboarding:step-opened",
39
+ sharedOnboarding_step_completed: "shared-onboarding:step-completed",
40
+ sharedOnboarding_completed: "shared-onboarding:completed"
38
41
  };
39
42
  const HumanSegmentEventType = {
40
43
  [SegmentEventType.command_init_start]: "SliceMachine Init Start",
@@ -66,13 +69,16 @@ const HumanSegmentEventType = {
66
69
  [SegmentEventType.sliceMachine_start]: "SliceMachine Start",
67
70
  [SegmentEventType.sliceLibrary_beta_modalOpened]: "SliceMachine Slice Library [BETA] CTA modal displayed",
68
71
  [SegmentEventType.sliceLibrary_beta_codeOpened]: "SliceMachine Slice Library [BETA] CTA example code opened",
69
- [SegmentEventType.onboarding_step_opened]: "SliceMachine Onboarding Step Opened",
70
- [SegmentEventType.onboarding_step_completed]: "SliceMachine Onboarding Step Completed",
71
- [SegmentEventType.onboarding_completed]: "SliceMachine Onboarding Completed",
72
72
  [SegmentEventType.postPush_emptyStateCtaClicked]: "SliceMachine Post Push Empty State CTA Clicked",
73
73
  [SegmentEventType.postPush_toastCtaClicked]: "SliceMachine Post Push Toast CTA Clicked",
74
74
  [SegmentEventType.experiment_exposure]: "$exposure",
75
- [SegmentEventType.sliceName_pascalCaseError]: "SliceMachine Slice Name Pascal Case Error"
75
+ [SegmentEventType.sliceName_pascalCaseError]: "SliceMachine Slice Name Pascal Case Error",
76
+ [SegmentEventType.onboarding_step_opened]: "SliceMachine Onboarding Step Opened",
77
+ [SegmentEventType.onboarding_step_completed]: "SliceMachine Onboarding Step Completed",
78
+ [SegmentEventType.onboarding_completed]: "SliceMachine Onboarding Completed",
79
+ [SegmentEventType.sharedOnboarding_step_completed]: "Prismic Onboarding Guide Step Completed",
80
+ [SegmentEventType.sharedOnboarding_step_opened]: "Prismic Onboarding Guide Step Open",
81
+ [SegmentEventType.sharedOnboarding_completed]: "Prismic Onboarding Guide Completed"
76
82
  };
77
83
  export {
78
84
  HumanSegmentEventType,
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tonboarding_step_opened: \"onboarding:step-opened\",\n\tonboarding_step_completed: \"onboarding:step-completed\",\n\tonboarding_completed: \"onboarding:completed\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsliceName_pascalCaseError: \"slice-name-error:pascal-case\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.onboarding_step_opened]:\n\t\t\"SliceMachine Onboarding Step Opened\",\n\t[SegmentEventType.onboarding_step_completed]:\n\t\t\"SliceMachine Onboarding Step Completed\",\n\t[SegmentEventType.onboarding_completed]: \"SliceMachine Onboarding Completed\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sliceName_pascalCaseError]:\n\t\t\"SliceMachine Slice Name Pascal Case Error\",\n} as const;\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\" | \"advanced repository\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{ id: string; name: string; library: string; sliceTemplate?: string }\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype SliceMachineOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_step_opened,\n\t{\n\t\tstepId: string;\n\t\tstepTitle: string;\n\t}\n>;\n\ntype SliceMachineOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_step_completed,\n\t{\n\t\tstepId: string;\n\t\tstepTitle: string;\n\t}\n>;\n\ntype SliceMachineOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_completed\n>;\n\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\ntype SliceMachineSliceNamePascalCase = SegmentEvent<\n\ttypeof SegmentEventType.sliceName_pascalCaseError,\n\t{ errorType: \"create\" | \"update\" }\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineOnboardingStepOpened\n\t| SliceMachineOnboardingStepCompleted\n\t| SliceMachineOnboardingCompleted\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure\n\t| SliceMachineSliceNamePascalCase;\n"],"names":[],"mappings":"AAOO,MAAM,mBAAmB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,oBAAoB;AAAA,EACpB,+BAA+B;AAAA,EAC/B,8BAA8B;AAAA,EAC9B,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,sBAAsB;AAAA,EACtB,+BAA+B;AAAA,EAC/B,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,2BAA2B;;AAKrB,MAAM,wBAAwB;AAAA,EACpC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,qBAAqB,GAAG;AAAA,EAC1C,CAAC,iBAAiB,gBAAgB,GAAG;AAAA,EACrC,CAAC,iBAAiB,MAAM,GAAG;AAAA,EAC3B,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,2BAA2B,GAC5C;AAAA,EACD,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,WAAW,GAAG;AAAA,EAChC,CAAC,iBAAiB,oBAAoB,GAAG;AAAA,EACzC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,2BAA2B,GAC5C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,gBAAgB,GAAG;AAAA,EACrC,CAAC,iBAAiB,aAAa,GAAG;AAAA,EAClC,CAAC,iBAAiB,qBAAqB,GACtC;AAAA,EACD,CAAC,iBAAiB,eAAe,GAAG;AAAA,EACpC,CAAC,iBAAiB,cAAc,GAAG;AAAA,EACnC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,iBAAiB,GAAG;AAAA,EACtC,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,sBAAsB,GACvC;AAAA,EACD,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,oBAAoB,GAAG;AAAA,EACzC,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,wBAAwB,GACzC;AAAA,EACD,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,yBAAyB,GAC1C;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../src/managers/telemetry/types.ts"],"sourcesContent":["import { FieldType } from \"@prismicio/types-internal/lib/customtypes/widgets\";\n\nimport { CustomTypeFormat } from \"../customTypes/types\";\nimport type { PushChangesLimitType } from \"../prismicRepository/types\";\n\nexport type { Variant } from \"@amplitude/experiment-node-server\";\n\nexport const SegmentEventType = {\n\tcommand_init_start: \"command:init:start\",\n\tcommand_init_identify: \"command:init:identify\",\n\tcommand_init_end: \"command:init:end\",\n\treview: \"review\",\n\tsliceSimulator_open: \"slice-simulator:open\",\n\tsliceSimulator_isNotRunning: \"slice-simulator:is-not-running\",\n\tpageView: \"page-view\",\n\topenVideoTutorials: \"open-video-tutorials\",\n\tfield_added: \"field:added\",\n\tfield_settingsOpened: \"field:settings-opened\",\n\tcustomType_created: \"custom-type:created\",\n\tcustomType_sliceZoneUpdated: \"custom-type:slice-zone-updated\",\n\tcustomType_openAddFromTemplates: \"custom-type:open-add-from-templates\",\n\tcustomType_saved: \"custom-type:saved\",\n\tslice_created: \"slice:created\",\n\tlegacySlice_converted: \"legacy-slice:converted\",\n\tscreenshotTaken: \"screenshot-taken\",\n\tchanges_pushed: \"changes:pushed\",\n\tchanges_limitReach: \"changes:limit-reach\",\n\teditor_widgetUsed: \"editor:widget-used\",\n\topen_page_snippet: \"page-type:open-snippet\",\n\tcopy_page_snippet: \"page-type:copy-snippet\",\n\tswitch_environment: \"environment:switch\",\n\tdevCollab_joinBetaClicked: \"dev-collab:join-beta-clicked\",\n\tdevCollab_setUpWorkflowOpened: \"dev-collab:set-up-workflow-opened\",\n\tdevCollab_workflowStubDisplayed: \"dev-collab:workflow-stub-displayed\",\n\tsliceMachine_start: \"slice-machine:start\",\n\tsliceLibrary_beta_modalOpened: \"slice-library:beta:modal-opened\",\n\tsliceLibrary_beta_codeOpened: \"slice-library:beta:code-opened\",\n\tpostPush_emptyStateCtaClicked: \"post-push:empty-state-cta-clicked\",\n\tpostPush_toastCtaClicked: \"post-push:toast-cta-clicked\",\n\texperiment_exposure: \"experiment:exposure\",\n\tsliceName_pascalCaseError: \"slice-name-error:pascal-case\",\n\tonboarding_step_opened: \"onboarding:step-opened\",\n\tonboarding_step_completed: \"onboarding:step-completed\",\n\tonboarding_completed: \"onboarding:completed\",\n\tsharedOnboarding_step_opened: \"shared-onboarding:step-opened\",\n\tsharedOnboarding_step_completed: \"shared-onboarding:step-completed\",\n\tsharedOnboarding_completed: \"shared-onboarding:completed\",\n} as const;\ntype SegmentEventTypes =\n\t(typeof SegmentEventType)[keyof typeof SegmentEventType];\n\nexport const HumanSegmentEventType = {\n\t[SegmentEventType.command_init_start]: \"SliceMachine Init Start\",\n\t[SegmentEventType.command_init_identify]: \"SliceMachine Init Identify\",\n\t[SegmentEventType.command_init_end]: \"SliceMachine Init End\",\n\t[SegmentEventType.review]: \"SliceMachine Review\",\n\t[SegmentEventType.sliceSimulator_open]: \"SliceMachine Slice Simulator Open\",\n\t[SegmentEventType.sliceSimulator_isNotRunning]:\n\t\t\"SliceMachine Slice Simulator is not running\",\n\t[SegmentEventType.pageView]: \"SliceMachine Page View\",\n\t[SegmentEventType.openVideoTutorials]: \"SliceMachine Open Video Tutorials\",\n\t[SegmentEventType.field_added]: \"SliceMachine Field Added\",\n\t[SegmentEventType.field_settingsOpened]: \"SliceMachine Field Settings Opened\",\n\t[SegmentEventType.customType_created]: \"SliceMachine Custom Type Created\",\n\t[SegmentEventType.customType_sliceZoneUpdated]:\n\t\t\"SliceMachine Slicezone Updated\",\n\t[SegmentEventType.customType_openAddFromTemplates]:\n\t\t\"SliceMachine Open Add from templates\",\n\t[SegmentEventType.customType_saved]: \"SliceMachine Custom Type Saved\",\n\t[SegmentEventType.slice_created]: \"SliceMachine Slice Created\",\n\t[SegmentEventType.legacySlice_converted]:\n\t\t\"SliceMachine Legacy Slice Converted\",\n\t[SegmentEventType.screenshotTaken]: \"SliceMachine Screenshot Taken\",\n\t[SegmentEventType.changes_pushed]: \"SliceMachine Changes Pushed\",\n\t[SegmentEventType.changes_limitReach]: \"SliceMachine Changes Limit Reach\",\n\t[SegmentEventType.editor_widgetUsed]: \"SliceMachine Editor Widget Used\",\n\t[SegmentEventType.open_page_snippet]:\n\t\t\"SliceMachine Opens Page Type Snippet Dialog\",\n\t[SegmentEventType.copy_page_snippet]:\n\t\t\"Slice Machine page code snippet copied\",\n\t[SegmentEventType.switch_environment]: \"SliceMachine environment switch\",\n\t[SegmentEventType.devCollab_joinBetaClicked]:\n\t\t\"SliceMachine Dev Collab Join Beta Clicked\",\n\t[SegmentEventType.devCollab_setUpWorkflowOpened]:\n\t\t\"SliceMachine Dev Collab Set Up Workflow Opened\",\n\t[SegmentEventType.devCollab_workflowStubDisplayed]:\n\t\t\"SliceMachine Dev Collab Workflow Stub Displayed\",\n\t[SegmentEventType.sliceMachine_start]: \"SliceMachine Start\",\n\t[SegmentEventType.sliceLibrary_beta_modalOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA modal displayed\",\n\t[SegmentEventType.sliceLibrary_beta_codeOpened]:\n\t\t\"SliceMachine Slice Library [BETA] CTA example code opened\",\n\t[SegmentEventType.postPush_emptyStateCtaClicked]:\n\t\t\"SliceMachine Post Push Empty State CTA Clicked\",\n\t[SegmentEventType.postPush_toastCtaClicked]:\n\t\t\"SliceMachine Post Push Toast CTA Clicked\",\n\t[SegmentEventType.experiment_exposure]: \"$exposure\",\n\t[SegmentEventType.sliceName_pascalCaseError]:\n\t\t\"SliceMachine Slice Name Pascal Case Error\",\n\t[SegmentEventType.onboarding_step_opened]:\n\t\t\"SliceMachine Onboarding Step Opened\",\n\t[SegmentEventType.onboarding_step_completed]:\n\t\t\"SliceMachine Onboarding Step Completed\",\n\t[SegmentEventType.onboarding_completed]: \"SliceMachine Onboarding Completed\",\n\t[SegmentEventType.sharedOnboarding_step_completed]:\n\t\t\"Prismic Onboarding Guide Step Completed\",\n\t[SegmentEventType.sharedOnboarding_step_opened]:\n\t\t\"Prismic Onboarding Guide Step Open\",\n\t[SegmentEventType.sharedOnboarding_completed]:\n\t\t\"Prismic Onboarding Guide Completed\",\n} as const;\n\nexport type HumanSegmentEventTypes =\n\t(typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];\n\ntype SegmentEvent<\n\tTType extends SegmentEventTypes,\n\tTProperties extends Record<string, unknown> | void = void,\n> = TProperties extends void\n\t? {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t }\n\t: {\n\t\t\tevent: TType;\n\t\t\trepository?: string;\n\t } & TProperties;\n\ntype CommandInitStartSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_start\n>;\n\n// This event feels off, we have a dedicated `identify` method...\ntype CommandInitIdentifySegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_identify\n>;\n\ntype CommandInitEndSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.command_init_end,\n\t{ framework: string; success: boolean; error?: string }\n>;\n\ntype ReviewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.review,\n\t{\n\t\trating: number;\n\t\tcomment: string;\n\t\ttype: \"onboarding\" | \"advanced repository\";\n\t}\n>;\n\ntype SliceSimulatorOpenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_open\n>;\n\ntype SliceSimulatorIsNotRunningSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.sliceSimulator_isNotRunning\n>;\n\ntype PageViewSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.pageView,\n\t{\n\t\turl: string;\n\t\tpath: string;\n\t\tsearch: string;\n\t\ttitle: string;\n\t\treferrer: string;\n\t\tadapter: string;\n\t\t/*\n\t\t * We are tracking outer sizes instead of inner sizes as with the latter, we\n\t\t * can't differentiate between users with a high-density screen and those\n\t\t * zooming in/out with ⌘ + / ⌘ -. Indeed, when users zoom in/out, some\n\t\t * browsers (like Google Chrome) will update `window.devicePixelRatio` while\n\t\t * others (like Safari) will keep it unchanged so that it always reflects\n\t\t * the ratio of physical pixels to CSS pixels.\n\t\t */\n\t\touterWidth: number;\n\t\touterHeight: number;\n\t\tscreenWidth: number;\n\t\tscreenHeight: number;\n\t}\n>;\n\ntype OpenPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.open_page_snippet,\n\t{ framework: string }\n>;\n\ntype CopyPageSnippetSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.copy_page_snippet,\n\t{ framework: string }\n>;\n\ntype SwitchEnvironmentSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.switch_environment,\n\t{ domain: string }\n>;\n\ntype OpenVideoTutorialsSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.openVideoTutorials,\n\t{ video: string }\n>;\n\ntype FieldAddedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_added,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t\tallowText?: boolean;\n\t}\n>;\n\ntype FieldSettingsOpenedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.field_settingsOpened,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\ttype: FieldType;\n\t\tisInAGroup: boolean;\n\t\tcontentType: \"page type\" | \"custom type\" | \"slice\";\n\t}\n>;\n\ntype CustomTypeCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_created,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t\torigin: \"onboarding\" | \"table\";\n\t}\n>;\n\ntype CustomTypeSliceZoneUpdatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_sliceZoneUpdated,\n\t{ customTypeId: string }\n>;\n\ntype CustomTypeOpenAddFromTemplatesEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_openAddFromTemplates,\n\t{ customTypeId: string; customTypeFormat: CustomTypeFormat }\n>;\n\ntype CustomTypeSavedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.customType_saved,\n\t{\n\t\tid: string;\n\t\tname: string;\n\t\tformat: CustomTypeFormat;\n\t\ttype: \"repeatable\" | \"single\";\n\t}\n>;\n\ntype SliceCreatedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.slice_created,\n\t{ id: string; name: string; library: string; sliceTemplate?: string }\n>;\n\ntype LegacySliceConvertedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.legacySlice_converted,\n\t{\n\t\tid: string;\n\t\tvariation: string;\n\t\tlibrary: string;\n\t\tconversionType:\n\t\t\t| \"as_new_slice\"\n\t\t\t| \"as_new_variation\"\n\t\t\t| \"merge_with_identical\";\n\t}\n>;\n\ntype ScreenshotTakenSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.screenshotTaken,\n\t{\n\t\ttype: \"custom\";\n\t\tmethod: \"upload\" | \"dragAndDrop\";\n\t}\n>;\n\ntype ChangesPushedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_pushed,\n\t{\n\t\tcustomTypesCreated: number;\n\t\tcustomTypesModified: number;\n\t\tcustomTypesDeleted: number;\n\t\tslicesCreated: number;\n\t\tslicesModified: number;\n\t\tslicesDeleted: number;\n\t\tmissingScreenshots: number;\n\t\ttotal: number;\n\t\tduration: number;\n\t\thasDeletedDocuments: boolean;\n\t}\n>;\n\ntype ChangesLimitReachSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.changes_limitReach,\n\t{ limitType: PushChangesLimitType }\n>;\n\ntype EditorWidgetUsedSegmentEvent = SegmentEvent<\n\ttypeof SegmentEventType.editor_widgetUsed,\n\t{ sliceId: string }\n>;\n\ntype DevCollabJoinBetaClicked = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_joinBetaClicked\n>;\n\ntype DevCollabSetUpWorkflowOpened = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_setUpWorkflowOpened\n>;\n\ntype DevCollabWorkflowStubDisplayed = SegmentEvent<\n\ttypeof SegmentEventType.devCollab_workflowStubDisplayed\n>;\n\ntype SliceMachineStart = SegmentEvent<\n\ttypeof SegmentEventType.sliceMachine_start,\n\t{\n\t\tadapter?: string;\n\t\tadapterVersion?: string;\n\t\tgitProvider?: string;\n\t\tisAdapterUpdateAvailable?: boolean;\n\t\tisLoggedIn?: boolean;\n\t\tisSliceMachineUpdateAvailable?: boolean;\n\t\tisTypeScriptProject?: boolean;\n\t\tnodeVersion?: string;\n\t\tnumberOfCustomTypes?: number;\n\t\tnumberOfSlices?: number;\n\t\tosPlatform?: string;\n\t\tpackageManager?: string;\n\t\tprojectPort?: string;\n\t\tsliceMachineVersion?: string;\n\t\tversionControlSystem?: string;\n\t}\n>;\n\ntype SliceLibraryBetaModalOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_modalOpened\n>;\n\ntype SliceLibraryBetaCodeOpened = SegmentEvent<\n\ttypeof SegmentEventType.sliceLibrary_beta_codeOpened\n>;\n\ntype OnboardingCommonPayload = { stepId: string; stepTitle: string };\ntype SharedOnboardingProperties<T = Record<string, string>> = T & {\n\tsource: \"SliceMachine\";\n};\n\ntype SliceMachineOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_step_opened,\n\tOnboardingCommonPayload\n>;\ntype SliceMachineOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_step_completed,\n\tOnboardingCommonPayload\n>;\ntype SliceMachineOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.onboarding_completed\n>;\n\ntype SliceMachineSharedOnboardingStepOpened = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_opened,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingStepCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_step_completed,\n\tSharedOnboardingProperties<OnboardingCommonPayload>\n>;\ntype SliceMachineSharedOnboardingCompleted = SegmentEvent<\n\ttypeof SegmentEventType.sharedOnboarding_completed,\n\tSharedOnboardingProperties\n>;\n\ntype SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_emptyStateCtaClicked\n>;\n\ntype SliceMachinePostPushToastCtaClicked = SegmentEvent<\n\ttypeof SegmentEventType.postPush_toastCtaClicked\n>;\n\ntype SliceMachineExperimentExposure = SegmentEvent<\n\ttypeof SegmentEventType.experiment_exposure,\n\t{\n\t\tflag_key: string;\n\t\tvariant: string;\n\t}\n>;\n\ntype SliceMachineSliceNamePascalCase = SegmentEvent<\n\ttypeof SegmentEventType.sliceName_pascalCaseError,\n\t{ errorType: \"create\" | \"update\" }\n>;\n\nexport type SegmentEvents =\n\t| CommandInitStartSegmentEvent\n\t| CommandInitIdentifySegmentEvent\n\t| CommandInitEndSegmentEvent\n\t| ReviewSegmentEvent\n\t| SliceSimulatorOpenSegmentEvent\n\t| SliceSimulatorIsNotRunningSegmentEvent\n\t| PageViewSegmentEvent\n\t| OpenVideoTutorialsSegmentEvent\n\t| FieldAddedSegmentEvent\n\t| FieldSettingsOpenedSegmentEvent\n\t| CustomTypeCreatedSegmentEvent\n\t| CustomTypeSliceZoneUpdatedSegmentEvent\n\t| CustomTypeOpenAddFromTemplatesEvent\n\t| CustomTypeSavedSegmentEvent\n\t| SliceCreatedSegmentEvent\n\t| LegacySliceConvertedSegmentEvent\n\t| ScreenshotTakenSegmentEvent\n\t| ChangesPushedSegmentEvent\n\t| ChangesLimitReachSegmentEvent\n\t| EditorWidgetUsedSegmentEvent\n\t| OpenPageSnippetSegmentEvent\n\t| CopyPageSnippetSegmentEvent\n\t| SwitchEnvironmentSegmentEvent\n\t| DevCollabJoinBetaClicked\n\t| DevCollabSetUpWorkflowOpened\n\t| DevCollabWorkflowStubDisplayed\n\t| SliceMachineStart\n\t| SliceLibraryBetaModalOpened\n\t| SliceLibraryBetaCodeOpened\n\t| SliceMachineOnboardingStepOpened\n\t| SliceMachineOnboardingStepCompleted\n\t| SliceMachineOnboardingCompleted\n\t| SliceMachineSharedOnboardingStepOpened\n\t| SliceMachineSharedOnboardingStepCompleted\n\t| SliceMachineSharedOnboardingCompleted\n\t| SliceMachinePostPushEmptyStateCtaClicked\n\t| SliceMachinePostPushToastCtaClicked\n\t| SliceMachineExperimentExposure\n\t| SliceMachineSliceNamePascalCase;\n"],"names":[],"mappings":"AAOO,MAAM,mBAAmB;AAAA,EAC/B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,qBAAqB;AAAA,EACrB,6BAA6B;AAAA,EAC7B,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,iCAAiC;AAAA,EACjC,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAC3B,+BAA+B;AAAA,EAC/B,iCAAiC;AAAA,EACjC,oBAAoB;AAAA,EACpB,+BAA+B;AAAA,EAC/B,8BAA8B;AAAA,EAC9B,+BAA+B;AAAA,EAC/B,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,2BAA2B;AAAA,EAC3B,sBAAsB;AAAA,EACtB,8BAA8B;AAAA,EAC9B,iCAAiC;AAAA,EACjC,4BAA4B;;AAKtB,MAAM,wBAAwB;AAAA,EACpC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,qBAAqB,GAAG;AAAA,EAC1C,CAAC,iBAAiB,gBAAgB,GAAG;AAAA,EACrC,CAAC,iBAAiB,MAAM,GAAG;AAAA,EAC3B,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,2BAA2B,GAC5C;AAAA,EACD,CAAC,iBAAiB,QAAQ,GAAG;AAAA,EAC7B,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,WAAW,GAAG;AAAA,EAChC,CAAC,iBAAiB,oBAAoB,GAAG;AAAA,EACzC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,2BAA2B,GAC5C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,gBAAgB,GAAG;AAAA,EACrC,CAAC,iBAAiB,aAAa,GAAG;AAAA,EAClC,CAAC,iBAAiB,qBAAqB,GACtC;AAAA,EACD,CAAC,iBAAiB,eAAe,GAAG;AAAA,EACpC,CAAC,iBAAiB,cAAc,GAAG;AAAA,EACnC,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,iBAAiB,GAAG;AAAA,EACtC,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,iBAAiB,GAClC;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,kBAAkB,GAAG;AAAA,EACvC,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,6BAA6B,GAC9C;AAAA,EACD,CAAC,iBAAiB,wBAAwB,GACzC;AAAA,EACD,CAAC,iBAAiB,mBAAmB,GAAG;AAAA,EACxC,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,sBAAsB,GACvC;AAAA,EACD,CAAC,iBAAiB,yBAAyB,GAC1C;AAAA,EACD,CAAC,iBAAiB,oBAAoB,GAAG;AAAA,EACzC,CAAC,iBAAiB,+BAA+B,GAChD;AAAA,EACD,CAAC,iBAAiB,4BAA4B,GAC7C;AAAA,EACD,CAAC,iBAAiB,0BAA0B,GAC3C;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/manager",
3
- "version": "0.20.8-beta.1",
3
+ "version": "0.21.0",
4
4
  "description": "Manage all aspects of a Slice Machine project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -70,7 +70,7 @@
70
70
  "@prismicio/mocks": "^2.4.0",
71
71
  "@prismicio/types-internal": "^2.8.0",
72
72
  "@segment/analytics-node": "^2.1.2",
73
- "@slicemachine/plugin-kit": "0.4.52-beta.1",
73
+ "@slicemachine/plugin-kit": "0.4.52",
74
74
  "cookie": "^0.5.0",
75
75
  "cors": "^2.8.5",
76
76
  "execa": "^7.1.1",
@@ -131,6 +131,5 @@
131
131
  },
132
132
  "publishConfig": {
133
133
  "access": "public"
134
- },
135
- "stableVersion": "0.20.7"
134
+ }
136
135
  }
@@ -10,6 +10,7 @@ export type APIEndpoints = {
10
10
  PrismicEmbed: string;
11
11
  PrismicUnsplash: string;
12
12
  SliceMachineV1: string;
13
+ RepositoryService: string;
13
14
  };
14
15
 
15
16
  export const API_ENDPOINTS: APIEndpoints = (() => {
@@ -33,6 +34,9 @@ export const API_ENDPOINTS: APIEndpoints = (() => {
33
34
  process.env.slice_machine_v1_endpoint ??
34
35
  "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/",
35
36
  ),
37
+ RepositoryService: addTrailingSlash(
38
+ process.env.repository_api ?? "https://repository.wroom.io/",
39
+ ),
36
40
  };
37
41
 
38
42
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
@@ -81,6 +85,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
81
85
  PrismicUnsplash: "https://unsplash.wroom.io/",
82
86
  SliceMachineV1:
83
87
  "https://mc5qopc07a.execute-api.us-east-1.amazonaws.com/v1/",
88
+ RepositoryService: "https://repository.wroom.io/",
84
89
  };
85
90
  }
86
91
 
@@ -96,6 +101,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
96
101
  PrismicEmbed: "https://oembed.prismic.io",
97
102
  PrismicUnsplash: "https://unsplash.prismic.io/",
98
103
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
104
+ RepositoryService: "https://repository.prismic.io/",
99
105
  };
100
106
  }
101
107
  }
@@ -1,18 +1,37 @@
1
1
  import * as t from "io-ts";
2
2
  import { formatValidationErrors } from "io-ts-reporters";
3
+ import { ZodIssue } from "zod";
3
4
 
4
5
  type DecodeErrorConstructorArgs<TInput = unknown> = {
5
6
  input: TInput;
6
- errors: t.Errors;
7
+ errors: t.Errors | ZodIssue[];
7
8
  };
8
9
 
10
+ function isZodIssueArray(errors: object[]): errors is ZodIssue[] {
11
+ return "path" in errors[0];
12
+ }
13
+
14
+ function formatZodErrors(errors: ZodIssue[]): string[] {
15
+ return errors.map((err) => {
16
+ const path = err.path.length > 0 ? ` at ${err.path.join(".")}` : "";
17
+
18
+ return `${err.message}${path}`;
19
+ });
20
+ }
21
+
9
22
  export class DecodeError<TInput = unknown> extends Error {
10
23
  name = "DecodeError";
11
24
  input: TInput;
12
25
  errors: string[];
13
26
 
14
27
  constructor(args: DecodeErrorConstructorArgs<TInput>) {
15
- const formattedErrors = formatValidationErrors(args.errors);
28
+ let formattedErrors: string[] = [];
29
+
30
+ if (isZodIssueArray(args.errors)) {
31
+ formattedErrors = formatZodErrors(args.errors);
32
+ } else {
33
+ formattedErrors = formatValidationErrors(args.errors);
34
+ }
16
35
 
17
36
  super(formattedErrors.join(", "));
18
37
 
package/src/lib/decode.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as t from "io-ts";
2
+ import { ZodType, ZodTypeDef } from "zod";
2
3
  import * as E from "fp-ts/Either";
3
4
  import { pipe } from "fp-ts/function";
4
5
 
@@ -14,10 +15,35 @@ export type DecodeReturnType<A, _O, I> =
14
15
  error: DecodeError<I>;
15
16
  };
16
17
 
17
- export const decode = <A, O, I>(
18
- codec: t.Type<A, O, I>,
18
+ function isZodSchema(value: unknown): value is ZodType<unknown> {
19
+ return (
20
+ typeof (value as ZodType<unknown>).safeParse === "function" &&
21
+ value instanceof ZodType
22
+ );
23
+ }
24
+
25
+ export function decode<A, O, I>(
26
+ codec: ZodType<A, ZodTypeDef, unknown>,
27
+ input: I,
28
+ ): DecodeReturnType<A, O, I>;
29
+ export function decode<A, O, I>(
30
+ codec: t.Type<A, O, I> | ZodType<A, ZodTypeDef, unknown>,
31
+ input: I,
32
+ ): DecodeReturnType<A, O, I>;
33
+ export function decode<A, O, I>(
34
+ codec: t.Type<A, O, I> | ZodType<A, ZodTypeDef, unknown>,
19
35
  input: I,
20
- ): DecodeReturnType<A, O, I> => {
36
+ ): DecodeReturnType<A, O, I> {
37
+ if (isZodSchema(codec)) {
38
+ const parsed = codec.safeParse(input);
39
+
40
+ if (parsed.success) {
41
+ return { value: parsed.data };
42
+ }
43
+
44
+ return { error: new DecodeError({ input, errors: parsed.error.errors }) };
45
+ }
46
+
21
47
  return pipe(
22
48
  codec.decode(input),
23
49
  E.foldW(
@@ -33,4 +59,4 @@ export const decode = <A, O, I>(
33
59
  },
34
60
  ),
35
61
  );
36
- };
62
+ }
@@ -1,4 +1,5 @@
1
1
  import * as t from "io-ts";
2
+ import { z } from "zod";
2
3
  import fetch, { Response } from "../../lib/fetch";
3
4
  import { fold } from "fp-ts/Either";
4
5
 
@@ -35,6 +36,7 @@ import {
35
36
  FrameworkWroomTelemetryID,
36
37
  StarterId,
37
38
  Environment,
39
+ OnboardingState,
38
40
  } from "./types";
39
41
  import { sortEnvironments } from "./sortEnvironments";
40
42
 
@@ -506,6 +508,115 @@ export class PrismicRepositoryManager extends BaseManager {
506
508
  }
507
509
  }
508
510
 
511
+ async fetchOnboarding(): Promise<OnboardingState> {
512
+ const repositoryName = await this.project.getRepositoryName();
513
+
514
+ const url = new URL("/onboarding", API_ENDPOINTS.RepositoryService);
515
+ url.searchParams.set("repository", repositoryName);
516
+ const res = await this._fetch({ url });
517
+
518
+ if (res.ok) {
519
+ const json = await res.json();
520
+ const { value, error } = decode(OnboardingState, json);
521
+
522
+ if (error) {
523
+ throw new UnexpectedDataError(
524
+ `Failed to decode onboarding: ${error.errors.join(", ")}`,
525
+ );
526
+ }
527
+ if (value) {
528
+ return value;
529
+ }
530
+ }
531
+
532
+ switch (res.status) {
533
+ case 400:
534
+ case 401:
535
+ throw new UnauthenticatedError();
536
+ case 403:
537
+ throw new UnauthorizedError();
538
+ default:
539
+ throw new Error("Failed to fetch onboarding.");
540
+ }
541
+ }
542
+
543
+ async toggleOnboardingStep(
544
+ stepId: string,
545
+ ): Promise<{ completedSteps: string[] }> {
546
+ const repositoryName = await this.project.getRepositoryName();
547
+
548
+ const url = new URL(
549
+ `/onboarding/${stepId}/toggle`,
550
+ API_ENDPOINTS.RepositoryService,
551
+ );
552
+ url.searchParams.set("repository", repositoryName);
553
+ const res = await this._fetch({ url, method: "PATCH" });
554
+
555
+ if (res.ok) {
556
+ const json = await res.json();
557
+ const { value, error } = decode(
558
+ z.object({ completedSteps: z.array(z.string()) }),
559
+ json,
560
+ );
561
+
562
+ if (error) {
563
+ throw new UnexpectedDataError(
564
+ `Failed to decode onboarding step toggle: ${error.errors.join(", ")}`,
565
+ );
566
+ }
567
+
568
+ if (value) {
569
+ return value;
570
+ }
571
+ }
572
+
573
+ switch (res.status) {
574
+ case 400:
575
+ case 401:
576
+ throw new UnauthenticatedError();
577
+ case 403:
578
+ throw new UnauthorizedError();
579
+ default:
580
+ throw new Error("Failed to toggle onboarding step.");
581
+ }
582
+ }
583
+
584
+ async toggleOnboarding(): Promise<{ isDismissed: boolean }> {
585
+ const repositoryName = await this.project.getRepositoryName();
586
+
587
+ const url = new URL("/onboarding/toggle", API_ENDPOINTS.RepositoryService);
588
+ url.searchParams.set("repository", repositoryName);
589
+ const res = await this._fetch({ url, method: "PATCH" });
590
+
591
+ if (res.ok) {
592
+ const json = await res.json();
593
+ const { value, error } = decode(
594
+ z.object({ isDismissed: z.boolean() }),
595
+ json,
596
+ );
597
+
598
+ if (error) {
599
+ throw new UnexpectedDataError(
600
+ `Failed to decode onboarding toggle: ${error.errors.join(", ")}`,
601
+ );
602
+ }
603
+
604
+ if (value) {
605
+ return value;
606
+ }
607
+ }
608
+
609
+ switch (res.status) {
610
+ case 400:
611
+ case 401:
612
+ throw new UnauthenticatedError();
613
+ case 403:
614
+ throw new UnauthorizedError();
615
+ default:
616
+ throw new Error("Failed to toggle onboarding guide.");
617
+ }
618
+ }
619
+
509
620
  private _decodeLimitOrThrow(
510
621
  potentialLimit: unknown,
511
622
  statusCode: number,
@@ -531,7 +642,7 @@ export class PrismicRepositoryManager extends BaseManager {
531
642
 
532
643
  private async _fetch(args: {
533
644
  url: URL;
534
- method?: "GET" | "POST";
645
+ method?: "GET" | "POST" | "PATCH";
535
646
  body?: unknown;
536
647
  userAgent?: PrismicRepositoryUserAgents;
537
648
  repository?: string;
@@ -3,6 +3,7 @@ import {
3
3
  SharedSlice,
4
4
  } from "@prismicio/types-internal/lib/customtypes";
5
5
  import * as t from "io-ts";
6
+ import { z } from "zod";
6
7
 
7
8
  export const PrismicRepositoryUserAgent = {
8
9
  SliceMachine: "prismic-cli/sm",
@@ -167,3 +168,40 @@ export const Environment = t.type({
167
168
  ),
168
169
  });
169
170
  export type Environment = t.TypeOf<typeof Environment>;
171
+
172
+ export const supportedSliceMachineFrameworks = [
173
+ "next",
174
+ "nuxt",
175
+ "sveltekit",
176
+ ] as const;
177
+
178
+ type SupportedFramework = (typeof supportedSliceMachineFrameworks)[number];
179
+
180
+ function isSupportedFramework(value: string): value is SupportedFramework {
181
+ return supportedSliceMachineFrameworks.includes(value as SupportedFramework);
182
+ }
183
+
184
+ export const repositoryFramework = z.preprocess(
185
+ (value) => {
186
+ // NOTE: we persist a lot of different frameworks in the DB, but only the SM supported are relevant to us
187
+ // Any other framework is treated like "other"
188
+ if (typeof value === "string" && isSupportedFramework(value)) {
189
+ return value;
190
+ }
191
+
192
+ return "other";
193
+ },
194
+ z.enum([...supportedSliceMachineFrameworks, "other"]),
195
+ );
196
+
197
+ export type RepositoryFramework = z.TypeOf<typeof repositoryFramework>;
198
+
199
+ export const OnboardingState = z.object({
200
+ completedSteps: z.array(z.string()),
201
+ isDismissed: z.boolean(),
202
+ context: z.object({
203
+ framework: repositoryFramework,
204
+ starterId: z.string().nullable(),
205
+ }),
206
+ });
207
+ export type OnboardingState = z.infer<typeof OnboardingState>;
@@ -35,13 +35,16 @@ export const SegmentEventType = {
35
35
  sliceMachine_start: "slice-machine:start",
36
36
  sliceLibrary_beta_modalOpened: "slice-library:beta:modal-opened",
37
37
  sliceLibrary_beta_codeOpened: "slice-library:beta:code-opened",
38
- onboarding_step_opened: "onboarding:step-opened",
39
- onboarding_step_completed: "onboarding:step-completed",
40
- onboarding_completed: "onboarding:completed",
41
38
  postPush_emptyStateCtaClicked: "post-push:empty-state-cta-clicked",
42
39
  postPush_toastCtaClicked: "post-push:toast-cta-clicked",
43
40
  experiment_exposure: "experiment:exposure",
44
41
  sliceName_pascalCaseError: "slice-name-error:pascal-case",
42
+ onboarding_step_opened: "onboarding:step-opened",
43
+ onboarding_step_completed: "onboarding:step-completed",
44
+ onboarding_completed: "onboarding:completed",
45
+ sharedOnboarding_step_opened: "shared-onboarding:step-opened",
46
+ sharedOnboarding_step_completed: "shared-onboarding:step-completed",
47
+ sharedOnboarding_completed: "shared-onboarding:completed",
45
48
  } as const;
46
49
  type SegmentEventTypes =
47
50
  (typeof SegmentEventType)[keyof typeof SegmentEventType];
@@ -87,11 +90,6 @@ export const HumanSegmentEventType = {
87
90
  "SliceMachine Slice Library [BETA] CTA modal displayed",
88
91
  [SegmentEventType.sliceLibrary_beta_codeOpened]:
89
92
  "SliceMachine Slice Library [BETA] CTA example code opened",
90
- [SegmentEventType.onboarding_step_opened]:
91
- "SliceMachine Onboarding Step Opened",
92
- [SegmentEventType.onboarding_step_completed]:
93
- "SliceMachine Onboarding Step Completed",
94
- [SegmentEventType.onboarding_completed]: "SliceMachine Onboarding Completed",
95
93
  [SegmentEventType.postPush_emptyStateCtaClicked]:
96
94
  "SliceMachine Post Push Empty State CTA Clicked",
97
95
  [SegmentEventType.postPush_toastCtaClicked]:
@@ -99,7 +97,19 @@ export const HumanSegmentEventType = {
99
97
  [SegmentEventType.experiment_exposure]: "$exposure",
100
98
  [SegmentEventType.sliceName_pascalCaseError]:
101
99
  "SliceMachine Slice Name Pascal Case Error",
100
+ [SegmentEventType.onboarding_step_opened]:
101
+ "SliceMachine Onboarding Step Opened",
102
+ [SegmentEventType.onboarding_step_completed]:
103
+ "SliceMachine Onboarding Step Completed",
104
+ [SegmentEventType.onboarding_completed]: "SliceMachine Onboarding Completed",
105
+ [SegmentEventType.sharedOnboarding_step_completed]:
106
+ "Prismic Onboarding Guide Step Completed",
107
+ [SegmentEventType.sharedOnboarding_step_opened]:
108
+ "Prismic Onboarding Guide Step Open",
109
+ [SegmentEventType.sharedOnboarding_completed]:
110
+ "Prismic Onboarding Guide Completed",
102
111
  } as const;
112
+
103
113
  export type HumanSegmentEventTypes =
104
114
  (typeof HumanSegmentEventType)[keyof typeof HumanSegmentEventType];
105
115
 
@@ -338,26 +348,36 @@ type SliceLibraryBetaCodeOpened = SegmentEvent<
338
348
  typeof SegmentEventType.sliceLibrary_beta_codeOpened
339
349
  >;
340
350
 
351
+ type OnboardingCommonPayload = { stepId: string; stepTitle: string };
352
+ type SharedOnboardingProperties<T = Record<string, string>> = T & {
353
+ source: "SliceMachine";
354
+ };
355
+
341
356
  type SliceMachineOnboardingStepOpened = SegmentEvent<
342
357
  typeof SegmentEventType.onboarding_step_opened,
343
- {
344
- stepId: string;
345
- stepTitle: string;
346
- }
358
+ OnboardingCommonPayload
347
359
  >;
348
-
349
360
  type SliceMachineOnboardingStepCompleted = SegmentEvent<
350
361
  typeof SegmentEventType.onboarding_step_completed,
351
- {
352
- stepId: string;
353
- stepTitle: string;
354
- }
362
+ OnboardingCommonPayload
355
363
  >;
356
-
357
364
  type SliceMachineOnboardingCompleted = SegmentEvent<
358
365
  typeof SegmentEventType.onboarding_completed
359
366
  >;
360
367
 
368
+ type SliceMachineSharedOnboardingStepOpened = SegmentEvent<
369
+ typeof SegmentEventType.sharedOnboarding_step_opened,
370
+ SharedOnboardingProperties<OnboardingCommonPayload>
371
+ >;
372
+ type SliceMachineSharedOnboardingStepCompleted = SegmentEvent<
373
+ typeof SegmentEventType.sharedOnboarding_step_completed,
374
+ SharedOnboardingProperties<OnboardingCommonPayload>
375
+ >;
376
+ type SliceMachineSharedOnboardingCompleted = SegmentEvent<
377
+ typeof SegmentEventType.sharedOnboarding_completed,
378
+ SharedOnboardingProperties
379
+ >;
380
+
361
381
  type SliceMachinePostPushEmptyStateCtaClicked = SegmentEvent<
362
382
  typeof SegmentEventType.postPush_emptyStateCtaClicked
363
383
  >;
@@ -412,6 +432,9 @@ export type SegmentEvents =
412
432
  | SliceMachineOnboardingStepOpened
413
433
  | SliceMachineOnboardingStepCompleted
414
434
  | SliceMachineOnboardingCompleted
435
+ | SliceMachineSharedOnboardingStepOpened
436
+ | SliceMachineSharedOnboardingStepCompleted
437
+ | SliceMachineSharedOnboardingCompleted
415
438
  | SliceMachinePostPushEmptyStateCtaClicked
416
439
  | SliceMachinePostPushToastCtaClicked
417
440
  | SliceMachineExperimentExposure