New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@arcxmoney/analytics

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcxmoney/analytics - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

index.html

26

dist/esm/src/ArcxAnalyticsSdk.js

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,7 +10,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArcxAnalyticsSdk = void 0;
const sanitizers_1 = require("@restless/sanitizers");
const constants_1 = require("./constants");
class ArcxAnalyticsSdk {
import { cast, asString } from '@restless/sanitizers';
import { CONNECT_EVENT, DEFAULT_SDK_CONFIG, IDENTITY_KEY, PAGE_EVENT, PROD_URL_BACKEND, TRANSACTION_EVENT } from './constants';
export class ArcxAnalyticsSdk {
constructor(apiKey, identityId, arcxUrl, sdkConfig) {

@@ -38,7 +35,7 @@ this.apiKey = apiKey;

}
static init(apiKey, config, arcxUrl = constants_1.PROD_URL_BACKEND) {
static init(apiKey, config, arcxUrl = PROD_URL_BACKEND) {
return __awaiter(this, void 0, void 0, function* () {
const sdkConfig = Object.assign(Object.assign({}, constants_1.DEFAULT_SDK_CONFIG), config);
const identityId = ((sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.cacheIdentity) && localStorage.getItem(constants_1.IDENTITY_KEY)) || (yield this.postAnalytics(arcxUrl, apiKey, '/identify'));
(sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.cacheIdentity) && localStorage.setItem(constants_1.IDENTITY_KEY, identityId);
const sdkConfig = Object.assign(Object.assign({}, DEFAULT_SDK_CONFIG), config);
const identityId = ((sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.cacheIdentity) && localStorage.getItem(IDENTITY_KEY)) || (yield this.postAnalytics(arcxUrl, apiKey, '/identify'));
(sdkConfig === null || sdkConfig === void 0 ? void 0 : sdkConfig.cacheIdentity) && localStorage.setItem(IDENTITY_KEY, identityId);
return new ArcxAnalyticsSdk(apiKey, identityId, arcxUrl, sdkConfig);

@@ -55,6 +52,6 @@ });

page(attributes) {
return this.event(constants_1.PAGE_EVENT, attributes);
return this.event(PAGE_EVENT, attributes);
}
connectWallet(attributes) {
return this.event(constants_1.CONNECT_EVENT, attributes);
return this.event(CONNECT_EVENT, attributes);
}

@@ -66,3 +63,3 @@ transaction(transactionType, transactionHash, attributes) {

}
return this.event(constants_1.TRANSACTION_EVENT, _attributes);
return this.event(TRANSACTION_EVENT, _attributes);
}

@@ -81,7 +78,6 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

const body = yield response.json();
return (0, sanitizers_1.cast)(body, sanitizers_1.asString);
return cast(body, asString);
});
}
}
exports.ArcxAnalyticsSdk = ArcxAnalyticsSdk;
//# sourceMappingURL=ArcxAnalyticsSdk.js.map

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IDENTITY_KEY = exports.DEFAULT_SDK_CONFIG = void 0;
exports.DEFAULT_SDK_CONFIG = {
export const DEFAULT_SDK_CONFIG = {
trackPages: true,
cacheIdentity: true,
};
exports.IDENTITY_KEY = 'identity';
export const IDENTITY_KEY = 'identity';
//# sourceMappingURL=config.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRANSACTION_EVENT = exports.CONNECT_EVENT = exports.PAGE_EVENT = void 0;
exports.PAGE_EVENT = 'PAGE';
exports.CONNECT_EVENT = 'CONNECT';
exports.TRANSACTION_EVENT = 'TRANSACTION_SUBMITTED';
export const PAGE_EVENT = 'PAGE';
export const CONNECT_EVENT = 'CONNECT';
export const TRANSACTION_EVENT = 'TRANSACTION_SUBMITTED';
//# sourceMappingURL=events.js.map

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./config"), exports);
__exportStar(require("./events"), exports);
__exportStar(require("./urls"), exports);
export * from './config';
export * from './events';
export * from './urls';
//# sourceMappingURL=index.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PROD_URL_BACKEND = void 0;
exports.PROD_URL_BACKEND = 'https://api.arcx.money/v1';
export const PROD_URL_BACKEND = 'https://api.arcx.money/v1';
//# sourceMappingURL=urls.js.map

@@ -1,19 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ArcxAnalyticsSdk"), exports);
__exportStar(require("./types"), exports);
export * from './ArcxAnalyticsSdk';
export * from './types';
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=types.js.map

@@ -1,2 +0,1 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,10 +10,6 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const src_1 = require("../src");
const sinon_1 = __importDefault(require("sinon"));
const chai_1 = require("chai");
const constants_1 = require("../src/constants");
import { ArcxAnalyticsSdk } from '../src';
import sinon from 'sinon';
import { expect } from 'chai';
import { CONNECT_EVENT, PAGE_EVENT, PROD_URL_BACKEND, TRANSACTION_EVENT } from '../src/constants';
const TEST_CONFIG = {

@@ -34,25 +29,25 @@ trackPages: false,

beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
postAnalyticsStub = sinon_1.default.stub(src_1.ArcxAnalyticsSdk, 'postAnalytics').resolves(TEST_IDENTITY);
analyticsSdk = yield src_1.ArcxAnalyticsSdk.init(TEST_API_KEY, TEST_CONFIG);
postAnalyticsStub = sinon.stub(ArcxAnalyticsSdk, 'postAnalytics').resolves(TEST_IDENTITY);
analyticsSdk = yield ArcxAnalyticsSdk.init(TEST_API_KEY, TEST_CONFIG);
postAnalyticsStub.resetHistory();
}));
it('#init', () => __awaiter(void 0, void 0, void 0, function* () {
yield src_1.ArcxAnalyticsSdk.init('', TEST_CONFIG);
(0, chai_1.expect)(postAnalyticsStub.calledOnce).to.be.true;
yield ArcxAnalyticsSdk.init('', TEST_CONFIG);
expect(postAnalyticsStub.calledOnce).to.be.true;
}));
it('#event', () => __awaiter(void 0, void 0, void 0, function* () {
yield analyticsSdk.event('TEST_EVENT', TEST_ATTRIBUTES);
(0, chai_1.expect)(postAnalyticsStub.calledOnceWith(constants_1.PROD_URL_BACKEND, TEST_API_KEY, '/submit-event', getAnalyticsData('TEST_EVENT', TEST_ATTRIBUTES))).to.be.true;
expect(postAnalyticsStub.calledOnceWith(PROD_URL_BACKEND, TEST_API_KEY, '/submit-event', getAnalyticsData('TEST_EVENT', TEST_ATTRIBUTES))).to.be.true;
}));
it('#page', () => __awaiter(void 0, void 0, void 0, function* () {
const pageAttributes = { url: 'page.test' };
const eventStub = sinon_1.default.stub(analyticsSdk, 'event');
const eventStub = sinon.stub(analyticsSdk, 'event');
yield analyticsSdk.page(pageAttributes);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.PAGE_EVENT, pageAttributes)).to.be.true;
expect(eventStub.calledOnceWith(PAGE_EVENT, pageAttributes)).to.be.true;
}));
it('#connectWallet', () => __awaiter(void 0, void 0, void 0, function* () {
const attributes = { account: '0x12354', chain: '1' };
const eventStub = sinon_1.default.stub(analyticsSdk, 'event');
const eventStub = sinon.stub(analyticsSdk, 'event');
yield analyticsSdk.connectWallet(attributes);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.CONNECT_EVENT, attributes)).to.be.true;
expect(eventStub.calledOnceWith(CONNECT_EVENT, attributes)).to.be.true;
}));

@@ -65,11 +60,11 @@ describe('#transaction', () => __awaiter(void 0, void 0, void 0, function* () {

beforeEach(() => {
eventStub = sinon_1.default.stub(analyticsSdk, 'event');
eventStub = sinon.stub(analyticsSdk, 'event');
});
it('all parameters are passed', () => __awaiter(void 0, void 0, void 0, function* () {
yield analyticsSdk.transaction(transactionType, transactionHash, attributes);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.TRANSACTION_EVENT, Object.assign({ type: transactionType, transaction_hash: transactionHash }, attributes))).to.be.true;
expect(eventStub.calledOnceWith(TRANSACTION_EVENT, Object.assign({ type: transactionType, transaction_hash: transactionHash }, attributes))).to.be.true;
}));
it('none optional parameters are passed', () => __awaiter(void 0, void 0, void 0, function* () {
yield analyticsSdk.transaction(transactionType);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.TRANSACTION_EVENT, {
expect(eventStub.calledOnceWith(TRANSACTION_EVENT, {
type: transactionType,

@@ -80,3 +75,3 @@ })).to.be.true;

yield analyticsSdk.transaction(transactionType, transactionHash);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.TRANSACTION_EVENT, {
expect(eventStub.calledOnceWith(TRANSACTION_EVENT, {
type: transactionType,

@@ -88,7 +83,7 @@ transaction_hash: transactionHash,

yield analyticsSdk.transaction(transactionType, undefined, attributes);
(0, chai_1.expect)(eventStub.calledOnceWith(constants_1.TRANSACTION_EVENT, Object.assign({ type: transactionType }, attributes))).to.be.true;
expect(eventStub.calledOnceWith(TRANSACTION_EVENT, Object.assign({ type: transactionType }, attributes))).to.be.true;
}));
}));
afterEach(() => {
sinon_1.default.restore();
sinon.restore();
});

@@ -95,0 +90,0 @@ });

{
"name": "@arcxmoney/analytics",
"version": "0.0.8",
"version": "0.0.9",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -10,3 +10,2 @@ {

"strict": true,
"module": "commonjs",
"target": "es6",

@@ -13,0 +12,0 @@ "moduleResolution": "node",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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