@founderhq/journeys 1.0.2 → 1.1.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/README.md +4 -0
- package/dist/_tsup-dts-rollup.d.cts +4 -0
- package/dist/_tsup-dts-rollup.d.ts +4 -0
- package/dist/index.cjs +36 -13
- package/dist/index.js +36 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -323,6 +323,10 @@ architecture and security model are documented in
|
|
|
323
323
|
|
|
324
324
|
## Release notes
|
|
325
325
|
|
|
326
|
+
### 1.1.0
|
|
327
|
+
|
|
328
|
+
- `JourneyProvider` takes `history` (default `true`). With `history={false}`, the journey's steps stay out of the browser history, so Back leaves the page instead of stepping back through the journey. Use it for a journey shown inside another page, for example a demo on a landing page.
|
|
329
|
+
|
|
326
330
|
### 1.0.2
|
|
327
331
|
|
|
328
332
|
- Icons show again in the timeline, callout, card, metric, table and before-after blocks. From 0.6.0 to 1.0.1 they rendered with no stroke and were invisible.
|
|
@@ -1615,6 +1615,10 @@ declare type JourneyProviderProps = {
|
|
|
1615
1615
|
config: JourneyConfig;
|
|
1616
1616
|
/** False prepares the first screen without starting analytics or playback. */
|
|
1617
1617
|
active?: boolean;
|
|
1618
|
+
/** False keeps steps out of the browser history: Back leaves the page
|
|
1619
|
+
* instead of stepping through the journey. For a journey shown inside
|
|
1620
|
+
* another page (a demo on a landing page). Default true. */
|
|
1621
|
+
history?: boolean;
|
|
1618
1622
|
storageKey?: string;
|
|
1619
1623
|
/** Theme class override applied to the provider scope so global UI like dialogs inherits journey tokens. */
|
|
1620
1624
|
theme?: string;
|
|
@@ -1615,6 +1615,10 @@ declare type JourneyProviderProps = {
|
|
|
1615
1615
|
config: JourneyConfig;
|
|
1616
1616
|
/** False prepares the first screen without starting analytics or playback. */
|
|
1617
1617
|
active?: boolean;
|
|
1618
|
+
/** False keeps steps out of the browser history: Back leaves the page
|
|
1619
|
+
* instead of stepping through the journey. For a journey shown inside
|
|
1620
|
+
* another page (a demo on a landing page). Default true. */
|
|
1621
|
+
history?: boolean;
|
|
1618
1622
|
storageKey?: string;
|
|
1619
1623
|
/** Theme class override applied to the provider scope so global UI like dialogs inherits journey tokens. */
|
|
1620
1624
|
theme?: string;
|
package/dist/index.cjs
CHANGED
|
@@ -2811,6 +2811,7 @@ function stripOptionsFromEventStep(step) {
|
|
|
2811
2811
|
function useJourneyProviderRuntime({
|
|
2812
2812
|
config: rawConfig,
|
|
2813
2813
|
active = true,
|
|
2814
|
+
history = true,
|
|
2814
2815
|
storageKey = "journey",
|
|
2815
2816
|
onEvent,
|
|
2816
2817
|
onHaptic,
|
|
@@ -2975,12 +2976,14 @@ function useJourneyProviderRuntime({
|
|
|
2975
2976
|
}
|
|
2976
2977
|
setDirection("forward");
|
|
2977
2978
|
setCurrentStepIndex(nextIndex);
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2979
|
+
if (history) {
|
|
2980
|
+
window.history.pushState(
|
|
2981
|
+
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: nextIndex }),
|
|
2982
|
+
""
|
|
2983
|
+
);
|
|
2984
|
+
}
|
|
2982
2985
|
},
|
|
2983
|
-
[config.steps.length, trigger]
|
|
2986
|
+
[config.steps.length, history, trigger]
|
|
2984
2987
|
);
|
|
2985
2988
|
const goNext = React.useCallback(
|
|
2986
2989
|
(answer) => {
|
|
@@ -3062,7 +3065,7 @@ function useJourneyProviderRuntime({
|
|
|
3062
3065
|
]
|
|
3063
3066
|
);
|
|
3064
3067
|
const goBack = React.useCallback(() => {
|
|
3065
|
-
var _a;
|
|
3068
|
+
var _a, _b;
|
|
3066
3069
|
const step = config.steps[currentStepIndex];
|
|
3067
3070
|
const allowBack = (_a = step == null ? void 0 : step.allowBackNavigation) != null ? _a : config.allowBackNavigation;
|
|
3068
3071
|
if (allowBack === false) return;
|
|
@@ -3072,18 +3075,37 @@ function useJourneyProviderRuntime({
|
|
|
3072
3075
|
setTimeout(() => {
|
|
3073
3076
|
isTransitioning.current = false;
|
|
3074
3077
|
}, 400);
|
|
3075
|
-
|
|
3078
|
+
if (history) {
|
|
3079
|
+
window.history.back();
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
const prev = currentStepIndex - 1;
|
|
3083
|
+
setDirection("backward");
|
|
3084
|
+
setCurrentStepIndex(prev);
|
|
3085
|
+
(_b = onEventRef.current) == null ? void 0 : _b.call(onEventRef, __spreadValues({
|
|
3086
|
+
type: "navigate",
|
|
3087
|
+
from: stripOptionsFromEventStep(config.steps[currentStepIndex]),
|
|
3088
|
+
to: stripOptionsFromEventStep(config.steps[prev]),
|
|
3089
|
+
direction: "backward"
|
|
3090
|
+
}, getEventAnswers(config.computedVariables, rawAnswersRef.current)));
|
|
3076
3091
|
}
|
|
3077
|
-
}, [
|
|
3092
|
+
}, [
|
|
3093
|
+
active,
|
|
3094
|
+
config.allowBackNavigation,
|
|
3095
|
+
config.computedVariables,
|
|
3096
|
+
config.steps,
|
|
3097
|
+
currentStepIndex,
|
|
3098
|
+
history
|
|
3099
|
+
]);
|
|
3078
3100
|
React.useEffect(() => {
|
|
3079
|
-
if (!active) return;
|
|
3101
|
+
if (!active || !history) return;
|
|
3080
3102
|
window.history.replaceState(
|
|
3081
3103
|
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: 0 }),
|
|
3082
3104
|
""
|
|
3083
3105
|
);
|
|
3084
|
-
}, [active]);
|
|
3106
|
+
}, [active, history]);
|
|
3085
3107
|
React.useEffect(() => {
|
|
3086
|
-
if (!active) return;
|
|
3108
|
+
if (!active || !history) return;
|
|
3087
3109
|
const handlePopState = (event) => {
|
|
3088
3110
|
var _a, _b;
|
|
3089
3111
|
const step = (_b = (_a = event.state) == null ? void 0 : _a.__journeyStep) != null ? _b : 0;
|
|
@@ -3116,7 +3138,8 @@ function useJourneyProviderRuntime({
|
|
|
3116
3138
|
active,
|
|
3117
3139
|
config.allowBackNavigation,
|
|
3118
3140
|
config.computedVariables,
|
|
3119
|
-
config.steps
|
|
3141
|
+
config.steps,
|
|
3142
|
+
history
|
|
3120
3143
|
]);
|
|
3121
3144
|
const getStepAnswer = React.useCallback(
|
|
3122
3145
|
(stepId) => {
|
|
@@ -12845,7 +12868,7 @@ function useJourneyConfig({
|
|
|
12845
12868
|
|
|
12846
12869
|
// src/engine/journey-capture.ts
|
|
12847
12870
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
12848
|
-
var JOURNEY_LIBRARY_VERSION = "1.0
|
|
12871
|
+
var JOURNEY_LIBRARY_VERSION = "1.1.0";
|
|
12849
12872
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
12850
12873
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
12851
12874
|
var MAX_BEACON_BYTES = 60 * 1024;
|
package/dist/index.js
CHANGED
|
@@ -699,6 +699,7 @@ function stripOptionsFromEventStep(step) {
|
|
|
699
699
|
function useJourneyProviderRuntime({
|
|
700
700
|
config: rawConfig,
|
|
701
701
|
active = true,
|
|
702
|
+
history = true,
|
|
702
703
|
storageKey = "journey",
|
|
703
704
|
onEvent,
|
|
704
705
|
onHaptic,
|
|
@@ -863,12 +864,14 @@ function useJourneyProviderRuntime({
|
|
|
863
864
|
}
|
|
864
865
|
setDirection("forward");
|
|
865
866
|
setCurrentStepIndex(nextIndex);
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
867
|
+
if (history) {
|
|
868
|
+
window.history.pushState(
|
|
869
|
+
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: nextIndex }),
|
|
870
|
+
""
|
|
871
|
+
);
|
|
872
|
+
}
|
|
870
873
|
},
|
|
871
|
-
[config.steps.length, trigger]
|
|
874
|
+
[config.steps.length, history, trigger]
|
|
872
875
|
);
|
|
873
876
|
const goNext = useCallback(
|
|
874
877
|
(answer) => {
|
|
@@ -950,7 +953,7 @@ function useJourneyProviderRuntime({
|
|
|
950
953
|
]
|
|
951
954
|
);
|
|
952
955
|
const goBack = useCallback(() => {
|
|
953
|
-
var _a;
|
|
956
|
+
var _a, _b;
|
|
954
957
|
const step = config.steps[currentStepIndex];
|
|
955
958
|
const allowBack = (_a = step == null ? void 0 : step.allowBackNavigation) != null ? _a : config.allowBackNavigation;
|
|
956
959
|
if (allowBack === false) return;
|
|
@@ -960,18 +963,37 @@ function useJourneyProviderRuntime({
|
|
|
960
963
|
setTimeout(() => {
|
|
961
964
|
isTransitioning.current = false;
|
|
962
965
|
}, 400);
|
|
963
|
-
|
|
966
|
+
if (history) {
|
|
967
|
+
window.history.back();
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
const prev = currentStepIndex - 1;
|
|
971
|
+
setDirection("backward");
|
|
972
|
+
setCurrentStepIndex(prev);
|
|
973
|
+
(_b = onEventRef.current) == null ? void 0 : _b.call(onEventRef, __spreadValues({
|
|
974
|
+
type: "navigate",
|
|
975
|
+
from: stripOptionsFromEventStep(config.steps[currentStepIndex]),
|
|
976
|
+
to: stripOptionsFromEventStep(config.steps[prev]),
|
|
977
|
+
direction: "backward"
|
|
978
|
+
}, getEventAnswers(config.computedVariables, rawAnswersRef.current)));
|
|
964
979
|
}
|
|
965
|
-
}, [
|
|
980
|
+
}, [
|
|
981
|
+
active,
|
|
982
|
+
config.allowBackNavigation,
|
|
983
|
+
config.computedVariables,
|
|
984
|
+
config.steps,
|
|
985
|
+
currentStepIndex,
|
|
986
|
+
history
|
|
987
|
+
]);
|
|
966
988
|
useEffect(() => {
|
|
967
|
-
if (!active) return;
|
|
989
|
+
if (!active || !history) return;
|
|
968
990
|
window.history.replaceState(
|
|
969
991
|
__spreadProps(__spreadValues({}, window.history.state), { __journeyStep: 0 }),
|
|
970
992
|
""
|
|
971
993
|
);
|
|
972
|
-
}, [active]);
|
|
994
|
+
}, [active, history]);
|
|
973
995
|
useEffect(() => {
|
|
974
|
-
if (!active) return;
|
|
996
|
+
if (!active || !history) return;
|
|
975
997
|
const handlePopState = (event) => {
|
|
976
998
|
var _a, _b;
|
|
977
999
|
const step = (_b = (_a = event.state) == null ? void 0 : _a.__journeyStep) != null ? _b : 0;
|
|
@@ -1004,7 +1026,8 @@ function useJourneyProviderRuntime({
|
|
|
1004
1026
|
active,
|
|
1005
1027
|
config.allowBackNavigation,
|
|
1006
1028
|
config.computedVariables,
|
|
1007
|
-
config.steps
|
|
1029
|
+
config.steps,
|
|
1030
|
+
history
|
|
1008
1031
|
]);
|
|
1009
1032
|
const getStepAnswer = useCallback(
|
|
1010
1033
|
(stepId) => {
|
|
@@ -10733,7 +10756,7 @@ function useJourneyConfig({
|
|
|
10733
10756
|
|
|
10734
10757
|
// src/engine/journey-capture.ts
|
|
10735
10758
|
var JOURNEY_LIBRARY_NAME = "@founderhq/journeys";
|
|
10736
|
-
var JOURNEY_LIBRARY_VERSION = "1.0
|
|
10759
|
+
var JOURNEY_LIBRARY_VERSION = "1.1.0";
|
|
10737
10760
|
var DEFAULT_QUEUE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
10738
10761
|
var MAX_QUEUED_CAPTURE_EVENTS = 100;
|
|
10739
10762
|
var MAX_BEACON_BYTES = 60 * 1024;
|