Socket
Socket
Sign inDemoInstall

@ombori/ga-settings

Package Overview
Dependencies
Maintainers
18
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ombori/ga-settings - npm Package Compare versions

Comparing version 2.82.17 to 2.114.0

dist/get-local-browser-settings.d.ts

13

CHANGELOG.md

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

# [2.114.0](https://github.com/ombori/gridapp/compare/v2.113.5...v2.114.0) (2021-11-22)
### Features
* browser support ([06edbff](https://github.com/ombori/gridapp/commit/06edbff1ae50a601183417ce66573221744c22ff))
* more session manager init logic ([d99572c](https://github.com/ombori/gridapp/commit/d99572c6065ce6aa0bbc4c6c73aadf9e3e0104ec))
* useSessionManagerInitProps ([92edd70](https://github.com/ombori/gridapp/commit/92edd7060cb77bcf3bbba96fe4be9043ac9fc111))
## [2.82.17](https://github.com/ombori/gridapp/compare/v2.82.16...v2.82.17) (2021-08-13)

@@ -8,0 +21,0 @@

56

dist/index.d.ts

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

declare global {
interface Window {
gridapp: any;
}
}
/**

@@ -10,11 +15,6 @@ * @ui mediaPicker

};
declare global {
interface Window {
gridapp: any;
}
}
export declare function useSettings<T>(): T | null;
export declare type DeviceInfo = {
id: string;
name: string;
env: string;
};

@@ -28,2 +28,4 @@ export declare type AppInfo = {

organizationName: string;
dataResidency: string;
country: string;
provider: string;

@@ -35,2 +37,14 @@ release: string;

};
export declare type BuildInfo = {
bootVersion: string;
appName: string;
buildId: string;
};
export declare type GridappInfo = {
id: string;
buildId: string;
name: string;
iconUrl: string;
};
export declare function useSettings<T>(): T | null;
export declare const useAppInfo: () => AppInfo | {

@@ -44,2 +58,4 @@ device: DeviceInfo | null;

organizationName: string;
dataResidency: string;
country: string;
provider: string;

@@ -50,2 +66,15 @@ release: string;

} | null;
export declare const useSessionManagerInitProps: () => {
tenantId: string;
environment: string;
dataResidency: string;
country: string;
spaceId: string;
appId: string;
appVersion: string;
installationId: string;
installationVersion: string;
deviceId: string;
clientUserAgent: string;
} | null;
declare const _default: {

@@ -61,2 +90,4 @@ useSettings: typeof useSettings;

organizationName: string;
dataResidency: string;
country: string;
provider: string;

@@ -67,4 +98,17 @@ release: string;

} | null;
useSessionManagerInitProps: () => {
tenantId: string;
environment: string;
dataResidency: string;
country: string;
spaceId: string;
appId: string;
appVersion: string;
installationId: string;
installationVersion: string;
deviceId: string;
clientUserAgent: string;
} | null;
};
export default _default;
//# sourceMappingURL=index.d.ts.map

69

dist/index.js

@@ -13,7 +13,9 @@ var __assign = (this && this.__assign) || function () {

import { useEffect, useMemo, useState } from 'react';
import isDev from './is-dev';
import getLocalBrowserSettings from './get-local-browser-settings';
var globalSettings = null;
var globalInfo = null;
// NOTE: in dev mode we just load everything to a global variable
var IS_DEV = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
if (IS_DEV) {
// TODO: we should only execute this when we call useSettings
// We should not execute anything without any invoke event
if (isDev) {
console.log('Settings development mode', process.cwd());

@@ -25,3 +27,3 @@ var settings = require('settings/index.json');

export function useSettings() {
if (IS_DEV)
if (isDev)
return globalSettings;

@@ -45,15 +47,28 @@ var _a = useState(globalSettings), settings = _a[0], setSettings = _a[1];

var getDeviceInfo = function () {
// Note: Do not immediately return null if NODE_ENV is dev
// Sometimes we render the app within same network on GridOS device for development
var data = /GridOS\/[0-9.]+ \((.+)\)/.exec(navigator.userAgent);
if (!data || !data[1])
if (data && data[1]) {
return data[1]
.split('; ')
.map(function (line) { return line.split('='); })
.reduce(function (res, _a) {
var _b;
var name = _a[0], val = _a[1];
return (__assign(__assign({}, res), (_b = {}, _b[name] = val, _b)));
}, {});
}
if (isDev)
return null;
return data[1].split("; ")
.map(function (line) { return line.split("="); })
.reduce(function (res, _a) {
var _b;
var name = _a[0], val = _a[1];
return (__assign(__assign({}, res), (_b = {}, _b[name] = val, _b)));
}, {});
var browserSettings = getLocalBrowserSettings();
if (!browserSettings)
return null;
return {
id: browserSettings.uuid,
name: browserSettings.displayName,
env: browserSettings.env,
};
};
export var useAppInfo = function () {
if (IS_DEV)
if (isDev)
return globalInfo;

@@ -68,2 +83,28 @@ var settings = useSettings();

};
export default { useSettings: useSettings, useAppInfo: useAppInfo };
export var useSessionManagerInitProps = function () {
var settings = useSettings();
return useMemo(function () {
var _a, _b, _c, _d;
if (!settings || !settings._general || !settings._gridapp)
return null;
var device = getDeviceInfo();
return {
tenantId: settings._general.organizationId,
environment: ((device === null || device === void 0 ? void 0 : device.env) || '').toUpperCase(),
dataResidency: settings._general.dataResidency,
country: settings._general.country,
// TODO: Add support with env later. this is supported in the analytics service out-of-the-box
// locationAccuracy: 10,
// latitude: 0,
// longitude: 0,
spaceId: '',
appId: ((_a = settings._gridapp) === null || _a === void 0 ? void 0 : _a.id) || '',
appVersion: ((_b = settings._gridapp) === null || _b === void 0 ? void 0 : _b.buildId) || '',
installationId: ((_c = settings._general) === null || _c === void 0 ? void 0 : _c.appId) || '',
installationVersion: ((_d = settings._buildInfo) === null || _d === void 0 ? void 0 : _d.buildId) || '',
deviceId: (device === null || device === void 0 ? void 0 : device.id) || '',
clientUserAgent: navigator.userAgent,
};
}, [settings]);
};
export default { useSettings: useSettings, useAppInfo: useAppInfo, useSessionManagerInitProps: useSessionManagerInitProps };
{
"name": "@ombori/ga-settings",
"version": "2.82.17",
"version": "2.114.0",
"main": "dist/index.js",

@@ -19,3 +19,3 @@ "license": "UNLICENSED",

},
"gitHead": "1e65d47694cea0e74fb7a661dc21223adf5c33a8"
"gitHead": "f1efca6e3f9a35033fa05c705cc92edd1d929497"
}
import { useEffect, useMemo, useState } from 'react';
import isDev from './is-dev';
import getLocalBrowserSettings from './get-local-browser-settings';
declare global {
interface Window {
gridapp: any;
}
}
/**

@@ -11,17 +19,52 @@ * @ui mediaPicker

url: string;
}
};
declare global {
interface Window {
gridapp: any;
}
}
export type DeviceInfo = {
id: string;
name: string;
env: string;
};
export type AppInfo = {
appDisplayName: string;
appId: string;
appName: string;
defaultLanguage: string;
organizationId: string;
organizationName: string;
dataResidency: string;
country: string;
provider: string;
release: string;
supportedLanguages: string[];
type: string;
device?: DeviceInfo;
};
export type BuildInfo = {
bootVersion: string;
appName: string;
buildId: string;
};
export type GridappInfo = {
id: string;
buildId: string;
name: string;
iconUrl: string;
};
type Settings = {
_general: AppInfo;
_buildInfo: BuildInfo;
_gridapp: GridappInfo;
[key: string]: any;
} | null;
let globalSettings: any = null;
let globalInfo: AppInfo | null = null;
// NOTE: in dev mode we just load everything to a global variable
const IS_DEV = !process.env.NODE_ENV || process.env.NODE_ENV === 'development';
if (IS_DEV) {
// TODO: we should only execute this when we call useSettings
// We should not execute anything without any invoke event
if (isDev) {
console.log('Settings development mode', process.cwd());

@@ -34,3 +77,3 @@ const settings = require('settings/index.json');

export function useSettings<T>() {
if (IS_DEV) return globalSettings as T;
if (isDev) return globalSettings as T;

@@ -55,35 +98,34 @@ const [settings, setSettings] = useState<T | null>(globalSettings);

export type DeviceInfo = {
id: string;
name: string;
}
export type AppInfo = {
appDisplayName: string;
appId: string;
appName: string;
defaultLanguage: string;
organizationId: string;
organizationName: string;
provider: string;
release: string;
supportedLanguages: string[];
type: string;
device?: DeviceInfo;
};
const getDeviceInfo = (): DeviceInfo | null => {
// Note: Do not immediately return null if NODE_ENV is dev
// Sometimes we render the app within same network on GridOS device for development
const data = /GridOS\/[0-9.]+ \((.+)\)/.exec(navigator.userAgent);
if (!data || !data[1]) return null;
if (data && data[1]) {
return data[1]
.split('; ')
.map((line) => line.split('='))
.reduce<DeviceInfo>(
(res, [name, val]) => ({ ...res, [name]: val }),
{} as DeviceInfo,
);
}
return data[1].split("; ")
.map(line => line.split("="))
.reduce<DeviceInfo>((res, [name, val]) => ({ ...res, [name]: val }), {} as DeviceInfo);
}
if (isDev) return null;
const browserSettings = getLocalBrowserSettings();
if (!browserSettings) return null;
return {
id: browserSettings.uuid,
name: browserSettings.displayName,
env: browserSettings.env,
};
};
export const useAppInfo = () => {
if (IS_DEV) return globalInfo;
if (isDev) return globalInfo;
const settings = useSettings<{ _general: AppInfo } | null>();
const settings = useSettings<Settings>();

@@ -97,4 +139,32 @@ return useMemo(() => {

}, [settings]);
}
};
export default { useSettings, useAppInfo };
export const useSessionManagerInitProps = () => {
const settings = useSettings<Settings>();
return useMemo(() => {
if (!settings || !settings._general || !settings._gridapp) return null;
const device = getDeviceInfo();
return {
tenantId: settings._general.organizationId,
environment: (device?.env || '').toUpperCase(),
dataResidency: settings._general.dataResidency,
country: settings._general.country,
// TODO: Add support with env later. this is supported in the analytics service out-of-the-box
// locationAccuracy: 10,
// latitude: 0,
// longitude: 0,
spaceId: '',
appId: settings._gridapp?.id || '',
appVersion: settings._gridapp?.buildId || '',
installationId: settings._general?.appId || '',
installationVersion: settings._buildInfo?.buildId || '',
deviceId: device?.id || '',
clientUserAgent: navigator.userAgent,
};
}, [settings]);
};
export default { useSettings, useAppInfo, useSessionManagerInitProps };

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