Socket
Socket
Sign inDemoInstall

@mparticle/web-sdk

Package Overview
Dependencies
Maintainers
10
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mparticle/web-sdk - npm Package Compare versions

Comparing version 2.20.2 to 2.20.3

src/forwarders.interfaces.ts

10

package.json
{
"name": "@mparticle/web-sdk",
"version": "2.20.2",
"version": "2.20.3",
"description": "mParticle core SDK for web applications",

@@ -81,3 +81,3 @@ "license": "Apache-2.0",

"@rollup/plugin-typescript": "^8.3.3",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-babel": "6.0.3",
"@rollup/plugin-commonjs": "22.0.2",

@@ -97,4 +97,4 @@ "@rollup/plugin-node-resolve": "13.3.0",

"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "3.4.1",

@@ -121,3 +121,3 @@ "fetch-mock": "^7.5.1",

"tslib": "^2.1.0",
"typescript": "^4.2.4",
"typescript": "^5.0.2",
"uglify-js": "^3.4.9",

@@ -124,0 +124,0 @@ "webpack": "^5.36.2",

@@ -11,3 +11,3 @@ import Constants from './constants';

import KitBlocker from './kitBlocking';
import { Dictionary } from './utils';
import { Dictionary, getRampNumber } from './utils';
import { IUploadObject } from './serverModel';

@@ -71,5 +71,3 @@

const rampNumber = mpInstance._Helpers.getRampNumber(
mpInstance._Store.deviceId
);
const rampNumber = getRampNumber(mpInstance._Store.deviceId);
return eventsV3Percentage >= rampNumber;

@@ -76,0 +74,0 @@ };

@@ -32,4 +32,5 @@ import { DataPlanConfig } from '@mparticle/web-sdk';

attributeFilters: number[];
filteringEventAttributeValue: Dictionary;
filteringConsentRuleValues: Dictionary;
filteringEventAttributeValue: IFilteringAttributeValue;
filteringUserAttributeValue: IFilteringAttributeValue;
filteringConsentRuleValues: IFilteringConsentRulesValue;
consentRegulationFilters: number[];

@@ -43,2 +44,18 @@ consentRegulationPurposeFilters: number[];

export interface IFilteringAttributeValue {
eventAttributeName: string;
eventAttributeValue: string;
includeOnMatch: boolean
}
export interface IFilteringConsentRulesValue {
includeOnMatch: boolean;
values: IConsentRuleValue[];
}
export interface IConsentRuleValue {
consentPurpose: string;
hasConsented: boolean
}
export interface IPixelConfig {

@@ -45,0 +62,0 @@ name: string;

@@ -653,3 +653,3 @@ import Types from './types';

// TODO: isSandbox, hasSandbox is never used in any kit or in core SDK.
// isVisibleInvestigate is only used in 1 place. It is always true if
// isVisible. Investigate is only used in 1 place. It is always true if
// it is sent to JS. Investigate further to determine if these can be removed.

@@ -656,0 +656,0 @@ // https://go.mparticle.com/work/SQDSDKS-5156

@@ -29,13 +29,2 @@ import Types from './types';

/**
* Returns a value between 1-100 inclusive.
*/
this.getRampNumber = function(deviceId) {
if (!deviceId) {
return 100;
}
var hash = self.generateHash(deviceId);
return Math.abs(hash % 100) + 1;
};
this.invokeCallback = function(

@@ -288,35 +277,2 @@ callback,

function generateRandomValue(a) {
var randomValue;
if (window.crypto && window.crypto.getRandomValues) {
randomValue = window.crypto.getRandomValues(new Uint8Array(1)); // eslint-disable-line no-undef
}
if (randomValue) {
return (a ^ (randomValue[0] % 16 >> (a / 4))).toString(16);
}
return (a ^ ((Math.random() * 16) >> (a / 4))).toString(16);
}
this.generateUniqueId = function(a) {
// https://gist.github.com/jed/982883
// Added support for crypto for better random
return a // if the placeholder was passed, return
? generateRandomValue(a) // a random number
: // or otherwise a concatenated string:
(
[1e7] + // 10000000 +
-1e3 + // -1000 +
-4e3 + // -4000 +
-8e3 + // -80000000 +
-1e11
) // -100000000000,
.replace(
// replacing
/[018]/g, // zeroes, ones, and eights with
self.generateUniqueId // random hex digits
);
};
this.filterUserIdentities = function(userIdentitiesObject, filterList) {

@@ -408,33 +364,2 @@ var filteredUserIdentities = [];

this.generateHash = function(name) {
var hash = 0,
i = 0,
character;
if (name === undefined || name === null) {
return 0;
}
name = name.toString().toLowerCase();
if (Array.prototype.reduce) {
return name.split('').reduce(function(a, b) {
a = (a << 5) - a + b.charCodeAt(0);
return a & a;
}, 0);
}
if (name.length === 0) {
return hash;
}
for (i = 0; i < name.length; i++) {
character = name.charCodeAt(i);
hash = (hash << 5) - hash + character;
hash = hash & hash;
}
return hash;
};
this.sanitizeAttributes = function(attrs, name) {

@@ -507,2 +432,4 @@ if (!attrs || !self.isObject(attrs)) {

// TODO: Refactor SDK to directly use these methods
// https://go.mparticle.com/work/SQDSDKS-5239
// Utility Functions

@@ -517,2 +444,4 @@ this.converted = utils.converted;

this.parseStringOrNumber = utils.parseStringOrNumber;
this.generateHash = utils.generateHash;
this.generateUniqueId = utils.generateUniqueId;

@@ -519,0 +448,0 @@ // Imported Validators

@@ -235,3 +235,2 @@ import * as EventsApi from '@mparticle/event-models';

getFeatureFlag?(feature: string); // TODO: Feature Constants should be converted to enum
getRampNumber?(deviceId: string): number;
isDelayedByIntegration?(

@@ -238,0 +237,0 @@ delayedIntegrations: Dictionary<boolean>,

@@ -39,2 +39,77 @@ import slugify from 'slugify';

function generateHash(name: string): number {
let hash: number = 0;
let character: number;
if (name === undefined || name === null) {
return 0;
}
name = name.toString().toLowerCase();
if (Array.prototype.reduce) {
return name.split('').reduce(function (a: number, b: string) {
a = (a << 5) - a + b.charCodeAt(0);
return a & a;
}, 0);
}
if (name.length === 0) {
return hash;
}
for (let i = 0; i < name.length; i++) {
character = name.charCodeAt(i);
hash = (hash << 5) - hash + character;
hash = hash & hash;
}
return hash;
}
const generateRandomValue = (value?: string): string => {
let randomValue: string;
let a: number;
if (window.crypto && window.crypto.getRandomValues) {
// @ts-ignore
randomValue = window.crypto.getRandomValues(new Uint8Array(1)); // eslint-disable-line no-undef
}
if (randomValue) {
// @ts-ignore
return (a ^ (randomValue[0] % 16 >> (a / 4))).toString(16);
}
return (a ^ ((Math.random() * 16) >> (a / 4))).toString(16);
};
const generateUniqueId = (a: string = ''): string =>
// https://gist.github.com/jed/982883
// Added support for crypto for better random
a // if the placeholder was passed, return
? generateRandomValue(a) // if the placeholder was passed, return
: // [1e7] -> // 10000000 +
// -1e3 -> // -1000 +
// -4e3 -> // -4000 +
// -8e3 -> // -80000000 +
// -1e11 -> //-100000000000,
`${1e7}-${1e3}-${4e3}-${8e3}-${1e11}`.replace(
/[018]/g, // zeroes, ones, and eights with
generateUniqueId // random hex digits
);
/**
* Returns a value between 1-100 inclusive.
*/
const getRampNumber = (value?: string): number => {
if (!value) {
return 100;
}
const hash = generateHash(value);
return Math.abs(hash % 100) + 1;
};
const isObject = (value: any): boolean => {

@@ -80,6 +155,3 @@ var objType = Object.prototype.toString.call(value);

if (s.indexOf('"') === 0) {
s = s
.slice(1, -1)
.replace(/\\"/g, '"')
.replace(/\\\\/g, '\\');
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

@@ -109,2 +181,5 @@

findKeyInObject,
generateHash,
generateUniqueId,
getRampNumber,
inArray,

@@ -111,0 +186,0 @@ isObject,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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