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

posthog-js-lite

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthog-js-lite - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/package.json
{
"name": "posthog-js-lite",
"version": "0.0.4",
"version": "0.0.5",
"description": "Reimplementation of posthog-js to be as light and modular as possible.",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

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

const session = {};
const anonymousId = utils_1.generateUUID();
const anonymousId = utils_1.generateUUID(globalThis);
let postHogInstance = {

@@ -27,0 +27,0 @@ options: Object.assign(Object.assign(Object.assign({}, defaultOptions), options), { apiKey }),

@@ -1,18 +0,1 @@

export declare function getContext(window: Window): {
$os: string;
$browser: string;
$referrer: string;
$referring_domain: string;
$device: string;
$current_url: string;
$host: string;
$pathname: string;
$browser_version: number | null;
$screen_height: number;
$screen_width: number;
$screen_dpr: number;
$lib: string;
$lib_version: string;
$insert_id: string;
$time: number;
};
export declare function getContext(window: Window): {};

@@ -7,16 +7,21 @@ "use strict";

function getContext(window) {
const userAgent = window.navigator.userAgent;
const context = {
$os: os(window),
$browser: browser(userAgent, navigator.vendor, !!window.opera),
$referrer: window.document.referrer,
$referring_domain: referringDomain(window.document.referrer),
$device: device(userAgent),
$current_url: window.location.href,
$host: window.location.host,
$pathname: window.location.pathname,
$browser_version: browserVersion(userAgent, window.navigator.vendor, !!window.opera),
$screen_height: window.screen.height,
$screen_width: window.screen.width,
$screen_dpr: window.devicePixelRatio,
const context = {};
if (window.navigator) {
const userAgent = window.navigator.userAgent;
Object.assign(context, {
$os: os(window),
$browser: browser(userAgent, window.navigator.vendor, !!window.opera),
$referrer: window.document.referrer,
$referring_domain: referringDomain(window.document.referrer),
$device: device(userAgent),
$current_url: window.location.href,
$host: window.location.host,
$pathname: window.location.pathname,
$browser_version: browserVersion(userAgent, window.navigator.vendor, !!window.opera),
$screen_height: window.screen.height,
$screen_width: window.screen.width,
$screen_dpr: window.devicePixelRatio,
});
}
Object.assign(context, {
$lib: 'js',

@@ -26,3 +31,3 @@ $lib_version: package_json_1.version,

$time: utils_1.currentTimestamp() / 1000,
};
});
return context;

@@ -29,0 +34,0 @@ }

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

export declare function generateUUID(): string;
export declare function generateUUID(globalThis: any): string;
export declare function currentTimestamp(): number;
export declare function currentISOTime(): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.currentISOTime = exports.currentTimestamp = exports.generateUUID = void 0;
function generateUUID() {
function generateUUID(globalThis) {
var d = new Date().getTime();
var d2 = (performance && performance.now && performance.now() * 1000) || 0;
var d2 = (globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0;
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {

@@ -8,0 +8,0 @@ var r = Math.random() * 16;

{
"name": "posthog-js-lite",
"version": "0.0.4",
"version": "0.0.5",
"description": "Reimplementation of posthog-js to be as light and modular as possible.",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -1,3 +0,9 @@

WIP! Reimplementation of posthog-js to be as light and modular as possible.
[![NPM Version](https://img.shields.io/npm/v/posthog-js-lite.svg)](https://www.npmjs.com/package/posthog-js-lite)
[![minified](https://badgen.net/bundlephobia/min/posthog-js-lite)](https://bundlephobia.com/result?p=posthog-js-lite)
[![minified + gzipped](https://badgen.net/bundlephobia/minzip/posthog-js-lite)](https://bundlephobia.com/result?p=posthog-js-lite)
**This library is still a work in progress!**
Reimplementation of posthog-js to be as light and modular as possible.
Goals:

@@ -16,1 +22,5 @@ - simple api

- 10kb (includes 5kb compression code)
Browser support:
- This library ES6 compatible browsers (everything except IE). If you need to support IE,
feel free to transpile the source to ES5 after including it in your bundle.

@@ -16,3 +16,3 @@ import { version } from '../package.json'

const session = {} as Partial<PostHogSession> // getDataFromCookiesAndLocalStorage
const anonymousId = generateUUID()
const anonymousId = generateUUID(globalThis)

@@ -19,0 +19,0 @@ let postHogInstance = {

@@ -5,16 +5,21 @@ import { version } from '../../package.json'

export function getContext(window: Window) {
const userAgent = window.navigator.userAgent
const context = {
$os: os(window),
$browser: browser(userAgent, navigator.vendor, !!(window as any).opera),
$referrer: window.document.referrer,
$referring_domain: referringDomain(window.document.referrer),
$device: device(userAgent),
$current_url: window.location.href,
$host: window.location.host,
$pathname: window.location.pathname,
$browser_version: browserVersion(userAgent, window.navigator.vendor, !!(window as any).opera),
$screen_height: window.screen.height,
$screen_width: window.screen.width,
$screen_dpr: window.devicePixelRatio,
const context = {}
if (window.navigator) {
const userAgent = window.navigator.userAgent
Object.assign(context, {
$os: os(window),
$browser: browser(userAgent, window.navigator.vendor, !!(window as any).opera),
$referrer: window.document.referrer,
$referring_domain: referringDomain(window.document.referrer),
$device: device(userAgent),
$current_url: window.location.href,
$host: window.location.host,
$pathname: window.location.pathname,
$browser_version: browserVersion(userAgent, window.navigator.vendor, !!(window as any).opera),
$screen_height: window.screen.height,
$screen_width: window.screen.width,
$screen_dpr: window.devicePixelRatio,
})
}
Object.assign(context, {
$lib: 'js',

@@ -24,3 +29,3 @@ $lib_version: version,

$time: currentTimestamp() / 1000, // epoch time in seconds
}
})
return context // TODO: strip empty props?

@@ -27,0 +32,0 @@ }

// https://stackoverflow.com/a/8809472
export function generateUUID(): string {
export function generateUUID(globalThis: any): string {
// Public Domain/MIT
var d = new Date().getTime() //Timestamp
var d2 = (performance && performance.now && performance.now() * 1000) || 0 //Time in microseconds since page-load or 0 if unsupported
var d2 =
(globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0 //Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {

@@ -7,0 +8,0 @@ var r = Math.random() * 16 //random number between 0 and 16

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