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

@arms/rum-core

Package Overview
Dependencies
Maintainers
0
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.25-beta.19 to 0.0.25-beta.20

lib/utils/verify.d.ts

1

lib/index.d.ts

@@ -17,2 +17,3 @@ import Client from './model/client';

export * from './utils/trace';
export * from './utils/verify';
export { Client, Context, Reporter, Shell };

@@ -102,2 +102,9 @@ "use strict";

exports[key] = _trace[key];
});
var _verify = require("./utils/verify");
Object.keys(_verify).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _verify[key]) return;
exports[key] = _verify[key];
});

2

lib/model/context.js

@@ -13,3 +13,3 @@ "use strict";

this.session = rumSession;
this.session.init(config);
this.session.init(this);
}

@@ -16,0 +16,0 @@ }

import { IContext } from '../types/client';
import { RumEvent, IViewData } from '../types/rum-event';
import { RumEvent, IViewData, RumEventBundle } from '../types/rum-event';
export default abstract class Reporter {

@@ -22,6 +22,7 @@ name: string;

protected flushEventQueue(): void;
mergeEvent(ctx: IContext, events: RumEvent[], view: IViewData): void;
/**
* 接口请求由各平台 sdk reporter 实现
*/
abstract request(ctx: IContext, events: RumEvent[], view: IViewData): void;
abstract request(ctx: IContext, bundle: RumEventBundle): void;
/**

@@ -28,0 +29,0 @@ * 初始化时

@@ -8,4 +8,6 @@ "use strict";

var _is = require("../utils/is");
var _verify = require("../utils/verify");
var FLUSH_TIME = 3000;
var MAX_EVENT_COUNT = 20;
var attrs = ['app', 'user', 'device', 'os', 'geo', 'isp', 'net', 'attributes'];
var Reporter = exports["default"] = /*#__PURE__*/function () {

@@ -112,7 +114,7 @@ function Reporter() {

if (view.id === curView.id) {
var _events = eventQueue.filter(function (event) {
var events = eventQueue.filter(function (event) {
var _event$view;
return ((_event$view = event.view) === null || _event$view === void 0 ? void 0 : _event$view.id) === view.id;
});
_events.forEach(function (event) {
events.forEach(function (event) {
delete event.view;

@@ -124,6 +126,62 @@ });

var sampled = session ? session.getSampled() : true;
sampled && this.request(ctx, eventQueue, curView);
sampled && this.mergeEvent(ctx, eventQueue, curView);
this.eventQueue = [];
};
_proto.mergeEvent = function mergeEvent(ctx, events, view) {
var _config$net;
var config = ctx.getConfig();
var session = ctx.session;
var sessionId = session.getSessionId();
events.forEach(function (event) {
if (event.session_id === sessionId) {
delete event.session_id;
}
});
var bundle = {
app: {
id: config.pid,
env: config.env || 'prod',
version: config.version,
type: ''
},
user: {
id: session.getUserId()
},
session: {
id: sessionId
},
net: {
model: (_config$net = config.net) === null || _config$net === void 0 ? void 0 : _config$net.model
},
view: view,
events: events
};
attrs.forEach(function (key) {
var obj = config[key];
(0, _is.isObject)(obj) && Object.keys(obj).forEach(function (k) {
var val = obj[k];
// user 的 id 不能被覆盖
if (key === 'user' && k === 'id') return;
if (key === 'attributes') {
bundle[key] = (0, _verify.verifyAttributes)(obj);
} else if ((0, _is.isString)(val) || (0, _is.isNumber)(val)) {
if (!(key in bundle)) {
bundle[key] = {};
}
bundle[key][k] = val;
}
});
});
if (typeof config.beforeReport === 'function') {
bundle = config.beforeReport(bundle);
if (!bundle) return;
}
this.request(ctx, bundle);
}
// /**
// * 接口请求由各平台 sdk reporter 实现
// */
// abstract request(ctx: IContext, events: RumEvent[], view: IViewData): void;
/**

@@ -130,0 +188,0 @@ * 接口请求由各平台 sdk reporter 实现

@@ -39,3 +39,3 @@ import { ICollector } from './collector';

export interface IRumSession {
init(config: IConfiguration): void;
init(ctx: IContext): void;
sessionConfig: SessionConfig;

@@ -48,2 +48,3 @@ getSessionId: () => string;

getUserId: () => string;
getBaseEvent: () => any;
}

@@ -50,0 +51,0 @@ export interface IClient {

import { IContext } from './client';
import { RumEvent, IViewData } from './rum-event';
import { RumEventBundle } from './rum-event';
export interface IReporter {
name: string;
init(ctx: IContext): void;
request(ctx: IContext, events: RumEvent[], view: IViewData): void;
request(ctx: IContext, bundle: RumEventBundle): void;
report(ctx: IContext): void;
}

@@ -19,3 +19,3 @@ export declare enum RumEventType {

export type BaseObjectValue = BaseObjectPrimitiveValue | BaseObject | BaseObjectPrimitiveValue[] | IViewData;
export interface RumBaseEvent {
export interface RumBaseEvent extends BaseObject {
event_type?: RumEventType;

@@ -28,3 +28,3 @@ event_id?: string;

snapshots?: string;
[key: string]: BaseObjectValue;
attributes?: BaseObject;
}

@@ -122,3 +122,3 @@ export interface RumViewEvent extends RumBaseEvent {

id: string;
type: AppType;
type: AppType | string;
name?: string;

@@ -172,3 +172,4 @@ version?: string;

events: Array<RumEvent>;
_v: string;
attributes?: BaseObject;
_v?: string;
}
{
"name": "@arms/rum-core",
"version": "0.0.25-beta.19",
"version": "0.0.25-beta.20",
"description": "arms rum javascript sdk core",

@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>",

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