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

@ombori/grid-signals

Package Overview
Dependencies
Maintainers
18
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ombori/grid-signals - npm Package Compare versions

Comparing version 2.133.0 to 2.135.3

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## [2.135.3](https://github.com/ombori/gridapp/compare/v2.135.2...v2.135.3) (2021-12-10)
### Bug Fixes
* comments and new features ([4b3c621](https://github.com/ombori/gridapp/commit/4b3c6212fe9e50521edb9e495d08307174e797f5))
* init params validation ([a6529c5](https://github.com/ombori/gridapp/commit/a6529c59b57841085e65802e2632ad0b0b13deb2))
# [2.133.0](https://github.com/ombori/gridapp/compare/v2.132.2...v2.133.0) (2021-12-09)

@@ -8,0 +20,0 @@

2

dist/api/get-base-url.d.ts

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

declare const getBaseUrl: (dataResidency: string) => "https://analytics-qa.omborigrid.com/api" | "https://session-au.omborigrid.com/api" | "https://session-eu.omborigrid.com/api" | "https://session-in.omborigrid.com/api" | "https://session-uea.omborigrid.com/api" | "https://session-us.omborigrid.com/api";
declare const getBaseUrl: (dataResidency: string) => string;
export default getBaseUrl;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../types");
const { NODE_ENV, GRID_SIGNALS_API, REACT_APP_GRID_SIGNALS_API } = process.env;
const getBaseUrl = (dataResidency) => {
if (process.env.NODE_ENV === 'development') {
if (GRID_SIGNALS_API) {
return GRID_SIGNALS_API;
}
if (REACT_APP_GRID_SIGNALS_API) {
return REACT_APP_GRID_SIGNALS_API;
}
if (NODE_ENV === 'development') {
return 'https://analytics-qa.omborigrid.com/api';

@@ -7,0 +14,0 @@ }

import { Session, Event, Client, DataRequestTypeEnum } from '../types';
export declare const sendEvent: (event: Event) => Promise<void>;
export declare const sendSession: (session: Session) => Promise<void>;
export declare const sendClient: (client: Client) => Promise<void>;
export declare const getCallbackSendFunction: (requestType: DataRequestTypeEnum) => ((event: Event) => Promise<void>) | ((session: Session) => Promise<void>) | ((client: Client) => Promise<void>) | null;
export declare const sendEvent: (event: Event) => Promise<any>;
export declare const sendSession: (session: Session) => Promise<any>;
export declare const sendClient: (client: Client) => Promise<any>;
export declare const getCallbackSendFunction: (requestType: DataRequestTypeEnum) => ((event: Event) => Promise<any>) | ((session: Session) => Promise<any>) | ((client: Client) => Promise<any>) | null;

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

})
.then((res) => (res.status === 200 ? Promise.resolve() : Promise.reject()));
.then((res) => (res.status === 200 ? Promise.resolve(res.data) : Promise.reject()));
};

@@ -26,0 +26,0 @@ exports.sendEvent = (event) => {

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

export declare const MESSAGE_PREFIX = "@ombori/grid-session-manager:";
export declare const MESSAGE_PREFIX = "@ombori/grid-signals:";
export declare const EVENTS_CACHE_KEY = "_OMBORI_GRID_SIGNALS_EVENTS_CACHE";

@@ -3,0 +3,0 @@ export declare const CLIENT_CACHE_KEY = "_OMBORI_GRID_SIGNALS_CLIENT_CACHE";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.INIT_NOT_CALLED = exports.INIT_ONCE_ERROR_MESSAGE = exports.TRACK_EVENT_ERROR_INIT_MESSAGE = exports.CREATE_SESSION_ERROR_INIT_MESSAGE = exports.CLIENT_CACHE_KEY = exports.EVENTS_CACHE_KEY = exports.MESSAGE_PREFIX = void 0;
exports.MESSAGE_PREFIX = '@ombori/grid-session-manager:';
exports.MESSAGE_PREFIX = '@ombori/grid-signals:';
exports.EVENTS_CACHE_KEY = '_OMBORI_GRID_SIGNALS_EVENTS_CACHE';

@@ -6,0 +6,0 @@ exports.CLIENT_CACHE_KEY = '_OMBORI_GRID_SIGNALS_CLIENT_CACHE';

@@ -5,4 +5,4 @@ import { TrackEvent, InitProps, Instance, IdentityTypeEnum } from './types';

constructor(initParams?: InitProps);
init: (initParams: InitProps) => Promise<void[] | undefined>;
createSession: () => Promise<void>;
init: (initParams: InitProps) => Promise<any[] | undefined>;
createSession: () => Promise<any>;
getInstanceState: () => Instance;

@@ -14,3 +14,3 @@ private sendOrCacheData;

*/
sendCustomEvent: (event: TrackEvent) => Promise<void>;
sendCustomEvent: (event: TrackEvent) => Promise<any>;
/**

@@ -24,3 +24,3 @@ * Identifying the user based on a known identifyer

customIdentityType?: string | undefined;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -33,3 +33,3 @@ * Identifying the customer based on a known identifyer

str2: string;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -43,3 +43,3 @@ * Information about the user, return from computer vision or selected by a user in the UI

certainty: number;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -54,3 +54,3 @@ * Information about the user, returned from computer vision, 3rd party services, or selected by a user in the UI

ageRange: number;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -65,3 +65,3 @@ * Information about the user, returned from computer vision, 3rd party services, or selected by a user in the UI

certainty: number;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -72,3 +72,3 @@ * Browsing products under a category

categoryId: string;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -79,3 +79,3 @@ * Viewing a specific product page

productId: string;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -86,3 +86,3 @@ * Viewing a specific fashion look, which is an array of products

lookId: string;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -94,7 +94,7 @@ * Adding a product to the cart

quantity: number;
}) => Promise<void>;
}) => Promise<any>;
/**
* Viewing the cart page
*/
sendCartView: () => Promise<void>;
sendCartView: () => Promise<any>;
/**

@@ -106,11 +106,11 @@ * Removing a product from the cart

quantity: number;
}) => Promise<void>;
}) => Promise<any>;
/**
* Clear the cart
*/
sendCartClear: () => Promise<void>;
sendCartClear: () => Promise<any>;
/**
* Checkout step before payment
*/
sendCheckout: () => Promise<void>;
sendCheckout: () => Promise<any>;
/**

@@ -126,3 +126,3 @@ * Payment success

coupon?: string | undefined;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -139,3 +139,3 @@ * Everytime gridapp loads

localizedTitle?: string | undefined;
}) => Promise<void>;
}) => Promise<any>;
/**

@@ -146,7 +146,7 @@ * Searching a product, category, or anything in the app

searchQueryString: string;
}) => Promise<void>;
}) => Promise<any>;
/**
* Searching a product, category, or anything in the app
*/
sendSearchClear: () => Promise<void>;
sendSearchClear: () => Promise<any>;
/**

@@ -159,4 +159,4 @@ * User's rate of the experience

comment: string;
}) => Promise<void>;
sendQrScan: () => Promise<void>;
}) => Promise<any>;
sendQrScan: () => Promise<any>;
/**

@@ -169,3 +169,3 @@ * Setting state key, value and expiry duration (in ms)

expiryDuration: number;
}) => Promise<void>;
}) => Promise<any>;
getSessionState: () => Promise<import("./types").GetSessionStateResponse>;

@@ -172,0 +172,0 @@ getSpaceState: () => Promise<import("./types").GetSpaceStateResponse>;

@@ -44,5 +44,5 @@ "use strict";

appId: '',
appVersion: '',
appVersion: undefined,
installationId: '',
installationVersion: '',
installationVersion: undefined,
deviceId: null,

@@ -64,2 +64,8 @@ clientId: null,

else {
const missingParams = instance_helper_1.getMissingRequiredInstanceParams(initParams);
if (missingParams.length) {
const errorMessage = `${constants_1.MESSAGE_PREFIX} missing or invalid init params ${missingParams.join(', ')}`;
console.error(errorMessage);
throw new Error(errorMessage);
}
this.instance = Object.assign(Object.assign({}, this.instance), initParams);

@@ -118,6 +124,7 @@ const clientInfo = get_client_id_1.default(this.instance);

}
yield sendFunction(data);
const response = yield sendFunction(data);
if (this.instance.clientUserAgent && cache_1.cache && cache_1.cache.length) {
cache_1.flushCacheOnce(this.sendOrCacheData);
}
return response;
}

@@ -124,0 +131,0 @@ catch (err) {

@@ -71,5 +71,5 @@ export declare enum DataResidencyEnum {

appId: string;
appVersion: string;
appVersion?: string;
installationId: string;
installationVersion: string;
installationVersion?: string;
deviceId?: string | null;

@@ -76,0 +76,0 @@ clientId: string | null;

@@ -14,8 +14,9 @@ import { Instance } from '../types';

appId: string;
appVersion: string;
appVersion: string | undefined;
installationId: string;
installationVersion: string;
installationVersion: string | undefined;
deviceId: string | null | undefined;
clientId: string | null;
};
export declare const getMissingRequiredInstanceParams: (initParams: Partial<Instance>) => string[];
export declare const isInstanceInitialized: (instance: Instance) => boolean;

@@ -35,5 +36,5 @@ declare const _default: {

appId: string;
appVersion: string;
appVersion: string | undefined;
installationId: string;
installationVersion: string;
installationVersion: string | undefined;
deviceId: string | null | undefined;

@@ -40,0 +41,0 @@ clientId: string | null;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInstanceInitialized = exports.getSessionFromInstance = void 0;
exports.isInstanceInitialized = exports.getMissingRequiredInstanceParams = exports.getSessionFromInstance = void 0;
exports.getSessionFromInstance = (instance) => ({

@@ -22,11 +22,17 @@ tenantId: instance.tenantId,

});
exports.getMissingRequiredInstanceParams = (initParams) => {
const requiredFields = [
'tenantId',
'environment',
'dataResidency',
'country',
'appId',
'installationId',
];
const missingParams = requiredFields.filter((field) => !initParams[field]);
return missingParams;
};
exports.isInstanceInitialized = (instance) => {
return !!(instance.tenantId &&
instance.environment &&
instance.dataResidency &&
instance.country &&
instance.appId &&
instance.appVersion &&
instance.installationId &&
instance.installationVersion);
const missingParams = exports.getMissingRequiredInstanceParams(instance);
return missingParams.length === 0;
};

@@ -33,0 +39,0 @@ exports.default = {

{
"name": "@ombori/grid-signals",
"version": "2.133.0",
"version": "2.135.3",
"main": "dist/index.js",

@@ -32,3 +32,3 @@ "scripts": {

},
"gitHead": "0f4b5c74d72a6af1ba33c454b25ae5915fdc9cb7"
"gitHead": "ea37989d64a84efc9ddab462b1a5f584f4257059"
}
import { DataResidencyEnum } from '../types';
const { NODE_ENV, GRID_SIGNALS_API, REACT_APP_GRID_SIGNALS_API } = process.env;
const getBaseUrl = (dataResidency: string) => {
if (process.env.NODE_ENV === 'development') {
if (GRID_SIGNALS_API) {
return GRID_SIGNALS_API;
}
if (REACT_APP_GRID_SIGNALS_API) {
return REACT_APP_GRID_SIGNALS_API;
}
if (NODE_ENV === 'development') {
return 'https://analytics-qa.omborigrid.com/api';

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

import axios from 'axios';
import getBaseUrl from './get-base-url';
import { Session, Event, Client, RequestData, DataRequestTypeEnum } from '../types';
import { omitBy, isNil } from 'lodash';
import {
Session,
Event,
Client,
RequestData,
DataRequestTypeEnum,
EventTypeEnum,
} from '../types';
import shortenKeys from './shorten-look-ups';

@@ -21,3 +27,3 @@

})
.then((res) => (res.status === 200 ? Promise.resolve() : Promise.reject()));
.then((res) => (res.status === 200 ? Promise.resolve(res.data) : Promise.reject()));
};

@@ -24,0 +30,0 @@

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

export const MESSAGE_PREFIX = '@ombori/grid-session-manager:';
export const MESSAGE_PREFIX = '@ombori/grid-signals:';
export const EVENTS_CACHE_KEY = '_OMBORI_GRID_SIGNALS_EVENTS_CACHE';

@@ -3,0 +3,0 @@ export const CLIENT_CACHE_KEY = '_OMBORI_GRID_SIGNALS_CLIENT_CACHE';

@@ -18,6 +18,11 @@ import { v4 as uuid } from 'uuid';

TRACK_EVENT_ERROR_INIT_MESSAGE,
MESSAGE_PREFIX,
} from './constants';
import getClientInfo from './utils/get-client-id';
import getDateString from './utils/get-date-string';
import { getSessionFromInstance, isInstanceInitialized } from './utils/instance-helper';
import {
getSessionFromInstance,
isInstanceInitialized,
getMissingRequiredInstanceParams,
} from './utils/instance-helper';
import { getCallbackSendFunction } from './api/send-events';

@@ -55,5 +60,5 @@ import { cache, cacheData, flushCacheOnce } from './utils/cache';

appId: '',
appVersion: '',
appVersion: undefined,
installationId: '',
installationVersion: '',
installationVersion: undefined,
deviceId: null,

@@ -82,2 +87,12 @@ clientId: null,

} else {
const missingParams = getMissingRequiredInstanceParams(initParams);
if (missingParams.length) {
const errorMessage = `${MESSAGE_PREFIX} missing or invalid init params ${missingParams.join(
', ',
)}`;
console.error(errorMessage);
throw new Error(errorMessage);
}
this.instance = {

@@ -145,3 +160,6 @@ ...this.instance,

private sendOrCacheData = async (type: DataRequestTypeEnum, data: RequestData) => {
private sendOrCacheData = async (
type: DataRequestTypeEnum,
data: RequestData,
): Promise<any> => {
try {

@@ -160,3 +178,3 @@ if (!isOnline && this.instance.clientUserAgent) {

await sendFunction(data);
const response = await sendFunction(data);

@@ -166,2 +184,4 @@ if (this.instance.clientUserAgent && cache && cache.length) {

}
return response;
} catch (err) {

@@ -168,0 +188,0 @@ if (this.instance.clientUserAgent && cache) {

@@ -76,5 +76,5 @@ export enum DataResidencyEnum {

appId: string;
appVersion: string;
appVersion?: string;
installationId: string;
installationVersion: string;
installationVersion?: string;
deviceId?: string | null;

@@ -81,0 +81,0 @@ clientId: string | null;

@@ -22,15 +22,24 @@ import { Instance } from '../types';

export const isInstanceInitialized = (instance: Instance) => {
return !!(
instance.tenantId &&
instance.environment &&
instance.dataResidency &&
instance.country &&
instance.appId &&
instance.appVersion &&
instance.installationId &&
instance.installationVersion
export const getMissingRequiredInstanceParams = (initParams: Partial<Instance>) => {
const requiredFields = [
'tenantId',
'environment',
'dataResidency',
'country',
'appId',
'installationId',
];
const missingParams = requiredFields.filter(
(field) => !(initParams as Record<string, string>)[field],
);
return missingParams;
};
export const isInstanceInitialized = (instance: Instance) => {
const missingParams = getMissingRequiredInstanceParams(instance);
return missingParams.length === 0;
};
export default {

@@ -37,0 +46,0 @@ getSessionFromInstance,

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