Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions demo/nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"cookie-parser": "^1.4.6",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
"@nestjs/common": "^11.1.8",
"@nestjs/core": "^11.1.8",
"@nestjs/platform-express": "^11.1.8",
"cookie-parser": "^1.4.7",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^4.17.13",
"@types/jest": "29.2.4",
"@types/node": "18.11.18",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.3.1",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "29.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.1.1",
"typescript": "^4.7.4",
"webpack": "^5.92.0"
"@nestjs/cli": "^11.0.10",
"@nestjs/schematics": "^11.0.9",
"@nestjs/testing": "^11.1.8",
"@types/cookie-parser": "^1.4.10",
"@types/express": "^5.0.5",
"@types/jest": "30.0.0",
"@types/node": "24.10.0",
"@types/supertest": "^6.0.3",
"@typescript-eslint/eslint-plugin": "^8.46.4",
"@typescript-eslint/parser": "^8.46.4",
"eslint": "^9.39.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"jest": "30.2.0",
"prettier": "^3.6.2",
"source-map-support": "^0.5.21",
"supertest": "^7.1.4",
"ts-jest": "29.4.5",
"ts-loader": "^9.5.4",
"ts-node": "^10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "^5.9.3",
"webpack": "^5.102.1"
},
"peerDependencies": {
"@convertcom/js-sdk": ">=2.0.0"
Expand Down
12 changes: 6 additions & 6 deletions demo/nextjs/middleware.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// middleware.js

import { NextResponse } from 'next/server';
import sdkInstance from '@/lib/convertSdk';
import {NextResponse} from 'next/server';
import sdkInstance from '@/convert/convertSdk';
export async function middleware(request) {
try {
await sdkInstance.onReady();

const userId = request.cookies.get('user-id') || 'default-user-id';
const context = sdkInstance.createContext(userId, {
mobile: false,
mobile: false
});
context.setDefaultSegments({ country: 'US' });
context.setDefaultSegments({country: 'US'});

// You can attach the context to the request if needed
request.convertContext = context;
Expand All @@ -24,5 +24,5 @@ export async function middleware(request) {
}

export const config = {
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)']
};
3 changes: 2 additions & 1 deletion demo/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
4 changes: 1 addition & 3 deletions demo/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {

};
const nextConfig = {};

export default nextConfig;
23 changes: 12 additions & 11 deletions demo/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
"lint": "next lint"
},
"dependencies": {
"cookies-next": "^4.2.1",
"next": "14.2.13",
"react": "^18",
"react-dom": "^18"
"cookies-next": "^6.1.1",
"next": "16.0.1",
"react": "^19",
"react-dom": "^19"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"dotenv-cli": "^7.4.2",
"eslint": "^8",
"eslint-config-next": "14.2.13",
"@tailwindcss/postcss": "^4.1.17",
"@types/node": "^24",
"@types/react": "^19",
"@types/react-dom": "^19",
"dotenv-cli": "^11.0.0",
"eslint": "^9",
"eslint-config-next": "16.0.1",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"tailwindcss": "^4.1.17",
"typescript": "^5"
}
}
4 changes: 2 additions & 2 deletions demo/nextjs/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
'@tailwindcss/postcss': {}
}
};

export default config;
28 changes: 19 additions & 9 deletions demo/nextjs/src/context/ConvertContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
'use client';

import { ConvertInterface } from '@convertcom/js-sdk';
import { createContext, useContext, useEffect, useMemo, useState, ReactNode } from 'react';
import {ConvertInterface} from '../convert/sdkWrapper';
import {
createContext,
useContext,
useEffect,
useMemo,
useState,
ReactNode
} from 'react';

// Define the shape of the context
interface ConvertContextType {
Expand All @@ -18,8 +25,10 @@ interface ConvertProviderProps {
children: ReactNode;
}

export function ConvertProvider({ children }: Readonly<ConvertProviderProps>) {
const [sdkContext, setSdkContext] = useState<ConvertInterface>({} as ConvertInterface);
export function ConvertProvider({children}: Readonly<ConvertProviderProps>) {
const [sdkContext, setSdkContext] = useState<ConvertInterface>(
{} as ConvertInterface
);
const [userId, setUserId] = useState<string>(() => {
if (typeof window !== 'undefined') {
const storedUserId = localStorage.getItem('user-id');
Expand All @@ -39,7 +48,7 @@ export function ConvertProvider({ children }: Readonly<ConvertProviderProps>) {
if (!data) {
return;
}
const { _visitorId } = data;
const {_visitorId} = data;
setUserId(_visitorId);
setSdkContext(data);
})
Expand All @@ -49,12 +58,13 @@ export function ConvertProvider({ children }: Readonly<ConvertProviderProps>) {
}, [userId]);

// Memoize the value to prevent unnecessary re-renders
const value = useMemo(() => ({ sdkContext, userId, setUserId }), [sdkContext, userId, setUserId]);
const value = useMemo(
() => ({sdkContext, userId, setUserId}),
[sdkContext, userId, setUserId]
);

return (
<ConvertContext.Provider value={value}>
{children}
</ConvertContext.Provider>
<ConvertContext.Provider value={value}>{children}</ConvertContext.Provider>
);
}

Expand Down
4 changes: 2 additions & 2 deletions demo/nextjs/src/convert/convertSdk.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// lib/convertSdk.js
import ConvertSDK from '@convertcom/js-sdk'; // [ConvertSDK]
import ConvertSDK from './sdkWrapper'; // [ConvertSDK]
import DataStore from './DataStore';
const dataStore = new DataStore();
const sdkConfig = {
sdkKey: '10035569/10034190', // [ConvertSDK]
dataStore, // // [ConvertSDK] optional
dataStore // // [ConvertSDK] optional
};
const sdkInstance = new ConvertSDK(sdkConfig); // [ConvertSDK]
export default sdkInstance;
4 changes: 4 additions & 0 deletions demo/nextjs/src/convert/sdkWrapper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Type definitions for sdkWrapper
// Re-export all types from the SDK
export * from '../../../../packages/js-sdk/lib/index';
export { default } from '../../../../packages/js-sdk/lib/index';
Comment thread
abbaseya marked this conversation as resolved.
4 changes: 4 additions & 0 deletions demo/nextjs/src/convert/sdkWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Wrapper to force ESM import instead of browser UMD bundle
// Re-export everything from the ESM build
export * from '../../../../packages/js-sdk/lib/index.mjs';
export { default } from '../../../../packages/js-sdk/lib/index.mjs';
Comment thread
abbaseya marked this conversation as resolved.
27 changes: 21 additions & 6 deletions demo/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -10,17 +14,28 @@
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
"@/*": [
"./src/*"
]
},
"target": "ES2017"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
10 changes: 5 additions & 5 deletions demo/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"start:debug": "NODE_TLS_REJECT_UNAUTHORIZED=0 DEBUG=nodejs:* yarn start"
},
"dependencies": {
"cookie-parser": "^1.4.6",
"debug": "^4.3.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"cookie-parser": "^1.4.7",
"debug": "^4.4.3",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"http-errors": "^2.0.0",
"morgan": "^1.10.0",
"morgan": "^1.10.1",
"pug": "^3.0.3"
},
"peerDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions demo/reactjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
"license": "Apache-2.0",
"dependencies": {
"feather-icons": "^4.29.2",
"framer-motion": "^11.2.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-modal": "^3.16.1",
"react-router-dom": "^6.23.1",
"framer-motion": "^12.23.24",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-modal": "^3.16.3",
"react-router-dom": "^7.9.5",
"react-scripts": "5.0.1",
"styled-components": "^6.1.11",
"styled-components": "^6.1.19",
"tailwindcss": "^3.4.4",
"twin.macro": "^3.4.1"
},
"peerDependencies": {
"@convertcom/js-sdk": ">=2.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build"
Comment thread
abbaseya marked this conversation as resolved.
},
"watch": {
"build": {
Expand Down
Loading