@statsig/next 3.24.4
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/LICENSE +14 -0
- package/README.md +49 -0
- package/package.json +23 -0
- package/src/BootstrapClientSubProvider.d.ts +9 -0
- package/src/BootstrapClientSubProvider.js +10 -0
- package/src/StatsigBootstrapProvider.d.ts +10 -0
- package/src/StatsigBootstrapProvider.js +43 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
ISC License (ISC)
|
|
2
|
+
Copyright (c) 2021, Statsig, Inc.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
5
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
6
|
+
and this permission notice appear in all copies.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
10
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
12
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
13
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
14
|
+
THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and create an account at [statsig.com](https://www.statsig.com/?ref=gh_jsm).
|
|
2
|
+
|
|
3
|
+
<h1 align="center">
|
|
4
|
+
<a href="https://statsig.com/?ref=gh_jsm">
|
|
5
|
+
<img src="https://github.com/statsig-io/js-client-monorepo/assets/95646168/ae5499ed-20ff-4584-bf21-8857f800d485" />
|
|
6
|
+
</a>
|
|
7
|
+
<div />
|
|
8
|
+
<a href="https://statsig.com/?ref=gh_jsm">Statsig</a>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/statsig-io/js-client-monorepo/blob/main/LICENSE">
|
|
13
|
+
<img src="https://img.shields.io/badge/license-ISC-blue.svg?colorA=1b2528&colorB=ccfbc7&style=for-the-badge">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@statsig/js-client">
|
|
16
|
+
<img src="https://img.shields.io/npm/v/@statsig/js-client.svg?colorA=1b2528&colorB=b2d3ff&style=for-the-badge">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://statsig.com/community?ref=gh_jsm">
|
|
19
|
+
<img src="https://img.shields.io/badge/slack-statsig-brightgreen.svg?logo=slack&colorA=1b2528&colorB=FFF8BA&style=for-the-badge">
|
|
20
|
+
</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## Getting Started
|
|
24
|
+
|
|
25
|
+
Read through the [Documentation](https://docs.statsig.com/client/javascript-sdk?ref=gh_jsm) or check out the [Samples](samples/).
|
|
26
|
+
|
|
27
|
+
## Packages
|
|
28
|
+
|
|
29
|
+
Clients
|
|
30
|
+
|
|
31
|
+
- Precomputed Evaluations (Recommended) [[npm](https://www.npmjs.com/package/@statsig/js-client)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/js-client)]
|
|
32
|
+
- On Device Evaluations [[npm](https://www.npmjs.com/package/@statsig/js-on-device-eval-client)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/js-on-device-eval-client)]
|
|
33
|
+
|
|
34
|
+
Product Bundles
|
|
35
|
+
|
|
36
|
+
- Session Replay [[npm](https://www.npmjs.com/package/@statsig/session-replay)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/session-replay)]
|
|
37
|
+
- Web Analytics [[npm](https://www.npmjs.com/package/@statsig/web-analytics)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/web-analytics)]
|
|
38
|
+
|
|
39
|
+
Framework Specific Bindings
|
|
40
|
+
|
|
41
|
+
- React [[npm](https://www.npmjs.com/package/@statsig/react-bindings)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/react-bindings)]
|
|
42
|
+
|
|
43
|
+
- React Native [[npm](https://www.npmjs.com/package/@statsig/react-native-bindings)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/react-native-bindings)]
|
|
44
|
+
|
|
45
|
+
- React Native (Expo) [[npm](https://www.npmjs.com/package/@statsig/expo-bindings)] [[source](https://github.com/statsig-io/js-client-monorepo/tree/main/packages/expo-bindings)]
|
|
46
|
+
|
|
47
|
+
## Community
|
|
48
|
+
|
|
49
|
+
If you need any assistance or just have a question, feel free to reach out to us on [Slack](https://statsig.com/community?ref=gh_jsm).
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@statsig/next",
|
|
3
|
+
"version": "3.24.4",
|
|
4
|
+
"license": "ISC",
|
|
5
|
+
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "github:statsig-io/js-client-monorepo",
|
|
9
|
+
"directory": "packages/next"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@statsig/client-core": "3.24.4",
|
|
13
|
+
"@statsig/react-bindings": "3.24.4",
|
|
14
|
+
"statsig-node": "^6.4.5"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"next": "^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
18
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
19
|
+
},
|
|
20
|
+
"type": "commonjs",
|
|
21
|
+
"main": "./src/index.js",
|
|
22
|
+
"typings": "./src/index.d.ts"
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StatsigOptions, StatsigUser } from '@statsig/react-bindings';
|
|
3
|
+
export default function BootstrapClientSubProvider({ user, values, children, clientKey, clientOptions, }: {
|
|
4
|
+
user: StatsigUser;
|
|
5
|
+
values: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
clientKey: string;
|
|
8
|
+
clientOptions?: StatsigOptions | null;
|
|
9
|
+
}): React.ReactElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_bindings_1 = require("@statsig/react-bindings");
|
|
6
|
+
function BootstrapClientSubProvider({ user, values, children, clientKey, clientOptions, }) {
|
|
7
|
+
const client = (0, react_bindings_1.useClientBootstrapInit)(clientKey, user, values, clientOptions);
|
|
8
|
+
return (0, jsx_runtime_1.jsx)(react_bindings_1.StatsigProvider, { client: client, children: children });
|
|
9
|
+
}
|
|
10
|
+
exports.default = BootstrapClientSubProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSX, ReactNode } from 'react';
|
|
2
|
+
import { StatsigOptions, StatsigUser } from '@statsig/react-bindings';
|
|
3
|
+
export default function StatsigBootstrapProvider({ children, user, clientKey, serverKey, useCookie, clientOptions, }: {
|
|
4
|
+
user: StatsigUser;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
clientKey: string;
|
|
7
|
+
serverKey: string;
|
|
8
|
+
useCookie?: boolean;
|
|
9
|
+
clientOptions?: StatsigOptions | null;
|
|
10
|
+
}): Promise<JSX.Element>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
|
+
const headers_1 = require("next/headers");
|
|
14
|
+
const statsig_node_1 = require("statsig-node");
|
|
15
|
+
const client_core_1 = require("@statsig/client-core");
|
|
16
|
+
const BootstrapClientSubProvider_1 = require("./BootstrapClientSubProvider");
|
|
17
|
+
const statsigInitialization = {};
|
|
18
|
+
function StatsigBootstrapProvider(_a) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* ({ children, user, clientKey, serverKey, useCookie = true, clientOptions, }) {
|
|
20
|
+
var _b, _c;
|
|
21
|
+
if (!statsigInitialization[serverKey]) {
|
|
22
|
+
statsigInitialization[serverKey] = statsig_node_1.default.initialize(serverKey);
|
|
23
|
+
}
|
|
24
|
+
yield statsigInitialization[serverKey];
|
|
25
|
+
if (!((_b = user.customIDs) === null || _b === void 0 ? void 0 : _b.stableID) && useCookie) {
|
|
26
|
+
if ((0, headers_1.cookies)().get((0, client_core_1.getCookieName)(clientKey))) {
|
|
27
|
+
user.customIDs = Object.assign(Object.assign({}, (user.customIDs || {})), { stableID: (_c = (0, headers_1.cookies)().get((0, client_core_1.getCookieName)(clientKey))) === null || _c === void 0 ? void 0 : _c.value });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const stableID = (0, client_core_1.getUUID)();
|
|
31
|
+
user.customIDs = Object.assign(Object.assign({}, (user.customIDs || {})), { stableID: stableID });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (useCookie && !(clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.enableCookies)) {
|
|
35
|
+
clientOptions = Object.assign(Object.assign({}, clientOptions), { enableCookies: true });
|
|
36
|
+
}
|
|
37
|
+
const values = JSON.stringify(statsig_node_1.default.getClientInitializeResponse(user, clientKey, {
|
|
38
|
+
hash: 'djb2',
|
|
39
|
+
}));
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(BootstrapClientSubProvider_1.default, { user: user, values: values, clientKey: clientKey, clientOptions: clientOptions, children: children }));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
exports.default = StatsigBootstrapProvider;
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatsigBootstrapProvider = void 0;
|
|
4
|
+
const StatsigBootstrapProvider_1 = require("./StatsigBootstrapProvider");
|
|
5
|
+
exports.StatsigBootstrapProvider = StatsigBootstrapProvider_1.default;
|