@inslytic/sdk-react 0.1.1
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/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +58 -0
- package/dist/index.mjs +30 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { InslyticConfig, track, identify, page, setConsent, reset } from '@inslytic/sdk-browser';
|
|
3
|
+
|
|
4
|
+
type InslyticProviderProps = {
|
|
5
|
+
config: InslyticConfig;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
declare function InslyticProvider({ config, children }: InslyticProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare function useInslytic(): {
|
|
11
|
+
track: typeof track;
|
|
12
|
+
identify: typeof identify;
|
|
13
|
+
page: typeof page;
|
|
14
|
+
setConsent: typeof setConsent;
|
|
15
|
+
reset: typeof reset;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { InslyticProvider, useInslytic };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { InslyticConfig, track, identify, page, setConsent, reset } from '@inslytic/sdk-browser';
|
|
3
|
+
|
|
4
|
+
type InslyticProviderProps = {
|
|
5
|
+
config: InslyticConfig;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
declare function InslyticProvider({ config, children }: InslyticProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
declare function useInslytic(): {
|
|
11
|
+
track: typeof track;
|
|
12
|
+
identify: typeof identify;
|
|
13
|
+
page: typeof page;
|
|
14
|
+
setConsent: typeof setConsent;
|
|
15
|
+
reset: typeof reset;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { InslyticProvider, useInslytic };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
InslyticProvider: () => InslyticProvider,
|
|
24
|
+
useInslytic: () => useInslytic
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/provider.tsx
|
|
29
|
+
var import_sdk_browser = require("@inslytic/sdk-browser");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var InslyticContext = (0, import_react.createContext)(null);
|
|
33
|
+
function InslyticProvider({ config, children }) {
|
|
34
|
+
const initialized = (0, import_react.useRef)(false);
|
|
35
|
+
(0, import_react.useEffect)(() => {
|
|
36
|
+
if (!initialized.current) {
|
|
37
|
+
(0, import_sdk_browser.init)(config);
|
|
38
|
+
initialized.current = true;
|
|
39
|
+
}
|
|
40
|
+
}, [config]);
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InslyticContext.Provider, { value: config, children });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/use-inslytic.ts
|
|
45
|
+
var import_sdk_browser2 = require("@inslytic/sdk-browser");
|
|
46
|
+
var import_react2 = require("react");
|
|
47
|
+
function useInslytic() {
|
|
48
|
+
const config = (0, import_react2.useContext)(InslyticContext);
|
|
49
|
+
if (!config) {
|
|
50
|
+
throw new Error("useInslytic must be used within an InslyticProvider");
|
|
51
|
+
}
|
|
52
|
+
return { track: import_sdk_browser2.track, identify: import_sdk_browser2.identify, page: import_sdk_browser2.page, setConsent: import_sdk_browser2.setConsent, reset: import_sdk_browser2.reset };
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
InslyticProvider,
|
|
57
|
+
useInslytic
|
|
58
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/provider.tsx
|
|
2
|
+
import { init } from "@inslytic/sdk-browser";
|
|
3
|
+
import { createContext, useEffect, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var InslyticContext = createContext(null);
|
|
6
|
+
function InslyticProvider({ config, children }) {
|
|
7
|
+
const initialized = useRef(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!initialized.current) {
|
|
10
|
+
init(config);
|
|
11
|
+
initialized.current = true;
|
|
12
|
+
}
|
|
13
|
+
}, [config]);
|
|
14
|
+
return /* @__PURE__ */ jsx(InslyticContext.Provider, { value: config, children });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/use-inslytic.ts
|
|
18
|
+
import { identify, page, reset, setConsent, track } from "@inslytic/sdk-browser";
|
|
19
|
+
import { useContext } from "react";
|
|
20
|
+
function useInslytic() {
|
|
21
|
+
const config = useContext(InslyticContext);
|
|
22
|
+
if (!config) {
|
|
23
|
+
throw new Error("useInslytic must be used within an InslyticProvider");
|
|
24
|
+
}
|
|
25
|
+
return { track, identify, page, setConsent, reset };
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
InslyticProvider,
|
|
29
|
+
useInslytic
|
|
30
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inslytic/sdk-react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "React hooks and components for Inslytic — AI-powered product analytics",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/inslytic/inslytic",
|
|
9
|
+
"directory": "packages/sdk-react"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"analytics",
|
|
13
|
+
"tracking",
|
|
14
|
+
"product-analytics",
|
|
15
|
+
"react",
|
|
16
|
+
"hooks",
|
|
17
|
+
"inslytic"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.mjs",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": {
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"default": "./dist/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"require": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@inslytic/sdk-browser": "0.1.1"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/react": "^19.0.0",
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"tsup": "^8.0.0",
|
|
51
|
+
"typescript": "^5.7.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
55
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"clean": "rm -rf dist .turbo node_modules"
|
|
58
|
+
}
|
|
59
|
+
}
|