@coframe/sdk 1.1.24 → 1.1.25
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/dist/pkg/cf.cjs.js +51 -2
- package/dist/pkg/cf.esm.mjs +51 -2
- package/package.json +1 -1
package/dist/pkg/cf.cjs.js
CHANGED
|
@@ -2835,7 +2835,7 @@ function keepRolledOutExperiments(frames) {
|
|
|
2835
2835
|
function buildSessionContext(isInitialApply) {
|
|
2836
2836
|
const context = {};
|
|
2837
2837
|
const viewport = getScreenSize();
|
|
2838
|
-
if (isReportedSize(viewport.width) && isReportedSize(viewport.height)) {
|
|
2838
|
+
if (isReportedSize$1(viewport.width) && isReportedSize$1(viewport.height)) {
|
|
2839
2839
|
context.viewport_width = viewport.width;
|
|
2840
2840
|
context.viewport_height = viewport.height;
|
|
2841
2841
|
}
|
|
@@ -2858,7 +2858,7 @@ function buildSessionContext(isInitialApply) {
|
|
|
2858
2858
|
}
|
|
2859
2859
|
return context;
|
|
2860
2860
|
}
|
|
2861
|
-
function isReportedSize(size) {
|
|
2861
|
+
function isReportedSize$1(size) {
|
|
2862
2862
|
return (typeof size === 'number' && size > 0 && size !== Number.POSITIVE_INFINITY);
|
|
2863
2863
|
}
|
|
2864
2864
|
function getNavigationType(isInitialApply) {
|
|
@@ -3779,6 +3779,39 @@ async function modifyPage(Coframe, configResult, projectResult, analytics) {
|
|
|
3779
3779
|
}
|
|
3780
3780
|
|
|
3781
3781
|
const TIMEOUT_MAX_MS = 5000;
|
|
3782
|
+
const MAX_NOT_RENDERED_REASON_CHARS = 200;
|
|
3783
|
+
function isReportedSize(size) {
|
|
3784
|
+
return (typeof size === 'number' && size > 0 && size !== Number.POSITIVE_INFINITY);
|
|
3785
|
+
}
|
|
3786
|
+
function describeEnvironment(initTime) {
|
|
3787
|
+
const metadata = {};
|
|
3788
|
+
if (typeof window !== 'undefined') {
|
|
3789
|
+
if (isReportedSize(window.innerWidth)) {
|
|
3790
|
+
metadata.viewport_width = window.innerWidth;
|
|
3791
|
+
}
|
|
3792
|
+
if (isReportedSize(window.innerHeight)) {
|
|
3793
|
+
metadata.viewport_height = window.innerHeight;
|
|
3794
|
+
}
|
|
3795
|
+
const screen = window.screen;
|
|
3796
|
+
if (screen && isReportedSize(screen.width)) {
|
|
3797
|
+
metadata.screen_width = screen.width;
|
|
3798
|
+
}
|
|
3799
|
+
if (screen && isReportedSize(screen.height)) {
|
|
3800
|
+
metadata.screen_height = screen.height;
|
|
3801
|
+
}
|
|
3802
|
+
if (isReportedSize(window.devicePixelRatio)) {
|
|
3803
|
+
metadata.device_pixel_ratio = window.devicePixelRatio;
|
|
3804
|
+
}
|
|
3805
|
+
if (typeof navigator.userAgent === 'string') {
|
|
3806
|
+
metadata.user_agent = navigator.userAgent;
|
|
3807
|
+
}
|
|
3808
|
+
if (typeof document.readyState === 'string') {
|
|
3809
|
+
metadata.document_ready_state = document.readyState;
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
metadata.ms_since_init = Math.max(0, Date.now() - initTime);
|
|
3813
|
+
return metadata;
|
|
3814
|
+
}
|
|
3782
3815
|
function getFeatureFlagValue(cmd) {
|
|
3783
3816
|
if (cmd.featureFlagSet !== undefined)
|
|
3784
3817
|
return cmd.featureFlagSet;
|
|
@@ -3832,6 +3865,15 @@ async function resolveConfig(Coframe, revealPage) {
|
|
|
3832
3865
|
logger.warn('Failed to wait for variant rendered command', 'missing_variant_rendered');
|
|
3833
3866
|
}
|
|
3834
3867
|
};
|
|
3868
|
+
const warnVariantNotRendered = (reason) => {
|
|
3869
|
+
if (!applyVariantChangesStarted)
|
|
3870
|
+
return;
|
|
3871
|
+
const metadata = describeEnvironment(executionStartTime.getTime());
|
|
3872
|
+
if (typeof reason === 'string') {
|
|
3873
|
+
metadata.reason = reason.slice(0, MAX_NOT_RENDERED_REASON_CHARS);
|
|
3874
|
+
}
|
|
3875
|
+
logger.warn('Variant not rendered', 'variant_not_rendered', metadata);
|
|
3876
|
+
};
|
|
3835
3877
|
waitForCmd((cmd) => cmd.variantRendered === true || cmd.emit === 'variantRendered', Coframe, timeoutMs)
|
|
3836
3878
|
.then((cmd) => {
|
|
3837
3879
|
if (!cmd) {
|
|
@@ -3841,6 +3883,13 @@ async function resolveConfig(Coframe, revealPage) {
|
|
|
3841
3883
|
.finally(() => {
|
|
3842
3884
|
revealPage();
|
|
3843
3885
|
});
|
|
3886
|
+
const loggedReasons = [];
|
|
3887
|
+
listenForCmd((cmd) => cmd.emit === 'variantNotRendered', (cmd) => {
|
|
3888
|
+
if (loggedReasons.indexOf(cmd.reason) !== -1)
|
|
3889
|
+
return;
|
|
3890
|
+
loggedReasons.push(cmd.reason);
|
|
3891
|
+
warnVariantNotRendered(cmd.reason);
|
|
3892
|
+
});
|
|
3844
3893
|
if (!projectId) {
|
|
3845
3894
|
logger.error('No project ID', 'no_project_id', {
|
|
3846
3895
|
description: 'No Coframe Page ID',
|
package/dist/pkg/cf.esm.mjs
CHANGED
|
@@ -2833,7 +2833,7 @@ function keepRolledOutExperiments(frames) {
|
|
|
2833
2833
|
function buildSessionContext(isInitialApply) {
|
|
2834
2834
|
const context = {};
|
|
2835
2835
|
const viewport = getScreenSize();
|
|
2836
|
-
if (isReportedSize(viewport.width) && isReportedSize(viewport.height)) {
|
|
2836
|
+
if (isReportedSize$1(viewport.width) && isReportedSize$1(viewport.height)) {
|
|
2837
2837
|
context.viewport_width = viewport.width;
|
|
2838
2838
|
context.viewport_height = viewport.height;
|
|
2839
2839
|
}
|
|
@@ -2856,7 +2856,7 @@ function buildSessionContext(isInitialApply) {
|
|
|
2856
2856
|
}
|
|
2857
2857
|
return context;
|
|
2858
2858
|
}
|
|
2859
|
-
function isReportedSize(size) {
|
|
2859
|
+
function isReportedSize$1(size) {
|
|
2860
2860
|
return (typeof size === 'number' && size > 0 && size !== Number.POSITIVE_INFINITY);
|
|
2861
2861
|
}
|
|
2862
2862
|
function getNavigationType(isInitialApply) {
|
|
@@ -3777,6 +3777,39 @@ async function modifyPage(Coframe, configResult, projectResult, analytics) {
|
|
|
3777
3777
|
}
|
|
3778
3778
|
|
|
3779
3779
|
const TIMEOUT_MAX_MS = 5000;
|
|
3780
|
+
const MAX_NOT_RENDERED_REASON_CHARS = 200;
|
|
3781
|
+
function isReportedSize(size) {
|
|
3782
|
+
return (typeof size === 'number' && size > 0 && size !== Number.POSITIVE_INFINITY);
|
|
3783
|
+
}
|
|
3784
|
+
function describeEnvironment(initTime) {
|
|
3785
|
+
const metadata = {};
|
|
3786
|
+
if (typeof window !== 'undefined') {
|
|
3787
|
+
if (isReportedSize(window.innerWidth)) {
|
|
3788
|
+
metadata.viewport_width = window.innerWidth;
|
|
3789
|
+
}
|
|
3790
|
+
if (isReportedSize(window.innerHeight)) {
|
|
3791
|
+
metadata.viewport_height = window.innerHeight;
|
|
3792
|
+
}
|
|
3793
|
+
const screen = window.screen;
|
|
3794
|
+
if (screen && isReportedSize(screen.width)) {
|
|
3795
|
+
metadata.screen_width = screen.width;
|
|
3796
|
+
}
|
|
3797
|
+
if (screen && isReportedSize(screen.height)) {
|
|
3798
|
+
metadata.screen_height = screen.height;
|
|
3799
|
+
}
|
|
3800
|
+
if (isReportedSize(window.devicePixelRatio)) {
|
|
3801
|
+
metadata.device_pixel_ratio = window.devicePixelRatio;
|
|
3802
|
+
}
|
|
3803
|
+
if (typeof navigator.userAgent === 'string') {
|
|
3804
|
+
metadata.user_agent = navigator.userAgent;
|
|
3805
|
+
}
|
|
3806
|
+
if (typeof document.readyState === 'string') {
|
|
3807
|
+
metadata.document_ready_state = document.readyState;
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
metadata.ms_since_init = Math.max(0, Date.now() - initTime);
|
|
3811
|
+
return metadata;
|
|
3812
|
+
}
|
|
3780
3813
|
function getFeatureFlagValue(cmd) {
|
|
3781
3814
|
if (cmd.featureFlagSet !== undefined)
|
|
3782
3815
|
return cmd.featureFlagSet;
|
|
@@ -3830,6 +3863,15 @@ async function resolveConfig(Coframe, revealPage) {
|
|
|
3830
3863
|
logger.warn('Failed to wait for variant rendered command', 'missing_variant_rendered');
|
|
3831
3864
|
}
|
|
3832
3865
|
};
|
|
3866
|
+
const warnVariantNotRendered = (reason) => {
|
|
3867
|
+
if (!applyVariantChangesStarted)
|
|
3868
|
+
return;
|
|
3869
|
+
const metadata = describeEnvironment(executionStartTime.getTime());
|
|
3870
|
+
if (typeof reason === 'string') {
|
|
3871
|
+
metadata.reason = reason.slice(0, MAX_NOT_RENDERED_REASON_CHARS);
|
|
3872
|
+
}
|
|
3873
|
+
logger.warn('Variant not rendered', 'variant_not_rendered', metadata);
|
|
3874
|
+
};
|
|
3833
3875
|
waitForCmd((cmd) => cmd.variantRendered === true || cmd.emit === 'variantRendered', Coframe, timeoutMs)
|
|
3834
3876
|
.then((cmd) => {
|
|
3835
3877
|
if (!cmd) {
|
|
@@ -3839,6 +3881,13 @@ async function resolveConfig(Coframe, revealPage) {
|
|
|
3839
3881
|
.finally(() => {
|
|
3840
3882
|
revealPage();
|
|
3841
3883
|
});
|
|
3884
|
+
const loggedReasons = [];
|
|
3885
|
+
listenForCmd((cmd) => cmd.emit === 'variantNotRendered', (cmd) => {
|
|
3886
|
+
if (loggedReasons.indexOf(cmd.reason) !== -1)
|
|
3887
|
+
return;
|
|
3888
|
+
loggedReasons.push(cmd.reason);
|
|
3889
|
+
warnVariantNotRendered(cmd.reason);
|
|
3890
|
+
});
|
|
3842
3891
|
if (!projectId) {
|
|
3843
3892
|
logger.error('No project ID', 'no_project_id', {
|
|
3844
3893
|
description: 'No Coframe Page ID',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coframe/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"description": "Coframe optimizes your website using generative AI to deliver maximum impact to your audience and allow your site to improve itself as you sleep. Learn more at coframe.com.",
|
|
5
5
|
"main": "dist/pkg/cf.cjs.js",
|
|
6
6
|
"module": "dist/pkg/cf.esm.mjs",
|