@devcycle/nextjs-sdk
Version:
The Next.js SDK for DevCycle!
34 lines • 1.25 kB
JavaScript
import { getBucketedConfig } from './bucketing.js';
export const getServerSideDevCycle = async ({ serverSDKKey, clientSDKKey, user, context, options = {}, }) => {
var _a;
const userAgent = (_a = context.req.headers['user-agent']) !== null && _a !== void 0 ? _a : null;
let bucketedConfig = null;
try {
const bucketingConfigResult = await getBucketedConfig(serverSDKKey, user, userAgent, !!options.enableObfuscation, options.configSource);
bucketedConfig = bucketingConfigResult.config;
}
catch (e) {
console.error('DevCycle: Error getting user config');
// no-op
}
return {
_devcycleSSR: {
bucketedConfig,
user,
sdkKey: clientSDKKey,
userAgent,
},
};
};
export const getStaticDevCycle = async ({ serverSDKKey, clientSDKKey, user, options = {}, }) => {
const bucketingConfig = await getBucketedConfig(serverSDKKey, user, null, !!options.enableObfuscation, options.configSource);
return {
_devcycleSSR: {
bucketedConfig: bucketingConfig.config,
sdkKey: clientSDKKey,
user,
userAgent: null,
},
};
};
//# sourceMappingURL=getServerSideDevCycle.js.map