Skip to content

Commit b719516

Browse files
update
1 parent 004fa81 commit b719516

File tree

6 files changed

+199
-2
lines changed

6 files changed

+199
-2
lines changed

docs/server-core/MigrationGuideTemplates/_GlobalChanges.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
**Lazy Initialization: User-Agent Parser & Country Lookup**
1818

19-
- User-Agent parsing and country lookup are now **lazy-loaded by default** to improve SDK initialization performance.
19+
- Country lookup and third-party ua parsersare now **lazy-loaded by default** to improve SDK initialization performance.
2020
- If your application relies on these features being ready **immediately after** `initialize()`, you can opt in by setting:
2121
- <code>{props.waitForUserAgentInit || 'wait_for_user_agent_init'}</code>
2222
- <code>{props.waitForCountryLookupInit || 'wait_for_country_lookup_init'}</code>
@@ -37,4 +37,12 @@
3737
- **Old**: `v1/download_config_specs`
3838
- **New**: `v2/download_config_specs`
3939
- If you are hosting your own **pass-through proxy**, ensure it supports and correctly routes the `v2` endpoint.
40-
- If you are using the **Statsig Forward Proxy (SFP)**, this endpoint migration is handled automatically.
40+
- If you are using the **Statsig Forward Proxy (SFP)**, this endpoint migration is handled automatically.
41+
42+
** New DataStore cache format**
43+
- **Old**: (Except Node v6+)
44+
- config_spec cahce key is: statsig.cache
45+
- IDLists statsig.id_lists
46+
- **New**
47+
- config_spec cache key: `statsig|/v2/download_config_specs|plain_text|{SHA256HashedBase64(secretkey)}`
48+
- IDLists: We don't support idlist data store.

docs/server-core/node-core.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
FieldsNeededMethods,
2727
ClientInitResponse,
2828
EventSubscriptions,
29+
MigrationGuide,
2930
} from "./Templates/index.mdx";
3031

3132
import Preamble from "./_preamble.mdx";
@@ -71,6 +72,13 @@ export const Builder = SDKDocsBuilder({
7172
initialize: <Initialize />,
7273
},
7374
],
75+
[
76+
MigrationGuide,
77+
{
78+
link: "/server-core/node/migration-guide",
79+
sdkType: "Node",
80+
},
81+
],
7482
[
7583
WorkingWith,
7684
{
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
4+
### Key Package and Class Changes
5+
6+
| Feature | Node Core SDK | Legacy Node SDK | Status |
7+
|---------|---------------|----------------|--------|
8+
| Package | `statsig-node-core` | `statsig-node` | ⚠️ Renamed |
9+
| Import | `import {Statsig} '@statsig/statsig-node-core'` |`const Statsig = require("statsig-node");` | ⚠️ Change |
10+
| Options | `StatsigOptions` | `StatsigOptions` | ✓ Same |
11+
| User | `StatsigUser` | `StatsigUser` | ⚠️ Changed from type to class |
12+
| Initialize | `await statsig.initialize()` | `await statsig.initialize()` | Same |
13+
| Check Gate | `statsig.check_gate()` | `statsig.check_gate()` | ✓ Same |
14+
| Get Config | `statsig.get_dynamic_config()` | `statsig.get_config()` | ⚠️ Renamed |
15+
| Get Experiment | `statsig.get_experiment()` | `statsig.get_experiment()` | ✓ Same |
16+
| Get Layer | `statsig.get_layer()` | `statsig.get_layer()` | ✓ Same |
17+
| Log Event | `statsig.log_event()` | `statsig.log_event()` | ✓ Same |
18+
| Shutdown | `await statsig.shutdown()` | `await statsig.shutdown()` | Same |
19+
20+
For more details on the new API, see [Python Core SDK documentation](/server-core/python-core).
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
| Old Option | New / Notes |
2+
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------- |
3+
| `api` | Deprecated |
4+
| `idlists_thread_limit`, `logging_interval`, `enable_debug_logs`, `events_flushed_callback` | Deprecated |
5+
| `timeout` | Deprecated (was only for network) |
6+
| `apiForDownloadConfigSpecs` | `specsUrl` – must complete with endpoint |
7+
| `apiForIdLists` | `idListsUrl` – must complete with endpoint |
8+
| `apiForLogEvent` | `logEventUrl` – must complete with endpoint |
9+
| `initTimeoutMs` | `initTimeoutMs` – applies to overall initialization (suggest adding +1000 ms if enabling UA) |
10+
| `rulesetsSyncIntervalMs` | `specsSyncIntervalMs` (unit: milliseconds) |
11+
| `idListsSyncIntervalMs` | `idListsSyncIntervalMs` (unit: milliseconds) |
12+
| `loggingIntervalMs` | `eventLoggingFlushIntervalMs` |
13+
| `loggingMaxBufferSize` | `eventLoggingMaxQueuesize` |
14+
| `dataAdapter` | Still supported but interface changed |
15+
| `initTimeoutMs` | Apply to overall initialize timeout |
16+
| `observability_client`, `sdk_error_callback` | Now within `observability_client` interface |
17+
| `logger` | Now `OutputLoggerProvider` interface |
18+
| `bootstrap_values`, `evaluation_callback`, `rules_updated_callback` | Not yet supported |
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
4+
User creation is still the same in the new python core SDK.
5+
6+
<Tabs>
7+
<TabItem value="new" label="New User Creation" default>
8+
```python
9+
from statsig_python_core import *
10+
11+
user = StatsigUser(
12+
user_id="user_123",
13+
email="user@example.com",
14+
ip="192.168.0.1",
15+
user_agent="Mozilla/5.0",
16+
country="US",
17+
custom={
18+
"subscription_level": "premium"
19+
}
20+
)
21+
```
22+
</TabItem>
23+
<TabItem value="legacy" label="Legacy User Creation">
24+
```python
25+
from statsig import StatsigUser
26+
27+
user = StatsigUser(
28+
user_id="user_123",
29+
email="user@example.com",
30+
ip="192.168.0.1",
31+
user_agent="Mozilla/5.0",
32+
country="US",
33+
custom={
34+
"subscription_level": "premium"
35+
}
36+
)
37+
```
38+
</TabItem>
39+
</Tabs>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: Node Core SDK Migration Guide
3+
displayed_sidebar: api
4+
---
5+
6+
import CodeBlock from '@theme/CodeBlock';
7+
import {
8+
SDKDocsBuilder,
9+
} from "../../../sdks/_SDKDocsBuilder.mdx";
10+
11+
import {
12+
APIChanges,
13+
GlobalChanges,
14+
Installation,
15+
MigrationHelp,
16+
StatsigOptions,
17+
UserCreation,
18+
NeedHelp,
19+
Troubleshooting,
20+
Intro,
21+
} from "../../MigrationGuideTemplates/index.mdx";
22+
import NodeAPIChanges from "./_api_changes.mdx";
23+
import NodeUserCreation from "./_user_creation.mdx";
24+
import NodeStatsigOptions from "./_statsig_options.mdx";
25+
26+
export const Builder = SDKDocsBuilder({
27+
sections: [
28+
[
29+
Intro,
30+
{
31+
sdkType: "Node JS",
32+
},
33+
],
34+
35+
[
36+
Installation,
37+
{
38+
legacyInstall: <CodeBlock>npm install statsig-node</CodeBlock>,
39+
install: <CodeBlock>npm install @statsig/statsig-node-core</CodeBlock>,
40+
},
41+
],
42+
[
43+
UserCreation,
44+
{
45+
newUserCreation: <CodeBlock language="nodejs">
46+
{`import {StatsigUser} from "@statsig/statsig-node-core"
47+
const user = new StatsigUser({
48+
userID: "user_123",
49+
email: "user@example.com",
50+
ip: "192.168.0.1",
51+
userAgent: "Mozilla/5.0",
52+
country: "US",
53+
custom={
54+
"subscription_level": "premium"
55+
}
56+
})
57+
`}</CodeBlock>,
58+
legacyUserCreation: <CodeBlock language="python">
59+
{`import type {StatsigUser} from "statsig-node"
60+
user = {
61+
userID: "user_123",
62+
email: "user@example.com",
63+
ip: "192.168.0.1",
64+
userAgent: "Mozilla/5.0",
65+
country: "US",
66+
custom={
67+
"subscription_level": "premium"
68+
}
69+
}
70+
`}</CodeBlock>,
71+
}
72+
],
73+
[
74+
APIChanges,
75+
{
76+
apiChanges: <NodeAPIChanges />
77+
}
78+
],
79+
[
80+
GlobalChanges,
81+
{
82+
waitForUserAgentInit: "wait_for_user_agent_init",
83+
waitForCountryLookupInit: "wait_for_country_lookup_init",
84+
disableUserAgentParsing: "disable_user_agent_parsing",
85+
disableCountryLookup: "disable_country_lookup",
86+
enableIdLists: "enable_id_lists"
87+
},
88+
],
89+
[
90+
StatsigOptions,
91+
{
92+
optionsMapping: <NodeStatsigOptions />
93+
}
94+
],
95+
[
96+
NeedHelp,
97+
{}
98+
],
99+
]
100+
})
101+
102+
export const toc = Builder.toc;
103+
104+
<>{Builder.result}</>

0 commit comments

Comments
 (0)