Skip to content

Commit

Permalink
more moving around
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 27, 2023
1 parent 8c6f167 commit 96f49b8
Show file tree
Hide file tree
Showing 35 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@

## 1.66.1 - 2023-06-07

- Update utils.ts (#686)
- Update index.ts (#686)

## 1.66.0 - 2023-06-06

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
unhandledRejectionToProperties,
} from '../../../extensions/exception-autocapture/error-conversion'

import { _isNull } from '../../../type-utils'
import { _isNull } from '../../../utils/type-utils'

// ugh, jest
// can't reference PromiseRejectionEvent to construct it 🤷
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/gdpr-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sinon from 'sinon'

import * as gdpr from '../gdpr-utils'

import { _isNull } from '../type-utils'
import { _isNull } from '../utils/type-utils'

const TOKENS = [
`test-token`,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/request-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _HTTPBuildQuery, _isUrlMatchingRegex } from '../request-utils'
import { _HTTPBuildQuery, _isUrlMatchingRegex } from '../utils/request-utils'

describe('request utils', () => {
describe('_HTTPBuildQuery', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/send-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addParamsToURL, encodePostData, xhr } from '../send-request'
import { assert, boolean, property, uint8Array, VerbosityLevel } from 'fast-check'
import { Compression, PostData, XHROptions, XHRParams } from '../types'

import { _isUndefined } from '../type-utils'
import { _isUndefined } from '../utils/type-utils'

jest.mock('../config', () => ({ DEBUG: false, LIB_VERSION: '1.23.45' }))

Expand Down
2 changes: 1 addition & 1 deletion src/autocapture-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { AutocaptureConfig } from 'types'
import { _each, _includes, _trim, logger } from './utils'

import { _isNull, _isString, _isUndefined } from './type-utils'
import { _isNull, _isString, _isUndefined } from './utils/type-utils'

export function getClassName(el: Element): string {
switch (typeof el.className) {
Expand Down
2 changes: 1 addition & 1 deletion src/autocapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { AutocaptureConfig, AutoCaptureCustomProperty, DecideResponse, Propertie
import { PostHog } from './posthog-core'
import { AUTOCAPTURE_DISABLED_SERVER_SIDE } from './constants'

import { _isBoolean, _isFunction, _isNull, _isUndefined } from './type-utils'
import { _isBoolean, _isFunction, _isNull, _isUndefined } from './utils/type-utils'

function limitText(length: number, text: string): string {
if (text.length > length) {
Expand Down
2 changes: 1 addition & 1 deletion src/decide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PostHog } from './posthog-core'
import { DecideResponse } from './types'
import { STORED_GROUP_PROPERTIES_KEY, STORED_PERSON_PROPERTIES_KEY } from './constants'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

export class Decide {
instance: PostHog
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/exception-autocapture/error-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from './type-checking'
import { defaultStackParser, StackFrame } from './stack-trace'

import { _isNumber, _isString, _isUndefined } from '../../type-utils'
import { _isNumber, _isString, _isUndefined } from '../../utils/type-utils'

/**
* based on the very wonderful MIT licensed Sentry SDK
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/exception-autocapture/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DecideResponse, Properties } from '../../types'
import { ErrorEventArgs, ErrorProperties, errorToProperties, unhandledRejectionToProperties } from './error-conversion'
import { isPrimitive } from './type-checking'

import { _isArray, _isObject, _isUndefined } from '../../type-utils'
import { _isArray, _isObject, _isUndefined } from '../../utils/type-utils'

const EXCEPTION_INGESTION_ENDPOINT = '/e/'

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/exception-autocapture/stack-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import { _isUndefined } from '../../type-utils'
import { _isUndefined } from '../../utils/type-utils'

const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/
const STACKTRACE_FRAME_LIMIT = 50
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/exception-autocapture/type-checking.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _isFunction, _isNull, _isObject, _isUndefined } from '../../type-utils'
import { _isFunction, _isNull, _isObject, _isUndefined } from '../../utils/type-utils'

export function isEvent(candidate: unknown): candidate is Event {
return !_isUndefined(Event) && isInstanceOf(candidate, Event)
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/replay/sessionrecording-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
} from '@rrweb/types'
import type { Mirror, MaskInputOptions, MaskInputFn, MaskTextFn, SlimDOMOptions, DataURLOptions } from 'rrweb-snapshot'

import { _isObject } from '../../type-utils'
import { _isObject } from '../../utils/type-utils'

export const replacementImageURI =
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg=='
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/replay/sessionrecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { EventType, type eventWithTime, type listenerHandler } from '@rrweb/type
import Config from '../../config'
import { _timestamp, loadScript, logger } from '../../utils'

import { _isBoolean, _isNull, _isNumber, _isObject, _isString, _isUndefined } from '../../type-utils'
import { _isBoolean, _isNull, _isNumber, _isObject, _isString, _isUndefined } from '../../utils/type-utils'

const BASE_ENDPOINT = '/s/'

Expand Down
4 changes: 2 additions & 2 deletions src/extensions/replay/web-performance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logger } from '../../utils'
import { PostHog } from '../../posthog-core'
import { DecideResponse, NetworkRequest } from '../../types'
import { isLocalhost } from '../../request-utils'
import { isLocalhost } from '../../utils/request-utils'

import { _isUndefined } from '../../type-utils'
import { _isUndefined } from '../../utils/type-utils'

const PERFORMANCE_EVENTS_MAPPING: { [key: string]: number } = {
// BASE_PERFORMANCE_EVENT_COLUMNS
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/surveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SurveyQuestion,
} from '../posthog-surveys-types'

import { _isUndefined } from '../type-utils'
import { _isUndefined } from '../utils/type-utils'

const satisfiedEmoji =
'<svg class="emoji-svg" xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z"/></svg>'
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { _register_event, _try, loadScript, logger, window } from '../utils'
import { PostHog } from '../posthog-core'
import { DecideResponse, ToolbarParams } from '../types'
import { POSTHOG_MANAGED_HOSTS } from './cloud'
import { _getHashParam } from '../request-utils'
import { _getHashParam } from '../utils/request-utils'

// TRICKY: Many web frameworks will modify the route on load, potentially before posthog is initialized.
// To get ahead of this we grab it as soon as the posthog-js is parsed
Expand Down
2 changes: 1 addition & 1 deletion src/gdpr-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { cookieStore, localStore, localPlusCookieStore } from './storage'
import { GDPROptions, PersistentStore } from './types'
import { PostHog } from './posthog-core'

import { _isNumber, _isString } from './type-utils'
import { _isNumber, _isString } from './utils/type-utils'

/**
* A function used to capture a PostHog event (e.g. PostHogLib.capture)
Expand Down
2 changes: 1 addition & 1 deletion src/loader-exception-autocapture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { extendPostHog } from './extensions/exception-autocapture'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

const win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window

Expand Down
2 changes: 1 addition & 1 deletion src/loader-recorder-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import rrwebRecord from 'rrweb/es/rrweb/packages/rrweb/src/record'
// @ts-ignore
import { getRecordConsolePlugin } from 'rrweb/es/rrweb/packages/rrweb/src/plugins/console/record'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

const win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window

Expand Down
2 changes: 1 addition & 1 deletion src/loader-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import rrwebRecord from 'rrweb-v1/es/rrweb/packages/rrweb/src/record'
// @ts-ignore
import { getRecordConsolePlugin } from 'rrweb-v1/es/rrweb/packages/rrweb/src/plugins/console/record'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

Expand Down
2 changes: 1 addition & 1 deletion src/loader-surveys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateSurveys } from './extensions/surveys'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

const win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window

Expand Down
2 changes: 1 addition & 1 deletion src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import { RateLimiter } from './rate-limiter'
import { uuidv7 } from './uuidv7'
import { SurveyCallback } from './posthog-surveys-types'
import { document } from './utils'
import { _isArray, _isEmptyObject, _isFunction, _isObject, _isString, _isUndefined } from './type-utils'
import { _isArray, _isEmptyObject, _isFunction, _isObject, _isString, _isUndefined } from './utils/type-utils'

/*
SIMPLE STYLE GUIDE:
Expand Down
2 changes: 1 addition & 1 deletion src/posthog-featureflags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
FLAG_CALL_REPORTED,
} from './constants'

import { _isArray } from './type-utils'
import { _isArray } from './utils/type-utils'

const PERSISTENCE_ACTIVE_FEATURE_FLAGS = '$active_feature_flags'
const PERSISTENCE_OVERRIDE_FEATURE_FLAGS = '$override_feature_flags'
Expand Down
2 changes: 1 addition & 1 deletion src/posthog-persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
USER_STATE,
} from './constants'

import { _isObject, _isUndefined } from './type-utils'
import { _isObject, _isUndefined } from './utils/type-utils'

const CASE_INSENSITIVE_PERSISTENCE_TYPES: readonly Lowercase<PostHogConfig['persistence']>[] = [
'cookie',
Expand Down
2 changes: 1 addition & 1 deletion src/posthog-surveys.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PostHog } from './posthog-core'
import { SURVEYS } from './constants'
import { SurveyCallback, SurveyUrlMatchType } from './posthog-surveys-types'
import { _isUrlMatchingRegex } from './request-utils'
import { _isUrlMatchingRegex } from './utils/request-utils'

export const surveyUrlValidationMap: Record<SurveyUrlMatchType, (conditionsUrl: string) => boolean> = {
icontains: (conditionsUrl) => window.location.href.toLowerCase().indexOf(conditionsUrl.toLowerCase()) > -1,
Expand Down
2 changes: 1 addition & 1 deletion src/request-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RequestQueueScaffold } from './base-request-queue'
import { _each } from './utils'
import { Properties, QueuedRequestData, XHROptions } from './types'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

export class RequestQueue extends RequestQueueScaffold {
handlePollRequest: (url: string, data: Properties, options?: XHROptions) => void
Expand Down
2 changes: 1 addition & 1 deletion src/retry-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QueuedRequestData, RetryQueueElement } from './types'
import { logger } from './utils'
import { RateLimiter } from './rate-limiter'

import { _isUndefined } from './type-utils'
import { _isUndefined } from './utils/type-utils'

const thirtyMinutes = 30 * 60 * 1000

Expand Down
4 changes: 2 additions & 2 deletions src/send-request.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { _each, logger } from './utils'
import Config from './config'
import { PostData, XHROptions, XHRParams } from './types'
import { _HTTPBuildQuery } from './request-utils'
import { _HTTPBuildQuery } from './utils/request-utils'

import { _isArray, _isFunction, _isUint8Array } from './type-utils'
import { _isArray, _isFunction, _isUint8Array } from './utils/type-utils'

export const addParamsToURL = (
url: string,
Expand Down
2 changes: 1 addition & 1 deletion src/sessionid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PostHogConfig, SessionIdChangedCallback } from './types'
import { uuidv7 } from './uuidv7'
import { logger, window } from './utils'

import { _isArray, _isNumber, _isUndefined } from './type-utils'
import { _isArray, _isNumber, _isUndefined } from './utils/type-utils'

const MAX_SESSION_IDLE_TIMEOUT = 30 * 60 // 30 minutes
const MIN_SESSION_IDLE_TIMEOUT = 60 // 1 minute
Expand Down
2 changes: 1 addition & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { _extend, logger } from './utils'
import { PersistentStore, Properties } from './types'
import { DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants'

import { _isNull, _isUndefined } from './type-utils'
import { _isNull, _isUndefined } from './utils/type-utils'

const DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i

Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts → src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Config from './config'
import { Breaker, EventHandler, Properties } from './types'
import Config from '../config'
import { Breaker, EventHandler, Properties } from '../types'
import { _getQueryParam } from './request-utils'
import {
_isArray,
Expand Down
2 changes: 1 addition & 1 deletion src/request-utils.ts → src/utils/request-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _each, _isValidRegex, logger } from './utils'
import { _each, _isValidRegex, logger } from './'

import { _isNull, _isString, _isUndefined } from './type-utils'

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/uuidv7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// polyfill for IE11
import { window } from './utils'

import { _isNumber, _isUndefined } from './type-utils'
import { _isNumber, _isUndefined } from './utils/type-utils'

if (!Math.trunc) {
Math.trunc = function (v) {
Expand Down

0 comments on commit 96f49b8

Please sign in to comment.