react-native-kochava-measurement
Version:
A lightweight and easy to integrate SDK, providing first-class integration with Kochava’s installation attribution and analytics platform.
57 lines (56 loc) • 1.75 kB
JavaScript
/*
Authored by Brett Barinaga on 11/17/21.
Copyright (c) Kochava, Inc. All rights reserved.
*/
export var getPackageName = function () {
if (window && window.location && window.location.hostname)
return window.location.hostname;
return null;
};
export var getLanguage = function () {
return (navigator) ? navigator.language : null;
};
export var getDeviceWidth = function () {
if (window && window.screen && window.screen.availWidth)
return window.screen.availWidth;
return null;
};
export var getDeviceHeight = function () {
if (window && window.screen && window.screen.availHeight)
return window.screen.availHeight;
return null;
};
export var getDeviceOrientation = function () {
return (window) ? window.innerWidth < window.innerHeight
? "portrait" : "landscape" : null;
};
export var getBaseDomain = function () {
try {
var regexResult = window.location.host.match(/[^.]*\.[^.]*$/);
if (regexResult)
return regexResult[0];
return null;
}
catch (err) {
return window.location.host;
}
};
export var getPageName = function () {
var page = "";
if (window.location) {
page = window.location.pathname.substring(1);
page = page.replace(/\/+$/, "");
}
return page === "" ? "/" : page;
};
export var getUrlParameter = function (name) {
if (!window.location || !window.location.search) {
return null;
}
name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(window.location.search);
return results === null
? ""
: decodeURIComponent(results[1].replace(/\+/g, " "));
};