@arms/rum-browser
Advanced tools
Comparing version 0.0.27-beta.5 to 0.0.27-beta.6
@@ -1,2 +0,5 @@ | ||
import _extends from"@babel/runtime/helpers/extends";import{interceptFunction,isFunction,isUndefined,RumEventType}from"@arms/rum-core";import{getCurrentURL,getPathByURL}from"../../utils/url";import{global,document,location,history}from"../../utils/global";var supportsHistory=history&&!!history.pushState&&!!history.replaceState,PvCollector=/*#__PURE__*/function(){function a(){var a=this;this.name="pv-collector",this.ctx=void 0,this.sendEvent=void 0,this.prevUrl=void 0,this.sendPv=function(b,c,d){void 0===d&&(d="route_change");var e=a.getViewName(b),f=a.prevUrl;// 如果两次的view.name相同,判断为没有pv发生 | ||
if(a.prevUrl=b,!(f&&e===a.getViewName(f))){a.ctx.addView({id:a.ctx.session.getViewId(),name:e});var g=a.ctx.session.getBaseEvent();a.sendEvent(_extends({},g,{event_type:RumEventType.VIEW,type:"pv",name:e,url:b,referrer:c,loading_type:d}))}},this.historyFn=function(){var b=2<arguments.length?2>=arguments.length?void 0:arguments[2]:void 0;if(b){var c=location.origin+b,d=a.prevUrl;a.sendPv(c,d)}},this.popstateFn=function(){var b=getCurrentURL(),c=a.prevUrl;a.sendPv(b,c)}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.sendPv(getCurrentURL(),document.referrer||"","initial_load");var c=this.getSpaMode();supportsHistory&&c&&(interceptFunction(global.history,"pushState",this.historyFn),interceptFunction(global.history,"replaceState",this.historyFn),global.addEventListener("popstate",this.popstateFn))},b.getSpaMode=function getSpaMode(){var a=this.ctx.getConfig().spaMode;return isUndefined(a)&&(a=!0),!!a&&("history"!==a&&"hash"!==a?"history":a)},b.getViewName=function getViewName(a){var b=this.ctx.getConfig(),c=this.getSpaMode(),d=getPathByURL(a,"hash"===c);return isFunction(b.parseViewName)&&(d=b.parseViewName(a)),d},b.destroy=function destroy(){supportsHistory&&global.removeEventListener("popstate",this.popstateFn)},a}();export{PvCollector as default}; | ||
import _extends from"@babel/runtime/helpers/extends";import{interceptFunction,isFunction,RumEventType}from"@arms/rum-core";import{getCurrentURL,getPathByURL}from"../../utils/url";import{global,document,location,history}from"../../utils/global";var supportsHistory=history&&!!history.pushState&&!!history.replaceState,PvCollector=/*#__PURE__*/function(){function a(){var a=this;this.name="pv-collector",this.ctx=void 0,this.sendEvent=void 0,this.prevUrl=void 0,this.sendPv=function(b,c,d){void 0===d&&(d="route_change");var e=a.getViewName(b),f=a.prevUrl;// 如果两次的view.name相同,判断为没有pv发生 | ||
if(a.prevUrl=b,!(f&&e===a.getViewName(f))){a.ctx.addView({id:a.ctx.session.getViewId(),name:e});var g=a.ctx.session.getBaseEvent();a.sendEvent(_extends({},g,{event_type:RumEventType.VIEW,type:"pv",name:e,url:b,referrer:c,loading_type:d}))}},this.historyFn=function(){var b=2<arguments.length?2>=arguments.length?void 0:arguments[2]:void 0;if(b){var c=location.origin+b,d=a.prevUrl;a.sendPv(c,d)}},this.popstateFn=function(){var b=getCurrentURL(),c=a.prevUrl;a.sendPv(b,c)}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.sendPv(getCurrentURL(),document.referrer||"","initial_load");var c=this.getSpaMode();supportsHistory&&c&&(interceptFunction(global.history,"pushState",this.historyFn),interceptFunction(global.history,"replaceState",this.historyFn),global.addEventListener("popstate",this.popstateFn))},b.getSpaMode=function getSpaMode(){var a=this.ctx.getConfig().spaMode;// if (isUndefined(spaMode)) { | ||
// spaMode = true; | ||
// } | ||
return!!a&&("history"!==a&&"hash"!==a?"auto":a)},b.getViewName=function getViewName(a){var b=this.ctx.getConfig(),c=getPathByURL(a,this.getSpaMode());return isFunction(b.parseViewName)&&(c=b.parseViewName(a)),c},b.destroy=function destroy(){supportsHistory&&global.removeEventListener("popstate",this.popstateFn)},a}();export{PvCollector as default}; |
import { IConfiguration, ITracingOption } from "@arms/rum-core"; | ||
import { IApiAttr } from "../utils/api"; | ||
import { SpaMode } from "../utils/url"; | ||
export interface IBrowserConfig extends IConfiguration { | ||
@@ -7,3 +8,3 @@ /** | ||
**/ | ||
spaMode?: false | 'hash' | 'history'; | ||
spaMode?: SpaMode; | ||
/** | ||
@@ -10,0 +11,0 @@ * view.name 解析 |
@@ -1,1 +0,1 @@ | ||
export var global=window;export var document=window.document;export var location=window.location;export var history=window.history;export var VERSION='0.0.27-beta.5'; | ||
export var global=window;export var document=window.document;export var location=window.location;export var history=window.history;export var VERSION='0.0.27-beta.6'; |
@@ -0,1 +1,2 @@ | ||
export type SpaMode = false | true | 'hash' | 'history' | 'auto'; | ||
/** | ||
@@ -6,7 +7,7 @@ * 获取目前的 URL | ||
/** | ||
* 根据指定 URL 获取视图的名称,默认为其path部分 | ||
* 根据指定 URL 获取视图的名称,默认为其 path 部分 | ||
* @param url 需要提取路径部分的 URL | ||
* @param isHash 是否为 hash 模式路由的 URL | ||
* @param spaMode 页面 SPA 路由模式 | ||
*/ | ||
export declare function getPathByURL(url: string, isHash?: boolean): string; | ||
export declare function getPathByURL(url: string, spaMode?: SpaMode): string; | ||
/** | ||
@@ -13,0 +14,0 @@ * 将不完整的 URL 补全 |
@@ -1,8 +0,8 @@ | ||
import{isFunction}from"@arms/rum-core";import{location}from"./global";/** | ||
import{isFunction,isString}from"@arms/rum-core";import{location}from"./global";/** | ||
* 获取目前的 URL | ||
*/export function getCurrentURL(){return location?location.href:""}/** | ||
* 根据指定 URL 获取视图的名称,默认为其path部分 | ||
*/export function getCurrentURL(){return location?location.href:""}function getHashPath(a){if(!isString(a)||!a)return"";var b=a.indexOf("#");0===b&&(a=a.substring(1));var c=a.indexOf("?");return 0<=c&&(a=a.substring(0,c)),a}/** | ||
* 根据指定 URL 获取视图的名称,默认为其 path 部分 | ||
* @param url 需要提取路径部分的 URL | ||
* @param isHash 是否为 hash 模式路由的 URL | ||
*/export function getPathByURL(a,b){void 0===b&&(b=!1);try{var c=new URL(fixRelativeUrl(a));if(b){var d=c.hash.replace("#","");return d.replace(/\?.*$/,"")||"/"}return c.pathname||"/"}catch(a){return"[unknown]"}}/** | ||
* @param spaMode 页面 SPA 路由模式 | ||
*/export function getPathByURL(a,b){void 0===b&&(b=!1);try{var c=new URL(fixRelativeUrl(a));if("auto"===b||!0===b){var d=getHashPath(c.hash||"");return c.pathname+(d?"#":"")+d}return"hash"===b?getHashPath(c.hash||""):c.pathname||"/"}catch(b){return a}}/** | ||
* 将不完整的 URL 补全 | ||
@@ -12,2 +12,2 @@ * @param url 待补全的 url | ||
* @param host 主机名 | ||
*/export function fixRelativeUrl(a,b,c){void 0===b&&(b=location.protocol),void 0===c&&(c=location.host);var d=/^https?:\/\//i.test(a);if(d)return a;var e=/^\/\//i.test(a);if(e)return""+b+a;var f=/^\//i.test(a);return b+"//"+c+(f?"":"/")+a}export function getResourceName(a,b){var c;return c=isFunction(b)?b(a):getPathByURL(a),c} | ||
*/export function fixRelativeUrl(a,b,c){if(void 0===b&&(b=location.protocol),void 0===c&&(c=location.host),!isString(a)||!a)throw new Error("Invalid URL provided");var d=/^https?:\/\//i.test(a);if(d)return a;var e=/^\/\//i.test(a);if(e)return""+b+a;var f=/^\//.test(a);return b+"//"+c+(f?"":"/")+a}export function getResourceName(a,b){var c;return c=isFunction(b)?b(a):getPathByURL(a),c} |
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_url=require("../../utils/url"),_global=require("../../utils/global"),supportsHistory=_global.history&&!!_global.history.pushState&&!!_global.history.replaceState,PvCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="pv-collector",this.ctx=void 0,this.sendEvent=void 0,this.prevUrl=void 0,this.sendPv=function(b,c,d){void 0===d&&(d="route_change");var e=a.getViewName(b),f=a.prevUrl;// 如果两次的view.name相同,判断为没有pv发生 | ||
if(a.prevUrl=b,!(f&&e===a.getViewName(f))){a.ctx.addView({id:a.ctx.session.getViewId(),name:e});var g=a.ctx.session.getBaseEvent();a.sendEvent((0,_extends2["default"])({},g,{event_type:_rumCore.RumEventType.VIEW,type:"pv",name:e,url:b,referrer:c,loading_type:d}))}},this.historyFn=function(){var b=2<arguments.length?2>=arguments.length?void 0:arguments[2]:void 0;if(b){var c=_global.location.origin+b,d=a.prevUrl;a.sendPv(c,d)}},this.popstateFn=function(){var b=(0,_url.getCurrentURL)(),c=a.prevUrl;a.sendPv(b,c)}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.sendPv((0,_url.getCurrentURL)(),_global.document.referrer||"","initial_load");var c=this.getSpaMode();supportsHistory&&c&&((0,_rumCore.interceptFunction)(_global.global.history,"pushState",this.historyFn),(0,_rumCore.interceptFunction)(_global.global.history,"replaceState",this.historyFn),_global.global.addEventListener("popstate",this.popstateFn))},b.getSpaMode=function getSpaMode(){var a=this.ctx.getConfig().spaMode;return(0,_rumCore.isUndefined)(a)&&(a=!0),!!a&&("history"!==a&&"hash"!==a?"history":a)},b.getViewName=function getViewName(a){var b=this.ctx.getConfig(),c=this.getSpaMode(),d=(0,_url.getPathByURL)(a,"hash"===c);return(0,_rumCore.isFunction)(b.parseViewName)&&(d=b.parseViewName(a)),d},b.destroy=function destroy(){supportsHistory&&_global.global.removeEventListener("popstate",this.popstateFn)},a}(); | ||
if(a.prevUrl=b,!(f&&e===a.getViewName(f))){a.ctx.addView({id:a.ctx.session.getViewId(),name:e});var g=a.ctx.session.getBaseEvent();a.sendEvent((0,_extends2["default"])({},g,{event_type:_rumCore.RumEventType.VIEW,type:"pv",name:e,url:b,referrer:c,loading_type:d}))}},this.historyFn=function(){var b=2<arguments.length?2>=arguments.length?void 0:arguments[2]:void 0;if(b){var c=_global.location.origin+b,d=a.prevUrl;a.sendPv(c,d)}},this.popstateFn=function(){var b=(0,_url.getCurrentURL)(),c=a.prevUrl;a.sendPv(b,c)}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.sendPv((0,_url.getCurrentURL)(),_global.document.referrer||"","initial_load");var c=this.getSpaMode();supportsHistory&&c&&((0,_rumCore.interceptFunction)(_global.global.history,"pushState",this.historyFn),(0,_rumCore.interceptFunction)(_global.global.history,"replaceState",this.historyFn),_global.global.addEventListener("popstate",this.popstateFn))},b.getSpaMode=function getSpaMode(){var a=this.ctx.getConfig().spaMode;// if (isUndefined(spaMode)) { | ||
// spaMode = true; | ||
// } | ||
return!!a&&("history"!==a&&"hash"!==a?"auto":a)},b.getViewName=function getViewName(a){var b=this.ctx.getConfig(),c=(0,_url.getPathByURL)(a,this.getSpaMode());return(0,_rumCore.isFunction)(b.parseViewName)&&(c=b.parseViewName(a)),c},b.destroy=function destroy(){supportsHistory&&_global.global.removeEventListener("popstate",this.popstateFn)},a}(); |
import { IConfiguration, ITracingOption } from "@arms/rum-core"; | ||
import { IApiAttr } from "../utils/api"; | ||
import { SpaMode } from "../utils/url"; | ||
export interface IBrowserConfig extends IConfiguration { | ||
@@ -7,3 +8,3 @@ /** | ||
**/ | ||
spaMode?: false | 'hash' | 'history'; | ||
spaMode?: SpaMode; | ||
/** | ||
@@ -10,0 +11,0 @@ * view.name 解析 |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports.location=exports.history=exports.global=exports.document=exports.VERSION=void 0;var global=exports.global=window,document=exports.document=window.document,location=exports.location=window.location,history=exports.history=window.history,VERSION=exports.VERSION='0.0.27-beta.5'; | ||
"use strict";exports.__esModule=!0,exports.location=exports.history=exports.global=exports.document=exports.VERSION=void 0;var global=exports.global=window,document=exports.document=window.document,location=exports.location=window.location,history=exports.history=window.history,VERSION=exports.VERSION='0.0.27-beta.6'; |
@@ -0,1 +1,2 @@ | ||
export type SpaMode = false | true | 'hash' | 'history' | 'auto'; | ||
/** | ||
@@ -6,7 +7,7 @@ * 获取目前的 URL | ||
/** | ||
* 根据指定 URL 获取视图的名称,默认为其path部分 | ||
* 根据指定 URL 获取视图的名称,默认为其 path 部分 | ||
* @param url 需要提取路径部分的 URL | ||
* @param isHash 是否为 hash 模式路由的 URL | ||
* @param spaMode 页面 SPA 路由模式 | ||
*/ | ||
export declare function getPathByURL(url: string, isHash?: boolean): string; | ||
export declare function getPathByURL(url: string, spaMode?: SpaMode): string; | ||
/** | ||
@@ -13,0 +14,0 @@ * 将不完整的 URL 补全 |
"use strict";exports.__esModule=!0,exports.fixRelativeUrl=fixRelativeUrl,exports.getCurrentURL=getCurrentURL,exports.getPathByURL=getPathByURL,exports.getResourceName=getResourceName;var _rumCore=require("@arms/rum-core"),_global=require("./global");/** | ||
* 获取目前的 URL | ||
*/function getCurrentURL(){return _global.location?_global.location.href:""}/** | ||
* 根据指定 URL 获取视图的名称,默认为其path部分 | ||
*/function getCurrentURL(){return _global.location?_global.location.href:""}function getHashPath(a){if(!(0,_rumCore.isString)(a)||!a)return"";var b=a.indexOf("#");0===b&&(a=a.substring(1));var c=a.indexOf("?");return 0<=c&&(a=a.substring(0,c)),a}/** | ||
* 根据指定 URL 获取视图的名称,默认为其 path 部分 | ||
* @param url 需要提取路径部分的 URL | ||
* @param isHash 是否为 hash 模式路由的 URL | ||
*/function getPathByURL(a,b){void 0===b&&(b=!1);try{var c=new URL(fixRelativeUrl(a));if(b){var d=c.hash.replace("#","");return d.replace(/\?.*$/,"")||"/"}return c.pathname||"/"}catch(a){return"[unknown]"}}/** | ||
* @param spaMode 页面 SPA 路由模式 | ||
*/function getPathByURL(a,b){void 0===b&&(b=!1);try{var c=new URL(fixRelativeUrl(a));if("auto"===b||!0===b){var d=getHashPath(c.hash||"");return c.pathname+(d?"#":"")+d}return"hash"===b?getHashPath(c.hash||""):c.pathname||"/"}catch(b){return a}}/** | ||
* 将不完整的 URL 补全 | ||
@@ -12,2 +12,2 @@ * @param url 待补全的 url | ||
* @param host 主机名 | ||
*/function fixRelativeUrl(a,b,c){void 0===b&&(b=_global.location.protocol),void 0===c&&(c=_global.location.host);var d=/^https?:\/\//i.test(a);if(d)return a;var e=/^\/\//i.test(a);if(e)return""+b+a;var f=/^\//i.test(a);return b+"//"+c+(f?"":"/")+a}function getResourceName(a,b){var c;return c=(0,_rumCore.isFunction)(b)?b(a):getPathByURL(a),c} | ||
*/function fixRelativeUrl(a,b,c){if(void 0===b&&(b=_global.location.protocol),void 0===c&&(c=_global.location.host),!(0,_rumCore.isString)(a)||!a)throw new Error("Invalid URL provided");var d=/^https?:\/\//i.test(a);if(d)return a;var e=/^\/\//i.test(a);if(e)return""+b+a;var f=/^\//.test(a);return b+"//"+c+(f?"":"/")+a}function getResourceName(a,b){var c;return c=(0,_rumCore.isFunction)(b)?b(a):getPathByURL(a),c} |
{ | ||
"name": "@arms/rum-browser", | ||
"version": "0.0.27-beta.5", | ||
"version": "0.0.27-beta.6", | ||
"description": "arms rum javascript sdk for browser", | ||
@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
295176
1927