@coframe/sdk 1.1.31 → 1.1.33

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.
@@ -991,7 +991,13 @@ function isDebugToolsSessionEnabled(allowed) {
991
991
  clearDebugToolsSession();
992
992
  return false;
993
993
  }
994
- const enabledByUrl = resolveDebugToolsEntry().kind !== 'none';
994
+ const entry = resolveDebugToolsEntry();
995
+ const enabledByUrl = entry.kind !== 'none';
996
+ const annotationUrlEntry = entry.kind === 'tool' && entry.toolId === 'annotations';
997
+ if (annotationUrlEntry) {
998
+ clearDebugToolsSession();
999
+ return true;
1000
+ }
995
1001
  if (enabledByUrl) {
996
1002
  enableDebugToolsSession();
997
1003
  return true;
@@ -999,6 +1005,8 @@ function isDebugToolsSessionEnabled(allowed) {
999
1005
  try {
1000
1006
  const enabled = window.sessionStorage.getItem(COFRAME_DEBUG_TOOLS_SESSION_STORAGE_KEY) ===
1001
1007
  ENABLED_VALUE;
1008
+ if (!enabled)
1009
+ clearDebugToolsSession();
1002
1010
  return enabled;
1003
1011
  }
1004
1012
  catch (_a) {
@@ -3799,6 +3807,20 @@ const COMPILED_REPLAY_SCRIPT_URL = `${"https://edge.cofra.me"}/replay/latest.js`
3799
3807
  function configureReplayScriptUrl(url) {
3800
3808
  replayScriptUrl = (url === null || url === void 0 ? void 0 : url.trim()) || undefined;
3801
3809
  }
3810
+ function replayConsentAllowed() {
3811
+ var _a;
3812
+ try {
3813
+ const privacy = (_a = window.Shopify) === null || _a === void 0 ? void 0 : _a.customerPrivacy;
3814
+ const analyticsAllowed = !privacy ||
3815
+ typeof privacy.analyticsProcessingAllowed !== 'function' ||
3816
+ privacy.analyticsProcessingAllowed() === true;
3817
+ return (navigator
3818
+ .globalPrivacyControl !== true && analyticsAllowed);
3819
+ }
3820
+ catch (_b) {
3821
+ return false;
3822
+ }
3823
+ }
3802
3824
  function createMonitoringPayload(coframe, monitoringType, metadata) {
3803
3825
  return {
3804
3826
  event_id: generateUUID(),
@@ -3826,7 +3848,7 @@ function createStartContext(coframe, settings, forceSample) {
3826
3848
  getPageViewId: () => coframe.sessionId,
3827
3849
  getUserToken: () => coframe.userToken,
3828
3850
  getVariantIds: () => { var _a; return ((_a = coframe.experimentInfo) !== null && _a !== void 0 ? _a : []).map((experiment) => experiment.variant_id); },
3829
- canSend: shouldSendEvents,
3851
+ canSend: () => shouldSendEvents() && replayConsentAllowed(),
3830
3852
  onEventsFlushed: (callback) => {
3831
3853
  if (queuedEvents.length === 0 && queuedSessions.length === 0) {
3832
3854
  callback();
@@ -3845,6 +3867,7 @@ function startReplayIfEnabled(coframe, project, nonce) {
3845
3867
  if ((settings === null || settings === void 0 ? void 0 : settings.enabled) !== true ||
3846
3868
  typeof CompressionStream !== 'function' ||
3847
3869
  !shouldSendEvents() ||
3870
+ !replayConsentAllowed() ||
3848
3871
  startRequested) {
3849
3872
  return;
3850
3873
  }
@@ -989,7 +989,13 @@ function isDebugToolsSessionEnabled(allowed) {
989
989
  clearDebugToolsSession();
990
990
  return false;
991
991
  }
992
- const enabledByUrl = resolveDebugToolsEntry().kind !== 'none';
992
+ const entry = resolveDebugToolsEntry();
993
+ const enabledByUrl = entry.kind !== 'none';
994
+ const annotationUrlEntry = entry.kind === 'tool' && entry.toolId === 'annotations';
995
+ if (annotationUrlEntry) {
996
+ clearDebugToolsSession();
997
+ return true;
998
+ }
993
999
  if (enabledByUrl) {
994
1000
  enableDebugToolsSession();
995
1001
  return true;
@@ -997,6 +1003,8 @@ function isDebugToolsSessionEnabled(allowed) {
997
1003
  try {
998
1004
  const enabled = window.sessionStorage.getItem(COFRAME_DEBUG_TOOLS_SESSION_STORAGE_KEY) ===
999
1005
  ENABLED_VALUE;
1006
+ if (!enabled)
1007
+ clearDebugToolsSession();
1000
1008
  return enabled;
1001
1009
  }
1002
1010
  catch (_a) {
@@ -3797,6 +3805,20 @@ const COMPILED_REPLAY_SCRIPT_URL = `${"https://edge.cofra.me"}/replay/latest.js`
3797
3805
  function configureReplayScriptUrl(url) {
3798
3806
  replayScriptUrl = (url === null || url === void 0 ? void 0 : url.trim()) || undefined;
3799
3807
  }
3808
+ function replayConsentAllowed() {
3809
+ var _a;
3810
+ try {
3811
+ const privacy = (_a = window.Shopify) === null || _a === void 0 ? void 0 : _a.customerPrivacy;
3812
+ const analyticsAllowed = !privacy ||
3813
+ typeof privacy.analyticsProcessingAllowed !== 'function' ||
3814
+ privacy.analyticsProcessingAllowed() === true;
3815
+ return (navigator
3816
+ .globalPrivacyControl !== true && analyticsAllowed);
3817
+ }
3818
+ catch (_b) {
3819
+ return false;
3820
+ }
3821
+ }
3800
3822
  function createMonitoringPayload(coframe, monitoringType, metadata) {
3801
3823
  return {
3802
3824
  event_id: generateUUID(),
@@ -3824,7 +3846,7 @@ function createStartContext(coframe, settings, forceSample) {
3824
3846
  getPageViewId: () => coframe.sessionId,
3825
3847
  getUserToken: () => coframe.userToken,
3826
3848
  getVariantIds: () => { var _a; return ((_a = coframe.experimentInfo) !== null && _a !== void 0 ? _a : []).map((experiment) => experiment.variant_id); },
3827
- canSend: shouldSendEvents,
3849
+ canSend: () => shouldSendEvents() && replayConsentAllowed(),
3828
3850
  onEventsFlushed: (callback) => {
3829
3851
  if (queuedEvents.length === 0 && queuedSessions.length === 0) {
3830
3852
  callback();
@@ -3843,6 +3865,7 @@ function startReplayIfEnabled(coframe, project, nonce) {
3843
3865
  if ((settings === null || settings === void 0 ? void 0 : settings.enabled) !== true ||
3844
3866
  typeof CompressionStream !== 'function' ||
3845
3867
  !shouldSendEvents() ||
3868
+ !replayConsentAllowed() ||
3846
3869
  startRequested) {
3847
3870
  return;
3848
3871
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coframe/sdk",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
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",