cryptique-sdk 1.1.7 → 1.1.8

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/lib/cjs/index.js CHANGED
@@ -6903,11 +6903,15 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6903
6903
  const isInteractive = isInteractiveElement(element);
6904
6904
 
6905
6905
  if (!isInteractive) {
6906
- // Capture coordinates before setTimeout
6906
+ // Capture coordinates and page context before setTimeout (for heatmaps)
6907
6907
  const clickX = event.clientX;
6908
6908
  const clickY = event.clientY;
6909
6909
  const clickElement = element;
6910
-
6910
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6911
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6912
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6913
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6914
+
6911
6915
  // Mark this click as potentially dead
6912
6916
  const clickId = `${now}_${Math.random().toString(36).substr(2, 9)}`;
6913
6917
  pendingDeadClicks.set(clickId, {
@@ -6917,7 +6921,13 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6917
6921
  timestamp: now,
6918
6922
  url: window.location.href,
6919
6923
  clickX,
6920
- clickY
6924
+ clickY,
6925
+ page_x: event.pageX,
6926
+ page_y: event.pageY,
6927
+ scroll_x: scrollX,
6928
+ scroll_y: scrollY,
6929
+ document_height: docHeight,
6930
+ document_width: docWidth
6921
6931
  });
6922
6932
 
6923
6933
  // Check after 1 second if navigation occurred or if it's still a dead click
@@ -6931,6 +6941,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6931
6941
 
6932
6942
  EventsManager.trackAutoEvent('dead_click', {
6933
6943
  click_coordinates: { x: pendingClick.clickX, y: pendingClick.clickY },
6944
+ page_x: pendingClick.page_x,
6945
+ page_y: pendingClick.page_y,
6946
+ scroll_x: pendingClick.scroll_x,
6947
+ scroll_y: pendingClick.scroll_y,
6948
+ document_height: pendingClick.document_height,
6949
+ document_width: pendingClick.document_width,
6934
6950
  element_area: clickElement.offsetWidth * clickElement.offsetHeight,
6935
6951
  element_category: pendingClick.elementCategory,
6936
6952
  element_has_onclick: !!clickElement.onclick,
@@ -6946,9 +6962,19 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6946
6962
  }, 1000);
6947
6963
  }
6948
6964
 
6949
- // Track regular click with enhanced data
6965
+ // Track regular click with enhanced data (viewport + page-relative for heatmaps)
6966
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6967
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6968
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6969
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6950
6970
  EventsManager.trackAutoEvent('element_click', {
6951
6971
  click_coordinates: { x: event.clientX, y: event.clientY },
6972
+ page_x: event.pageX,
6973
+ page_y: event.pageY,
6974
+ scroll_x: scrollX,
6975
+ scroll_y: scrollY,
6976
+ document_height: docHeight,
6977
+ document_width: docWidth,
6952
6978
  double_click: event.detail === 2,
6953
6979
  element_category: elementCategory
6954
6980
  }, elementData).catch(err => {
@@ -6973,11 +6999,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6973
6999
  clearTimeout(scrollTimeout);
6974
7000
 
6975
7001
  scrollTimeout = setTimeout(() => {
6976
- const scrollDepth = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100);
6977
-
7002
+ const maxScroll = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) - window.innerHeight;
7003
+ const scrollDepth = maxScroll <= 0 ? 100 : Math.round((window.scrollY / maxScroll) * 100);
7004
+
6978
7005
  if (scrollDepth > maxScrollDepth) {
6979
7006
  maxScrollDepth = scrollDepth;
6980
-
7007
+
6981
7008
  EventsManager.trackAutoEvent('page_scroll', {
6982
7009
  scroll_depth: scrollDepth,
6983
7010
  max_scroll_reached: maxScrollDepth,
package/lib/esm/index.js CHANGED
@@ -6901,11 +6901,15 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6901
6901
  const isInteractive = isInteractiveElement(element);
6902
6902
 
6903
6903
  if (!isInteractive) {
6904
- // Capture coordinates before setTimeout
6904
+ // Capture coordinates and page context before setTimeout (for heatmaps)
6905
6905
  const clickX = event.clientX;
6906
6906
  const clickY = event.clientY;
6907
6907
  const clickElement = element;
6908
-
6908
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6909
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6910
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6911
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6912
+
6909
6913
  // Mark this click as potentially dead
6910
6914
  const clickId = `${now}_${Math.random().toString(36).substr(2, 9)}`;
6911
6915
  pendingDeadClicks.set(clickId, {
@@ -6915,7 +6919,13 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6915
6919
  timestamp: now,
6916
6920
  url: window.location.href,
6917
6921
  clickX,
6918
- clickY
6922
+ clickY,
6923
+ page_x: event.pageX,
6924
+ page_y: event.pageY,
6925
+ scroll_x: scrollX,
6926
+ scroll_y: scrollY,
6927
+ document_height: docHeight,
6928
+ document_width: docWidth
6919
6929
  });
6920
6930
 
6921
6931
  // Check after 1 second if navigation occurred or if it's still a dead click
@@ -6929,6 +6939,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6929
6939
 
6930
6940
  EventsManager.trackAutoEvent('dead_click', {
6931
6941
  click_coordinates: { x: pendingClick.clickX, y: pendingClick.clickY },
6942
+ page_x: pendingClick.page_x,
6943
+ page_y: pendingClick.page_y,
6944
+ scroll_x: pendingClick.scroll_x,
6945
+ scroll_y: pendingClick.scroll_y,
6946
+ document_height: pendingClick.document_height,
6947
+ document_width: pendingClick.document_width,
6932
6948
  element_area: clickElement.offsetWidth * clickElement.offsetHeight,
6933
6949
  element_category: pendingClick.elementCategory,
6934
6950
  element_has_onclick: !!clickElement.onclick,
@@ -6944,9 +6960,19 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6944
6960
  }, 1000);
6945
6961
  }
6946
6962
 
6947
- // Track regular click with enhanced data
6963
+ // Track regular click with enhanced data (viewport + page-relative for heatmaps)
6964
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6965
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6966
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6967
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6948
6968
  EventsManager.trackAutoEvent('element_click', {
6949
6969
  click_coordinates: { x: event.clientX, y: event.clientY },
6970
+ page_x: event.pageX,
6971
+ page_y: event.pageY,
6972
+ scroll_x: scrollX,
6973
+ scroll_y: scrollY,
6974
+ document_height: docHeight,
6975
+ document_width: docWidth,
6950
6976
  double_click: event.detail === 2,
6951
6977
  element_category: elementCategory
6952
6978
  }, elementData).catch(err => {
@@ -6971,11 +6997,12 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
6971
6997
  clearTimeout(scrollTimeout);
6972
6998
 
6973
6999
  scrollTimeout = setTimeout(() => {
6974
- const scrollDepth = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100);
6975
-
7000
+ const maxScroll = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) - window.innerHeight;
7001
+ const scrollDepth = maxScroll <= 0 ? 100 : Math.round((window.scrollY / maxScroll) * 100);
7002
+
6976
7003
  if (scrollDepth > maxScrollDepth) {
6977
7004
  maxScrollDepth = scrollDepth;
6978
-
7005
+
6979
7006
  EventsManager.trackAutoEvent('page_scroll', {
6980
7007
  scroll_depth: scrollDepth,
6981
7008
  max_scroll_reached: maxScrollDepth,
package/lib/umd/index.js CHANGED
@@ -6907,11 +6907,15 @@
6907
6907
  const isInteractive = isInteractiveElement(element);
6908
6908
 
6909
6909
  if (!isInteractive) {
6910
- // Capture coordinates before setTimeout
6910
+ // Capture coordinates and page context before setTimeout (for heatmaps)
6911
6911
  const clickX = event.clientX;
6912
6912
  const clickY = event.clientY;
6913
6913
  const clickElement = element;
6914
-
6914
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6915
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6916
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6917
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6918
+
6915
6919
  // Mark this click as potentially dead
6916
6920
  const clickId = `${now}_${Math.random().toString(36).substr(2, 9)}`;
6917
6921
  pendingDeadClicks.set(clickId, {
@@ -6921,7 +6925,13 @@
6921
6925
  timestamp: now,
6922
6926
  url: window.location.href,
6923
6927
  clickX,
6924
- clickY
6928
+ clickY,
6929
+ page_x: event.pageX,
6930
+ page_y: event.pageY,
6931
+ scroll_x: scrollX,
6932
+ scroll_y: scrollY,
6933
+ document_height: docHeight,
6934
+ document_width: docWidth
6925
6935
  });
6926
6936
 
6927
6937
  // Check after 1 second if navigation occurred or if it's still a dead click
@@ -6935,6 +6945,12 @@
6935
6945
 
6936
6946
  EventsManager.trackAutoEvent('dead_click', {
6937
6947
  click_coordinates: { x: pendingClick.clickX, y: pendingClick.clickY },
6948
+ page_x: pendingClick.page_x,
6949
+ page_y: pendingClick.page_y,
6950
+ scroll_x: pendingClick.scroll_x,
6951
+ scroll_y: pendingClick.scroll_y,
6952
+ document_height: pendingClick.document_height,
6953
+ document_width: pendingClick.document_width,
6938
6954
  element_area: clickElement.offsetWidth * clickElement.offsetHeight,
6939
6955
  element_category: pendingClick.elementCategory,
6940
6956
  element_has_onclick: !!clickElement.onclick,
@@ -6950,9 +6966,19 @@
6950
6966
  }, 1000);
6951
6967
  }
6952
6968
 
6953
- // Track regular click with enhanced data
6969
+ // Track regular click with enhanced data (viewport + page-relative for heatmaps)
6970
+ const scrollX = window.scrollX != null ? window.scrollX : window.pageXOffset;
6971
+ const scrollY = window.scrollY != null ? window.scrollY : window.pageYOffset;
6972
+ const docHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
6973
+ const docWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
6954
6974
  EventsManager.trackAutoEvent('element_click', {
6955
6975
  click_coordinates: { x: event.clientX, y: event.clientY },
6976
+ page_x: event.pageX,
6977
+ page_y: event.pageY,
6978
+ scroll_x: scrollX,
6979
+ scroll_y: scrollY,
6980
+ document_height: docHeight,
6981
+ document_width: docWidth,
6956
6982
  double_click: event.detail === 2,
6957
6983
  element_category: elementCategory
6958
6984
  }, elementData).catch(err => {
@@ -6977,11 +7003,12 @@
6977
7003
  clearTimeout(scrollTimeout);
6978
7004
 
6979
7005
  scrollTimeout = setTimeout(() => {
6980
- const scrollDepth = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100);
6981
-
7006
+ const maxScroll = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) - window.innerHeight;
7007
+ const scrollDepth = maxScroll <= 0 ? 100 : Math.round((window.scrollY / maxScroll) * 100);
7008
+
6982
7009
  if (scrollDepth > maxScrollDepth) {
6983
7010
  maxScrollDepth = scrollDepth;
6984
-
7011
+
6985
7012
  EventsManager.trackAutoEvent('page_scroll', {
6986
7013
  scroll_depth: scrollDepth,
6987
7014
  max_scroll_reached: maxScrollDepth,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cryptique-sdk",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "type": "module",
5
5
  "description": "Cryptique Analytics SDK - Comprehensive web analytics and user tracking for modern web applications",
6
6
  "main": "lib/cjs/index.js",