@cloudcare/browser-core 3.1.1 → 3.1.3
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/cjs/browser/htmlDomUtils.js +13 -4
- package/cjs/browser/htmlDomUtils.js.map +1 -1
- package/cjs/configuration/configuration.js +3 -1
- package/cjs/configuration/configuration.js.map +1 -1
- package/cjs/dataMap.js +7 -3
- package/cjs/dataMap.js.map +1 -1
- package/cjs/helper/enums.js +2 -1
- package/cjs/helper/enums.js.map +1 -1
- package/cjs/helper/errorTools.js +2 -1
- package/cjs/helper/errorTools.js.map +1 -1
- package/cjs/helper/monitor.js +1 -0
- package/cjs/helper/monitor.js.map +1 -1
- package/cjs/helper/serialisation/contextManager.js +20 -5
- package/cjs/helper/serialisation/contextManager.js.map +1 -1
- package/cjs/helper/serialisation/rowData.js +7 -5
- package/cjs/helper/serialisation/rowData.js.map +1 -1
- package/cjs/helper/serialisation/storedContextManager.js +47 -0
- package/cjs/helper/serialisation/storedContextManager.js.map +1 -0
- package/cjs/helper/tools.js +19 -3
- package/cjs/helper/tools.js.map +1 -1
- package/cjs/index.js +11 -0
- package/cjs/index.js.map +1 -1
- package/cjs/transport/batch.js +23 -10
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/httpRequest.js +31 -12
- package/cjs/transport/httpRequest.js.map +1 -1
- package/cjs/transport/startBatchWithReplica.js +2 -2
- package/cjs/transport/startBatchWithReplica.js.map +1 -1
- package/esm/browser/htmlDomUtils.js +11 -3
- package/esm/browser/htmlDomUtils.js.map +1 -1
- package/esm/configuration/configuration.js +3 -1
- package/esm/configuration/configuration.js.map +1 -1
- package/esm/dataMap.js +7 -3
- package/esm/dataMap.js.map +1 -1
- package/esm/helper/enums.js +2 -1
- package/esm/helper/enums.js.map +1 -1
- package/esm/helper/errorTools.js +1 -0
- package/esm/helper/errorTools.js.map +1 -1
- package/esm/helper/monitor.js +1 -0
- package/esm/helper/monitor.js.map +1 -1
- package/esm/helper/serialisation/contextManager.js +21 -6
- package/esm/helper/serialisation/contextManager.js.map +1 -1
- package/esm/helper/serialisation/rowData.js +8 -6
- package/esm/helper/serialisation/rowData.js.map +1 -1
- package/esm/helper/serialisation/storedContextManager.js +39 -0
- package/esm/helper/serialisation/storedContextManager.js.map +1 -0
- package/esm/helper/tools.js +18 -3
- package/esm/helper/tools.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/transport/batch.js +24 -11
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/httpRequest.js +31 -12
- package/esm/transport/httpRequest.js.map +1 -1
- package/esm/transport/startBatchWithReplica.js +2 -2
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +2 -2
- package/src/browser/htmlDomUtils.js +11 -4
- package/src/configuration/configuration.js +3 -1
- package/src/dataMap.js +9 -3
- package/src/helper/enums.js +2 -1
- package/src/helper/errorTools.js +1 -0
- package/src/helper/monitor.js +1 -0
- package/src/helper/serialisation/contextManager.js +21 -6
- package/src/helper/serialisation/rowData.js +9 -6
- package/src/helper/serialisation/storedContextManager.js +56 -0
- package/src/helper/tools.js +19 -4
- package/src/index.js +1 -0
- package/src/transport/batch.js +28 -12
- package/src/transport/httpRequest.js +46 -11
- package/src/transport/startBatchWithReplica.js +3 -1
package/esm/dataMap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataMap.js","names":["RumEventType","commonTags","sdk_name","sdk_version","app_id","env","service","version","userid","user_email","user_name","session_id","session_type","session_sampling","session_has_replay","is_signin","os","os_version","os_version_major","browser","browser_version","browser_version_major","screen_size","network_type","device","view_id","view_referrer","view_url","view_host","view_path","view_name","view_path_group","view_url_query","commonFields","action_id","action_ids","view_in_foreground","display","dataMap","view","type","VIEW","tags","view_loading_type","view_apdex_level","view_privacy_replay_level","fields","is_active","session_replay_stats","session_is_active","view_error_count","view_resource_count","view_long_task_count","view_action_count","first_contentful_paint","largest_contentful_paint","largest_contentful_paint_element_selector","cumulative_layout_shift","first_input_delay","loading_time","dom_interactive","dom_content_loaded","dom_complete","load_event","first_input_time","first_paint_time","interaction_to_next_paint","resource_load_time","time_to_interactive","dom","dom_ready","time_spent","first_byte","page_states","frustration_count","custom_timings","resource","RESOURCE","trace_id","span_id","resource_url","resource_url_host","resource_url_path","resource_url_path_group","resource_url_query","resource_type","resource_status","resource_status_group","resource_method","duration","resource_size","resource_encode_size","resource_render_blocking_status","resource_dns","resource_tcp","resource_ssl","resource_ttfb","resource_trans","resource_redirect","resource_first_byte","resource_dns_time","resource_download_time","resource_first_byte_time","resource_connect_time","resource_ssl_time","resource_redirect_time","error","ERROR","error_id","error_source","error_type","error_handling","error_message","error_stack","error_causes","long_task","LONG_TASK","long_task_id","action","ACTION","action_type","action_name","action_error_count","action_resource_count","action_frustration_types","action_long_task_count","action_target","action_position","telemetry","status","message","error_kind","browser_log","LOGGER","error_resource_url","error_resource_url_host","error_resource_url_path","error_resource_url_path_group","error_resource_status","error_resource_status_group","error_resource_method"],"sources":["../src/dataMap.js"],"sourcesContent":["import { RumEventType } from './helper/enums'\nexport var commonTags = {\n sdk_name: '_gc.sdk_name',\n sdk_version: '_gc.sdk_version',\n app_id: 'application.id',\n env: 'env',\n service: 'service',\n version: 'version',\n userid: 'user.id',\n user_email: 'user.email',\n user_name: 'user.name',\n session_id: 'session.id',\n session_type: 'session.type',\n session_sampling: 'session.is_sampling',\n session_has_replay: 'session.has_replay',\n is_signin: 'user.is_signin',\n os: 'device.os',\n os_version: 'device.os_version',\n os_version_major: 'device.os_version_major',\n browser: 'device.browser',\n browser_version: 'device.browser_version',\n browser_version_major: 'device.browser_version_major',\n screen_size: 'device.screen_size',\n network_type: 'device.network_type',\n device: 'device.device',\n view_id: 'view.id',\n view_referrer: 'view.referrer',\n view_url: 'view.url',\n view_host: 'view.host',\n view_path: 'view.path',\n view_name: 'view.path', // 冗余一个字段\n view_path_group: 'view.path_group',\n view_url_query: 'view.url_query'\n}\nexport var commonFields = {\n action_id: 'action.id',\n action_ids: 'action.ids',\n view_in_foreground: 'view.in_foreground',\n display: 'display'\n}\n// 需要用双引号将字符串类型的field value括起来, 这里有数组标示[string, path]\nexport var dataMap = {\n view: {\n type: RumEventType.VIEW,\n tags: {\n view_loading_type: 'view.loading_type',\n view_apdex_level: 'view.apdex_level',\n view_privacy_replay_level: 'privacy.replay_level'\n },\n fields: {\n is_active: 'view.is_active',\n session_replay_stats: '_gc.replay_stats',\n session_is_active: 'session.is_active',\n view_error_count: 'view.error.count',\n view_resource_count: 'view.resource.count',\n view_long_task_count: 'view.long_task.count',\n view_action_count: 'view.action.count',\n first_contentful_paint: 'view.first_contentful_paint',\n largest_contentful_paint: 'view.largest_contentful_paint',\n largest_contentful_paint_element_selector:\n 'view.largest_contentful_paint_element_selector',\n cumulative_layout_shift: 'view.cumulative_layout_shift',\n first_input_delay: 'view.first_input_delay',\n loading_time: 'view.loading_time',\n dom_interactive: 'view.dom_interactive',\n dom_content_loaded: 'view.dom_content_loaded',\n dom_complete: 'view.dom_complete',\n load_event: 'view.load_event',\n first_input_time: 'view.first_input_time',\n first_paint_time: 'view.fpt',\n interaction_to_next_paint: 'view.interaction_to_next_paint',\n resource_load_time: 'view.resource_load_time',\n time_to_interactive: 'view.tti',\n dom: 'view.dom',\n dom_ready: 'view.dom_ready',\n time_spent: 'view.time_spent',\n first_byte: 'view.first_byte',\n page_states: '_gc.page_states',\n frustration_count: 'view.frustration.count',\n custom_timings: 'view.custom_timings'\n }\n },\n resource: {\n type: RumEventType.RESOURCE,\n tags: {\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n resource_url: 'resource.url',\n resource_url_host: 'resource.url_host',\n resource_url_path: 'resource.url_path',\n resource_url_path_group: 'resource.url_path_group',\n resource_url_query: 'resource.url_query',\n resource_type: 'resource.type',\n resource_status: 'resource.status',\n resource_status_group: 'resource.status_group',\n resource_method: 'resource.method'\n },\n fields: {\n duration: 'resource.duration',\n resource_size: 'resource.size',\n resource_encode_size: 'resource.encode_size',\n resource_render_blocking_status: 'resource.render_blocking_status',\n resource_dns: 'resource.dns',\n resource_tcp: 'resource.tcp',\n resource_ssl: 'resource.ssl',\n resource_ttfb: 'resource.ttfb',\n resource_trans: 'resource.trans',\n resource_redirect: 'resource.redirect',\n resource_first_byte: 'resource.firstbyte',\n resource_dns_time: 'resource.dns_time',\n resource_download_time: 'resource.download_time',\n resource_first_byte_time: 'resource.first_byte_time',\n resource_connect_time: 'resource.connect_time',\n resource_ssl_time: 'resource.ssl_time',\n resource_redirect_time: 'resource.redirect_time'\n }\n },\n error: {\n type: RumEventType.ERROR,\n tags: {\n error_id: 'error.id',\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n error_source: 'error.source',\n error_type: 'error.type',\n error_handling: 'error.handling'\n // resource_url: 'error.resource.url',\n // resource_url_host: 'error.resource.url_host',\n // resource_url_path: 'error.resource.url_path',\n // resource_url_path_group: 'error.resource.url_path_group',\n // resource_status: 'error.resource.status',\n // resource_status_group: 'error.resource.status_group',\n // resource_method: 'error.resource.method'\n },\n fields: {\n error_message: ['string', 'error.message'],\n error_stack: ['string', 'error.stack'],\n error_causes: ['string', 'error.causes']\n }\n },\n long_task: {\n type: RumEventType.LONG_TASK,\n tags: {\n long_task_id: 'long_task.id'\n },\n fields: {\n duration: 'long_task.duration'\n }\n },\n action: {\n type: RumEventType.ACTION,\n tags: {\n action_type: 'action.type'\n },\n fields: {\n action_name: 'action.target.name',\n duration: 'action.loading_time',\n action_error_count: 'action.error.count',\n action_resource_count: 'action.resource.count',\n action_frustration_types: 'action.frustration.type',\n action_long_task_count: 'action.long_task.count',\n action_target: '_gc.action.target',\n action_position: '_gc.action.position'\n }\n },\n telemetry: {\n type: 'telemetry',\n fields: {\n status: 'telemetry.status',\n message: ['string', 'telemetry.message'],\n type: 'telemetry.type',\n error_stack: ['string', 'telemetry.error.stack'],\n error_kind: ['string', 'telemetry.error.kind']\n }\n },\n browser_log: {\n type: RumEventType.LOGGER,\n tags: {\n error_source: 'error.source',\n error_type: 'error.type',\n error_resource_url: 'http.url',\n error_resource_url_host: 'http.url_host',\n error_resource_url_path: 'http.url_path',\n error_resource_url_path_group: 'http.url_path_group',\n error_resource_status: 'http.status_code',\n error_resource_status_group: 'http.status_group',\n error_resource_method: 'http.method',\n action_id: 'user_action.id',\n service: 'service',\n status: 'status'\n },\n fields: {\n message: ['string', 'message']\n }\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,OAAO,IAAIC,UAAU,GAAG;EACtBC,QAAQ,EAAE,cAAc;EACxBC,WAAW,EAAE,iBAAiB;EAC9BC,MAAM,EAAE,gBAAgB;EACxBC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,SAAS;EACjBC,UAAU,EAAE,YAAY;EACxBC,SAAS,EAAE,WAAW;EACtBC,UAAU,EAAE,YAAY;EACxBC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,qBAAqB;EACvCC,kBAAkB,EAAE,oBAAoB;EACxCC,SAAS,EAAE,gBAAgB;EAC3BC,EAAE,EAAE,WAAW;EACfC,UAAU,EAAE,mBAAmB;EAC/BC,gBAAgB,EAAE,yBAAyB;EAC3CC,OAAO,EAAE,gBAAgB;EACzBC,eAAe,EAAE,wBAAwB;EACzCC,qBAAqB,EAAE,8BAA8B;EACrDC,WAAW,EAAE,oBAAoB;EACjCC,YAAY,EAAE,qBAAqB;EACnCC,MAAM,EAAE,eAAe;EACvBC,OAAO,EAAE,SAAS;EAClBC,aAAa,EAAE,eAAe;EAC9BC,QAAQ,EAAE,UAAU;EACpBC,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,WAAW;EAAE;EACxBC,eAAe,EAAE,iBAAiB;EAClCC,cAAc,EAAE;AAClB,CAAC;AACD,OAAO,IAAIC,YAAY,GAAG;EACxBC,SAAS,EAAE,W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B;MAChDC,qBAAqB,EAAE,aAAa;MACpC1G,SAAS,EAAE,gBAAgB;MAC3B5B,OAAO,EAAE,SAAS;MAClB2H,MAAM,EAAE;IACV,CAAC;IACDnF,MAAM,EAAE;MACNoF,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS;IAC/B;EACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"dataMap.js","names":["RumEventType","commonTags","sdk_name","sdk_version","app_id","env","service","version","userid","user_email","user_name","session_id","session_type","session_sampling","is_signin","os","os_version","os_version_major","browser","browser_version","browser_version_major","screen_size","network_type","device","view_id","view_referrer","view_url","view_host","view_path","view_name","view_path_group","view_url_query","commonFields","action_id","action_ids","view_in_foreground","display","session_has_replay","is_login","page_states","dataMap","view","type","VIEW","tags","view_loading_type","view_apdex_level","view_privacy_replay_level","fields","is_active","session_replay_stats","session_is_active","view_error_count","view_resource_count","view_long_task_count","view_action_count","first_contentful_paint","largest_contentful_paint","largest_contentful_paint_element_selector","cumulative_layout_shift","cumulative_layout_shift_target_selector","first_input_delay","loading_time","dom_interactive","dom_content_loaded","dom_complete","load_event","first_input_time","first_input_target_selector","first_paint_time","interaction_to_next_paint","interaction_to_next_paint_target_selector","resource_load_time","time_to_interactive","dom","dom_ready","time_spent","first_byte","frustration_count","custom_timings","resource","RESOURCE","trace_id","span_id","resource_url","resource_url_host","resource_url_path","resource_url_path_group","resource_url_query","resource_type","resource_status","resource_status_group","resource_method","duration","resource_size","resource_encode_size","resource_render_blocking_status","resource_dns","resource_tcp","resource_ssl","resource_ttfb","resource_trans","resource_redirect","resource_first_byte","resource_dns_time","resource_download_time","resource_first_byte_time","resource_connect_time","resource_ssl_time","resource_redirect_time","error","ERROR","error_id","error_source","error_type","error_handling","error_message","error_stack","error_causes","long_task","LONG_TASK","long_task_id","action","ACTION","action_type","action_name","action_error_count","action_resource_count","action_frustration_types","action_long_task_count","action_target","action_position","telemetry","status","message","error_kind","browser_log","LOGGER","error_resource_url","error_resource_url_host","error_resource_url_path","error_resource_url_path_group","error_resource_status","error_resource_status_group","error_resource_method"],"sources":["../src/dataMap.js"],"sourcesContent":["import { RumEventType } from './helper/enums'\nexport var commonTags = {\n sdk_name: '_gc.sdk_name',\n sdk_version: '_gc.sdk_version',\n app_id: 'application.id',\n env: 'env',\n service: 'service',\n version: 'version',\n userid: 'user.id',\n user_email: 'user.email',\n user_name: 'user.name',\n session_id: 'session.id',\n session_type: 'session.type',\n session_sampling: 'session.is_sampling',\n is_signin: 'user.is_signin',\n os: 'device.os',\n os_version: 'device.os_version',\n os_version_major: 'device.os_version_major',\n browser: 'device.browser',\n browser_version: 'device.browser_version',\n browser_version_major: 'device.browser_version_major',\n screen_size: 'device.screen_size',\n network_type: 'device.network_type',\n device: 'device.device',\n view_id: 'view.id',\n view_referrer: 'view.referrer',\n view_url: 'view.url',\n view_host: 'view.host',\n view_path: 'view.path',\n view_name: 'view.path', // 冗余一个字段\n view_path_group: 'view.path_group',\n view_url_query: 'view.url_query'\n}\nexport var commonFields = {\n action_id: 'action.id',\n action_ids: 'action.ids',\n view_in_foreground: 'view.in_foreground',\n display: 'display',\n session_has_replay: 'session.has_replay',\n is_login: 'user.is_login',\n page_states: '_gc.page_states'\n}\n// 需要用双引号将字符串类型的field value括起来, 这里有数组标示[string, path]\nexport var dataMap = {\n view: {\n type: RumEventType.VIEW,\n tags: {\n view_loading_type: 'view.loading_type',\n view_apdex_level: 'view.apdex_level',\n view_privacy_replay_level: 'privacy.replay_level'\n },\n fields: {\n is_active: 'view.is_active',\n session_replay_stats: '_gc.replay_stats',\n session_is_active: 'session.is_active',\n view_error_count: 'view.error.count',\n view_resource_count: 'view.resource.count',\n view_long_task_count: 'view.long_task.count',\n view_action_count: 'view.action.count',\n first_contentful_paint: 'view.first_contentful_paint',\n largest_contentful_paint: 'view.largest_contentful_paint',\n largest_contentful_paint_element_selector:\n 'view.largest_contentful_paint_element_selector',\n cumulative_layout_shift: 'view.cumulative_layout_shift',\n cumulative_layout_shift_target_selector:\n 'view.cumulative_layout_shift_target_selector',\n first_input_delay: 'view.first_input_delay',\n loading_time: 'view.loading_time',\n dom_interactive: 'view.dom_interactive',\n dom_content_loaded: 'view.dom_content_loaded',\n dom_complete: 'view.dom_complete',\n load_event: 'view.load_event',\n first_input_time: 'view.first_input_time',\n first_input_target_selector: 'view.first_input_target_selector',\n first_paint_time: 'view.fpt',\n interaction_to_next_paint: 'view.interaction_to_next_paint',\n interaction_to_next_paint_target_selector:\n 'view.interaction_to_next_paint_target_selector',\n resource_load_time: 'view.resource_load_time',\n time_to_interactive: 'view.tti',\n dom: 'view.dom',\n dom_ready: 'view.dom_ready',\n time_spent: 'view.time_spent',\n first_byte: 'view.first_byte',\n frustration_count: 'view.frustration.count',\n custom_timings: 'view.custom_timings'\n }\n },\n resource: {\n type: RumEventType.RESOURCE,\n tags: {\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n resource_url: 'resource.url',\n resource_url_host: 'resource.url_host',\n resource_url_path: 'resource.url_path',\n resource_url_path_group: 'resource.url_path_group',\n resource_url_query: 'resource.url_query',\n resource_type: 'resource.type',\n resource_status: 'resource.status',\n resource_status_group: 'resource.status_group',\n resource_method: 'resource.method'\n },\n fields: {\n duration: 'resource.duration',\n resource_size: 'resource.size',\n resource_encode_size: 'resource.encode_size',\n resource_render_blocking_status: 'resource.render_blocking_status',\n resource_dns: 'resource.dns',\n resource_tcp: 'resource.tcp',\n resource_ssl: 'resource.ssl',\n resource_ttfb: 'resource.ttfb',\n resource_trans: 'resource.trans',\n resource_redirect: 'resource.redirect',\n resource_first_byte: 'resource.firstbyte',\n resource_dns_time: 'resource.dns_time',\n resource_download_time: 'resource.download_time',\n resource_first_byte_time: 'resource.first_byte_time',\n resource_connect_time: 'resource.connect_time',\n resource_ssl_time: 'resource.ssl_time',\n resource_redirect_time: 'resource.redirect_time'\n }\n },\n error: {\n type: RumEventType.ERROR,\n tags: {\n error_id: 'error.id',\n trace_id: '_gc.trace_id',\n span_id: '_gc.span_id',\n error_source: 'error.source',\n error_type: 'error.type',\n error_handling: 'error.handling'\n // resource_url: 'error.resource.url',\n // resource_url_host: 'error.resource.url_host',\n // resource_url_path: 'error.resource.url_path',\n // resource_url_path_group: 'error.resource.url_path_group',\n // resource_status: 'error.resource.status',\n // resource_status_group: 'error.resource.status_group',\n // resource_method: 'error.resource.method'\n },\n fields: {\n error_message: ['string', 'error.message'],\n error_stack: ['string', 'error.stack'],\n error_causes: ['string', 'error.causes']\n }\n },\n long_task: {\n type: RumEventType.LONG_TASK,\n tags: {\n long_task_id: 'long_task.id'\n },\n fields: {\n duration: 'long_task.duration'\n }\n },\n action: {\n type: RumEventType.ACTION,\n tags: {\n action_type: 'action.type'\n },\n fields: {\n action_name: 'action.target.name',\n duration: 'action.loading_time',\n action_error_count: 'action.error.count',\n action_resource_count: 'action.resource.count',\n action_frustration_types: 'action.frustration.type',\n action_long_task_count: 'action.long_task.count',\n action_target: '_gc.action.target',\n action_position: '_gc.action.position'\n }\n },\n telemetry: {\n type: 'telemetry',\n fields: {\n status: 'telemetry.status',\n message: ['string', 'telemetry.message'],\n type: 'telemetry.type',\n error_stack: ['string', 'telemetry.error.stack'],\n error_kind: ['string', 'telemetry.error.kind']\n }\n },\n browser_log: {\n type: RumEventType.LOGGER,\n tags: {\n error_source: 'error.source',\n error_type: 'error.type',\n error_resource_url: 'http.url',\n error_resource_url_host: 'http.url_host',\n error_resource_url_path: 'http.url_path',\n error_resource_url_path_group: 'http.url_path_group',\n error_resource_status: 'http.status_code',\n error_resource_status_group: 'http.status_group',\n error_resource_method: 'http.method',\n action_id: 'user_action.id',\n service: 'service',\n status: 'status'\n },\n fields: {\n message: ['string', 'message']\n }\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C,OAAO,IAAIC,UAAU,GAAG;EACtBC,QAAQ,EAAE,cAAc;EACxBC,WAAW,EAAE,iBAAiB;EAC9BC,MAAM,EAAE,gBAAgB;EACxBC,GAAG,EAAE,KAAK;EACV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33
33
|
SECURITY_POLICY_VIOLATION: 'securitypolicyviolation',
|
|
34
|
-
SELECTION_CHANGE: 'selectionchange'
|
|
34
|
+
SELECTION_CHANGE: 'selectionchange',
|
|
35
|
+
STORAGE: 'storage'
|
|
35
36
|
};
|
|
36
37
|
export var ResourceType = {
|
|
37
38
|
DOCUMENT: 'document',
|
package/esm/helper/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","names":["DOM_EVENT","BEFORE_UNLOAD","CLICK","DBL_CLICK","KEY_DOWN","LOAD","POP_STATE","SCROLL","TOUCH_START","TOUCH_END","TOUCH_MOVE","VISIBILITY_CHANGE","PAGE_SHOW","FREEZE","RESUME","DOM_CONTENT_LOADED","POINTER_DOWN","POINTER_UP","POINTER_CANCEL","HASH_CHANGE","PAGE_HIDE","MOUSE_DOWN","MOUSE_UP","MOUSE_MOVE","FOCUS","BLUR","CONTEXT_MENU","RESIZE","CHANGE","INPUT","PLAY","PAUSE","SECURITY_POLICY_VIOLATION","SELECTION_CHANGE","ResourceType","DOCUMENT","XHR","BEACON","FETCH","CSS","JS","IMAGE","FONT","MEDIA","OTHER","ActionType","CUSTOM","FrustrationType","RAGE_CLICK","ERROR_CLICK","DEAD_CLICK","RumEventType","ACTION","ERROR","LONG_TASK","VIEW","RESOURCE","LOGGER","ViewLoadingType","INITIAL_LOAD","ROUTE_CHANGE","RequestType","TraceType","DDTRACE","ZIPKIN_MULTI_HEADER","ZIPKIN_SINGLE_HEADER","W3C_TRACEPARENT","W3C_TRACEPARENT_64","SKYWALKING_V3","JAEGER","ErrorHandling","HANDLED","UNHANDLED","NonErrorPrefix","UNCAUGHT","PROVIDED"],"sources":["../../src/helper/enums.js"],"sourcesContent":["export var DOM_EVENT = {\n BEFORE_UNLOAD: 'beforeunload',\n CLICK: 'click',\n DBL_CLICK: 'dblclick',\n KEY_DOWN: 'keydown',\n LOAD: 'load',\n POP_STATE: 'popstate',\n SCROLL: 'scroll',\n TOUCH_START: 'touchstart',\n TOUCH_END: 'touchend',\n TOUCH_MOVE: 'touchmove',\n VISIBILITY_CHANGE: 'visibilitychange',\n PAGE_SHOW: 'pageshow',\n FREEZE: 'freeze',\n RESUME: 'resume',\n DOM_CONTENT_LOADED: 'DOMContentLoaded',\n POINTER_DOWN: 'pointerdown',\n POINTER_UP: 'pointerup',\n POINTER_CANCEL: 'pointercancel',\n HASH_CHANGE: 'hashchange',\n PAGE_HIDE: 'pagehide',\n MOUSE_DOWN: 'mousedown',\n MOUSE_UP: 'mouseup',\n MOUSE_MOVE: 'mousemove',\n FOCUS: 'focus',\n BLUR: 'blur',\n CONTEXT_MENU: 'contextmenu',\n RESIZE: 'resize',\n CHANGE: 'change',\n INPUT: 'input',\n PLAY: 'play',\n PAUSE: 'pause',\n SECURITY_POLICY_VIOLATION: 'securitypolicyviolation',\n SELECTION_CHANGE: 'selectionchange'\n}\nexport var ResourceType = {\n DOCUMENT: 'document',\n XHR: 'xhr',\n BEACON: 'beacon',\n FETCH: 'fetch',\n CSS: 'css',\n JS: 'js',\n IMAGE: 'image',\n FONT: 'font',\n MEDIA: 'media',\n OTHER: 'other'\n}\n\nexport var ActionType = {\n CLICK: 'click',\n CUSTOM: 'custom'\n}\nexport var FrustrationType = {\n RAGE_CLICK: 'rage_click',\n ERROR_CLICK: 'error_click',\n DEAD_CLICK: 'dead_click'\n}\nexport var RumEventType = {\n ACTION: 'action',\n ERROR: 'error',\n LONG_TASK: 'long_task',\n VIEW: 'view',\n RESOURCE: 'resource',\n LOGGER: 'logger'\n}\n\nexport var ViewLoadingType = {\n INITIAL_LOAD: 'initial_load',\n ROUTE_CHANGE: 'route_change'\n}\nexport var RequestType = {\n FETCH: ResourceType.FETCH,\n XHR: ResourceType.XHR\n}\n\nexport var TraceType = {\n DDTRACE: 'ddtrace',\n ZIPKIN_MULTI_HEADER: 'zipkin',\n ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',\n W3C_TRACEPARENT: 'w3c_traceparent',\n W3C_TRACEPARENT_64: 'w3c_traceparent_64bit',\n SKYWALKING_V3: 'skywalking_v3',\n JAEGER: 'jaeger'\n}\nexport var ErrorHandling = {\n HANDLED: 'handled',\n UNHANDLED: 'unhandled'\n}\nexport var NonErrorPrefix = {\n UNCAUGHT: 'Uncaught',\n PROVIDED: 'Provided'\n}\n"],"mappings":"AAAA,OAAO,IAAIA,SAAS,GAAG;EACrBC,aAAa,EAAE,cAAc;EAC7BC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAE,UAAU;EACrBC,QAAQ,EAAE,SAAS;EACnBC,IAAI,EAAE,MAAM;EACZC,SAAS,EAAE,UAAU;EACrBC,MAAM,EAAE,QAAQ;EAChBC,WAAW,EAAE,YAAY;EACzBC,SAAS,EAAE,UAAU;EACrBC,UAAU,EAAE,WAAW;EACvBC,iBAAiB,EAAE,kBAAkB;EACrCC,SAAS,EAAE,UAAU;EACrBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE,QAAQ;EAChBC,kBAAkB,EAAE,kBAAkB;EACtCC,YAAY,EAAE,aAAa;EAC3BC,UAAU,EAAE,WAAW;EACvBC,cAAc,EAAE,eAAe;EAC/BC,WAAW,EAAE,YAAY;EACzBC,SAAS,EAAE,UAAU;EACrBC,UAAU,EAAE,WAAW;EACvBC,QAAQ,EAAE,SAAS;EACnBC,UAAU,EAAE,WAAW;EACvBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,YAAY,EAAE,aAAa;EAC3BC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,yBAAyB,EAAE,yBAAyB;EACpDC,gBAAgB,EAAE;
|
|
1
|
+
{"version":3,"file":"enums.js","names":["DOM_EVENT","BEFORE_UNLOAD","CLICK","DBL_CLICK","KEY_DOWN","LOAD","POP_STATE","SCROLL","TOUCH_START","TOUCH_END","TOUCH_MOVE","VISIBILITY_CHANGE","PAGE_SHOW","FREEZE","RESUME","DOM_CONTENT_LOADED","POINTER_DOWN","POINTER_UP","POINTER_CANCEL","HASH_CHANGE","PAGE_HIDE","MOUSE_DOWN","MOUSE_UP","MOUSE_MOVE","FOCUS","BLUR","CONTEXT_MENU","RESIZE","CHANGE","INPUT","PLAY","PAUSE","SECURITY_POLICY_VIOLATION","SELECTION_CHANGE","STORAGE","ResourceType","DOCUMENT","XHR","BEACON","FETCH","CSS","JS","IMAGE","FONT","MEDIA","OTHER","ActionType","CUSTOM","FrustrationType","RAGE_CLICK","ERROR_CLICK","DEAD_CLICK","RumEventType","ACTION","ERROR","LONG_TASK","VIEW","RESOURCE","LOGGER","ViewLoadingType","INITIAL_LOAD","ROUTE_CHANGE","RequestType","TraceType","DDTRACE","ZIPKIN_MULTI_HEADER","ZIPKIN_SINGLE_HEADER","W3C_TRACEPARENT","W3C_TRACEPARENT_64","SKYWALKING_V3","JAEGER","ErrorHandling","HANDLED","UNHANDLED","NonErrorPrefix","UNCAUGHT","PROVIDED"],"sources":["../../src/helper/enums.js"],"sourcesContent":["export var DOM_EVENT = {\n BEFORE_UNLOAD: 'beforeunload',\n CLICK: 'click',\n DBL_CLICK: 'dblclick',\n KEY_DOWN: 'keydown',\n LOAD: 'load',\n POP_STATE: 'popstate',\n SCROLL: 'scroll',\n TOUCH_START: 'touchstart',\n TOUCH_END: 'touchend',\n TOUCH_MOVE: 'touchmove',\n VISIBILITY_CHANGE: 'visibilitychange',\n PAGE_SHOW: 'pageshow',\n FREEZE: 'freeze',\n RESUME: 'resume',\n DOM_CONTENT_LOADED: 'DOMContentLoaded',\n POINTER_DOWN: 'pointerdown',\n POINTER_UP: 'pointerup',\n POINTER_CANCEL: 'pointercancel',\n HASH_CHANGE: 'hashchange',\n PAGE_HIDE: 'pagehide',\n MOUSE_DOWN: 'mousedown',\n MOUSE_UP: 'mouseup',\n MOUSE_MOVE: 'mousemove',\n FOCUS: 'focus',\n BLUR: 'blur',\n CONTEXT_MENU: 'contextmenu',\n RESIZE: 'resize',\n CHANGE: 'change',\n INPUT: 'input',\n PLAY: 'play',\n PAUSE: 'pause',\n SECURITY_POLICY_VIOLATION: 'securitypolicyviolation',\n SELECTION_CHANGE: 'selectionchange',\n STORAGE: 'storage'\n}\nexport var ResourceType = {\n DOCUMENT: 'document',\n XHR: 'xhr',\n BEACON: 'beacon',\n FETCH: 'fetch',\n CSS: 'css',\n JS: 'js',\n IMAGE: 'image',\n FONT: 'font',\n MEDIA: 'media',\n OTHER: 'other'\n}\n\nexport var ActionType = {\n CLICK: 'click',\n CUSTOM: 'custom'\n}\nexport var FrustrationType = {\n RAGE_CLICK: 'rage_click',\n ERROR_CLICK: 'error_click',\n DEAD_CLICK: 'dead_click'\n}\nexport var RumEventType = {\n ACTION: 'action',\n ERROR: 'error',\n LONG_TASK: 'long_task',\n VIEW: 'view',\n RESOURCE: 'resource',\n LOGGER: 'logger'\n}\n\nexport var ViewLoadingType = {\n INITIAL_LOAD: 'initial_load',\n ROUTE_CHANGE: 'route_change'\n}\nexport var RequestType = {\n FETCH: ResourceType.FETCH,\n XHR: ResourceType.XHR\n}\n\nexport var TraceType = {\n DDTRACE: 'ddtrace',\n ZIPKIN_MULTI_HEADER: 'zipkin',\n ZIPKIN_SINGLE_HEADER: 'zipkin_single_header',\n W3C_TRACEPARENT: 'w3c_traceparent',\n W3C_TRACEPARENT_64: 'w3c_traceparent_64bit',\n SKYWALKING_V3: 'skywalking_v3',\n JAEGER: 'jaeger'\n}\nexport var ErrorHandling = {\n HANDLED: 'handled',\n UNHANDLED: 'unhandled'\n}\nexport var NonErrorPrefix = {\n UNCAUGHT: 'Uncaught',\n PROVIDED: 'Provided'\n}\n"],"mappings":"AAAA,OAAO,IAAIA,SAAS,GAAG;EACrBC,aAAa,EAAE,cAAc;EAC7BC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAE,UAAU;EACrBC,QAAQ,EAAE,SAAS;EACnBC,IAAI,EAAE,MA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E;AACd,CAAC;AACD,OAAO,IAAIC,YAAY,GAAG;EACxBC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,SAAS,EAAE,WAAW;EACtBC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAE,UAAU;EACpBC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,IAAIC,eAAe,GAAG;EAC3BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE;AAChB,CAAC;AACD,OAAO,IAAIC,WAAW,GAAG;EACvBvB,KAAK,EAAEJ,YAAY,CAACI,KAAK;EACzBF,GAAG,EAAEF,YAAY,CAACE;AACpB,CAAC;AAED,OAAO,IAAI0B,SAAS,GAAG;EACrBC,OAAO,EAAE,SAAS;EAClBC,mBAAmB,EAAE,QAAQ;EAC7BC,oBAAoB,EAAE,sBAAsB;EAC5CC,eAAe,EAAE,iBAAiB;EAClCC,kBAAkB,EAAE,uBAAuB;EAC3CC,aAAa,EAAE,eAAe;EAC9BC,MAAM,EAAE;AACV,CAAC;AACD,OAAO,IAAIC,aAAa,GAAG;EACzBC,OAAO,EAAE,SAAS;EAClBC,SAAS,EAAE;AACb,CAAC;AACD,OAAO,IAAIC,cAAc,GAAG;EAC1BC,QAAQ,EAAE,UAAU;EACpBC,QAAQ,EAAE;AACZ,CAAC"}
|
package/esm/helper/errorTools.js
CHANGED
|
@@ -2,6 +2,7 @@ import { each, noop } from './tools';
|
|
|
2
2
|
import { jsonStringify } from '../helper/serialisation/jsonStringify';
|
|
3
3
|
import { computeStackTrace } from '../tracekit';
|
|
4
4
|
import { callMonitored } from '../helper/monitor';
|
|
5
|
+
import { sanitize } from '../helper/sanitize';
|
|
5
6
|
export var NO_ERROR_STACK_PRESENT_MESSAGE = 'No stack, consider using an instance of Error';
|
|
6
7
|
export var ErrorSource = {
|
|
7
8
|
AGENT: 'agent',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorTools.js","names":["each","noop","jsonStringify","computeStackTrace","callMonitored","NO_ERROR_STACK_PRESENT_MESSAGE","ErrorSource","AGENT","CONSOLE","NETWORK","SOURCE","LOGGER","CUSTOM","computeRawError","data","stackTrace","originalError","handlingStack","startClocks","nonErrorPrefix","source","handling","isErrorInstance","Error","message","computeMessage","stack","hasUsableStack","toStackTraceString","causes","flattenErrorCauses","undefined","type","name","sanitize","length","url","formatUnknownError","errorObject","createHandlingStack","internalFramesToSkip","error","formattedStack","e","slice","result","formatErrorMessage","frame","func","args","join","line","column","getFileFromStackTraceString","execResult","exec","parentSource","currentError","cause","push"],"sources":["../../src/helper/errorTools.js"],"sourcesContent":["import { each, noop } from './tools'\nimport { jsonStringify } from '../helper/serialisation/jsonStringify'\nimport { computeStackTrace } from '../tracekit'\nimport { callMonitored } from '../helper/monitor'\nexport var NO_ERROR_STACK_PRESENT_MESSAGE =\n 'No stack, consider using an instance of Error'\nexport var ErrorSource = {\n AGENT: 'agent',\n CONSOLE: 'console',\n NETWORK: 'network',\n SOURCE: 'source',\n LOGGER: 'logger',\n CUSTOM: 'custom'\n}\n\nexport function computeRawError(data) {\n var stackTrace = data.stackTrace\n var originalError = data.originalError\n var handlingStack = data.handlingStack\n var startClocks = data.startClocks\n var nonErrorPrefix = data.nonErrorPrefix\n var source = data.source\n var handling = data.handling\n var isErrorInstance = originalError instanceof Error\n var message = computeMessage(\n stackTrace,\n isErrorInstance,\n nonErrorPrefix,\n originalError\n )\n var stack = hasUsableStack(isErrorInstance, stackTrace)\n ? toStackTraceString(stackTrace)\n : NO_ERROR_STACK_PRESENT_MESSAGE\n var causes = isErrorInstance\n ? flattenErrorCauses(originalError, source)\n : undefined\n var type = stackTrace && stackTrace.name\n\n return {\n startClocks: startClocks,\n source: source,\n handling: handling,\n originalError: originalError,\n message: message,\n stack: stack,\n handlingStack: handlingStack,\n type: type,\n causes: causes\n }\n}\nfunction computeMessage(\n stackTrace,\n isErrorInstance,\n nonErrorPrefix,\n originalError\n) {\n // Favor stackTrace message only if tracekit has really been able to extract something meaningful (message + name)\n // TODO rework tracekit integration to avoid scattering error building logic\n return stackTrace && stackTrace.message && stackTrace && stackTrace.name\n ? stackTrace.message\n : !isErrorInstance\n ? nonErrorPrefix + ' ' + jsonStringify(sanitize(originalError))\n : 'Empty message'\n}\nfunction hasUsableStack(isErrorInstance, stackTrace) {\n if (stackTrace === undefined) {\n return false\n }\n if (isErrorInstance) {\n return true\n }\n // handle cases where tracekit return stack = [] or stack = [{url: undefined, line: undefined, column: undefined}]\n // TODO rework tracekit integration to avoid generating those unusable stack\n return (\n stackTrace.stack.length > 0 &&\n (stackTrace.stack.length > 1 || stackTrace.stack[0].url !== undefined)\n )\n}\n\nexport function formatUnknownError(\n stackTrace,\n errorObject,\n nonErrorPrefix,\n handlingStack\n) {\n if (\n !stackTrace ||\n (stackTrace.message === undefined && !(errorObject instanceof Error))\n ) {\n return {\n message: nonErrorPrefix + '' + jsonStringify(errorObject),\n stack: 'No stack, consider using an instance of Error',\n handlingStack: handlingStack,\n type: stackTrace && stackTrace.name\n }\n }\n return {\n message: stackTrace.message || 'Empty message',\n stack: toStackTraceString(stackTrace),\n handlingStack: handlingStack,\n type: stackTrace.name\n }\n}\n/**\n Creates a stacktrace without SDK internal frames.\n \n Constraints:\n - Has to be called at the utmost position of the call stack.\n - No internal monitoring should encapsulate the function, that is why we need to use callMonitored inside of it.\n */\nexport function createHandlingStack() {\n /**\n * Skip the two internal frames:\n * - SDK API (console.error, ...)\n * - this function\n * in order to keep only the user calls\n */\n var internalFramesToSkip = 2\n var error = new Error()\n var formattedStack\n\n // IE needs to throw the error to fill in the stack trace\n if (!error.stack) {\n try {\n throw error\n } catch (e) {\n noop()\n }\n }\n callMonitored(function () {\n var stackTrace = computeStackTrace(error)\n stackTrace.stack = stackTrace.stack.slice(internalFramesToSkip)\n formattedStack = toStackTraceString(stackTrace)\n })\n\n return formattedStack\n}\nexport function toStackTraceString(stack) {\n var result = formatErrorMessage(stack)\n each(stack.stack, function (frame) {\n var func = frame.func === '?' ? '<anonymous>' : frame.func\n var args =\n frame.args && frame.args.length > 0\n ? '(' + frame.args.join(', ') + ')'\n : ''\n var line = frame.line ? ':' + frame.line : ''\n var column = frame.line && frame.column ? ':' + frame.column : ''\n result += '\\n at ' + func + args + ' @ ' + frame.url + line + column\n })\n return result\n}\nexport function formatErrorMessage(stack) {\n return (stack.name || 'Error') + ': ' + stack.message\n}\nexport function getFileFromStackTraceString(stack) {\n var execResult = /@ (.+)/.exec(stack)\n return execResult && execResult[1]\n}\nexport function flattenErrorCauses(error, parentSource) {\n var currentError = error\n var causes = []\n while (\n currentError &&\n currentError.cause instanceof Error &&\n causes.length < 10\n ) {\n var stackTrace = computeStackTrace(currentError.cause)\n causes.push({\n message: currentError.cause.message,\n source: parentSource,\n type: stackTrace && stackTrace.name,\n stack: stackTrace && toStackTraceString(stackTrace)\n })\n currentError = currentError.cause\n }\n return causes.length ? causes : undefined\n}\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,IAAI,QAAQ,SAAS;AACpC,SAASC,aAAa,QAAQ,uCAAuC;AACrE,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,OAAO,IAAIC,8BAA8B,GACvC,+CAA+C;AACjD,OAAO,IAAIC,WAAW,GAAG;EACvBC,KAAK,EAAE,OAAO;EACdC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EACpC,IAAIC,UAAU,GAAGD,IAAI,CAACC,UAAU;EAChC,IAAIC,aAAa,GAAGF,IAAI,CAACE,aAAa;EACtC,IAAIC,aAAa,GAAGH,IAAI,CAACG,aAAa;EACtC,IAAIC,WAAW,GAAGJ,IAAI,CAACI,WAAW;EAClC,IAAIC,cAAc,GAAGL,IAAI,CAACK,cAAc;EACxC,IAAIC,MAAM,G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U,CAAC,CAAC,CAAC;AACpC;AACA,OAAO,SAASxB,kBAAkBA,CAACW,KAAK,EAAEe,YAAY,EAAE;EACtD,IAAIC,YAAY,GAAGhB,KAAK;EACxB,IAAIZ,MAAM,GAAG,EAAE;EACf,OACE4B,YAAY,IACZA,YAAY,CAACC,KAAK,YAAYnC,KAAK,IACnCM,MAAM,CAACM,MAAM,GAAG,EAAE,EAClB;IACA,IAAIpB,UAAU,GAAGZ,iBAAiB,CAACsD,YAAY,CAACC,KAAK,CAAC;IACtD7B,MAAM,CAAC8B,IAAI,CAAC;MACVnC,OAAO,EAAEiC,YAAY,CAACC,KAAK,CAAClC,OAAO;MACnCJ,MAAM,EAAEoC,YAAY;MACpBxB,IAAI,EAAEjB,UAAU,IAAIA,UAAU,CAACkB,IAAI;MACnCP,KAAK,EAAEX,UAAU,IAAIa,kBAAkB,CAACb,UAAU;IACpD,CAAC,CAAC;IACF0C,YAAY,GAAGA,YAAY,CAACC,KAAK;EACnC;EACA,OAAO7B,MAAM,CAACM,MAAM,GAAGN,MAAM,GAAGE,SAAS;AAC3C"}
|
|
1
|
+
{"version":3,"file":"errorTools.js","names":["each","noop","jsonStringify","computeStackTrace","callMonitored","sanitize","NO_ERROR_STACK_PRESENT_MESSAGE","ErrorSource","AGENT","CONSOLE","NETWORK","SOURCE","LOGGER","CUSTOM","computeRawError","data","stackTrace","originalError","handlingStack","startClocks","nonErrorPrefix","source","handling","isErrorInstance","Error","message","computeMessage","stack","hasUsableStack","toStackTraceString","causes","flattenErrorCauses","undefined","type","name","length","url","formatUnknownError","errorObject","createHandlingStack","internalFramesToSkip","error","formattedStack","e","slice","result","formatErrorMessage","frame","func","args","join","line","column","getFileFromStackTraceString","execResult","exec","parentSource","currentError","cause","push"],"sources":["../../src/helper/errorTools.js"],"sourcesContent":["import { each, noop } from './tools'\nimport { jsonStringify } from '../helper/serialisation/jsonStringify'\nimport { computeStackTrace } from '../tracekit'\nimport { callMonitored } from '../helper/monitor'\nimport { sanitize } from '../helper/sanitize'\nexport var NO_ERROR_STACK_PRESENT_MESSAGE =\n 'No stack, consider using an instance of Error'\nexport var ErrorSource = {\n AGENT: 'agent',\n CONSOLE: 'console',\n NETWORK: 'network',\n SOURCE: 'source',\n LOGGER: 'logger',\n CUSTOM: 'custom'\n}\n\nexport function computeRawError(data) {\n var stackTrace = data.stackTrace\n var originalError = data.originalError\n var handlingStack = data.handlingStack\n var startClocks = data.startClocks\n var nonErrorPrefix = data.nonErrorPrefix\n var source = data.source\n var handling = data.handling\n var isErrorInstance = originalError instanceof Error\n var message = computeMessage(\n stackTrace,\n isErrorInstance,\n nonErrorPrefix,\n originalError\n )\n var stack = hasUsableStack(isErrorInstance, stackTrace)\n ? toStackTraceString(stackTrace)\n : NO_ERROR_STACK_PRESENT_MESSAGE\n var causes = isErrorInstance\n ? flattenErrorCauses(originalError, source)\n : undefined\n var type = stackTrace && stackTrace.name\n\n return {\n startClocks: startClocks,\n source: source,\n handling: handling,\n originalError: originalError,\n message: message,\n stack: stack,\n handlingStack: handlingStack,\n type: type,\n causes: causes\n }\n}\nfunction computeMessage(\n stackTrace,\n isErrorInstance,\n nonErrorPrefix,\n originalError\n) {\n // Favor stackTrace message only if tracekit has really been able to extract something meaningful (message + name)\n // TODO rework tracekit integration to avoid scattering error building logic\n return stackTrace && stackTrace.message && stackTrace && stackTrace.name\n ? stackTrace.message\n : !isErrorInstance\n ? nonErrorPrefix + ' ' + jsonStringify(sanitize(originalError))\n : 'Empty message'\n}\nfunction hasUsableStack(isErrorInstance, stackTrace) {\n if (stackTrace === undefined) {\n return false\n }\n if (isErrorInstance) {\n return true\n }\n // handle cases where tracekit return stack = [] or stack = [{url: undefined, line: undefined, column: undefined}]\n // TODO rework tracekit integration to avoid generating those unusable stack\n return (\n stackTrace.stack.length > 0 &&\n (stackTrace.stack.length > 1 || stackTrace.stack[0].url !== undefined)\n )\n}\n\nexport function formatUnknownError(\n stackTrace,\n errorObject,\n nonErrorPrefix,\n handlingStack\n) {\n if (\n !stackTrace ||\n (stackTrace.message === undefined && !(errorObject instanceof Error))\n ) {\n return {\n message: nonErrorPrefix + '' + jsonStringify(errorObject),\n stack: 'No stack, consider using an instance of Error',\n handlingStack: handlingStack,\n type: stackTrace && stackTrace.name\n }\n }\n return {\n message: stackTrace.message || 'Empty message',\n stack: toStackTraceString(stackTrace),\n handlingStack: handlingStack,\n type: stackTrace.name\n }\n}\n/**\n Creates a stacktrace without SDK internal frames.\n \n Constraints:\n - Has to be called at the utmost position of the call stack.\n - No internal monitoring should encapsulate the function, that is why we need to use callMonitored inside of it.\n */\nexport function createHandlingStack() {\n /**\n * Skip the two internal frames:\n * - SDK API (console.error, ...)\n * - this function\n * in order to keep only the user calls\n */\n var internalFramesToSkip = 2\n var error = new Error()\n var formattedStack\n\n // IE needs to throw the error to fill in the stack trace\n if (!error.stack) {\n try {\n throw error\n } catch (e) {\n noop()\n }\n }\n callMonitored(function () {\n var stackTrace = computeStackTrace(error)\n stackTrace.stack = stackTrace.stack.slice(internalFramesToSkip)\n formattedStack = toStackTraceString(stackTrace)\n })\n\n return formattedStack\n}\nexport function toStackTraceString(stack) {\n var result = formatErrorMessage(stack)\n each(stack.stack, function (frame) {\n var func = frame.func === '?' ? '<anonymous>' : frame.func\n var args =\n frame.args && frame.args.length > 0\n ? '(' + frame.args.join(', ') + ')'\n : ''\n var line = frame.line ? ':' + frame.line : ''\n var column = frame.line && frame.column ? ':' + frame.column : ''\n result += '\\n at ' + func + args + ' @ ' + frame.url + line + column\n })\n return result\n}\nexport function formatErrorMessage(stack) {\n return (stack.name || 'Error') + ': ' + stack.message\n}\nexport function getFileFromStackTraceString(stack) {\n var execResult = /@ (.+)/.exec(stack)\n return execResult && execResult[1]\n}\nexport function flattenErrorCauses(error, parentSource) {\n var currentError = error\n var causes = []\n while (\n currentError &&\n currentError.cause instanceof Error &&\n causes.length < 10\n ) {\n var stackTrace = computeStackTrace(currentError.cause)\n causes.push({\n message: currentError.cause.message,\n source: parentSource,\n type: stackTrace && stackTrace.name,\n stack: stackTrace && toStackTraceString(stackTrace)\n })\n currentError = currentError.cause\n }\n return causes.length ? causes : undefined\n}\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,IAAI,QAAQ,SAAS;AACpC,SAASC,aAAa,QAAQ,uCAAuC;AACrE,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,aAAa,QAAQ,mBAAmB;AACjD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,OAAO,IAAIC,8BAA8B,GACvC,+CAA+C;AACjD,OAAO,IAAIC,WAAW,GAAG;EACvBC,KAAK,EAAE,OAAO;EACdC,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE,QAAQ;EAChBC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EACpC,IAAIC,UAAU,GAAGD,IAAI,CAACC,UAAU;EAChC,IAAIC,aAAa,GAAGF,IAAI,CAACE,aAAa;EACtC,IAAIC,aAAa,GAAGH,IAAI,CAACG,aAAa;EACtC,IAAIC,WAAW,GAAGJ,IAAI,CAACI,WAAW;EAClC,IAAIC,cAAc,GAAGL,IAAI,CAACK,cAAc;EACxC,IAAIC,MAAM,GAAGN,IAAI,CAACM,MAAM;EACxB,IAAIC,QAAQ,GAAGP,IAAI,CAACO,QAAQ;EAC5B,IAAIC,eAAe,GAAGN,aAAa,YAAYO,KAAK;EACpD,IAAIC,OAAO,GAAGC,cAAc,CAC1BV,UAAU,EACVO,eAAe,EACfH,cAAc,EACdH,aACF,CAAC;EACD,IAAIU,KAAK,GAAGC,cAAc,CAACL,eAAe,EAAEP,UAAU,CAAC,GACnDa,kBAAkB,CAACb,UAAU,CAAC,GAC9BV,8BAA8B;EAClC,IAAIwB,MAAM,GAAGP,eAAe,GACxBQ,kBAAkB,CAACd,aAAa,EAAEI,MAAM,CAAC,GACzCW,SAAS;EACb,IAAIC,IAAI,GA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pBvB,IAAI,EAAEjB,UAAU,IAAIA,UAAU,CAACkB,IAAI;MACnCP,KAAK,EAAEX,UAAU,IAAIa,kBAAkB,CAACb,UAAU;IACpD,CAAC,CAAC;IACFyC,YAAY,GAAGA,YAAY,CAACC,KAAK;EACnC;EACA,OAAO5B,MAAM,CAACK,MAAM,GAAGL,MAAM,GAAGE,SAAS;AAC3C"}
|
package/esm/helper/monitor.js
CHANGED
|
@@ -32,6 +32,7 @@ export function callMonitored(fn, context, args) {
|
|
|
32
32
|
}
|
|
33
33
|
export function displayIfDebugEnabled(api) {
|
|
34
34
|
var args = [].slice.call(arguments, 1);
|
|
35
|
+
// display.apply(null, [api, '[MONITOR]'].concat(args))
|
|
35
36
|
if (debugMode) {
|
|
36
37
|
display.apply(null, [api, '[MONITOR]'].concat(args));
|
|
37
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","names":["ConsoleApiName","display","onMonitorErrorCollected","debugMode","startMonitorErrorCollection","newOnMonitorErrorCollected","setDebugMode","newDebugMode","resetMonitor","undefined","monitor","fn","callMonitored","arguments","context","args","apply","e","displayIfDebugEnabled","error","api","slice","call","concat"],"sources":["../../src/helper/monitor.js"],"sourcesContent":["import { ConsoleApiName, display } from './display'\nvar onMonitorErrorCollected\nvar debugMode = false\n\nexport function startMonitorErrorCollection(newOnMonitorErrorCollected) {\n onMonitorErrorCollected = newOnMonitorErrorCollected\n}\n\nexport function setDebugMode(newDebugMode) {\n debugMode = newDebugMode\n}\n\nexport function resetMonitor() {\n onMonitorErrorCollected = undefined\n debugMode = false\n}\n\nexport function monitor(fn) {\n return function () {\n return callMonitored(fn, this, arguments)\n }\n}\n\nexport function callMonitored(fn, context, args) {\n try {\n return fn.apply(context, args)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n if (onMonitorErrorCollected) {\n try {\n onMonitorErrorCollected(e)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n }\n }\n }\n}\n\nexport function displayIfDebugEnabled(api) {\n var args = [].slice.call(arguments, 1)\n if (debugMode) {\n display.apply(null, [api, '[MONITOR]'].concat(args))\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,OAAO,QAAQ,WAAW;AACnD,IAAIC,uBAAuB;AAC3B,IAAIC,SAAS,GAAG,KAAK;AAErB,OAAO,SAASC,2BAA2BA,CAACC,0BAA0B,EAAE;EACtEH,uBAAuB,GAAGG,0BAA0B;AACtD;AAEA,OAAO,SAASC,YAAYA,CAACC,YAAY,EAAE;EACzCJ,SAAS,GAAGI,YAAY;AAC1B;AAEA,OAAO,SAASC,YAAYA,CAAA,EAAG;EAC7BN,uBAAuB,GAAGO,SAAS;EACnCN,SAAS,GAAG,KAAK;AACnB;AAEA,OAAO,SAASO,OAAOA,CAACC,EAAE,EAAE;EAC1B,OAAO,YAAY;IACjB,OAAOC,aAAa,CAACD,EAAE,EAAE,IAAI,EAAEE,SAAS,CAAC;EAC3C,CAAC;AACH;AAEA,OAAO,SAASD,aAAaA,CAACD,EAAE,EAAEG,OAAO,EAAEC,IAAI,EAAE;EAC/C,IAAI;IACF,OAAOJ,EAAE,CAACK,KAAK,CAACF,OAAO,EAAEC,IAAI,CAAC;EAChC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACVC,qBAAqB,CAAClB,cAAc,CAACmB,KAAK,EAAEF,CAAC,CAAC;IAC9C,IAAIf,uBAAuB,EAAE;MAC3B,IAAI;QACFA,uBAAuB,CAACe,CAAC,CAAC;MAC5B,CAAC,CAAC,OAAOA,CAAC,EAAE;QACVC,qBAAqB,CAAClB,cAAc,CAACmB,KAAK,EAAEF,CAAC,CAAC;MAChD;IACF;EACF;AACF;AAEA,OAAO,SAASC,qBAAqBA,CAACE,GAAG,EAAE;EACzC,IAAIL,IAAI,GAAG,EAAE,CAACM,KAAK,CAACC,IAAI,CAACT,SAAS,EAAE,CAAC,CAAC;EACtC,IAAIV,SAAS,EAAE;IACbF,OAAO,CAACe,KAAK,CAAC,IAAI,EAAE,CAACI,GAAG,EAAE,WAAW,CAAC,CAACG,MAAM,CAACR,IAAI,CAAC,CAAC;EACtD;AACF"}
|
|
1
|
+
{"version":3,"file":"monitor.js","names":["ConsoleApiName","display","onMonitorErrorCollected","debugMode","startMonitorErrorCollection","newOnMonitorErrorCollected","setDebugMode","newDebugMode","resetMonitor","undefined","monitor","fn","callMonitored","arguments","context","args","apply","e","displayIfDebugEnabled","error","api","slice","call","concat"],"sources":["../../src/helper/monitor.js"],"sourcesContent":["import { ConsoleApiName, display } from './display'\nvar onMonitorErrorCollected\nvar debugMode = false\n\nexport function startMonitorErrorCollection(newOnMonitorErrorCollected) {\n onMonitorErrorCollected = newOnMonitorErrorCollected\n}\n\nexport function setDebugMode(newDebugMode) {\n debugMode = newDebugMode\n}\n\nexport function resetMonitor() {\n onMonitorErrorCollected = undefined\n debugMode = false\n}\n\nexport function monitor(fn) {\n return function () {\n return callMonitored(fn, this, arguments)\n }\n}\n\nexport function callMonitored(fn, context, args) {\n try {\n return fn.apply(context, args)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n if (onMonitorErrorCollected) {\n try {\n onMonitorErrorCollected(e)\n } catch (e) {\n displayIfDebugEnabled(ConsoleApiName.error, e)\n }\n }\n }\n}\n\nexport function displayIfDebugEnabled(api) {\n var args = [].slice.call(arguments, 1)\n // display.apply(null, [api, '[MONITOR]'].concat(args))\n if (debugMode) {\n display.apply(null, [api, '[MONITOR]'].concat(args))\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,OAAO,QAAQ,WAAW;AACnD,IAAIC,uBAAuB;AAC3B,IAAIC,SAAS,GAAG,KAAK;AAErB,OAAO,SAASC,2BAA2BA,CAACC,0BAA0B,EAAE;EACtEH,uBAAuB,GAAGG,0BAA0B;AACtD;AAEA,OAAO,SAASC,YAAYA,CAACC,YAAY,EAAE;EACzCJ,SAAS,GAAGI,YAAY;AAC1B;AAEA,OAAO,SAASC,YAAYA,CAAA,EAAG;EAC7BN,uBAAuB,GAAGO,SAAS;EACnCN,SAAS,GAAG,KAAK;AACnB;AAEA,OAAO,SAASO,OAAOA,CAACC,EAAE,EAAE;EAC1B,OAAO,YAAY;IACjB,OAAOC,aAAa,CAACD,EAAE,EAAE,IAAI,EAAEE,SAAS,CAAC;EAC3C,CAAC;AACH;AAEA,OAAO,SAASD,aAAaA,CAACD,EAAE,EAAEG,OAAO,EAAEC,IAAI,EAAE;EAC/C,IAAI;IACF,OAAOJ,EAAE,CAACK,KAAK,CAACF,OAAO,EAAEC,IAAI,CAAC;EAChC,CAAC,CAAC,OAAOE,CAAC,EAAE;IACVC,qBAAqB,CAAClB,cAAc,CAACmB,KAAK,EAAEF,CAAC,CAAC;IAC9C,IAAIf,uBAAuB,EAAE;MAC3B,IAAI;QACFA,uBAAuB,CAACe,CAAC,CAAC;MAC5B,CAAC,CAAC,OAAOA,CAAC,EAAE;QACVC,qBAAqB,CAAClB,cAAc,CAACmB,KAAK,EAAEF,CAAC,CAAC;MAChD;IACF;EACF;AACF;AAEA,OAAO,SAASC,qBAAqBA,CAACE,GAAG,EAAE;EACzC,IAAIL,IAAI,GAAG,EAAE,CAACM,KAAK,CAACC,IAAI,CAACT,SAAS,EAAE,CAAC,CAAC;EACtC;EACA,IAAIV,SAAS,EAAE;IACbF,OAAO,CAACe,KAAK,CAAC,IAAI,EAAE,CAACI,GAAG,EAAE,WAAW,CAAC,CAACG,MAAM,CAACR,IAAI,CAAC,CAAC;EACtD;AACF"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { computeBytesCount } from '../byteUtils';
|
|
2
|
-
import { deepClone, throttle } from '../tools';
|
|
2
|
+
import { deepClone, throttle, getType } from '../tools';
|
|
3
|
+
import { sanitize } from '../sanitize';
|
|
3
4
|
import { jsonStringify } from './jsonStringify';
|
|
5
|
+
import { Observable } from '../observable';
|
|
4
6
|
import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning';
|
|
5
7
|
export var BYTES_COMPUTATION_THROTTLING_DELAY = 200;
|
|
6
8
|
export function createContextManager(customerDataType, computeBytesCountImpl) {
|
|
@@ -10,7 +12,7 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
|
|
|
10
12
|
var context = {};
|
|
11
13
|
var bytesCountCache;
|
|
12
14
|
var alreadyWarned = false;
|
|
13
|
-
|
|
15
|
+
var changeObservable = new Observable();
|
|
14
16
|
// Throttle the bytes computation to minimize the impact on performance.
|
|
15
17
|
// Especially useful if the user call context APIs synchronously multiple times in a row
|
|
16
18
|
var computeBytesCountThrottled = throttle(function (context) {
|
|
@@ -19,7 +21,7 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
|
|
|
19
21
|
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType);
|
|
20
22
|
}
|
|
21
23
|
}, BYTES_COMPUTATION_THROTTLING_DELAY).throttled;
|
|
22
|
-
|
|
24
|
+
var contextManager = {
|
|
23
25
|
getBytesCount: function getBytesCount() {
|
|
24
26
|
return bytesCountCache;
|
|
25
27
|
},
|
|
@@ -31,36 +33,49 @@ export function createContextManager(customerDataType, computeBytesCountImpl) {
|
|
|
31
33
|
add: function add(key, value) {
|
|
32
34
|
context[key] = value;
|
|
33
35
|
computeBytesCountThrottled(context);
|
|
36
|
+
changeObservable.notify();
|
|
34
37
|
},
|
|
35
38
|
/** @deprecated renamed to removeContextProperty */
|
|
36
39
|
remove: function remove(key) {
|
|
37
40
|
delete context[key];
|
|
38
41
|
computeBytesCountThrottled(context);
|
|
42
|
+
changeObservable.notify();
|
|
39
43
|
},
|
|
40
44
|
/** @deprecated use setContext instead */
|
|
41
45
|
set: function set(newContext) {
|
|
42
46
|
context = newContext;
|
|
43
47
|
computeBytesCountThrottled(context);
|
|
48
|
+
changeObservable.notify();
|
|
44
49
|
},
|
|
45
50
|
getContext: function getContext() {
|
|
46
51
|
return deepClone(context);
|
|
47
52
|
},
|
|
48
53
|
setContext: function setContext(newContext) {
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
if (getType(newContext) === 'object') {
|
|
55
|
+
context = sanitize(newContext);
|
|
56
|
+
computeBytesCountThrottled(context);
|
|
57
|
+
} else {
|
|
58
|
+
contextManager.clearContext();
|
|
59
|
+
}
|
|
60
|
+
changeObservable.notify();
|
|
51
61
|
},
|
|
52
62
|
setContextProperty: function setContextProperty(key, property) {
|
|
53
63
|
context[key] = deepClone(property);
|
|
54
64
|
computeBytesCountThrottled(context);
|
|
65
|
+
changeObservable.notify();
|
|
55
66
|
},
|
|
56
67
|
removeContextProperty: function removeContextProperty(key) {
|
|
57
68
|
delete context[key];
|
|
58
69
|
computeBytesCountThrottled(context);
|
|
70
|
+
changeObservable.notify();
|
|
59
71
|
},
|
|
60
72
|
clearContext: function clearContext() {
|
|
61
73
|
context = {};
|
|
62
74
|
bytesCountCache = 0;
|
|
63
|
-
|
|
75
|
+
changeObservable.notify();
|
|
76
|
+
},
|
|
77
|
+
changeObservable: changeObservable
|
|
64
78
|
};
|
|
79
|
+
return contextManager;
|
|
65
80
|
}
|
|
66
81
|
//# sourceMappingURL=contextManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.js","names":["computeBytesCount","deepClone","throttle","jsonStringify","warnIfCustomerDataLimitReached","BYTES_COMPUTATION_THROTTLING_DELAY","createContextManager","customerDataType","computeBytesCountImpl","context","bytesCountCache","alreadyWarned","computeBytesCountThrottled","throttled","getBytesCount","get","add","key","value","remove","set","newContext","getContext","setContext","setContextProperty","property","removeContextProperty"
|
|
1
|
+
{"version":3,"file":"contextManager.js","names":["computeBytesCount","deepClone","throttle","getType","sanitize","jsonStringify","Observable","warnIfCustomerDataLimitReached","BYTES_COMPUTATION_THROTTLING_DELAY","createContextManager","customerDataType","computeBytesCountImpl","context","bytesCountCache","alreadyWarned","changeObservable","computeBytesCountThrottled","throttled","contextManager","getBytesCount","get","add","key","value","notify","remove","set","newContext","getContext","setContext","clearContext","setContextProperty","property","removeContextProperty"],"sources":["../../../src/helper/serialisation/contextManager.js"],"sourcesContent":["import { computeBytesCount } from '../byteUtils'\nimport { deepClone, throttle, getType } from '../tools'\nimport { sanitize } from '../sanitize'\nimport { jsonStringify } from './jsonStringify'\nimport { Observable } from '../observable'\nimport { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'\n\nexport var BYTES_COMPUTATION_THROTTLING_DELAY = 200\n\nexport function createContextManager(customerDataType, computeBytesCountImpl) {\n if (typeof computeBytesCountImpl === 'undefined') {\n computeBytesCountImpl = computeBytesCount\n }\n var context = {}\n var bytesCountCache\n var alreadyWarned = false\n var changeObservable = new Observable()\n // Throttle the bytes computation to minimize the impact on performance.\n // Especially useful if the user call context APIs synchronously multiple times in a row\n var computeBytesCountThrottled = throttle(function (context) {\n bytesCountCache = computeBytesCountImpl(jsonStringify(context))\n if (!alreadyWarned) {\n alreadyWarned = warnIfCustomerDataLimitReached(\n bytesCountCache,\n customerDataType\n )\n }\n }, BYTES_COMPUTATION_THROTTLING_DELAY).throttled\n\n var contextManager = {\n getBytesCount: function () {\n return bytesCountCache\n },\n /** @deprecated use getContext instead */\n get: function () {\n return context\n },\n\n /** @deprecated use setContextProperty instead */\n add: function (key, value) {\n context[key] = value\n computeBytesCountThrottled(context)\n changeObservable.notify()\n },\n\n /** @deprecated renamed to removeContextProperty */\n remove: function (key) {\n delete context[key]\n computeBytesCountThrottled(context)\n changeObservable.notify()\n },\n\n /** @deprecated use setContext instead */\n set: function (newContext) {\n context = newContext\n computeBytesCountThrottled(context)\n changeObservable.notify()\n },\n\n getContext: function () {\n return deepClone(context)\n },\n\n setContext: function (newContext) {\n if (getType(newContext) === 'object') {\n context = sanitize(newContext)\n computeBytesCountThrottled(context)\n } else {\n contextManager.clearContext()\n }\n changeObservable.notify()\n },\n\n setContextProperty: function (key, property) {\n context[key] = deepClone(property)\n computeBytesCountThrottled(context)\n changeObservable.notify()\n },\n\n removeContextProperty: function (key) {\n delete context[key]\n computeBytesCountThrottled(context)\n changeObservable.notify()\n },\n\n clearContext: function () {\n context = {}\n bytesCountCache = 0\n changeObservable.notify()\n },\n changeObservable: changeObservable\n }\n return contextManager\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,cAAc;AAChD,SAASC,SAAS,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,UAAU;AACvD,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,8BAA8B,QAAQ,4BAA4B;AAE3E,OAAO,IAAIC,kCAAkC,GAAG,GAAG;AAEnD,OAAO,SAASC,oBAAoBA,CAACC,gBAAgB,EAAEC,qBAAqB,EAAE;EAC5E,IAAI,OAAOA,qBAAqB,KAAK,WAAW,EAAE;IAChDA,qBAAqB,GAAGX,iBAAiB;EAC3C;EACA,IAAIY,OAAO,GAAG,CAAC,CAAC;EAChB,IAAIC,eAAe;EACnB,IAAIC,aAAa,GAAG,KAAK;EACzB,IAAIC,gBAAgB,GAAG,IAAIT,UAAU,CAAC,CAAC;EACvC;EACA;EACA,IAAIU,0BAA0B,GAAGd,QAAQ,CAAC,UAAUU,OAAO,EAAE;IAC3DC,eAAe,GAAGF,qBAAqB,CAACN,aAAa,CAACO,OAAO,CAAC,CAAC;IAC/D,IAAI,CAACE,aAAa,EAAE;MAClBA,aAAa,GAAGP,8BAA8B,CAC5CM,eAAe,EACfH,gBACF,CAAC;IACH;EACF,CAAC,EAAEF,kCAAkC,CAAC,CAACS,SAAS;EAEhD,IAAIC,cAAc,GAAG;IACnBC,aAAa,EAAE,SAAAA,cAAA,EAAY;MACzB,OAAON,eAAe;IACxB,CAAC;IACD;IACAO,GAAG,EAAE,SAAAA,IAAA,EAAY;MACf,OAAOR,OAAO;IAChB,CAAC;IAED;IACAS,GAAG,EAAE,SAAAA,IAAUC,GAAG,EAAEC,KAAK,EAAE;MACzBX,OAAO,CAACU,GAAG,CAAC,GAAGC,KAAK;MACpBP,0BAA0B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EAAY;MACxBlB,OAAO,GAAG,CAAC,CAAC;MACZC,eAAe,GAAG,CAAC;MACnBE,gBAAgB,CAACS,MAAM,CAAC,CAAC;IAC3B,CAAC;IACDT,gBAAgB,EAAEA;EACpB,CAAC;EACD,OAAOG,cAAc;AACvB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
2
|
import { jsonStringify } from './jsonStringify';
|
|
3
|
-
import { isString } from '../tools';
|
|
3
|
+
import { isString, isNumber } from '../tools';
|
|
4
4
|
export function escapeRowData(str) {
|
|
5
5
|
if (_typeof(str) === 'object' && str) {
|
|
6
6
|
str = jsonStringify(str);
|
|
@@ -12,12 +12,14 @@ export function escapeRowData(str) {
|
|
|
12
12
|
return '\\' + word;
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
export function escapeJsonValue(value) {
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
} else {
|
|
19
|
-
|
|
15
|
+
export function escapeJsonValue(value, isTag) {
|
|
16
|
+
if (_typeof(value) === 'object' && value) {
|
|
17
|
+
value = jsonStringify(value);
|
|
18
|
+
} else if (isTag) {
|
|
19
|
+
// tag json 只能是字符串
|
|
20
|
+
value = '' + value;
|
|
20
21
|
}
|
|
22
|
+
return value;
|
|
21
23
|
}
|
|
22
24
|
export function escapeFieldValueStr(str) {
|
|
23
25
|
return '"' + str.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowData.js","names":["jsonStringify","isString","escapeRowData","str","_typeof","reg","String","replace","word","escapeJsonValue","value","escapeFieldValueStr","escapeRowField"],"sources":["../../../src/helper/serialisation/rowData.js"],"sourcesContent":["import { jsonStringify } from './jsonStringify'\nimport { isString } from '../tools'\nexport function escapeRowData(str) {\n if (typeof str === 'object' && str) {\n str = jsonStringify(str)\n } else if (!isString(str)) {\n return str\n }\n var reg = /[\\s=,\"]/g\n return String(str).replace(reg, function (word) {\n return '\\\\' + word\n })\n}\n\nexport function escapeJsonValue(value) {\n if (
|
|
1
|
+
{"version":3,"file":"rowData.js","names":["jsonStringify","isString","isNumber","escapeRowData","str","_typeof","reg","String","replace","word","escapeJsonValue","value","isTag","escapeFieldValueStr","escapeRowField"],"sources":["../../../src/helper/serialisation/rowData.js"],"sourcesContent":["import { jsonStringify } from './jsonStringify'\nimport { isString, isNumber } from '../tools'\nexport function escapeRowData(str) {\n if (typeof str === 'object' && str) {\n str = jsonStringify(str)\n } else if (!isString(str)) {\n return str\n }\n var reg = /[\\s=,\"]/g\n return String(str).replace(reg, function (word) {\n return '\\\\' + word\n })\n}\n\nexport function escapeJsonValue(value, isTag) {\n if (typeof value === 'object' && value) {\n value = jsonStringify(value)\n } else if (isTag) {\n // tag json 只能是字符串\n value = '' + value\n }\n\n return value\n}\n\nexport function escapeFieldValueStr(str) {\n return '\"' + str.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"') + '\"'\n}\nexport function escapeRowField(value) {\n if (typeof value === 'object' && value) {\n return escapeFieldValueStr(jsonStringify(value))\n } else if (isString(value)) {\n return escapeFieldValueStr(value)\n } else {\n return value\n }\n}\n"],"mappings":";AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,UAAU;AAC7C,OAAO,SAASC,aAAaA,CAACC,GAAG,EAAE;EACjC,IAAIC,OAAA,CAAOD,GAAG,MAAK,QAAQ,IAAIA,GAAG,EAAE;IAClCA,GAAG,GAAGJ,aAAa,CAACI,GAAG,CAAC;EAC1B,CAAC,MAAM,IAAI,CAACH,QAAQ,CAACG,GAAG,CAAC,EAAE;IACzB,OAAOA,GAAG;EACZ;EACA,IAAIE,GAAG,GAAG,UAAU;EACpB,OAAOC,MAAM,CAACH,GAAG,CAAC,CAACI,OAAO,CAACF,GAAG,EAAE,UAAUG,IAAI,EAAE;IAC9C,OAAO,IAAI,GAAGA,IAAI;EACpB,CAAC,CAAC;AACJ;AAEA,OAAO,SAASC,eAAeA,CAACC,KAAK,EAAEC,KAAK,EAAE;EAC5C,IAAIP,OAAA,CAAOM,KAAK,MAAK,QAAQ,IAAIA,KAAK,EAAE;IACtCA,KAAK,GAAGX,aAAa,CAACW,KAAK,CAAC;EAC9B,CAAC,MAAM,IAAIC,KAAK,EAAE;IAChB;IACAD,KAAK,GAAG,EAAE,GAAGA,KAAK;EACpB;EAEA,OAAOA,KAAK;AACd;AAEA,OAAO,SAASE,mBAAmBA,CAACT,GAAG,EAAE;EACvC,OAAO,GAAG,GAAGA,GAAG,CAACI,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,GAAG;AACpE;AACA,OAAO,SAASM,cAAcA,CAACH,KAAK,EAAE;EACpC,IAAIN,OAAA,CAAOM,KAAK,MAAK,QAAQ,IAAIA,KAAK,EAAE;IACtC,OAAOE,mBAAmB,CAACb,aAAa,CAACW,KAAK,CAAC,CAAC;EAClD,CAAC,MAAM,IAAIV,QAAQ,CAACU,KAAK,CAAC,EAAE;IAC1B,OAAOE,mBAAmB,CAACF,KAAK,CAAC;EACnC,CAAC,MAAM;IACL,OAAOA,KAAK;EACd;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { computeBytesCount } from '../byteUtils';
|
|
2
|
+
import { DOM_EVENT } from '../enums';
|
|
3
|
+
import { map } from '../tools';
|
|
4
|
+
import { addEventListener } from '../../browser/addEventListener';
|
|
5
|
+
import { createContextManager } from './contextManager';
|
|
6
|
+
var CONTEXT_STORE_KEY_PREFIX = '_gc_s';
|
|
7
|
+
var storageListeners = [];
|
|
8
|
+
export function createStoredContextManager(productKey, customerDataType, computeBytesCountImpl) {
|
|
9
|
+
if (computeBytesCountImpl === undefined) {
|
|
10
|
+
computeBytesCountImpl = computeBytesCount;
|
|
11
|
+
}
|
|
12
|
+
var storageKey = buildStorageKey(productKey, customerDataType);
|
|
13
|
+
var contextManager = createContextManager(customerDataType, computeBytesCountImpl);
|
|
14
|
+
synchronizeWithStorage();
|
|
15
|
+
storageListeners.push(addEventListener(window, DOM_EVENT.STORAGE, function (params) {
|
|
16
|
+
if (storageKey === params.key) {
|
|
17
|
+
synchronizeWithStorage();
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
contextManager.changeObservable.subscribe(dumpToStorage);
|
|
21
|
+
function synchronizeWithStorage() {
|
|
22
|
+
var rawContext = localStorage.getItem(storageKey);
|
|
23
|
+
var context = rawContext !== null ? JSON.parse(rawContext) : {};
|
|
24
|
+
contextManager.setContext(context);
|
|
25
|
+
}
|
|
26
|
+
function dumpToStorage() {
|
|
27
|
+
localStorage.setItem(storageKey, JSON.stringify(contextManager.getContext()));
|
|
28
|
+
}
|
|
29
|
+
return contextManager;
|
|
30
|
+
}
|
|
31
|
+
export function buildStorageKey(productKey, customerDataType) {
|
|
32
|
+
return CONTEXT_STORE_KEY_PREFIX + '_' + productKey + '_' + customerDataType;
|
|
33
|
+
}
|
|
34
|
+
export function removeStorageListeners() {
|
|
35
|
+
map(storageListeners, function (listener) {
|
|
36
|
+
listener.stop();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=storedContextManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storedContextManager.js","names":["computeBytesCount","DOM_EVENT","map","addEventListener","createContextManager","CONTEXT_STORE_KEY_PREFIX","storageListeners","createStoredContextManager","productKey","customerDataType","computeBytesCountImpl","undefined","storageKey","buildStorageKey","contextManager","synchronizeWithStorage","push","window","STORAGE","params","key","changeObservable","subscribe","dumpToStorage","rawContext","localStorage","getItem","context","JSON","parse","setContext","setItem","stringify","getContext","removeStorageListeners","listener","stop"],"sources":["../../../src/helper/serialisation/storedContextManager.js"],"sourcesContent":["import { computeBytesCount } from '../byteUtils'\nimport { DOM_EVENT } from '../enums'\nimport { map } from '../tools'\nimport { addEventListener } from '../../browser/addEventListener'\nimport { createContextManager } from './contextManager'\nvar CONTEXT_STORE_KEY_PREFIX = '_gc_s'\n\nvar storageListeners = []\n\nexport function createStoredContextManager(\n productKey,\n customerDataType,\n computeBytesCountImpl\n) {\n if (computeBytesCountImpl === undefined) {\n computeBytesCountImpl = computeBytesCount\n }\n var storageKey = buildStorageKey(productKey, customerDataType)\n var contextManager = createContextManager(\n customerDataType,\n computeBytesCountImpl\n )\n\n synchronizeWithStorage()\n storageListeners.push(\n addEventListener(window, DOM_EVENT.STORAGE, function (params) {\n if (storageKey === params.key) {\n synchronizeWithStorage()\n }\n })\n )\n contextManager.changeObservable.subscribe(dumpToStorage)\n function synchronizeWithStorage() {\n var rawContext = localStorage.getItem(storageKey)\n var context = rawContext !== null ? JSON.parse(rawContext) : {}\n contextManager.setContext(context)\n }\n\n function dumpToStorage() {\n localStorage.setItem(\n storageKey,\n JSON.stringify(contextManager.getContext())\n )\n }\n return contextManager\n}\n\nexport function buildStorageKey(productKey, customerDataType) {\n return CONTEXT_STORE_KEY_PREFIX + '_' + productKey + '_' + customerDataType\n}\n\nexport function removeStorageListeners() {\n map(storageListeners, function (listener) {\n listener.stop()\n })\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,cAAc;AAChD,SAASC,SAAS,QAAQ,UAAU;AACpC,SAASC,GAAG,QAAQ,UAAU;AAC9B,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASC,oBAAoB,QAAQ,kBAAkB;AACvD,IAAIC,wBAAwB,GAAG,OAAO;AAEtC,IAAIC,gBAAgB,GAAG,EAAE;AAEzB,OAAO,SAASC,0BAA0BA,CACxCC,UAAU,EACVC,gBAAgB,EAChBC,qBAAqB,EACrB;EACA,IAAIA,qBA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J"}
|
package/esm/helper/tools.js
CHANGED
|
@@ -226,6 +226,7 @@ export var matchList = function matchList(list, value, useStartsWith) {
|
|
|
226
226
|
} catch (e) {
|
|
227
227
|
display.error(e);
|
|
228
228
|
}
|
|
229
|
+
return false;
|
|
229
230
|
});
|
|
230
231
|
};
|
|
231
232
|
// https://github.com/jquery/jquery/blob/a684e6ba836f7c553968d7d026ed7941e1a612d8/src/selector/escapeSelector.js
|
|
@@ -1417,13 +1418,27 @@ export function isPercentage(value) {
|
|
|
1417
1418
|
export function getLocationOrigin() {
|
|
1418
1419
|
return getLinkElementOrigin(window.location);
|
|
1419
1420
|
}
|
|
1421
|
+
var browserIsIE;
|
|
1420
1422
|
export function isIE() {
|
|
1421
|
-
|
|
1423
|
+
if (browserIsIE === undefined) {
|
|
1424
|
+
browserIsIE = Boolean(document.documentMode);
|
|
1425
|
+
}
|
|
1426
|
+
return browserIsIE;
|
|
1422
1427
|
}
|
|
1428
|
+
var browserIsChromium;
|
|
1423
1429
|
export function isChromium() {
|
|
1424
|
-
|
|
1430
|
+
if (browserIsChromium === undefined) {
|
|
1431
|
+
browserIsChromium = !!window.chrome || /HeadlessChrome/.test(window.navigator.userAgent);
|
|
1432
|
+
}
|
|
1433
|
+
return browserIsChromium;
|
|
1434
|
+
}
|
|
1435
|
+
var browserIsSafari;
|
|
1436
|
+
export function isSafari() {
|
|
1437
|
+
if (browserIsSafari === undefined) {
|
|
1438
|
+
browserIsSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1439
|
+
}
|
|
1440
|
+
return browserIsSafari;
|
|
1425
1441
|
}
|
|
1426
|
-
|
|
1427
1442
|
/**
|
|
1428
1443
|
* IE fallback
|
|
1429
1444
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/origin
|