@depsmith/depsmith-sdk-react 0.0.0-stage → 0.2.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 +116 -2
- package/dist/chunk-6P5WIXSS.cjs +96 -0
- package/dist/chunk-6P5WIXSS.cjs.map +1 -0
- package/dist/chunk-GCBPFIL3.js +96 -0
- package/dist/chunk-GCBPFIL3.js.map +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +59 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/react-router.cjs +26 -0
- package/dist/react-router.cjs.map +1 -0
- package/dist/react-router.d.cts +23 -0
- package/dist/react-router.d.ts +23 -0
- package/dist/react-router.js +25 -0
- package/dist/react-router.js.map +1 -0
- package/package.json +63 -4
package/README.md
CHANGED
|
@@ -1,3 +1,117 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @depsmith/depsmith-sdk-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React bindings for the DepSmith web SDK: a provider, a `useDepsmith()` hook, and page views
|
|
4
|
+
driven by your router. Event capture, batching, consent and storage all come from
|
|
5
|
+
[`@depsmith/depsmith-sdk`](../web), which is a peer dependency, so the app and this package
|
|
6
|
+
share one client.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @depsmith/depsmith-sdk @depsmith/depsmith-sdk-react
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Provider and hook
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { DepsmithProvider, useDepsmith } from '@depsmith/depsmith-sdk-react';
|
|
16
|
+
|
|
17
|
+
export function App() {
|
|
18
|
+
return (
|
|
19
|
+
<DepsmithProvider config={{ apiKey: 'your-key', endpoint: 'https://collector.example.com' }}>
|
|
20
|
+
<Checkout />
|
|
21
|
+
</DepsmithProvider>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Checkout() {
|
|
26
|
+
const depsmith = useDepsmith();
|
|
27
|
+
return <button onClick={() => depsmith.track('checkout_clicked', { plan: 'pro' })}>Buy</button>;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`useDepsmith()` returns everything on the web SDK's `DepsmithSdk` facade (`track`, `identify`,
|
|
32
|
+
`register`, `optIn`, …) except `init`/`shutdown`.
|
|
33
|
+
|
|
34
|
+
- **Init timing.** The provider initialises on its first render, not in an effect, because child
|
|
35
|
+
effects run before their parent's. Events a component tracks on mount are therefore kept.
|
|
36
|
+
- **`config` is read once.** Later changes to it are ignored, matching `DepsmithSdk.init`, which
|
|
37
|
+
is a no-op for the same `apiKey`. That also makes StrictMode and hot reload safe.
|
|
38
|
+
- **SSR-safe.** With no `window` the provider does not initialise, and every call is a silent
|
|
39
|
+
no-op until the browser renders.
|
|
40
|
+
- **No shutdown on unmount.** The client owns the persisted queue and the `pagehide` flush,
|
|
41
|
+
which must outlive any one component tree.
|
|
42
|
+
- **Custom instance.** `<DepsmithProvider client={new DepsmithSdkClient(config)}>` routes the
|
|
43
|
+
hooks to an instance you built yourself instead of the singleton.
|
|
44
|
+
|
|
45
|
+
## Page views
|
|
46
|
+
|
|
47
|
+
The web SDK can already autocapture page views by patching the History API. Pick **one** source.
|
|
48
|
+
If you use both, every navigation is counted twice.
|
|
49
|
+
|
|
50
|
+
| You want | Config | Use |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| SDK-driven (zero code) | `autocapture: true` | nothing else |
|
|
53
|
+
| Router-driven (route-aware names/properties) | `autocapture: { pageviews: false }` | the hooks below |
|
|
54
|
+
|
|
55
|
+
The router hooks enforce this. When the provider's config autocaptures page views, they do
|
|
56
|
+
nothing, and with `debug: true` they log why.
|
|
57
|
+
|
|
58
|
+
### React Router (v6, v7)
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { DepsmithRouterPageViews } from '@depsmith/depsmith-sdk-react/react-router';
|
|
62
|
+
|
|
63
|
+
function RootLayout() {
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<DepsmithRouterPageViews
|
|
67
|
+
getName={(location) => location.pathname}
|
|
68
|
+
getProperties={(location) => ({ section: location.pathname.split('/')[1] })}
|
|
69
|
+
/>
|
|
70
|
+
<Outlet />
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
One `$page_view` per `pathname + search`. Hash changes never count. Pass `includeSearch={false}`
|
|
77
|
+
to ignore query changes as well. `useRouterPageViews(options)` is the hook form.
|
|
78
|
+
|
|
79
|
+
### Any other router (Next.js App Router, TanStack, …)
|
|
80
|
+
|
|
81
|
+
`usePageView(key, { name, properties })` emits once per distinct `key`:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
'use client';
|
|
85
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
86
|
+
import { usePageView } from '@depsmith/depsmith-sdk-react';
|
|
87
|
+
|
|
88
|
+
export function PageViews() {
|
|
89
|
+
const pathname = usePathname();
|
|
90
|
+
const search = useSearchParams().toString();
|
|
91
|
+
usePageView(search ? `${pathname}?${search}` : pathname);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Render it inside `<DepsmithProvider>`. In Next.js, wrap it in `<Suspense>`, because
|
|
97
|
+
`useSearchParams` requires it. A `key` of `undefined` is skipped, and a repeated key is
|
|
98
|
+
ignored, which also absorbs StrictMode's effect replay.
|
|
99
|
+
|
|
100
|
+
The package ships with a `'use client'` directive, so `<DepsmithProvider>` can be rendered
|
|
101
|
+
directly from a Next.js server-component layout.
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npm install
|
|
107
|
+
npm test # vitest + jsdom, including an end-to-end $page_view count through the real SDK
|
|
108
|
+
npm run build # tsup → dist/ (index + react-router entries, ESM + CJS)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Tests run against `../web/src` through a vitest alias, so they verify the web SDK in the same
|
|
112
|
+
checkout. Typecheck and the `.d.ts` build use the published `@depsmith/depsmith-sdk` types.
|
|
113
|
+
|
|
114
|
+
Regenerating `package-lock.json` from scratch currently fails on npm 10.9 with `Cannot read
|
|
115
|
+
properties of null (reading 'edgesOut')`. That's an npm bug triggered by `vitest@4`'s peer
|
|
116
|
+
dependencies, and it reproduces in an empty directory. Use `npm install --legacy-peer-deps`
|
|
117
|
+
for that one regeneration. Installs from the committed lockfile are unaffected.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }'use client';
|
|
2
|
+
|
|
3
|
+
// src/provider.tsx
|
|
4
|
+
var _react = require('react');
|
|
5
|
+
var _depsmithsdk = require('@depsmith/depsmith-sdk');
|
|
6
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
7
|
+
var DepsmithContext = _react.createContext.call(void 0, null);
|
|
8
|
+
function DepsmithProvider(props) {
|
|
9
|
+
const [value] = _react.useState.call(void 0, () => {
|
|
10
|
+
if (props.client) {
|
|
11
|
+
return { api: bindClient(props.client), pageViewsAutocaptured: false, debug: false };
|
|
12
|
+
}
|
|
13
|
+
const config = props.config;
|
|
14
|
+
if (typeof window !== "undefined") _depsmithsdk.DepsmithSdk.init(config);
|
|
15
|
+
return {
|
|
16
|
+
api: _depsmithsdk.DepsmithSdk,
|
|
17
|
+
pageViewsAutocaptured: autocapturesPageViews(config),
|
|
18
|
+
debug: _nullishCoalesce(config.debug, () => ( false))
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DepsmithContext.Provider, { value, children: props.children });
|
|
22
|
+
}
|
|
23
|
+
function useDepsmith() {
|
|
24
|
+
return useDepsmithContext().api;
|
|
25
|
+
}
|
|
26
|
+
function useDepsmithContext() {
|
|
27
|
+
const ctx = _react.useContext.call(void 0, DepsmithContext);
|
|
28
|
+
if (!ctx) throw new Error("useDepsmith must be used inside <DepsmithProvider>");
|
|
29
|
+
return ctx;
|
|
30
|
+
}
|
|
31
|
+
function autocapturesPageViews(config) {
|
|
32
|
+
const ac = config.autocapture;
|
|
33
|
+
if (ac === true) return true;
|
|
34
|
+
if (ac && typeof ac === "object") {
|
|
35
|
+
const pageviews = ac.pageviews;
|
|
36
|
+
return pageviews === void 0 || Boolean(pageviews);
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function bindClient(c) {
|
|
41
|
+
return {
|
|
42
|
+
track: (name, properties) => c.track(name, properties),
|
|
43
|
+
// Spread, so the `{ type }` options argument reaches the client.
|
|
44
|
+
page: (...args) => c.page(...args),
|
|
45
|
+
screen: (...args) => c.screen(...args),
|
|
46
|
+
identify: (userId, traits) => c.identify(userId, traits),
|
|
47
|
+
alias: (aliasId) => c.alias(aliasId),
|
|
48
|
+
reset: () => c.reset(),
|
|
49
|
+
group: (groupId, traits) => c.group(groupId, traits),
|
|
50
|
+
setGroupTraits: (traits) => c.setGroupTraits(traits),
|
|
51
|
+
setProperty: (key, value) => c.setProperty(key, value),
|
|
52
|
+
setOnceProperty: (key, value) => c.setOnceProperty(key, value),
|
|
53
|
+
unsetProperty: (key) => c.unsetProperty(key),
|
|
54
|
+
setUserProperties: (ops) => c.setUserProperties(ops),
|
|
55
|
+
register: (properties) => c.register(properties),
|
|
56
|
+
registerOnce: (properties) => c.registerOnce(properties),
|
|
57
|
+
unregister: (key) => c.unregister(key),
|
|
58
|
+
optIn: () => c.optIn(),
|
|
59
|
+
optOut: () => c.optOut(),
|
|
60
|
+
flush: () => c.flush(),
|
|
61
|
+
getAnonymousId: () => c.getAnonymousId(),
|
|
62
|
+
getSessionId: () => c.getSessionId(),
|
|
63
|
+
setSessionId: (sessionId, startedAt) => c.setSessionId(sessionId, startedAt)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/page-view.ts
|
|
68
|
+
|
|
69
|
+
function usePageView(key, options = {}) {
|
|
70
|
+
const { api, pageViewsAutocaptured, debug } = useDepsmithContext();
|
|
71
|
+
const lastKey = _react.useRef.call(void 0, void 0);
|
|
72
|
+
const latest = _react.useRef.call(void 0, options);
|
|
73
|
+
latest.current = options;
|
|
74
|
+
_react.useEffect.call(void 0, () => {
|
|
75
|
+
if (key === void 0 || key === lastKey.current) return;
|
|
76
|
+
lastKey.current = key;
|
|
77
|
+
if (pageViewsAutocaptured) {
|
|
78
|
+
if (debug) {
|
|
79
|
+
console.warn(
|
|
80
|
+
"[depsmith-sdk-react] usePageView ignored: autocapture already emits page views. Set autocapture.pageviews: false to drive them from the router."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { name, properties, type } = latest.current;
|
|
86
|
+
if (type === void 0) api.page(name, properties);
|
|
87
|
+
else api.page(name, properties, { type });
|
|
88
|
+
}, [key, api, pageViewsAutocaptured, debug]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
exports.DepsmithProvider = DepsmithProvider; exports.useDepsmith = useDepsmith; exports.usePageView = usePageView;
|
|
96
|
+
//# sourceMappingURL=chunk-6P5WIXSS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/chunk-6P5WIXSS.cjs","../src/provider.tsx","../src/page-view.ts"],"names":[],"mappings":"AAAA,yLAAY;AACZ;AACA;ACFA,8BAAuF;AACvF,qDAA4E;AA0DnE,+CAAA;AA1CT,IAAM,gBAAA,EAAkB,kCAAA,IAA+C,CAAA;AA6BhE,SAAS,gBAAA,CAAiB,KAAA,EAA4C;AAC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AAM;AACd,IAAA,GAAA,CAAI,IAAA,IAAQ,KAAA,EAAA,GAAa,IAAA,IAAQ,OAAA,CAAQ,OAAA,EAAS,MAAA;AAClD,IAAA,OAAA,CAAQ,QAAA,EAAU,GAAA;AAClB,IAAA,GAAA,CAAI,qBAAA,EAAuB;AACzB,MAAA,GAAA,CAAI,KAAA,EAAO;AACT,QAAA,OAAA,CAAQ,IAAA;AAAA,UACN;AAAA,QAEF,CAAA;AAAA,MACF;AACA,MAAA,MAAA;AAAA,IACF;AACA,IAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,KAAK,EAAA,EAAI,MAAA,CAAO,OAAA;AAE1C,IAAA,GAAA,CAAI,KAAA,IAAS,KAAA,CAAA,EAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAAM,UAAU,CAAA;AAAA,IAAA,KAC5C,GAAA,CAAI,IAAA,CAAK,IAAA,EAAM,UAAA,EAAY,EAAE,KAAK,CAAC,CAAA;AAAA,EAC1C,CAAA,EAAG,CAAC,GAAA,EAAK,GAAA,EAAK,qBAAA,EAAuB,KAAK,CAAC,CAAA;AAC7C;AFoCA;AACA;AACE;AACA;AACA;AACF,kHAAC","file":"/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/chunk-6P5WIXSS.cjs","sourcesContent":[null,"import { createContext, useContext, useState, type ReactElement, type ReactNode } from 'react';\nimport { DepsmithSdk, type DepsmithSdkClient, type DepsmithSdkConfig } from '@depsmith/depsmith-sdk';\n\n/** Every tracking call the singleton facade offers, minus its lifecycle (init/shutdown). */\nexport type DepsmithApi = Omit<typeof DepsmithSdk, 'init' | 'shutdown'>;\n\ninterface DepsmithContextValue {\n api: DepsmithApi;\n /**\n * True when the SDK's own autocapture already emits `$page_view` on every History navigation.\n * Router-driven page views must then stand down, or each route change is counted twice: the\n * SDK's pushState patch fires first, and an explicit `page()` always emits.\n */\n pageViewsAutocaptured: boolean;\n debug: boolean;\n}\n\nconst DepsmithContext = createContext<DepsmithContextValue | null>(null);\n\nexport type DepsmithProviderProps = {\n children?: ReactNode;\n} & (\n | {\n /** Passed to `DepsmithSdk.init()`. Read once, on first render — later changes are ignored. */\n config: DepsmithSdkConfig;\n client?: never;\n }\n | {\n /** A client you constructed yourself, e.g. a second instance alongside the singleton. */\n client: DepsmithSdkClient;\n config?: never;\n }\n);\n\n/**\n * Initialises the SDK and makes it available to `useDepsmith()` and the page-view hooks.\n *\n * Initialises during the first render, not in an effect. Child effects run before their\n * parent's, so an effect-time init would drop every event a descendant tracks on mount. Render-time\n * is safe to repeat: `DepsmithSdk.init` is a no-op for the same apiKey, which also covers\n * StrictMode's double render and hot reload. On the server (no `window`) it does nothing, and\n * every call through the hooks is a silent no-op until the browser renders.\n *\n * The client is never shut down on unmount: it owns the persisted queue and the `pagehide` flush,\n * which must outlive any one component tree.\n */\nexport function DepsmithProvider(props: DepsmithProviderProps): ReactElement {\n const [value] = useState<DepsmithContextValue>(() => {\n if (props.client) {\n return { api: bindClient(props.client), pageViewsAutocaptured: false, debug: false };\n }\n const config = props.config;\n if (typeof window !== 'undefined') DepsmithSdk.init(config);\n return {\n api: DepsmithSdk,\n pageViewsAutocaptured: autocapturesPageViews(config),\n debug: config.debug ?? false,\n };\n });\n return <DepsmithContext.Provider value={value}>{props.children}</DepsmithContext.Provider>;\n}\n\n/** The SDK, from the nearest `<DepsmithProvider>`. Every method is safe to call during SSR. */\nexport function useDepsmith(): DepsmithApi {\n return useDepsmithContext().api;\n}\n\nexport function useDepsmithContext(): DepsmithContextValue {\n const ctx = useContext(DepsmithContext);\n if (!ctx) throw new Error('useDepsmith must be used inside <DepsmithProvider>');\n return ctx;\n}\n\n/**\n * Mirrors the web SDK's resolveConfig: `true` means all defaults, which include pageviews.\n * `pageviews` is `'path' | 'all' | boolean` from SDK 0.8.0: `'path'`, `'all'` and `true` all\n * autocapture, an absent key keeps the default (`'path'`), and only a falsy value turns it off.\n */\nfunction autocapturesPageViews(config: DepsmithSdkConfig): boolean {\n const ac = config.autocapture;\n if (ac === true) return true;\n if (ac && typeof ac === 'object') {\n // Widened: the published SDK's types may still declare a boolean here.\n const pageviews: unknown = ac.pageviews;\n return pageviews === undefined || Boolean(pageviews);\n }\n return false;\n}\n\nfunction bindClient(c: DepsmithSdkClient): DepsmithApi {\n return {\n track: (name, properties) => c.track(name, properties),\n // Spread, so the `{ type }` options argument reaches the client.\n page: (...args: Parameters<DepsmithSdkClient['page']>) => c.page(...args),\n screen: (...args: Parameters<DepsmithSdkClient['screen']>) => c.screen(...args),\n identify: (userId, traits) => c.identify(userId, traits),\n alias: (aliasId) => c.alias(aliasId),\n reset: () => c.reset(),\n group: (groupId, traits) => c.group(groupId, traits),\n setGroupTraits: (traits) => c.setGroupTraits(traits),\n setProperty: (key, value) => c.setProperty(key, value),\n setOnceProperty: (key, value) => c.setOnceProperty(key, value),\n unsetProperty: (key) => c.unsetProperty(key),\n setUserProperties: (ops) => c.setUserProperties(ops),\n register: (properties) => c.register(properties),\n registerOnce: (properties) => c.registerOnce(properties),\n unregister: (key) => c.unregister(key),\n optIn: () => c.optIn(),\n optOut: () => c.optOut(),\n flush: () => c.flush(),\n getAnonymousId: () => c.getAnonymousId(),\n getSessionId: () => c.getSessionId(),\n setSessionId: (sessionId, startedAt) => c.setSessionId(sessionId, startedAt),\n };\n}\n","import { useEffect, useRef } from 'react';\nimport type { Properties } from '@depsmith/depsmith-sdk';\nimport { useDepsmithContext } from './provider';\n\nexport interface PageViewOptions {\n /**\n * Page name. Defaults to the SDK's `pageNames` match for the location, else `document.title`\n * at the time the view is recorded.\n */\n name?: string;\n properties?: Properties;\n /** Page type, sent as `$page_type` (`product`, `collection`, `cart`, …). */\n type?: string;\n}\n\n/**\n * Emits one `$page_view` per distinct `key` — pass whatever identifies a page in your router:\n * the pathname, or pathname + search if query changes are separate pages for you (the\n * equivalent of `pageviews: 'all'`). Router-agnostic; `@depsmith/depsmith-sdk-react/react-router`\n * wraps it for React Router.\n *\n * Does nothing when the provider's config autocaptures page views (`autocapture: true`, or an\n * object without `pageviews: false`): the SDK already emits on every History navigation, and an\n * explicit `page()` on top would count each route twice. Set `autocapture.pageviews: false` to\n * let the router drive page views instead.\n *\n * `key === undefined` skips — useful while a router is still resolving. A repeated key is ignored,\n * which also absorbs StrictMode's mount → unmount → mount effect replay.\n */\nexport function usePageView(key: string | undefined, options: PageViewOptions = {}): void {\n const { api, pageViewsAutocaptured, debug } = useDepsmithContext();\n const lastKey = useRef<string | undefined>(undefined);\n // Read through a ref so inline `{ properties: {...} }` literals don't re-fire the effect.\n const latest = useRef(options);\n latest.current = options;\n\n useEffect(() => {\n if (key === undefined || key === lastKey.current) return;\n lastKey.current = key;\n if (pageViewsAutocaptured) {\n if (debug) {\n console.warn(\n '[depsmith-sdk-react] usePageView ignored: autocapture already emits page views. ' +\n 'Set autocapture.pageviews: false to drive them from the router.'\n );\n }\n return;\n }\n const { name, properties, type } = latest.current;\n // The options argument only when there is a type, so a call without one is unchanged.\n if (type === undefined) api.page(name, properties);\n else api.page(name, properties, { type });\n }, [key, api, pageViewsAutocaptured, debug]);\n}\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/provider.tsx
|
|
4
|
+
import { createContext, useContext, useState } from "react";
|
|
5
|
+
import { DepsmithSdk } from "@depsmith/depsmith-sdk";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var DepsmithContext = createContext(null);
|
|
8
|
+
function DepsmithProvider(props) {
|
|
9
|
+
const [value] = useState(() => {
|
|
10
|
+
if (props.client) {
|
|
11
|
+
return { api: bindClient(props.client), pageViewsAutocaptured: false, debug: false };
|
|
12
|
+
}
|
|
13
|
+
const config = props.config;
|
|
14
|
+
if (typeof window !== "undefined") DepsmithSdk.init(config);
|
|
15
|
+
return {
|
|
16
|
+
api: DepsmithSdk,
|
|
17
|
+
pageViewsAutocaptured: autocapturesPageViews(config),
|
|
18
|
+
debug: config.debug ?? false
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ jsx(DepsmithContext.Provider, { value, children: props.children });
|
|
22
|
+
}
|
|
23
|
+
function useDepsmith() {
|
|
24
|
+
return useDepsmithContext().api;
|
|
25
|
+
}
|
|
26
|
+
function useDepsmithContext() {
|
|
27
|
+
const ctx = useContext(DepsmithContext);
|
|
28
|
+
if (!ctx) throw new Error("useDepsmith must be used inside <DepsmithProvider>");
|
|
29
|
+
return ctx;
|
|
30
|
+
}
|
|
31
|
+
function autocapturesPageViews(config) {
|
|
32
|
+
const ac = config.autocapture;
|
|
33
|
+
if (ac === true) return true;
|
|
34
|
+
if (ac && typeof ac === "object") {
|
|
35
|
+
const pageviews = ac.pageviews;
|
|
36
|
+
return pageviews === void 0 || Boolean(pageviews);
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function bindClient(c) {
|
|
41
|
+
return {
|
|
42
|
+
track: (name, properties) => c.track(name, properties),
|
|
43
|
+
// Spread, so the `{ type }` options argument reaches the client.
|
|
44
|
+
page: (...args) => c.page(...args),
|
|
45
|
+
screen: (...args) => c.screen(...args),
|
|
46
|
+
identify: (userId, traits) => c.identify(userId, traits),
|
|
47
|
+
alias: (aliasId) => c.alias(aliasId),
|
|
48
|
+
reset: () => c.reset(),
|
|
49
|
+
group: (groupId, traits) => c.group(groupId, traits),
|
|
50
|
+
setGroupTraits: (traits) => c.setGroupTraits(traits),
|
|
51
|
+
setProperty: (key, value) => c.setProperty(key, value),
|
|
52
|
+
setOnceProperty: (key, value) => c.setOnceProperty(key, value),
|
|
53
|
+
unsetProperty: (key) => c.unsetProperty(key),
|
|
54
|
+
setUserProperties: (ops) => c.setUserProperties(ops),
|
|
55
|
+
register: (properties) => c.register(properties),
|
|
56
|
+
registerOnce: (properties) => c.registerOnce(properties),
|
|
57
|
+
unregister: (key) => c.unregister(key),
|
|
58
|
+
optIn: () => c.optIn(),
|
|
59
|
+
optOut: () => c.optOut(),
|
|
60
|
+
flush: () => c.flush(),
|
|
61
|
+
getAnonymousId: () => c.getAnonymousId(),
|
|
62
|
+
getSessionId: () => c.getSessionId(),
|
|
63
|
+
setSessionId: (sessionId, startedAt) => c.setSessionId(sessionId, startedAt)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/page-view.ts
|
|
68
|
+
import { useEffect, useRef } from "react";
|
|
69
|
+
function usePageView(key, options = {}) {
|
|
70
|
+
const { api, pageViewsAutocaptured, debug } = useDepsmithContext();
|
|
71
|
+
const lastKey = useRef(void 0);
|
|
72
|
+
const latest = useRef(options);
|
|
73
|
+
latest.current = options;
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (key === void 0 || key === lastKey.current) return;
|
|
76
|
+
lastKey.current = key;
|
|
77
|
+
if (pageViewsAutocaptured) {
|
|
78
|
+
if (debug) {
|
|
79
|
+
console.warn(
|
|
80
|
+
"[depsmith-sdk-react] usePageView ignored: autocapture already emits page views. Set autocapture.pageviews: false to drive them from the router."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { name, properties, type } = latest.current;
|
|
86
|
+
if (type === void 0) api.page(name, properties);
|
|
87
|
+
else api.page(name, properties, { type });
|
|
88
|
+
}, [key, api, pageViewsAutocaptured, debug]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
DepsmithProvider,
|
|
93
|
+
useDepsmith,
|
|
94
|
+
usePageView
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=chunk-GCBPFIL3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx","../src/page-view.ts"],"sourcesContent":["import { createContext, useContext, useState, type ReactElement, type ReactNode } from 'react';\nimport { DepsmithSdk, type DepsmithSdkClient, type DepsmithSdkConfig } from '@depsmith/depsmith-sdk';\n\n/** Every tracking call the singleton facade offers, minus its lifecycle (init/shutdown). */\nexport type DepsmithApi = Omit<typeof DepsmithSdk, 'init' | 'shutdown'>;\n\ninterface DepsmithContextValue {\n api: DepsmithApi;\n /**\n * True when the SDK's own autocapture already emits `$page_view` on every History navigation.\n * Router-driven page views must then stand down, or each route change is counted twice: the\n * SDK's pushState patch fires first, and an explicit `page()` always emits.\n */\n pageViewsAutocaptured: boolean;\n debug: boolean;\n}\n\nconst DepsmithContext = createContext<DepsmithContextValue | null>(null);\n\nexport type DepsmithProviderProps = {\n children?: ReactNode;\n} & (\n | {\n /** Passed to `DepsmithSdk.init()`. Read once, on first render — later changes are ignored. */\n config: DepsmithSdkConfig;\n client?: never;\n }\n | {\n /** A client you constructed yourself, e.g. a second instance alongside the singleton. */\n client: DepsmithSdkClient;\n config?: never;\n }\n);\n\n/**\n * Initialises the SDK and makes it available to `useDepsmith()` and the page-view hooks.\n *\n * Initialises during the first render, not in an effect. Child effects run before their\n * parent's, so an effect-time init would drop every event a descendant tracks on mount. Render-time\n * is safe to repeat: `DepsmithSdk.init` is a no-op for the same apiKey, which also covers\n * StrictMode's double render and hot reload. On the server (no `window`) it does nothing, and\n * every call through the hooks is a silent no-op until the browser renders.\n *\n * The client is never shut down on unmount: it owns the persisted queue and the `pagehide` flush,\n * which must outlive any one component tree.\n */\nexport function DepsmithProvider(props: DepsmithProviderProps): ReactElement {\n const [value] = useState<DepsmithContextValue>(() => {\n if (props.client) {\n return { api: bindClient(props.client), pageViewsAutocaptured: false, debug: false };\n }\n const config = props.config;\n if (typeof window !== 'undefined') DepsmithSdk.init(config);\n return {\n api: DepsmithSdk,\n pageViewsAutocaptured: autocapturesPageViews(config),\n debug: config.debug ?? false,\n };\n });\n return <DepsmithContext.Provider value={value}>{props.children}</DepsmithContext.Provider>;\n}\n\n/** The SDK, from the nearest `<DepsmithProvider>`. Every method is safe to call during SSR. */\nexport function useDepsmith(): DepsmithApi {\n return useDepsmithContext().api;\n}\n\nexport function useDepsmithContext(): DepsmithContextValue {\n const ctx = useContext(DepsmithContext);\n if (!ctx) throw new Error('useDepsmith must be used inside <DepsmithProvider>');\n return ctx;\n}\n\n/**\n * Mirrors the web SDK's resolveConfig: `true` means all defaults, which include pageviews.\n * `pageviews` is `'path' | 'all' | boolean` from SDK 0.8.0: `'path'`, `'all'` and `true` all\n * autocapture, an absent key keeps the default (`'path'`), and only a falsy value turns it off.\n */\nfunction autocapturesPageViews(config: DepsmithSdkConfig): boolean {\n const ac = config.autocapture;\n if (ac === true) return true;\n if (ac && typeof ac === 'object') {\n // Widened: the published SDK's types may still declare a boolean here.\n const pageviews: unknown = ac.pageviews;\n return pageviews === undefined || Boolean(pageviews);\n }\n return false;\n}\n\nfunction bindClient(c: DepsmithSdkClient): DepsmithApi {\n return {\n track: (name, properties) => c.track(name, properties),\n // Spread, so the `{ type }` options argument reaches the client.\n page: (...args: Parameters<DepsmithSdkClient['page']>) => c.page(...args),\n screen: (...args: Parameters<DepsmithSdkClient['screen']>) => c.screen(...args),\n identify: (userId, traits) => c.identify(userId, traits),\n alias: (aliasId) => c.alias(aliasId),\n reset: () => c.reset(),\n group: (groupId, traits) => c.group(groupId, traits),\n setGroupTraits: (traits) => c.setGroupTraits(traits),\n setProperty: (key, value) => c.setProperty(key, value),\n setOnceProperty: (key, value) => c.setOnceProperty(key, value),\n unsetProperty: (key) => c.unsetProperty(key),\n setUserProperties: (ops) => c.setUserProperties(ops),\n register: (properties) => c.register(properties),\n registerOnce: (properties) => c.registerOnce(properties),\n unregister: (key) => c.unregister(key),\n optIn: () => c.optIn(),\n optOut: () => c.optOut(),\n flush: () => c.flush(),\n getAnonymousId: () => c.getAnonymousId(),\n getSessionId: () => c.getSessionId(),\n setSessionId: (sessionId, startedAt) => c.setSessionId(sessionId, startedAt),\n };\n}\n","import { useEffect, useRef } from 'react';\nimport type { Properties } from '@depsmith/depsmith-sdk';\nimport { useDepsmithContext } from './provider';\n\nexport interface PageViewOptions {\n /**\n * Page name. Defaults to the SDK's `pageNames` match for the location, else `document.title`\n * at the time the view is recorded.\n */\n name?: string;\n properties?: Properties;\n /** Page type, sent as `$page_type` (`product`, `collection`, `cart`, …). */\n type?: string;\n}\n\n/**\n * Emits one `$page_view` per distinct `key` — pass whatever identifies a page in your router:\n * the pathname, or pathname + search if query changes are separate pages for you (the\n * equivalent of `pageviews: 'all'`). Router-agnostic; `@depsmith/depsmith-sdk-react/react-router`\n * wraps it for React Router.\n *\n * Does nothing when the provider's config autocaptures page views (`autocapture: true`, or an\n * object without `pageviews: false`): the SDK already emits on every History navigation, and an\n * explicit `page()` on top would count each route twice. Set `autocapture.pageviews: false` to\n * let the router drive page views instead.\n *\n * `key === undefined` skips — useful while a router is still resolving. A repeated key is ignored,\n * which also absorbs StrictMode's mount → unmount → mount effect replay.\n */\nexport function usePageView(key: string | undefined, options: PageViewOptions = {}): void {\n const { api, pageViewsAutocaptured, debug } = useDepsmithContext();\n const lastKey = useRef<string | undefined>(undefined);\n // Read through a ref so inline `{ properties: {...} }` literals don't re-fire the effect.\n const latest = useRef(options);\n latest.current = options;\n\n useEffect(() => {\n if (key === undefined || key === lastKey.current) return;\n lastKey.current = key;\n if (pageViewsAutocaptured) {\n if (debug) {\n console.warn(\n '[depsmith-sdk-react] usePageView ignored: autocapture already emits page views. ' +\n 'Set autocapture.pageviews: false to drive them from the router.'\n );\n }\n return;\n }\n const { name, properties, type } = latest.current;\n // The options argument only when there is a type, so a call without one is unchanged.\n if (type === undefined) api.page(name, properties);\n else api.page(name, properties, { type });\n }, [key, api, pageViewsAutocaptured, debug]);\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,YAAY,gBAAmD;AACvF,SAAS,mBAAmE;AA0DnE;AA1CT,IAAM,kBAAkB,cAA2C,IAAI;AA6BhE,SAAS,iBAAiB,OAA4C;AAC3E,QAAM,CAAC,KAAK,IAAI,SAA+B,MAAM;AACnD,QAAI,MAAM,QAAQ;AAChB,aAAO,EAAE,KAAK,WAAW,MAAM,MAAM,GAAG,uBAAuB,OAAO,OAAO,MAAM;AAAA,IACrF;AACA,UAAM,SA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value: true});'use client';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk6P5WIXSScjs = require('./chunk-6P5WIXSS.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.DepsmithProvider = _chunk6P5WIXSScjs.DepsmithProvider; exports.useDepsmith = _chunk6P5WIXSScjs.useDepsmith; exports.usePageView = _chunk6P5WIXSScjs.usePageView;
|
|
13
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/index.cjs"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wKAAC","file":"/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { DepsmithSdk, DepsmithSdkConfig, DepsmithSdkClient, Properties } from '@depsmith/depsmith-sdk';
|
|
3
|
+
|
|
4
|
+
/** Every tracking call the singleton facade offers, minus its lifecycle (init/shutdown). */
|
|
5
|
+
type DepsmithApi = Omit<typeof DepsmithSdk, 'init' | 'shutdown'>;
|
|
6
|
+
type DepsmithProviderProps = {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
} & ({
|
|
9
|
+
/** Passed to `DepsmithSdk.init()`. Read once, on first render — later changes are ignored. */
|
|
10
|
+
config: DepsmithSdkConfig;
|
|
11
|
+
client?: never;
|
|
12
|
+
} | {
|
|
13
|
+
/** A client you constructed yourself, e.g. a second instance alongside the singleton. */
|
|
14
|
+
client: DepsmithSdkClient;
|
|
15
|
+
config?: never;
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Initialises the SDK and makes it available to `useDepsmith()` and the page-view hooks.
|
|
19
|
+
*
|
|
20
|
+
* Initialises during the first render, not in an effect. Child effects run before their
|
|
21
|
+
* parent's, so an effect-time init would drop every event a descendant tracks on mount. Render-time
|
|
22
|
+
* is safe to repeat: `DepsmithSdk.init` is a no-op for the same apiKey, which also covers
|
|
23
|
+
* StrictMode's double render and hot reload. On the server (no `window`) it does nothing, and
|
|
24
|
+
* every call through the hooks is a silent no-op until the browser renders.
|
|
25
|
+
*
|
|
26
|
+
* The client is never shut down on unmount: it owns the persisted queue and the `pagehide` flush,
|
|
27
|
+
* which must outlive any one component tree.
|
|
28
|
+
*/
|
|
29
|
+
declare function DepsmithProvider(props: DepsmithProviderProps): ReactElement;
|
|
30
|
+
/** The SDK, from the nearest `<DepsmithProvider>`. Every method is safe to call during SSR. */
|
|
31
|
+
declare function useDepsmith(): DepsmithApi;
|
|
32
|
+
|
|
33
|
+
interface PageViewOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Page name. Defaults to the SDK's `pageNames` match for the location, else `document.title`
|
|
36
|
+
* at the time the view is recorded.
|
|
37
|
+
*/
|
|
38
|
+
name?: string;
|
|
39
|
+
properties?: Properties;
|
|
40
|
+
/** Page type, sent as `$page_type` (`product`, `collection`, `cart`, …). */
|
|
41
|
+
type?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Emits one `$page_view` per distinct `key` — pass whatever identifies a page in your router:
|
|
45
|
+
* the pathname, or pathname + search if query changes are separate pages for you (the
|
|
46
|
+
* equivalent of `pageviews: 'all'`). Router-agnostic; `@depsmith/depsmith-sdk-react/react-router`
|
|
47
|
+
* wraps it for React Router.
|
|
48
|
+
*
|
|
49
|
+
* Does nothing when the provider's config autocaptures page views (`autocapture: true`, or an
|
|
50
|
+
* object without `pageviews: false`): the SDK already emits on every History navigation, and an
|
|
51
|
+
* explicit `page()` on top would count each route twice. Set `autocapture.pageviews: false` to
|
|
52
|
+
* let the router drive page views instead.
|
|
53
|
+
*
|
|
54
|
+
* `key === undefined` skips — useful while a router is still resolving. A repeated key is ignored,
|
|
55
|
+
* which also absorbs StrictMode's mount → unmount → mount effect replay.
|
|
56
|
+
*/
|
|
57
|
+
declare function usePageView(key: string | undefined, options?: PageViewOptions): void;
|
|
58
|
+
|
|
59
|
+
export { type DepsmithApi, DepsmithProvider, type DepsmithProviderProps, type PageViewOptions, useDepsmith, usePageView };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { DepsmithSdk, DepsmithSdkConfig, DepsmithSdkClient, Properties } from '@depsmith/depsmith-sdk';
|
|
3
|
+
|
|
4
|
+
/** Every tracking call the singleton facade offers, minus its lifecycle (init/shutdown). */
|
|
5
|
+
type DepsmithApi = Omit<typeof DepsmithSdk, 'init' | 'shutdown'>;
|
|
6
|
+
type DepsmithProviderProps = {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
} & ({
|
|
9
|
+
/** Passed to `DepsmithSdk.init()`. Read once, on first render — later changes are ignored. */
|
|
10
|
+
config: DepsmithSdkConfig;
|
|
11
|
+
client?: never;
|
|
12
|
+
} | {
|
|
13
|
+
/** A client you constructed yourself, e.g. a second instance alongside the singleton. */
|
|
14
|
+
client: DepsmithSdkClient;
|
|
15
|
+
config?: never;
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* Initialises the SDK and makes it available to `useDepsmith()` and the page-view hooks.
|
|
19
|
+
*
|
|
20
|
+
* Initialises during the first render, not in an effect. Child effects run before their
|
|
21
|
+
* parent's, so an effect-time init would drop every event a descendant tracks on mount. Render-time
|
|
22
|
+
* is safe to repeat: `DepsmithSdk.init` is a no-op for the same apiKey, which also covers
|
|
23
|
+
* StrictMode's double render and hot reload. On the server (no `window`) it does nothing, and
|
|
24
|
+
* every call through the hooks is a silent no-op until the browser renders.
|
|
25
|
+
*
|
|
26
|
+
* The client is never shut down on unmount: it owns the persisted queue and the `pagehide` flush,
|
|
27
|
+
* which must outlive any one component tree.
|
|
28
|
+
*/
|
|
29
|
+
declare function DepsmithProvider(props: DepsmithProviderProps): ReactElement;
|
|
30
|
+
/** The SDK, from the nearest `<DepsmithProvider>`. Every method is safe to call during SSR. */
|
|
31
|
+
declare function useDepsmith(): DepsmithApi;
|
|
32
|
+
|
|
33
|
+
interface PageViewOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Page name. Defaults to the SDK's `pageNames` match for the location, else `document.title`
|
|
36
|
+
* at the time the view is recorded.
|
|
37
|
+
*/
|
|
38
|
+
name?: string;
|
|
39
|
+
properties?: Properties;
|
|
40
|
+
/** Page type, sent as `$page_type` (`product`, `collection`, `cart`, …). */
|
|
41
|
+
type?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Emits one `$page_view` per distinct `key` — pass whatever identifies a page in your router:
|
|
45
|
+
* the pathname, or pathname + search if query changes are separate pages for you (the
|
|
46
|
+
* equivalent of `pageviews: 'all'`). Router-agnostic; `@depsmith/depsmith-sdk-react/react-router`
|
|
47
|
+
* wraps it for React Router.
|
|
48
|
+
*
|
|
49
|
+
* Does nothing when the provider's config autocaptures page views (`autocapture: true`, or an
|
|
50
|
+
* object without `pageviews: false`): the SDK already emits on every History navigation, and an
|
|
51
|
+
* explicit `page()` on top would count each route twice. Set `autocapture.pageviews: false` to
|
|
52
|
+
* let the router drive page views instead.
|
|
53
|
+
*
|
|
54
|
+
* `key === undefined` skips — useful while a router is still resolving. A repeated key is ignored,
|
|
55
|
+
* which also absorbs StrictMode's mount → unmount → mount effect replay.
|
|
56
|
+
*/
|
|
57
|
+
declare function usePageView(key: string | undefined, options?: PageViewOptions): void;
|
|
58
|
+
|
|
59
|
+
export { type DepsmithApi, DepsmithProvider, type DepsmithProviderProps, type PageViewOptions, useDepsmith, usePageView };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }'use client';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk6P5WIXSScjs = require('./chunk-6P5WIXSS.cjs');
|
|
6
|
+
|
|
7
|
+
// src/react-router.ts
|
|
8
|
+
var _reactrouter = require('react-router');
|
|
9
|
+
function useRouterPageViews(options = {}) {
|
|
10
|
+
const location = _reactrouter.useLocation.call(void 0, );
|
|
11
|
+
const key = options.includeSearch === false ? location.pathname : location.pathname + location.search;
|
|
12
|
+
_chunk6P5WIXSScjs.usePageView.call(void 0, key, {
|
|
13
|
+
name: _optionalChain([options, 'access', _ => _.getName, 'optionalCall', _2 => _2(location)]),
|
|
14
|
+
properties: _optionalChain([options, 'access', _3 => _3.getProperties, 'optionalCall', _4 => _4(location)]),
|
|
15
|
+
type: _optionalChain([options, 'access', _5 => _5.getType, 'optionalCall', _6 => _6(location)])
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function DepsmithRouterPageViews(props) {
|
|
19
|
+
useRouterPageViews(props);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
exports.DepsmithRouterPageViews = DepsmithRouterPageViews; exports.useRouterPageViews = useRouterPageViews;
|
|
26
|
+
//# sourceMappingURL=react-router.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/react-router.cjs","../src/react-router.ts"],"names":[],"mappings":"AAAA,ylBAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACA;ACLA,2CAA2C;AAoBpC,SAAS,kBAAA,CAAmB,QAAA,EAAiC,CAAC,CAAA,EAAS;AAC5E,EAAA,MAAM,SAAA,EAAW,sCAAA,CAAY;AAC7B,EAAA,MAAM,IAAA,EACJ,OAAA,CAAQ,cAAA,IAAkB,MAAA,EAAQ,QAAA,CAAS,SAAA,EAAW,QAAA,CAAS,SAAA,EAAW,QAAA,CAAS,MAAA;AACrF,EAAA,2CAAA,GAAY,EAAK;AAAA,IACf,IAAA,kBAAM,OAAA,mBAAQ,OAAA,0BAAA,CAAU,QAAQ,GAAA;AAAA,IAChC,UAAA,kBAAY,OAAA,qBAAQ,aAAA,0BAAA,CAAgB,QAAQ,GAAA;AAAA,IAC5C,IAAA,kBAAM,OAAA,qBAAQ,OAAA,0BAAA,CAAU,QAAQ;AAAA,EAClC,CAAC,CAAA;AACH;AAGO,SAAS,uBAAA,CAAwB,KAAA,EAAoC;AAC1E,EAAA,kBAAA,CAAmB,KAAK,CAAA;AACxB,EAAA,OAAO,IAAA;AACT;ADfA;AACE;AACA;AACF,2GAAC","file":"/home/animesh/devspace/depsmith-dev/depsmith-sdk/react/dist/react-router.cjs","sourcesContent":[null,"import { useLocation, type Location } from 'react-router';\nimport type { Properties } from '@depsmith/depsmith-sdk';\nimport { usePageView } from './page-view';\n\nexport interface RouterPageViewOptions {\n /** Count a change in `?query` as a new page. Default true. The `#hash` never is. */\n includeSearch?: boolean;\n /** Page name for a location. Default: `document.title`. */\n getName?: (location: Location) => string | undefined;\n /** Page type for a location, sent as `$page_type`. */\n getType?: (location: Location) => string | undefined;\n /** Extra properties for a location's `$page_view`. */\n getProperties?: (location: Location) => Properties | undefined;\n}\n\n/**\n * One `$page_view` per React Router navigation. Must render inside the router and the\n * `<DepsmithProvider>`. Same autocapture rule as `usePageView`: with `autocapture.pageviews`\n * on, this stands down.\n */\nexport function useRouterPageViews(options: RouterPageViewOptions = {}): void {\n const location = useLocation();\n const key =\n options.includeSearch === false ? location.pathname : location.pathname + location.search;\n usePageView(key, {\n name: options.getName?.(location),\n properties: options.getProperties?.(location),\n type: options.getType?.(location),\n });\n}\n\n/** Component form of `useRouterPageViews`, for dropping into a layout route. Renders nothing. */\nexport function DepsmithRouterPageViews(props: RouterPageViewOptions): null {\n useRouterPageViews(props);\n return null;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Location } from 'react-router';
|
|
2
|
+
import { Properties } from '@depsmith/depsmith-sdk';
|
|
3
|
+
|
|
4
|
+
interface RouterPageViewOptions {
|
|
5
|
+
/** Count a change in `?query` as a new page. Default true. The `#hash` never is. */
|
|
6
|
+
includeSearch?: boolean;
|
|
7
|
+
/** Page name for a location. Default: `document.title`. */
|
|
8
|
+
getName?: (location: Location) => string | undefined;
|
|
9
|
+
/** Page type for a location, sent as `$page_type`. */
|
|
10
|
+
getType?: (location: Location) => string | undefined;
|
|
11
|
+
/** Extra properties for a location's `$page_view`. */
|
|
12
|
+
getProperties?: (location: Location) => Properties | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One `$page_view` per React Router navigation. Must render inside the router and the
|
|
16
|
+
* `<DepsmithProvider>`. Same autocapture rule as `usePageView`: with `autocapture.pageviews`
|
|
17
|
+
* on, this stands down.
|
|
18
|
+
*/
|
|
19
|
+
declare function useRouterPageViews(options?: RouterPageViewOptions): void;
|
|
20
|
+
/** Component form of `useRouterPageViews`, for dropping into a layout route. Renders nothing. */
|
|
21
|
+
declare function DepsmithRouterPageViews(props: RouterPageViewOptions): null;
|
|
22
|
+
|
|
23
|
+
export { DepsmithRouterPageViews, type RouterPageViewOptions, useRouterPageViews };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Location } from 'react-router';
|
|
2
|
+
import { Properties } from '@depsmith/depsmith-sdk';
|
|
3
|
+
|
|
4
|
+
interface RouterPageViewOptions {
|
|
5
|
+
/** Count a change in `?query` as a new page. Default true. The `#hash` never is. */
|
|
6
|
+
includeSearch?: boolean;
|
|
7
|
+
/** Page name for a location. Default: `document.title`. */
|
|
8
|
+
getName?: (location: Location) => string | undefined;
|
|
9
|
+
/** Page type for a location, sent as `$page_type`. */
|
|
10
|
+
getType?: (location: Location) => string | undefined;
|
|
11
|
+
/** Extra properties for a location's `$page_view`. */
|
|
12
|
+
getProperties?: (location: Location) => Properties | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One `$page_view` per React Router navigation. Must render inside the router and the
|
|
16
|
+
* `<DepsmithProvider>`. Same autocapture rule as `usePageView`: with `autocapture.pageviews`
|
|
17
|
+
* on, this stands down.
|
|
18
|
+
*/
|
|
19
|
+
declare function useRouterPageViews(options?: RouterPageViewOptions): void;
|
|
20
|
+
/** Component form of `useRouterPageViews`, for dropping into a layout route. Renders nothing. */
|
|
21
|
+
declare function DepsmithRouterPageViews(props: RouterPageViewOptions): null;
|
|
22
|
+
|
|
23
|
+
export { DepsmithRouterPageViews, type RouterPageViewOptions, useRouterPageViews };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
usePageView
|
|
4
|
+
} from "./chunk-GCBPFIL3.js";
|
|
5
|
+
|
|
6
|
+
// src/react-router.ts
|
|
7
|
+
import { useLocation } from "react-router";
|
|
8
|
+
function useRouterPageViews(options = {}) {
|
|
9
|
+
const location = useLocation();
|
|
10
|
+
const key = options.includeSearch === false ? location.pathname : location.pathname + location.search;
|
|
11
|
+
usePageView(key, {
|
|
12
|
+
name: options.getName?.(location),
|
|
13
|
+
properties: options.getProperties?.(location),
|
|
14
|
+
type: options.getType?.(location)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function DepsmithRouterPageViews(props) {
|
|
18
|
+
useRouterPageViews(props);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
DepsmithRouterPageViews,
|
|
23
|
+
useRouterPageViews
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=react-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react-router.ts"],"sourcesContent":["import { useLocation, type Location } from 'react-router';\nimport type { Properties } from '@depsmith/depsmith-sdk';\nimport { usePageView } from './page-view';\n\nexport interface RouterPageViewOptions {\n /** Count a change in `?query` as a new page. Default true. The `#hash` never is. */\n includeSearch?: boolean;\n /** Page name for a location. Default: `document.title`. */\n getName?: (location: Location) => string | undefined;\n /** Page type for a location, sent as `$page_type`. */\n getType?: (location: Location) => string | undefined;\n /** Extra properties for a location's `$page_view`. */\n getProperties?: (location: Location) => Properties | undefined;\n}\n\n/**\n * One `$page_view` per React Router navigation. Must render inside the router and the\n * `<DepsmithProvider>`. Same autocapture rule as `usePageView`: with `autocapture.pageviews`\n * on, this stands down.\n */\nexport function useRouterPageViews(options: RouterPageViewOptions = {}): void {\n const location = useLocation();\n const key =\n options.includeSearch === false ? location.pathname : location.pathname + location.search;\n usePageView(key, {\n name: options.getName?.(location),\n properties: options.getProperties?.(location),\n type: options.getType?.(location),\n });\n}\n\n/** Component form of `useRouterPageViews`, for dropping into a layout route. Renders nothing. */\nexport function DepsmithRouterPageViews(props: RouterPageViewOptions): null {\n useRouterPageViews(props);\n return null;\n}\n"],"mappings":";;;;;;AAAA,SAAS,mBAAkC;AAoBpC,SAAS,mBAAmB,UAAiC,CAAC,GAAS;AAC5E,QAAM,WAAW,YAAY;AAC7B,QAAM,MACJ,QAAQ,kBAAkB,QAAQ,SAAS,WAAW,SAAS,WAAW,SAAS;AACrF,cAAY,KAAK;AAAA,IACf,MAAM,QAAQ,UAAU,QAAQ;AAAA,IAChC,YAAY,QAAQ,gBAAgB,QAAQ;AAAA,IAC5C,MAAM,QAAQ,UAAU,QAAQ;AAAA,EAClC,CAAC;AACH;AAGO,SAAS,wBAAwB,OAAoC;AAC1E,qBAAmB,KAAK;AACxB,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depsmith/depsmith-sdk-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "DepSmith SDK — React bindings (provider, hooks, router page views) over @depsmith/depsmith-sdk",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://depsmith.com",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./react-router": {
|
|
19
|
+
"types": "./dist/react-router.d.ts",
|
|
20
|
+
"import": "./dist/react-router.js",
|
|
21
|
+
"require": "./dist/react-router.cjs"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@depsmith/depsmith-sdk": ">=0.8.0 <1.0.0",
|
|
35
|
+
"react": ">=16.8.0",
|
|
36
|
+
"react-router": ">=6.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"react-router": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@depsmith/depsmith-sdk": "^0.8.0",
|
|
45
|
+
"@testing-library/dom": "^10.4.2",
|
|
46
|
+
"@testing-library/react": "^16.3.0",
|
|
47
|
+
"@types/react": "^19.1.0",
|
|
48
|
+
"jsdom": "^25.0.1",
|
|
49
|
+
"react": "^19.1.0",
|
|
50
|
+
"react-dom": "^19.1.0",
|
|
51
|
+
"react-router": "^7.9.0",
|
|
52
|
+
"tsup": "^8.3.5",
|
|
53
|
+
"typescript": "^5.7.2",
|
|
54
|
+
"vitest": "^4.1.11"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"analytics",
|
|
58
|
+
"events",
|
|
59
|
+
"tracking",
|
|
60
|
+
"react",
|
|
61
|
+
"react-router",
|
|
62
|
+
"depsmith",
|
|
63
|
+
"depsmith-sdk"
|
|
64
|
+
]
|
|
65
|
+
}
|