Skip to content

Commit 5372394

Browse files
committed
Address PR review feedback
1 parent ebd2e7f commit 5372394

5 files changed

Lines changed: 19 additions & 90 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"packageManager": "pnpm@10.32.1",
2020
"engines": {
21-
"node": ">=20"
21+
"node": ">=20.19.0"
2222
},
2323
"pnpm": {
2424
"overrides": {

packages/react-native/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ export const logout = async (): Promise<void> => {
3939
};
4040

4141
export { Formbricks } from "@/components/formbricks";
42+
// eslint-disable-next-line import/no-default-export -- preserve the public SDK default export
43+
export { Formbricks as default } from "@/components/formbricks";

packages/react-native/src/lib/common/setup.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,6 @@ export const setIsSetup = (state: boolean): void => {
3737
isSetup = state;
3838
};
3939

40-
export const migrateUserStateAddContactId = async (): Promise<{
41-
changed: boolean;
42-
}> => {
43-
const existingConfigString = await AsyncStorage.getItem(RN_ASYNC_STORAGE_KEY);
44-
45-
if (existingConfigString) {
46-
const existingConfig = JSON.parse(existingConfigString) as Partial<TConfig>;
47-
48-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- data could be undefined
49-
if (existingConfig.user?.data?.contactId) {
50-
return { changed: false };
51-
}
52-
53-
54-
if (
55-
!existingConfig.user?.data.contactId &&
56-
existingConfig.user?.data.userId
57-
) {
58-
return { changed: true };
59-
}
60-
}
61-
62-
return { changed: false };
63-
};
64-
6540
// Helper: Handle missing field error
6641
function handleMissingField(
6742
field: string
@@ -294,15 +269,9 @@ export const setup = async (
294269
): Promise<
295270
Result<void, MissingFieldError | NetworkError | MissingPersonError>
296271
> => {
297-
let appConfig = await RNConfig.getInstance();
272+
const appConfig = await RNConfig.getInstance();
298273

299274
const logger = Logger.getInstance();
300-
const { changed } = await migrateUserStateAddContactId();
301-
302-
if (changed) {
303-
await appConfig.resetConfig();
304-
appConfig = await RNConfig.getInstance();
305-
}
306275

307276
if (isSetup) {
308277
logger.debug("Already set up, skipping setup.");

packages/react-native/src/lib/common/tests/setup.test.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -274,61 +274,6 @@ describe("setup.ts", () => {
274274
);
275275
});
276276

277-
test("reloads config after migrating legacy user state", async () => {
278-
const initialConfig = {
279-
resetConfig: vi.fn(),
280-
};
281-
const migratedConfig = {
282-
get: vi.fn().mockReturnValue({
283-
environmentId: "env_123",
284-
appUrl: "https://my.url",
285-
environment: {
286-
data: { surveys: [] },
287-
expiresAt: new Date(Date.now() + 60_000),
288-
},
289-
user: {
290-
data: {
291-
userId: "user_abc",
292-
contactId: null,
293-
segments: [],
294-
displays: [],
295-
responses: [],
296-
lastDisplayAt: null,
297-
},
298-
expiresAt: null,
299-
},
300-
filteredSurveys: [],
301-
status: { value: "success", expiresAt: null },
302-
}),
303-
update: vi.fn(),
304-
};
305-
306-
(AsyncStorage.getItem as Mock).mockResolvedValueOnce(
307-
JSON.stringify({
308-
user: {
309-
data: {
310-
userId: "user_abc",
311-
contactId: null,
312-
},
313-
},
314-
})
315-
);
316-
getInstanceConfigMock
317-
.mockReturnValueOnce(initialConfig as unknown as Promise<RNConfig>)
318-
.mockReturnValueOnce(migratedConfig as unknown as Promise<RNConfig>);
319-
(filterSurveys as unknown as Mock).mockReturnValueOnce([]);
320-
321-
const result = await setup({
322-
environmentId: "env_123",
323-
appUrl: "https://my.url",
324-
});
325-
326-
expect(result.ok).toBe(true);
327-
expect(initialConfig.resetConfig).toHaveBeenCalledTimes(1);
328-
expect(getInstanceConfigMock).toHaveBeenCalledTimes(2);
329-
expect(migratedConfig.update).toHaveBeenCalled();
330-
});
331-
332277
test("returns an error when environment sync fails", async () => {
333278
const mockConfig = {
334279
get: vi.fn().mockReturnValue({

scripts/check-exact-deps.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ collectPackageJsonPaths(rootDir, manifestPaths);
2323

2424
const violations = [];
2525
for (const manifestPath of manifestPaths) {
26-
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
26+
let manifest;
27+
try {
28+
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
29+
} catch (error) {
30+
const message = error instanceof Error ? error.message : String(error);
31+
console.error(
32+
`Failed to parse ${relativePath(manifestPath)}: ${message}`,
33+
);
34+
process.exit(1);
35+
}
2736

2837
for (const field of dependencyFields) {
2938
const dependencies = manifest[field] ?? {};
@@ -54,7 +63,11 @@ if (violations.length > 0) {
5463
}
5564

5665
function collectPackageJsonPaths(dirPath, results) {
57-
for (const entry of fs.readdirSync(dirPath, { withFileTypes: true })) {
66+
const entries = fs
67+
.readdirSync(dirPath, { withFileTypes: true })
68+
.sort((a, b) => a.name.localeCompare(b.name));
69+
70+
for (const entry of entries) {
5871
if (ignoredDirs.has(entry.name)) {
5972
continue;
6073
}

0 commit comments

Comments
 (0)