Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arms/rum-core

Package Overview
Dependencies
Maintainers
5
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arms/rum-core - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

6

lib/model/reporter.d.ts

@@ -12,4 +12,6 @@ import { IContext } from '../types/client';

private timer;
private FLUSH_TIME;
private MAX_EVENT_COUNT;
getReportCfg(): {
flushTime?: number;
maxEventCount?: number;
};
report(ctx: IContext): void;

@@ -16,0 +18,0 @@ private pushToQueue;

@@ -7,2 +7,5 @@ "use strict";

var _exception = require("../utils/exception");
var _is = require("../utils/is");
var FLUSH_TIME = 3000;
var MAX_EVENT_COUNT = 50;
var Reporter = exports["default"] = /*#__PURE__*/function () {

@@ -18,6 +21,17 @@ function Reporter() {

this.timer = void 0;
this.FLUSH_TIME = 3000;
this.MAX_EVENT_COUNT = 50;
}
var _proto = Reporter.prototype;
_proto.getReportCfg = function getReportCfg() {
var cfg = this.ctx.getConfig().reportConfig;
if (!(0, _is.isObject)(cfg)) {
cfg = {};
}
if (!cfg.flushTime || cfg.flushTime < 0 || cfg.flushTime > 10000) {
cfg.flushTime = FLUSH_TIME;
}
if (!cfg.maxEventCount || cfg.maxEventCount < 0 || cfg.maxEventCount > 100) {
cfg.maxEventCount = MAX_EVENT_COUNT;
}
return cfg;
};
_proto.report = function report(ctx) {

@@ -29,5 +43,5 @@ var _this = this;

this.pushToQueue();
var reportConfig = this.getReportCfg();
// 超过 MaxCount 直接 flush,否则延迟发送
if (this.eventQueue.length >= this.MAX_EVENT_COUNT) {
if (this.eventQueue.length >= reportConfig.maxEventCount) {
this.flushEventQueue();

@@ -37,3 +51,3 @@ } else {

_this.flushEventQueue();
}, this.FLUSH_TIME);
}, reportConfig.flushTime);
}

@@ -40,0 +54,0 @@ };

@@ -91,2 +91,9 @@ import { ICollector } from './collector';

/**
* reporter 发送节奏配置
*/
reportConfig?: {
flushTime?: number;
maxEventCount?: number;
};
/**
* 各个 collector config

@@ -93,0 +100,0 @@ */

@@ -7,7 +7,5 @@ /**

* @description: GUID v4
* @from https://gist.github.com/jed/982883
* @param placeholder {String}
* @return {String}
*/
export declare function generateGUID(placeholder?: string): string;
export declare function generateGUID(): string;
/**

@@ -14,0 +12,0 @@ * @description: 唯一的字符串 universe unique id

@@ -25,10 +25,16 @@ "use strict";

* @description: GUID v4
* @from https://gist.github.com/jed/982883
* @param placeholder {String}
* @return {String}
*/
function generateGUID(placeholder) {
return placeholder ?
// eslint-disable-next-line no-bitwise
(parseInt(placeholder, 10) ^ Math.random() * 16 >> parseInt(placeholder, 10) / 4).toString(16) : (1e7 + "-" + 1e3 + "-" + 4e3 + "-" + 8e3 + "-" + 1e11).replace(/[018]/g, generateGUID);
function generateGUID() {
try {
if (crypto && crypto.randomUUID) {
return crypto.randomUUID();
}
} catch (e) {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
}
}

@@ -35,0 +41,0 @@

@@ -11,1 +11,3 @@ export type IsFnHelper<T = unknown> = (value: unknown) => value is T;

export declare const isNumber: IsFnHelper<number | bigint>;
export declare const isNull: IsFnHelper<null>;
export declare const isObject: IsFnHelper<object>;
"use strict";
exports.__esModule = true;
exports.isString = exports.isRegExp = exports.isNumber = exports.isFunction = exports.isBoolean = exports.isArray = void 0;
exports.isString = exports.isRegExp = exports.isObject = exports.isNumber = exports.isNull = exports.isFunction = exports.isBoolean = exports.isArray = void 0;
exports.isToString = isToString;

@@ -34,2 +34,8 @@ exports.isTypeof = isTypeof;

return isTypeof(value, 'number') && !isNaN(value) || isTypeof(value, 'bigint');
};
var isNull = exports.isNull = function isNull(value) {
return isTypeof(value, 'null');
};
var isObject = exports.isObject = function isObject(value) {
return !isNull(value) && isTypeof(value, 'object');
};

@@ -15,4 +15,4 @@ import { MatchOption } from "./match";

}
export declare function generateTraceId(): any;
export declare function generateSpanId(): any;
export declare function generateTraceId(): string;
export declare function generateSpanId(): string;
export interface ITracingHeaders {

@@ -19,0 +19,0 @@ [key: string]: string;

@@ -12,20 +12,11 @@ "use strict";

var _is = require("./is");
var SPAN_ID_BYTES = 8;
var TRACE_ID_BYTES = 16;
var SHARED_CHAR_CODES_ARRAY = Array(32);
var _base = require("./base");
function isTraceOption(option) {
return option && (0, _match.isMatchOption)(option.match) && (0, _is.isArray)(option.propagatorTypes);
}
function generateId(bytes) {
for (var i = 0; i < bytes * 2; i++) {
SHARED_CHAR_CODES_ARRAY[i] = Math.floor(Math.random() * 16) + 48;
// valid hex characters in the range 48-57 and 97-102
if (SHARED_CHAR_CODES_ARRAY[i] >= 58) {
SHARED_CHAR_CODES_ARRAY[i] += 39;
}
}
return String.fromCharCode.apply(null, SHARED_CHAR_CODES_ARRAY.slice(0, bytes * 2));
function generateId() {
return (0, _base.generateGUID)().replace(/-/g, '');
}
function generateTraceId() {
var traceId = generateId(TRACE_ID_BYTES);
var traceId = generateId();
// 适配OpenTracing 实现(long long转成16进制最高位不能为0)

@@ -41,3 +32,3 @@ if (traceId[0] === '0') {

function generateSpanId() {
return generateId(SPAN_ID_BYTES);
return (0, _base.generateUUID)(8);
}

@@ -44,0 +35,0 @@ //skywalking TraceId https://github.com/apache/skywalking-client-js

{
"name": "@arms/rum-core",
"version": "0.0.17",
"version": "0.0.18",
"description": "arms rum javascript sdk core",

@@ -21,2 +21,3 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>",

"build": "build-scripts build --skip-demo",
"prepublishOnly": "npm run build",
"test": "node ./__tests__/@arms/core.test.js"

@@ -23,0 +24,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc