@guidelytech/shared 0.2.0 → 0.4.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.
- package/dist/chunk-QUKMOTT4.js +477 -0
- package/dist/chunk-QUKMOTT4.js.map +1 -0
- package/dist/index.cjs +267 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +352 -83
- package/dist/index.d.ts +352 -83
- package/dist/index.js +124 -7
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +181 -4
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +191 -2
- package/dist/runtime.d.ts +191 -2
- package/dist/runtime.js +47 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,27 +1,49 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_PLATFORMS,
|
|
3
|
+
GUIDELY_ID_ATTRIBUTE,
|
|
2
4
|
MAX_PROPERTY_BYTES,
|
|
5
|
+
MAX_STACK_FRAMES,
|
|
6
|
+
NETWORK_PLUGIN,
|
|
7
|
+
PLATFORMS,
|
|
3
8
|
RULE_FIELDS,
|
|
4
9
|
RULE_OPERATORS,
|
|
10
|
+
SENSITIVE_HEADER_PATTERN,
|
|
11
|
+
SENSITIVE_PARAM_PATTERN,
|
|
5
12
|
SENSITIVE_PROPERTY_PATTERN,
|
|
6
13
|
SERVER_ASSISTED_FIELDS,
|
|
14
|
+
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
15
|
+
SOURCEMAP_MAX_FILE_BYTES,
|
|
16
|
+
WS_MAX_MESSAGES_PER_SOCKET,
|
|
17
|
+
WS_MAX_MESSAGE_BYTES,
|
|
7
18
|
clamp,
|
|
8
19
|
compare,
|
|
20
|
+
compareVersions,
|
|
9
21
|
describeRule,
|
|
10
22
|
emptyRuleGroup,
|
|
11
23
|
evaluateRule,
|
|
12
24
|
evaluateRules,
|
|
25
|
+
fingerprintError,
|
|
13
26
|
fnv1a,
|
|
14
27
|
getPath,
|
|
28
|
+
guidePlatforms,
|
|
29
|
+
guidelyIdFromSelector,
|
|
30
|
+
isChecklistComplete,
|
|
15
31
|
isPlainObject,
|
|
32
|
+
isQuestionVisible,
|
|
16
33
|
isRuleGroup,
|
|
17
34
|
matchUrlPattern,
|
|
35
|
+
normalizeErrorMessage,
|
|
36
|
+
normalizeFrameFile,
|
|
37
|
+
parseStack,
|
|
18
38
|
randomId,
|
|
19
39
|
rolloutBucket,
|
|
20
40
|
safeRegExp,
|
|
21
41
|
sanitizeProperties,
|
|
42
|
+
screenPath,
|
|
22
43
|
slugify,
|
|
23
|
-
stripOrigin
|
|
24
|
-
|
|
44
|
+
stripOrigin,
|
|
45
|
+
supportsPlatform
|
|
46
|
+
} from "./chunk-QUKMOTT4.js";
|
|
25
47
|
|
|
26
48
|
// src/targeting.ts
|
|
27
49
|
import { z } from "zod";
|
|
@@ -48,7 +70,7 @@ var GUIDE_KINDS = ["flow", "modal", "tooltip", "banner", "checklist", "survey",
|
|
|
48
70
|
var GUIDE_STATUSES = ["draft", "published", "paused", "archived"];
|
|
49
71
|
var STEP_TYPES = ["modal", "tooltip", "popover", "spotlight", "hotspot", "banner", "slideout", "checklist", "custom", "survey"];
|
|
50
72
|
var PLACEMENTS = ["top", "top-start", "top-end", "right", "right-start", "right-end", "bottom", "bottom-start", "bottom-end", "left", "left-start", "left-end", "auto"];
|
|
51
|
-
var SELECTOR_KINDS = ["css", "id", "data-attr", "aria", "text", "xpath"];
|
|
73
|
+
var SELECTOR_KINDS = ["css", "id", "data-attr", "aria", "text", "xpath", "guidely-id"];
|
|
52
74
|
var SelectorStrategySchema = z2.object({
|
|
53
75
|
kind: z2.enum(SELECTOR_KINDS),
|
|
54
76
|
value: z2.string().min(1).max(1e3),
|
|
@@ -207,8 +229,10 @@ var GuideConfigSchema = z2.object({
|
|
|
207
229
|
appearance: AppearanceSchema.default({}),
|
|
208
230
|
checklist: ChecklistConfigSchema.optional(),
|
|
209
231
|
survey: SurveyConfigSchema.optional(),
|
|
210
|
-
/** Restrict guide to url pattern(s) (applied before trigger). */
|
|
211
|
-
urlPatterns: z2.array(z2.string().max(500)).max(20).default([])
|
|
232
|
+
/** Restrict guide to url pattern(s) (applied before trigger). On mobile these match the screen path `/<Screen>`. */
|
|
233
|
+
urlPatterns: z2.array(z2.string().max(500)).max(20).default([]),
|
|
234
|
+
/** Platforms that receive this guide. Guides created before mobile support are web-only. */
|
|
235
|
+
platforms: z2.array(z2.enum(PLATFORMS)).max(PLATFORMS.length).default(["web"])
|
|
212
236
|
});
|
|
213
237
|
function defaultGuideConfig(kind) {
|
|
214
238
|
return GuideConfigSchema.parse({
|
|
@@ -254,12 +278,17 @@ function validateGuideConfig(kind, config) {
|
|
|
254
278
|
} else {
|
|
255
279
|
if (config.steps.length === 0) issues.push({ level: "error", message: "Add at least one step." });
|
|
256
280
|
}
|
|
281
|
+
if (config.platforms.length === 0) issues.push({ level: "error", message: "Choose at least one platform (web, iOS or Android)." });
|
|
282
|
+
const mobile = config.platforms.some((p) => p !== "web");
|
|
257
283
|
const ids = /* @__PURE__ */ new Set();
|
|
258
284
|
config.steps.forEach((step, i) => {
|
|
259
285
|
if (ids.has(step.id)) issues.push({ level: "error", stepId: step.id, message: `Duplicate step id "${step.id}".` });
|
|
260
286
|
ids.add(step.id);
|
|
261
287
|
const anchored = ["tooltip", "popover", "spotlight", "hotspot"].includes(step.type);
|
|
262
288
|
if (anchored && (!step.target || step.target.selectors.length === 0)) issues.push({ level: "error", stepId: step.id, message: `Step ${i + 1} (${step.type}) needs a target element.` });
|
|
289
|
+
if (mobile && anchored && step.target && step.target.selectors.length > 0 && !step.target.selectors.some((s) => s.kind === "guidely-id" || s.kind === "id"))
|
|
290
|
+
issues.push({ level: "warning", stepId: step.id, message: `Step ${i + 1} has no Guidely id or element id target, so mobile apps cannot find its element.` });
|
|
291
|
+
if (mobile && step.type === "custom") issues.push({ level: "warning", stepId: step.id, message: `Step ${i + 1} is a custom HTML step; mobile apps show it as a plain modal.` });
|
|
263
292
|
if (!step.title && !step.body && step.type !== "custom") issues.push({ level: "warning", stepId: step.id, message: `Step ${i + 1} has no title or body.` });
|
|
264
293
|
if (step.buttons.length === 0 && step.advanceOn === "button" && step.type !== "hotspot" && step.type !== "custom") issues.push({ level: "warning", stepId: step.id, message: `Step ${i + 1} has no buttons and advances on button; users can only close it.` });
|
|
265
294
|
step.buttons.forEach((b) => {
|
|
@@ -311,8 +340,15 @@ var EVENT_NAMES = [
|
|
|
311
340
|
"scout_answered",
|
|
312
341
|
"custom",
|
|
313
342
|
"page_view",
|
|
314
|
-
"identify"
|
|
343
|
+
"identify",
|
|
344
|
+
// Product analytics (autocapture + error tracking)
|
|
345
|
+
"page_leave",
|
|
346
|
+
"click",
|
|
347
|
+
"rage_click",
|
|
348
|
+
"exception",
|
|
349
|
+
"heatmap"
|
|
315
350
|
];
|
|
351
|
+
var AUTOCAPTURE_EVENTS = ["page_view", "page_leave", "click", "rage_click", "exception", "heatmap"];
|
|
316
352
|
var GUIDE_LIFECYCLE_EVENTS = ["guide_viewed", "guide_started", "step_viewed", "step_completed", "guide_completed", "guide_skipped", "guide_dismissed", "guide_abandoned"];
|
|
317
353
|
var SdkEventSchema = z3.object({
|
|
318
354
|
eventId: z3.string().min(8).max(64),
|
|
@@ -412,6 +448,55 @@ var ConversationRatingSchema = z5.object({
|
|
|
412
448
|
comment: z5.string().max(1e3).optional()
|
|
413
449
|
});
|
|
414
450
|
|
|
451
|
+
// src/capture.ts
|
|
452
|
+
import { z as z6 } from "zod";
|
|
453
|
+
var AutocaptureSettingsSchema = z6.object({ pageviews: z6.boolean(), pageLeave: z6.boolean(), clicks: z6.boolean(), rageClicks: z6.boolean(), heatmaps: z6.boolean(), mouseMovement: z6.boolean() }).partial();
|
|
454
|
+
var ErrorTrackingSettingsSchema = z6.object({ enabled: z6.boolean() }).partial();
|
|
455
|
+
var ReplaySettingsSchema = z6.object({
|
|
456
|
+
enabled: z6.boolean(),
|
|
457
|
+
sampleRate: z6.number().int().min(0).max(100),
|
|
458
|
+
recordConsole: z6.boolean(),
|
|
459
|
+
recordNetwork: z6.boolean(),
|
|
460
|
+
recordNetworkPayloads: z6.boolean(),
|
|
461
|
+
maskAllText: z6.boolean(),
|
|
462
|
+
blockSelectors: z6.array(z6.string().min(1).max(200)).max(50),
|
|
463
|
+
retentionDays: z6.number().int().min(1).max(365)
|
|
464
|
+
}).partial();
|
|
465
|
+
var DEFAULT_CAPTURE_SETTINGS = {
|
|
466
|
+
autocapture: { pageviews: true, pageLeave: true, clicks: true, rageClicks: true, heatmaps: true, mouseMovement: true },
|
|
467
|
+
errorTracking: { enabled: true },
|
|
468
|
+
replay: { enabled: false, sampleRate: 100, recordConsole: true, recordNetwork: true, recordNetworkPayloads: false, maskAllText: false, blockSelectors: [], retentionDays: 30 }
|
|
469
|
+
};
|
|
470
|
+
function resolveCaptureSettings(settings) {
|
|
471
|
+
const s = settings && typeof settings === "object" ? settings : {};
|
|
472
|
+
const obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
473
|
+
const d = DEFAULT_CAPTURE_SETTINGS;
|
|
474
|
+
const a = AutocaptureSettingsSchema.safeParse(obj(s.autocapture));
|
|
475
|
+
const e = ErrorTrackingSettingsSchema.safeParse(obj(s.errorTracking));
|
|
476
|
+
const r = ReplaySettingsSchema.safeParse(obj(s.replay));
|
|
477
|
+
return {
|
|
478
|
+
autocapture: { ...d.autocapture, ...a.success ? a.data : {} },
|
|
479
|
+
errorTracking: { ...d.errorTracking, ...e.success ? e.data : {} },
|
|
480
|
+
replay: { ...d.replay, ...r.success ? r.data : {} }
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
var HEATMAP_VIEWPORTS = { mobile: [0, 767], tablet: [768, 1279], desktop: [1280, 1e5] };
|
|
484
|
+
var ReplayChunkSchema = z6.object({
|
|
485
|
+
sessionId: z6.string().min(1).max(128),
|
|
486
|
+
windowId: z6.string().min(1).max(64),
|
|
487
|
+
seq: z6.number().int().min(0).max(1e6),
|
|
488
|
+
anonymousId: z6.string().min(1).max(128),
|
|
489
|
+
userId: z6.string().max(256).optional().nullable(),
|
|
490
|
+
/** rrweb `eventWithTime` objects, in order. */
|
|
491
|
+
events: z6.array(z6.object({ type: z6.number().int(), timestamp: z6.number() }).passthrough()).min(1).max(5e4),
|
|
492
|
+
url: z6.string().max(2e3).optional(),
|
|
493
|
+
device: z6.object({ type: z6.string().max(20), browser: z6.string().max(40).optional(), os: z6.string().max(40).optional() }).optional(),
|
|
494
|
+
viewport: z6.object({ width: z6.number().int().min(0).max(1e5), height: z6.number().int().min(0).max(1e5) }).optional(),
|
|
495
|
+
sdk: z6.object({ name: z6.string().max(60), version: z6.string().max(30) }).optional()
|
|
496
|
+
});
|
|
497
|
+
var REPLAY_MAX_COMPRESSED_BYTES = 2 * 1024 * 1024;
|
|
498
|
+
var REPLAY_MAX_RAW_BYTES = 16 * 1024 * 1024;
|
|
499
|
+
|
|
415
500
|
// src/templates.ts
|
|
416
501
|
var nav = (opts = {}) => [
|
|
417
502
|
...opts.first ? [] : [{ id: "back", label: "Back", action: "back", variant: "ghost" }],
|
|
@@ -592,11 +677,13 @@ function templateConfig(id) {
|
|
|
592
677
|
|
|
593
678
|
// src/index.ts
|
|
594
679
|
var SDK_API_VERSION = "v1";
|
|
595
|
-
var SHARED_VERSION = "0.
|
|
680
|
+
var SHARED_VERSION = "0.4.0";
|
|
596
681
|
export {
|
|
597
682
|
ADVANCE_ON,
|
|
683
|
+
AUTOCAPTURE_EVENTS,
|
|
598
684
|
AppearanceSchema,
|
|
599
685
|
AuthoringPickSchema,
|
|
686
|
+
AutocaptureSettingsSchema,
|
|
600
687
|
BUTTON_ACTIONS,
|
|
601
688
|
ButtonSchema,
|
|
602
689
|
ChecklistConfigSchema,
|
|
@@ -604,32 +691,48 @@ export {
|
|
|
604
691
|
ChecklistTaskSchema,
|
|
605
692
|
ConversationLookupSchema,
|
|
606
693
|
ConversationRatingSchema,
|
|
694
|
+
DEFAULT_CAPTURE_SETTINGS,
|
|
695
|
+
DEFAULT_PLATFORMS,
|
|
607
696
|
EVENT_NAMES,
|
|
697
|
+
ErrorTrackingSettingsSchema,
|
|
608
698
|
EventBatchSchema,
|
|
609
699
|
FrequencySchema,
|
|
700
|
+
GUIDELY_ID_ATTRIBUTE,
|
|
610
701
|
GUIDE_KINDS,
|
|
611
702
|
GUIDE_LIFECYCLE_EVENTS,
|
|
612
703
|
GUIDE_STATUSES,
|
|
613
704
|
GUIDE_TEMPLATES,
|
|
614
705
|
GuideConfigSchema,
|
|
615
706
|
GuideStateUpdateSchema,
|
|
707
|
+
HEATMAP_VIEWPORTS,
|
|
616
708
|
IdentifyRequestSchema,
|
|
617
709
|
MAX_MESSAGE_LENGTH,
|
|
618
710
|
MAX_PROPERTY_BYTES,
|
|
711
|
+
MAX_STACK_FRAMES,
|
|
619
712
|
MESSAGE_AUTHORS,
|
|
713
|
+
NETWORK_PLUGIN,
|
|
620
714
|
PLACEMENTS,
|
|
715
|
+
PLATFORMS,
|
|
621
716
|
PostMessageSchema,
|
|
622
717
|
ProjectThemeSchema,
|
|
623
718
|
PublishedGuideSchema,
|
|
719
|
+
REPLAY_MAX_COMPRESSED_BYTES,
|
|
720
|
+
REPLAY_MAX_RAW_BYTES,
|
|
624
721
|
RULE_FIELDS,
|
|
625
722
|
RULE_OPERATORS,
|
|
723
|
+
ReplayChunkSchema,
|
|
724
|
+
ReplaySettingsSchema,
|
|
626
725
|
RuleGroupSchema,
|
|
627
726
|
RuleSchema,
|
|
628
727
|
SDK_API_VERSION,
|
|
629
728
|
SELECTOR_KINDS,
|
|
729
|
+
SENSITIVE_HEADER_PATTERN,
|
|
730
|
+
SENSITIVE_PARAM_PATTERN,
|
|
630
731
|
SENSITIVE_PROPERTY_PATTERN,
|
|
631
732
|
SERVER_ASSISTED_FIELDS,
|
|
632
733
|
SHARED_VERSION,
|
|
734
|
+
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
735
|
+
SOURCEMAP_MAX_FILE_BYTES,
|
|
633
736
|
STEP_TYPES,
|
|
634
737
|
SURVEY_QUESTION_TYPES,
|
|
635
738
|
SdkEventSchema,
|
|
@@ -643,25 +746,39 @@ export {
|
|
|
643
746
|
TRIGGER_TYPES,
|
|
644
747
|
TargetSchema,
|
|
645
748
|
TriggerSchema,
|
|
749
|
+
WS_MAX_MESSAGES_PER_SOCKET,
|
|
750
|
+
WS_MAX_MESSAGE_BYTES,
|
|
646
751
|
clamp,
|
|
647
752
|
compare,
|
|
753
|
+
compareVersions,
|
|
648
754
|
defaultGuideConfig,
|
|
649
755
|
defaultStep,
|
|
650
756
|
describeRule,
|
|
651
757
|
emptyRuleGroup,
|
|
652
758
|
evaluateRule,
|
|
653
759
|
evaluateRules,
|
|
760
|
+
fingerprintError,
|
|
654
761
|
fnv1a,
|
|
655
762
|
getPath,
|
|
763
|
+
guidePlatforms,
|
|
764
|
+
guidelyIdFromSelector,
|
|
765
|
+
isChecklistComplete,
|
|
656
766
|
isPlainObject,
|
|
767
|
+
isQuestionVisible,
|
|
657
768
|
isRuleGroup,
|
|
658
769
|
matchUrlPattern,
|
|
770
|
+
normalizeErrorMessage,
|
|
771
|
+
normalizeFrameFile,
|
|
772
|
+
parseStack,
|
|
659
773
|
randomId,
|
|
774
|
+
resolveCaptureSettings,
|
|
660
775
|
rolloutBucket,
|
|
661
776
|
safeRegExp,
|
|
662
777
|
sanitizeProperties,
|
|
778
|
+
screenPath,
|
|
663
779
|
slugify,
|
|
664
780
|
stripOrigin,
|
|
781
|
+
supportsPlatform,
|
|
665
782
|
templateConfig,
|
|
666
783
|
validateGuideConfig,
|
|
667
784
|
visibleButtons
|