@cimplify/sdk 0.93.0 → 0.94.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/react.d.mts +7 -1
- package/dist/react.d.ts +7 -1
- package/dist/react.js +34 -1
- package/dist/react.mjs +34 -1
- package/package.json +1 -1
package/dist/react.d.mts
CHANGED
|
@@ -869,8 +869,14 @@ interface CimplifyProviderProps {
|
|
|
869
869
|
optimistic?: boolean;
|
|
870
870
|
prefetch?: PrefetchOptions;
|
|
871
871
|
linkComponent?: CimplifyLinkComponent;
|
|
872
|
+
/**
|
|
873
|
+
* Auto-record a page view on mount and on every route change. Default true,
|
|
874
|
+
* so a storefront reports traffic without wiring anything. Set false where
|
|
875
|
+
* consent has not been given, or where the app tracks page views itself.
|
|
876
|
+
*/
|
|
877
|
+
trackPageViews?: boolean;
|
|
872
878
|
}
|
|
873
|
-
declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, }: CimplifyProviderProps): React$1.ReactElement;
|
|
879
|
+
declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, trackPageViews, }: CimplifyProviderProps): React$1.ReactElement;
|
|
874
880
|
declare function useCimplify(): CimplifyContextValue;
|
|
875
881
|
declare function useOptionalCimplify(): CimplifyContextValue | null;
|
|
876
882
|
declare function useCimplifyClient(): CimplifyClientContextValue;
|
package/dist/react.d.ts
CHANGED
|
@@ -869,8 +869,14 @@ interface CimplifyProviderProps {
|
|
|
869
869
|
optimistic?: boolean;
|
|
870
870
|
prefetch?: PrefetchOptions;
|
|
871
871
|
linkComponent?: CimplifyLinkComponent;
|
|
872
|
+
/**
|
|
873
|
+
* Auto-record a page view on mount and on every route change. Default true,
|
|
874
|
+
* so a storefront reports traffic without wiring anything. Set false where
|
|
875
|
+
* consent has not been given, or where the app tracks page views itself.
|
|
876
|
+
*/
|
|
877
|
+
trackPageViews?: boolean;
|
|
872
878
|
}
|
|
873
|
-
declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, }: CimplifyProviderProps): React$1.ReactElement;
|
|
879
|
+
declare function CimplifyProvider({ client, children, onLocationChange, initialBusiness, initialLocations, optimistic, prefetch, linkComponent, trackPageViews, }: CimplifyProviderProps): React$1.ReactElement;
|
|
874
880
|
declare function useCimplify(): CimplifyContextValue;
|
|
875
881
|
declare function useOptionalCimplify(): CimplifyContextValue | null;
|
|
876
882
|
declare function useCimplifyClient(): CimplifyClientContextValue;
|
package/dist/react.js
CHANGED
|
@@ -1137,6 +1137,37 @@ function preconnectOrigin(url, crossOrigin) {
|
|
|
1137
1137
|
if (crossOrigin) link.crossOrigin = crossOrigin;
|
|
1138
1138
|
document.head.appendChild(link);
|
|
1139
1139
|
}
|
|
1140
|
+
function usePageViewTracking(client, enabled) {
|
|
1141
|
+
React14.useEffect(() => {
|
|
1142
|
+
if (!enabled || typeof window === "undefined") return;
|
|
1143
|
+
let lastPath = null;
|
|
1144
|
+
const record = () => {
|
|
1145
|
+
const path = window.location.pathname;
|
|
1146
|
+
if (path === lastPath) return;
|
|
1147
|
+
lastPath = path;
|
|
1148
|
+
try {
|
|
1149
|
+
client.activity?.trackPageView({ pagePath: path });
|
|
1150
|
+
} catch {
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
record();
|
|
1154
|
+
const { pushState, replaceState } = window.history;
|
|
1155
|
+
window.history.pushState = function(...args) {
|
|
1156
|
+
pushState.apply(this, args);
|
|
1157
|
+
record();
|
|
1158
|
+
};
|
|
1159
|
+
window.history.replaceState = function(...args) {
|
|
1160
|
+
replaceState.apply(this, args);
|
|
1161
|
+
record();
|
|
1162
|
+
};
|
|
1163
|
+
window.addEventListener("popstate", record);
|
|
1164
|
+
return () => {
|
|
1165
|
+
window.history.pushState = pushState;
|
|
1166
|
+
window.history.replaceState = replaceState;
|
|
1167
|
+
window.removeEventListener("popstate", record);
|
|
1168
|
+
};
|
|
1169
|
+
}, [client, enabled]);
|
|
1170
|
+
}
|
|
1140
1171
|
var LOCATION_STORAGE_KEY = "cimplify_location_id";
|
|
1141
1172
|
var DISPLAY_CURRENCY_STORAGE_KEY = "cimplify_display_currency";
|
|
1142
1173
|
var FX_REFRESH_INTERVAL = 12e4;
|
|
@@ -1217,9 +1248,11 @@ function CimplifyProvider({
|
|
|
1217
1248
|
initialLocations,
|
|
1218
1249
|
optimistic = true,
|
|
1219
1250
|
prefetch,
|
|
1220
|
-
linkComponent
|
|
1251
|
+
linkComponent,
|
|
1252
|
+
trackPageViews = true
|
|
1221
1253
|
}) {
|
|
1222
1254
|
const resolvedClient = React14.useMemo(() => client ?? createDefaultClient(), [client]);
|
|
1255
|
+
usePageViewTracking(resolvedClient, trackPageViews);
|
|
1223
1256
|
const resolvedPrefetch = React14.useMemo(
|
|
1224
1257
|
() => ({
|
|
1225
1258
|
mode: prefetch?.mode ?? DEFAULT_PREFETCH_OPTIONS.mode,
|
package/dist/react.mjs
CHANGED
|
@@ -1113,6 +1113,37 @@ function preconnectOrigin(url, crossOrigin) {
|
|
|
1113
1113
|
if (crossOrigin) link.crossOrigin = crossOrigin;
|
|
1114
1114
|
document.head.appendChild(link);
|
|
1115
1115
|
}
|
|
1116
|
+
function usePageViewTracking(client, enabled) {
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
if (!enabled || typeof window === "undefined") return;
|
|
1119
|
+
let lastPath = null;
|
|
1120
|
+
const record = () => {
|
|
1121
|
+
const path = window.location.pathname;
|
|
1122
|
+
if (path === lastPath) return;
|
|
1123
|
+
lastPath = path;
|
|
1124
|
+
try {
|
|
1125
|
+
client.activity?.trackPageView({ pagePath: path });
|
|
1126
|
+
} catch {
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
record();
|
|
1130
|
+
const { pushState, replaceState } = window.history;
|
|
1131
|
+
window.history.pushState = function(...args) {
|
|
1132
|
+
pushState.apply(this, args);
|
|
1133
|
+
record();
|
|
1134
|
+
};
|
|
1135
|
+
window.history.replaceState = function(...args) {
|
|
1136
|
+
replaceState.apply(this, args);
|
|
1137
|
+
record();
|
|
1138
|
+
};
|
|
1139
|
+
window.addEventListener("popstate", record);
|
|
1140
|
+
return () => {
|
|
1141
|
+
window.history.pushState = pushState;
|
|
1142
|
+
window.history.replaceState = replaceState;
|
|
1143
|
+
window.removeEventListener("popstate", record);
|
|
1144
|
+
};
|
|
1145
|
+
}, [client, enabled]);
|
|
1146
|
+
}
|
|
1116
1147
|
var LOCATION_STORAGE_KEY = "cimplify_location_id";
|
|
1117
1148
|
var DISPLAY_CURRENCY_STORAGE_KEY = "cimplify_display_currency";
|
|
1118
1149
|
var FX_REFRESH_INTERVAL = 12e4;
|
|
@@ -1193,9 +1224,11 @@ function CimplifyProvider({
|
|
|
1193
1224
|
initialLocations,
|
|
1194
1225
|
optimistic = true,
|
|
1195
1226
|
prefetch,
|
|
1196
|
-
linkComponent
|
|
1227
|
+
linkComponent,
|
|
1228
|
+
trackPageViews = true
|
|
1197
1229
|
}) {
|
|
1198
1230
|
const resolvedClient = useMemo(() => client ?? createDefaultClient(), [client]);
|
|
1231
|
+
usePageViewTracking(resolvedClient, trackPageViews);
|
|
1199
1232
|
const resolvedPrefetch = useMemo(
|
|
1200
1233
|
() => ({
|
|
1201
1234
|
mode: prefetch?.mode ?? DEFAULT_PREFETCH_OPTIONS.mode,
|