@lapwy/react 0.0.0-stage → 0.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 +17 -2
- package/dist/index.cjs +53 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +24 -0
- package/package.json +36 -3
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lapwy/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
lapwy for React.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @lapwy/react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```jsx
|
|
10
|
+
import { Lapwy, useLapwy } from "@lapwy/react";
|
|
11
|
+
|
|
12
|
+
<Lapwy site="lw_…" /> // once, near the root
|
|
13
|
+
|
|
14
|
+
const { track } = useLapwy(); // in any component
|
|
15
|
+
<button onClick={() => track("signup", { plan: "pro" })}>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Works with React Router and any router that changes the address: route changes are page views without further setup. `track`, `page`, `consent` and `notFound` are also exported on their own, and are safe to call before `<Lapwy>` has mounted.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.tsx
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
Lapwy: () => Lapwy,
|
|
25
|
+
consent: () => import_js.consent,
|
|
26
|
+
notFound: () => import_js.notFound,
|
|
27
|
+
page: () => import_js.page,
|
|
28
|
+
track: () => import_js.track,
|
|
29
|
+
useLapwy: () => useLapwy
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_js = require("@lapwy/js");
|
|
34
|
+
function Lapwy(props) {
|
|
35
|
+
const { site, endpoint, cookie, release, api: apiHosts, pages, path } = props;
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
(0, import_js.init)({ site, endpoint, cookie, release, api: apiHosts, pages, path, sdk: "react-0.2" });
|
|
38
|
+
}, []);
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
var api = { track: import_js.track, page: import_js.page, consent: import_js.consent, notFound: import_js.notFound };
|
|
42
|
+
function useLapwy() {
|
|
43
|
+
return api;
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
Lapwy,
|
|
48
|
+
consent,
|
|
49
|
+
notFound,
|
|
50
|
+
page,
|
|
51
|
+
track,
|
|
52
|
+
useLapwy
|
|
53
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { consent, notFound, page, track, type Options, type Tracker } from "@lapwy/js";
|
|
2
|
+
export type LapwyProps = Omit<Options, "sdk">;
|
|
3
|
+
/** Starts tracking when it mounts. Renders nothing. Put it once near the root of the app. */
|
|
4
|
+
export declare function Lapwy(props: LapwyProps): null;
|
|
5
|
+
/** track, page and consent. They are safe to call before <Lapwy> has mounted: nothing is lost. */
|
|
6
|
+
export declare function useLapwy(): Tracker;
|
|
7
|
+
export { track, page, consent, notFound };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { consent, notFound, page, track, type Options, type Tracker } from "@lapwy/js";
|
|
2
|
+
export type LapwyProps = Omit<Options, "sdk">;
|
|
3
|
+
/** Starts tracking when it mounts. Renders nothing. Put it once near the root of the app. */
|
|
4
|
+
export declare function Lapwy(props: LapwyProps): null;
|
|
5
|
+
/** track, page and consent. They are safe to call before <Lapwy> has mounted: nothing is lost. */
|
|
6
|
+
export declare function useLapwy(): Tracker;
|
|
7
|
+
export { track, page, consent, notFound };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/index.tsx
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { consent, init, notFound, page, track } from "@lapwy/js";
|
|
6
|
+
function Lapwy(props) {
|
|
7
|
+
const { site, endpoint, cookie, release, api: apiHosts, pages, path } = props;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
init({ site, endpoint, cookie, release, api: apiHosts, pages, path, sdk: "react-0.2" });
|
|
10
|
+
}, []);
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
var api = { track, page, consent, notFound };
|
|
14
|
+
function useLapwy() {
|
|
15
|
+
return api;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
Lapwy,
|
|
19
|
+
consent,
|
|
20
|
+
notFound,
|
|
21
|
+
page,
|
|
22
|
+
track,
|
|
23
|
+
useLapwy
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lapwy/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "lapwy for React: the <Lapwy> component and useLapwy().",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@lapwy/js": "^0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/cts-types.mjs"
|
|
38
|
+
}
|
|
6
39
|
}
|