diff --git a/package.json b/package.json
index b7e06fe012..e7ea85ccd4 100644
--- a/package.json
+++ b/package.json
@@ -51,7 +51,8 @@
"lint:style": "stylelint 'res/css/**/*.scss'",
"test": "jest",
"test:e2e": "./test/end-to-end-tests/run.sh --app-url http://localhost:8080",
- "coverage": "yarn test --coverage"
+ "coverage": "yarn test --coverage",
+ "postinstall": "patch-package"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
@@ -87,7 +88,7 @@
"pako": "^2.0.3",
"parse5": "^6.0.1",
"png-chunks-extract": "^1.0.0",
- "posthog-js": "1.12.1",
+ "posthog-js": "1.12.2",
"prop-types": "^15.7.2",
"qrcode": "^1.4.4",
"re-resizable": "^6.9.0",
@@ -165,6 +166,8 @@
"matrix-mock-request": "^1.2.3",
"matrix-react-test-utils": "^0.2.3",
"matrix-web-i18n": "github:matrix-org/matrix-web-i18n",
+ "patch-package": "^6.4.7",
+ "postinstall-postinstall": "^2.1.0",
"react-test-renderer": "^17.0.2",
"rimraf": "^3.0.2",
"stylelint": "^13.9.0",
diff --git a/patches/posthog-js+1.12.2.patch b/patches/posthog-js+1.12.2.patch
new file mode 100644
index 0000000000..430a9f0a62
--- /dev/null
+++ b/patches/posthog-js+1.12.2.patch
@@ -0,0 +1,78 @@
+diff --git a/node_modules/posthog-js/dist/module.d.ts b/node_modules/posthog-js/dist/module.d.ts
+index d3cba02..8c87ef8 100644
+--- a/node_modules/posthog-js/dist/module.d.ts
++++ b/node_modules/posthog-js/dist/module.d.ts
+@@ -1,7 +1,5 @@
+ // Type definitions for exported methods
+-
+-import { EventProcessor, Integration } from '@sentry/types'
+-import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'
++// Patched to remove references to sentry and rrweb-snapshot which aren't otherwise SDK dependencies
+
+ declare class posthog {
+ /**
+@@ -485,25 +483,6 @@ declare class posthog {
+ */
+ static reloadFeatureFlags(): void
+
+- /**
+- * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog
+- *
+- * ### Usage
+- *
+- * Sentry.init({
+- * dsn: 'https://example',
+- * integrations: [
+- * new posthog.SentryIntegration(posthog)
+- * ]
+- * })
+- *
+- * @param {Object} [posthog] The posthog object
+- * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry
+- * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
+- * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
+- */
+- static SentryIntegration: typeof SentryIntegration
+-
+ static toString(): string
+
+ /* Will log all capture requests to the Javascript console, including event properties for easy debugging */
+@@ -585,7 +564,6 @@ declare namespace posthog {
+ request_batching?: boolean
+ sanitize_properties?: (properties: posthog.Properties, event_name: string) => posthog.Properties
+ properties_string_max_length?: number
+- session_recording?: SessionRecordingOptions
+ mask_all_element_attributes?: boolean
+ mask_all_text?: boolean
+ advanced_disable_decide?: boolean
+@@ -618,17 +596,6 @@ declare namespace posthog {
+ send_event: boolean
+ }
+
+- interface SessionRecordingOptions {
+- blockClass?: string | RegExp
+- blockSelector?: string
+- ignoreClass?: string
+- maskAllInputs?: boolean
+- maskInputOptions?: MaskInputOptions
+- maskInputFn?: (text: string) => string
+- slimDOMOptions?: SlimDOMOptions | 'all' | true
+- collectFonts?: boolean
+- }
+-
+ export class persistence {
+ static properties(): posthog.Properties
+
+@@ -768,12 +735,6 @@ declare namespace posthog {
+ export class feature_flags extends featureFlags {}
+ }
+
+-export class SentryIntegration implements Integration {
+- constructor(posthog: posthog, organization?: string, projectId?: number, prefix?: string)
+- name: string
+- setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void
+-}
+-
+ export type PostHog = typeof posthog
+
+ export default posthog
diff --git a/src/@types/posthog.d.ts b/src/@types/posthog.d.ts
deleted file mode 100644
index 1ca475cd3b..0000000000
--- a/src/@types/posthog.d.ts
+++ /dev/null
@@ -1,748 +0,0 @@
-// A clone of the type definitions from posthog-js, stripped of references to transitive
-// dependencies which we don't actually use, so that we don't need to install them.
-//
-// Original file lives in node_modules/posthog/dist/module.d.ts
-
-/* eslint-disable @typescript-eslint/member-delimiter-style */
-/* eslint-disable @typescript-eslint/naming-convention */
-/* eslint-disable camelcase */
-
-// Type definitions for exported methods
-
-declare class posthog {
- /**
- * This function initializes a new instance of the PostHog capturing object.
- * All new instances are added to the main posthog object as sub properties (such as
- * posthog.library_name) and also returned by this function. To define a
- * second instance on the page, you would call:
- *
- * posthog.init('new token', { your: 'config' }, 'library_name');
- *
- * and use it like so:
- *
- * posthog.library_name.capture(...);
- *
- * @param {String} token Your PostHog API token
- * @param {Object} [config] A dictionary of config options to override. See a list of default config options.
- * @param {String} [name] The name for the new posthog instance that you want created
- */
- static init(token: string, config?: posthog.Config, name?: string): posthog
-
- /**
- * Clears super properties and generates a new random distinct_id for this instance.
- * Useful for clearing data when a user logs out.
- */
- static reset(reset_device_id?: boolean): void
-
- /**
- * Capture an event. This is the most important and
- * frequently used PostHog function.
- *
- * ### Usage:
- *
- * // capture an event named 'Registered'
- * posthog.capture('Registered', {'Gender': 'Male', 'Age': 21});
- *
- * // capture an event using navigator.sendBeacon
- * posthog.capture('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
- *
- * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
- * @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
- * @param {Object} [options] Optional configuration for this capture request.
- * @param {String} [options.transport] Transport method for network request ('XHR' or 'sendBeacon').
- */
- static capture(
- event_name: string,
- properties?: posthog.Properties,
- options?: { transport: 'XHR' | 'sendBeacon' }
- ): posthog.CaptureResult
-
- /**
- * Capture a page view event, which is currently ignored by the server.
- * This function is called by default on page load unless the
- * capture_pageview configuration variable is false.
- *
- * @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
- * @api private
- */
- static capture_pageview(page?: string): void
-
- /**
- * Register a set of super properties, which are included with all
- * events. This will overwrite previous super property values.
- *
- * ### Usage:
- *
- * // register 'Gender' as a super property
- * posthog.register({'Gender': 'Female'});
- *
- * // register several super properties when a user signs up
- * posthog.register({
- * 'Email': 'jdoe@example.com',
- * 'Account Type': 'Free'
- * });
- *
- * @param {Object} properties An associative array of properties to store about the user
- * @param {Number} [days] How many days since the user's last visit to store the super properties
- */
- static register(properties: posthog.Properties, days?: number): void
-
- /**
- * Register a set of super properties only once. This will not
- * overwrite previous super property values, unlike register().
- *
- * ### Usage:
- *
- * // register a super property for the first time only
- * posthog.register_once({
- * 'First Login Date': new Date().toISOString()
- * });
- *
- * ### Notes:
- *
- * If default_value is specified, current super properties
- * with that value will be overwritten.
- *
- * @param {Object} properties An associative array of properties to store about the user
- * @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
- * @param {Number} [days] How many days since the users last visit to store the super properties
- */
- static register_once(properties: posthog.Properties, default_value?: posthog.Property, days?: number): void
-
- /**
- * Delete a super property stored with the current user.
- *
- * @param {String} property The name of the super property to remove
- */
- static unregister(property: string): void
-
- /**
- * Identify a user with a unique ID instead of a PostHog
- * randomly generated distinct_id. If the method is never called,
- * then unique visitors will be identified by a UUID generated
- * the first time they visit the site.
- *
- * If user properties are passed, they are also sent to posthog.
- *
- * ### Usage:
- *
- * posthog.identify('[user unique id]')
- * posthog.identify('[user unique id]', { email: 'john@example.com' })
- * posthog.identify('[user unique id]', {}, { referral_code: '12345' })
- *
- * ### Notes:
- *
- * You can call this function to overwrite a previously set
- * unique ID for the current user. PostHog cannot translate
- * between IDs at this time, so when you change a user's ID
- * they will appear to be a new user.
- *
- * When used alone, posthog.identify will change the user's
- * distinct_id to the unique ID provided. When used in tandem
- * with posthog.alias, it will allow you to identify based on
- * unique ID and map that back to the original, anonymous
- * distinct_id given to the user upon her first arrival to your
- * site (thus connecting anonymous pre-signup activity to
- * post-signup activity). Though the two work together, do not
- * call identify() at the same time as alias(). Calling the two
- * at the same time can cause a race condition, so it is best
- * practice to call identify on the original, anonymous ID
- * right after you've aliased it.
- *
- * @param {String} [unique_id] A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used.
- * @param {Object} [userProperties] Optional: An associative array of properties to store about the user
- * @param {Object} [userPropertiesToSetOnce] Optional: An associative array of properties to store about the user. If property is previously set, this does not override that value.
- */
- static identify(
- unique_id?: string,
- userPropertiesToSet?: posthog.Properties,
- userPropertiesToSetOnce?: posthog.Properties
- ): void
-
- /**
- * Create an alias, which PostHog will use to link two distinct_ids going forward (not retroactively).
- * Multiple aliases can map to the same original ID, but not vice-versa. Aliases can also be chained - the
- * following is a valid scenario:
- *
- * posthog.alias('new_id', 'existing_id');
- * ...
- * posthog.alias('newer_id', 'new_id');
- *
- * If the original ID is not passed in, we will use the current distinct_id - probably the auto-generated GUID.
- *
- * ### Notes:
- *
- * The best practice is to call alias() when a unique ID is first created for a user
- * (e.g., when a user first registers for an account and provides an email address).
- * alias() should never be called more than once for a given user, except to
- * chain a newer ID to a previously new ID, as described above.
- *
- * @param {String} alias A unique identifier that you want to use for this user in the future.
- * @param {String} [original] The current identifier being used for this user.
- */
- static alias(alias: string, original?: string): posthog.CaptureResult | number
-
- /**
- * Update the configuration of a posthog library instance.
- *
- * The default config is:
- *
- * {
- * // HTTP method for capturing requests
- * api_method: 'POST'
- *
- * // transport for sending requests ('XHR' or 'sendBeacon')
- * // NB: sendBeacon should only be used for scenarios such as
- * // page unload where a "best-effort" attempt to send is
- * // acceptable; the sendBeacon API does not support callbacks
- * // or any way to know the result of the request. PostHog
- * // capturing via sendBeacon will not support any event-
- * // batching or retry mechanisms.
- * api_transport: 'XHR'
- *
- * // Automatically capture clicks, form submissions and change events
- * autocapture: true
- *
- * // Capture rage clicks (beta) - useful for session recording
- * rageclick: false
- *
- * // super properties cookie expiration (in days)
- * cookie_expiration: 365
- *
- * // super properties span subdomains
- * cross_subdomain_cookie: true
- *
- * // debug mode
- * debug: false
- *
- * // if this is true, the posthog cookie or localStorage entry
- * // will be deleted, and no user persistence will take place
- * disable_persistence: false
- *
- * // if this is true, PostHog will automatically determine
- * // City, Region and Country data using the IP address of
- * //the client
- * ip: true
- *
- * // opt users out of capturing by this PostHog instance by default
- * opt_out_capturing_by_default: false
- *
- * // opt users out of browser data storage by this PostHog instance by default
- * opt_out_persistence_by_default: false
- *
- * // persistence mechanism used by opt-in/opt-out methods - cookie
- * // or localStorage - falls back to cookie if localStorage is unavailable
- * opt_out_capturing_persistence_type: 'localStorage'
- *
- * // customize the name of cookie/localStorage set by opt-in/opt-out methods
- * opt_out_capturing_cookie_prefix: null
- *
- * // type of persistent store for super properties (cookie/
- * // localStorage) if set to 'localStorage', any existing
- * // posthog cookie value with the same persistence_name
- * // will be transferred to localStorage and deleted
- * persistence: 'cookie'
- *
- * // name for super properties persistent store
- * persistence_name: ''
- *
- * // names of properties/superproperties which should never
- * // be sent with capture() calls
- * property_blacklist: []
- *
- * // if this is true, posthog cookies will be marked as
- * // secure, meaning they will only be transmitted over https
- * secure_cookie: false
- *
- * // should we capture a page view on page load
- * capture_pageview: true
- *
- * // if you set upgrade to be true, the library will check for
- * // a cookie from our old js library and import super
- * // properties from it, then the old cookie is deleted
- * // The upgrade config option only works in the initialization,
- * // so make sure you set it when you create the library.
- * upgrade: false
- *
- * // extra HTTP request headers to set for each API request, in
- * // the format {'Header-Name': value}
- * xhr_headers: {}
- *
- * // protocol for fetching in-app message resources, e.g.
- * // 'https://' or 'http://'; defaults to '//' (which defers to the
- * // current page's protocol)
- * inapp_protocol: '//'
- *
- * // whether to open in-app message link in new tab/window
- * inapp_link_new_window: false
- *
- * // a set of rrweb config options that PostHog users can configure
- * // see https://github.com/rrweb-io/rrweb/blob/master/guide.md
- * session_recording: {
- * blockClass: 'ph-no-capture',
- * blockSelector: null,
- * ignoreClass: 'ph-ignore-input',
- * maskAllInputs: false,
- * maskInputOptions: {},
- * maskInputFn: null,
- * slimDOMOptions: {},
- * collectFonts: false
- * }
- *
- * // prevent autocapture from capturing any attribute names on elements
- * mask_all_element_attributes: false
- *
- * // prevent autocapture from capturing textContent on all elements
- * mask_all_text: false
- *
- * // will disable requests to the /decide endpoint (please review documentation for details)
- * // autocapture, feature flags, compression and session recording will be disabled when set to `true`
- * advanced_disable_decide: false
- *
- * }
- *
- *
- * @param {Object} config A dictionary of new configuration values to update
- */
- static set_config(config: posthog.Config): void
-
- /**
- * returns the current config object for the library.
- */
- static get_config(prop_name: T): posthog.Config[T]
-
- /**
- * Returns the value of the super property named property_name. If no such
- * property is set, get_property() will return the undefined value.
- *
- * ### Notes:
- *
- * get_property() can only be called after the PostHog library has finished loading.
- * init() has a loaded function available to handle this automatically. For example:
- *
- * // grab value for 'user_id' after the posthog library has loaded
- * posthog.init('YOUR PROJECT TOKEN', {
- * loaded: function(posthog) {
- * user_id = posthog.get_property('user_id');
- * }
- * });
- *
- * @param {String} property_name The name of the super property you want to retrieve
- */
- static get_property(property_name: string): posthog.Property | undefined
-
- /**
- * Returns the current distinct id of the user. This is either the id automatically
- * generated by the library or the id that has been passed by a call to identify().
- *
- * ### Notes:
- *
- * get_distinct_id() can only be called after the PostHog library has finished loading.
- * init() has a loaded function available to handle this automatically. For example:
- *
- * // set distinct_id after the posthog library has loaded
- * posthog.init('YOUR PROJECT TOKEN', {
- * loaded: function(posthog) {
- * distinct_id = posthog.get_distinct_id();
- * }
- * });
- */
- static get_distinct_id(): string
-
- /**
- * Opt the user out of data capturing and cookies/localstorage for this PostHog instance
- *
- * ### Usage
- *
- * // opt user out
- * posthog.opt_out_capturing();
- *
- * // opt user out with different cookie configuration from PostHog instance
- * posthog.opt_out_capturing({
- * cookie_expiration: 30,
- * secure_cookie: true
- * });
- *
- * @param {Object} [options] A dictionary of config options to override
- * @param {boolean} [options.clear_persistence=true] If true, will delete all data stored by the sdk in persistence
- * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
- * @param {string} [options.cookie_prefix=__ph_opt_in_out] Custom prefix to be used in the cookie/localstorage name
- * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this PostHog instance's config)
- */
- static opt_out_capturing(options?: posthog.OptInOutCapturingOptions): void
-
- /**
- * Opt the user in to data capturing and cookies/localstorage for this PostHog instance
- *
- * ### Usage
- *
- * // opt user in
- * posthog.opt_in_capturing();
- *
- * // opt user in with specific event name, properties, cookie configuration
- * posthog.opt_in_capturing({
- * capture_event_name: 'User opted in',
- * capture_event_properties: {
- * 'Email': 'jdoe@example.com'
- * },
- * cookie_expiration: 30,
- * secure_cookie: true
- * });
- *
- * @param {Object} [options] A dictionary of config options to override
- * @param {function} [options.capture] Function used for capturing a PostHog event to record the opt-in action (default is this PostHog instance's capture method)
- * @param {string} [options.capture_event_name=$opt_in] Event name to be used for capturing the opt-in action
- * @param {Object} [options.capture_properties] Set of properties to be captured along with the opt-in action
- * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
- * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
- * @param {string} [options.cookie_prefix=__ph_opt_in_out] Custom prefix to be used in the cookie/localstorage name
- * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this PostHog instance's config)
- */
- static opt_in_capturing(options?: posthog.OptInOutCapturingOptions): void
-
- /**
- * Check whether the user has opted out of data capturing and cookies/localstorage for this PostHog instance
- *
- * ### Usage
- *
- * const has_opted_out = posthog.has_opted_out_capturing();
- * // use has_opted_out value
- *
- * @param {Object} [options] A dictionary of config options to override
- * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
- * @param {string} [options.cookie_prefix=__ph_opt_in_out] Custom prefix to be used in the cookie/localstorage name
- * @returns {boolean} current opt-out status
- */
- static has_opted_out_capturing(options?: posthog.HasOptedInOutCapturingOptions): boolean
-
- /**
- * Check whether the user has opted in to data capturing and cookies/localstorage for this PostHog instance
- *
- * ### Usage
- *
- * const has_opted_in = posthog.has_opted_in_capturing();
- * // use has_opted_in value
- *
- * @param {Object} [options] A dictionary of config options to override
- * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
- * @param {string} [options.cookie_prefix=__ph_opt_in_out] Custom prefix to be used in the cookie/localstorage name
- * @returns {boolean} current opt-in status
- */
- static has_opted_in_capturing(options?: posthog.HasOptedInOutCapturingOptions): boolean
-
- /**
- * Clear the user's opt in/out status of data capturing and cookies/localstorage for this PostHog instance
- *
- * ### Usage
- *
- * // clear user's opt-in/out status
- * posthog.clear_opt_in_out_capturing();
- *
- * // clear user's opt-in/out status with specific cookie configuration - should match
- * // configuration used when opt_in_capturing/opt_out_capturing methods were called.
- * posthog.clear_opt_in_out_capturing({
- * cookie_expiration: 30,
- * secure_cookie: true
- * });
- *
- * @param {Object} [options] A dictionary of config options to override
- * @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
- * @param {string} [options.persistence_type=localStorage] Persistence mechanism used - cookie or localStorage - falls back to cookie if localStorage is unavailable
- * @param {string} [options.cookie_prefix=__ph_opt_in_out] Custom prefix to be used in the cookie/localstorage name
- * @param {Number} [options.cookie_expiration] Number of days until the opt-in cookie expires (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.cross_subdomain_cookie] Whether the opt-in cookie is set as cross-subdomain or not (overrides value specified in this PostHog instance's config)
- * @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this PostHog instance's config)
- */
- static clear_opt_in_out_capturing(options?: posthog.ClearOptInOutCapturingOptions): void
-
- /*
- * See if feature flag is enabled for user.
- *
- * ### Usage:
- *
- * if(posthog.isFeatureEnabled('beta-feature')) { // do something }
- *
- * @param {Object|String} prop Key of the feature flag.
- * @param {Object|String} options (optional) If {send_event: false}, we won't send an $feature_flag_call event to PostHog.
- */
- static isFeatureEnabled(key: string, options?: posthog.isFeatureEnabledOptions): boolean
-
- /*
- * See if feature flags are available.
- *
- * ### Usage:
- *
- * posthog.onFeatureFlags(function(featureFlags) { // do something })
- *
- * @param {Function} [callback] The callback function will be called once the feature flags are ready. It'll return a list of feature flags enabled for the user.
- */
- static onFeatureFlags(callback: (flags: string[]) => void): false | undefined
-
- /*
- * Reload all feature flags for the user.
- *
- * ### Usage:
- *
- * posthog.reloadFeatureFlags()
- */
- static reloadFeatureFlags(): void
-
- static toString(): string
-
- /* Will log all capture requests to the Javascript console, including event properties for easy debugging */
- static debug(): void
-
- /*
- * Starts session recording and updates disable_session_recording to false.
- * Used for manual session recording management. By default, session recording is enabled and
- * starts automatically.
- *
- * ### Usage:
- *
- * posthog.startSessionRecording()
- */
- static startSessionRecording(): void
-
- /*
- * Stops session recording and updates disable_session_recording to true.
- *
- * ### Usage:
- *
- * posthog.stopSessionRecording()
- */
- static stopSessionRecording(): void
-
- /*
- * Check if session recording is currently running.
- *
- * ### Usage:
- *
- * const isSessionRecordingOn = posthog.sessionRecordingStarted()
- */
- static sessionRecordingStarted(): boolean
-}
-
-declare namespace posthog {
- /* eslint-disable @typescript-eslint/no-explicit-any */
- type Property = any;
- type Properties = Record;
- type CaptureResult = { event: string; properties: Properties } | undefined;
- type CaptureCallback = (response: any, data: any) => void;
- /* eslint-enable @typescript-eslint/no-explicit-any */
-
- interface Config {
- api_host?: string
- api_method?: string
- api_transport?: string
- autocapture?: boolean
- rageclick?: boolean
- cdn?: string
- cross_subdomain_cookie?: boolean
- persistence?: 'localStorage' | 'cookie' | 'memory'
- persistence_name?: string
- cookie_name?: string
- loaded?: (posthog_instance: typeof posthog) => void
- store_google?: boolean
- save_referrer?: boolean
- test?: boolean
- verbose?: boolean
- img?: boolean
- capture_pageview?: boolean
- debug?: boolean
- cookie_expiration?: number
- upgrade?: boolean
- disable_session_recording?: boolean
- disable_persistence?: boolean
- disable_cookie?: boolean
- secure_cookie?: boolean
- ip?: boolean
- opt_out_capturing_by_default?: boolean
- opt_out_persistence_by_default?: boolean
- opt_out_capturing_persistence_type?: 'localStorage' | 'cookie'
- opt_out_capturing_cookie_prefix?: string | null
- respect_dnt?: boolean
- property_blacklist?: string[]
- xhr_headers?: { [header_name: string]: string }
- inapp_protocol?: string
- inapp_link_new_window?: boolean
- request_batching?: boolean
- sanitize_properties?: (properties: posthog.Properties, event_name: string) => posthog.Properties
- properties_string_max_length?: number
- mask_all_element_attributes?: boolean
- mask_all_text?: boolean
- advanced_disable_decide?: boolean
- }
-
- interface OptInOutCapturingOptions {
- clear_persistence: boolean
- persistence_type: string
- cookie_prefix: string
- cookie_expiration: number
- cross_subdomain_cookie: boolean
- secure_cookie: boolean
- }
-
- interface HasOptedInOutCapturingOptions {
- persistence_type: string
- cookie_prefix: string
- }
-
- interface ClearOptInOutCapturingOptions {
- enable_persistence: boolean
- persistence_type: string
- cookie_prefix: string
- cookie_expiration: number
- cross_subdomain_cookie: boolean
- secure_cookie: boolean
- }
-
- interface isFeatureEnabledOptions {
- send_event: boolean
- }
-
- export class persistence {
- static properties(): posthog.Properties
-
- static load(): void
-
- static save(): void
-
- static remove(): void
-
- static clear(): void
-
- /**
- * @param {Object} props
- * @param {*=} default_value
- * @param {number=} days
- */
- static register_once(props: Properties, default_value?: Property, days?: number): boolean
-
- /**
- * @param {Object} props
- * @param {number=} days
- */
- static register(props: posthog.Properties, days?: number): boolean
-
- static unregister(prop: string): void
-
- static update_campaign_params(): void
-
- static update_search_keyword(referrer: string): void
-
- static update_referrer_info(referrer: string): void
-
- static get_referrer_info(): posthog.Properties
-
- static safe_merge(props: posthog.Properties): posthog.Properties
-
- static update_config(config: posthog.Config): void
-
- static set_disabled(disabled: boolean): void
-
- static set_cross_subdomain(cross_subdomain: boolean): void
-
- static get_cross_subdomain(): boolean
-
- static set_secure(secure: boolean): void
-
- static set_event_timer(event_name: string, timestamp: Date): void
-
- static remove_event_timer(event_name: string): Date | undefined
- }
-
- export class people {
- /*
- * Set properties on a user record.
- *
- * ### Usage:
- *
- * posthog.people.set('gender', 'm');
- *
- * // or set multiple properties at once
- * posthog.people.set({
- * 'Company': 'Acme',
- * 'Plan': 'Premium',
- * 'Upgrade date': new Date()
- * });
- * // properties can be strings, integers, dates, or lists
- *
- * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
- * @param {*} [to] A value to set on the given property name
- * @param {Function} [callback] If provided, the callback will be called after capturing the event.
- */
- static set(
- prop: posthog.Properties | string,
- to?: posthog.Property,
- callback?: posthog.CaptureCallback
- ): posthog.Properties
-
- /*
- * Set properties on a user record, only if they do not yet exist.
- * This will not overwrite previous people property values, unlike
- * people.set().
- *
- * ### Usage:
- *
- * posthog.people.set_once('First Login Date', new Date());
- *
- * // or set multiple properties at once
- * posthog.people.set_once({
- * 'First Login Date': new Date(),
- * 'Starting Plan': 'Premium'
- * });
- *
- * // properties can be strings, integers or dates
- *
- * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
- * @param {*} [to] A value to set on the given property name
- * @param {Function} [callback] If provided, the callback will be called after capturing the event.
- */
- static set_once(
- prop: posthog.Properties | string,
- to?: posthog.Property,
- callback?: posthog.CaptureCallback
- ): posthog.Properties
-
- static toString(): string
- }
-
- export class featureFlags {
- static getFlags(): string[]
-
- static reloadFeatureFlags(): void
-
- /*
- * See if feature flag is enabled for user.
- *
- * ### Usage:
- *
- * if(posthog.isFeatureEnabled('beta-feature')) { // do something }
- *
- * @param {Object|String} prop Key of the feature flag.
- * @param {Object|String} options (optional) If {send_event: false}, we won't send an $feature_flag_call event to PostHog.
- */
- static isFeatureEnabled(key: string, options?: { send_event?: boolean }): boolean
-
- /*
- * See if feature flags are available.
- *
- * ### Usage:
- *
- * posthog.onFeatureFlags(function(featureFlags) { // do something })
- *
- * @param {Function} [callback] The callback function will be called once the feature flags are ready. It'll return a list of feature flags enabled for the user.
- */
- static onFeatureFlags(callback: (flags: string[]) => void): false | undefined
- }
-
- export class feature_flags extends featureFlags {}
-}
-
-export type PostHog = typeof posthog;
-
-export default posthog;
diff --git a/tsconfig.json b/tsconfig.json
index b982d40b07..2e0131609c 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -23,11 +23,6 @@
"dom",
"dom.iterable"
],
- "paths": {
- "posthog-js": [
- "./src/@types/posthog.d.ts"
- ]
- }
},
"include": [
"./src/**/*.ts",
diff --git a/yarn.lock b/yarn.lock
index daed6f4377..6bb5654db8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1790,6 +1790,11 @@
object.fromentries "^2.0.0"
prop-types "^15.7.0"
+"@yarnpkg/lockfile@^1.1.0":
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
+ integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
+
abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a"
@@ -2713,7 +2718,7 @@ cross-fetch@^3.0.4:
dependencies:
node-fetch "2.6.1"
-cross-spawn@^6.0.0:
+cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
@@ -3664,6 +3669,13 @@ find-up@^4.0.0, find-up@^4.1.0:
locate-path "^5.0.0"
path-exists "^4.0.0"
+find-yarn-workspace-root@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"
+ integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==
+ dependencies:
+ micromatch "^4.0.2"
+
flat-cache@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11"
@@ -3743,6 +3755,15 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"
+fs-extra@^7.0.1:
+ version "7.0.1"
+ resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
+ integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
+ dependencies:
+ graceful-fs "^4.1.2"
+ jsonfile "^4.0.0"
+ universalify "^0.1.0"
+
fs-readdir-recursive@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
@@ -3919,7 +3940,7 @@ gonzales-pe@^4.3.0:
dependencies:
minimist "^1.2.5"
-graceful-fs@^4.1.11, graceful-fs@^4.2.4:
+graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.4:
version "4.2.6"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==
@@ -4595,7 +4616,7 @@ is-windows@^1.0.2:
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
-is-wsl@^2.2.0:
+is-wsl@^2.1.1, is-wsl@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"
integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==
@@ -5217,6 +5238,13 @@ json5@^2.1.2:
dependencies:
minimist "^1.2.5"
+jsonfile@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
+ integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
+ optionalDependencies:
+ graceful-fs "^4.1.6"
+
jsprim@^1.2.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
@@ -5266,6 +5294,13 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
+klaw-sync@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
+ integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
+ dependencies:
+ graceful-fs "^4.1.11"
+
kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
@@ -5937,6 +5972,14 @@ onetime@^5.1.0:
dependencies:
mimic-fn "^2.1.0"
+open@^7.4.2:
+ version "7.4.2"
+ resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
+ integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
+ dependencies:
+ is-docker "^2.0.0"
+ is-wsl "^2.1.1"
+
optionator@^0.8.1:
version "0.8.3"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
@@ -5966,6 +6009,11 @@ opus-recorder@^8.0.3:
resolved "https://registry.yarnpkg.com/opus-recorder/-/opus-recorder-8.0.3.tgz#f7b44f8f68500c9b96a15042a69f915fd9c1716d"
integrity sha512-8vXGiRwlJAavT9D3yYzukNVXQ8vEcKHcsQL/zXO24DQtJ0PLXvoPHNQPJrbMCdB4ypJgWDExvHF4JitQDL7dng==
+os-tmpdir@~1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
+ integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=
+
p-each-series@^2.1.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a"
@@ -6074,6 +6122,25 @@ pascalcase@^0.1.1:
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
+patch-package@^6.4.7:
+ version "6.4.7"
+ resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.4.7.tgz#2282d53c397909a0d9ef92dae3fdeb558382b148"
+ integrity sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==
+ dependencies:
+ "@yarnpkg/lockfile" "^1.1.0"
+ chalk "^2.4.2"
+ cross-spawn "^6.0.5"
+ find-yarn-workspace-root "^2.0.0"
+ fs-extra "^7.0.1"
+ is-ci "^2.0.0"
+ klaw-sync "^6.0.0"
+ minimist "^1.2.0"
+ open "^7.4.2"
+ rimraf "^2.6.3"
+ semver "^5.6.0"
+ slash "^2.0.0"
+ tmp "^0.0.33"
+
path-exists@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
@@ -6254,13 +6321,18 @@ postcss@^8.0.2:
nanoid "^3.1.23"
source-map-js "^0.6.2"
-posthog-js@1.12.1:
- version "1.12.1"
- resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.12.1.tgz#97834ee2574f34ffb5db2f5b07452c847e3c4d27"
- integrity sha512-Y3lzcWkS8xFY6Ryj3I4ees7qWP2WGkLw0Arcbk5xaT0+5YlA6UC2jlL/+fN9bz/Bl62EoN3BML901Cuot/QNjg==
+posthog-js@^1.12.2:
+ version "1.12.2"
+ resolved "https://registry.yarnpkg.com/posthog-js/-/posthog-js-1.12.2.tgz#ff76e26634067e003f8af7df654d7ea0e647d946"
+ integrity sha512-I0d6c+Yu2f91PFidz65AIkkqZM219EY9Z1wlbTkW5Zqfq5oXqogBMKS8BaDBOrMc46LjLX7IH67ytCcBFRo1uw==
dependencies:
fflate "^0.4.1"
+postinstall-postinstall@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3"
+ integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ==
+
prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -6834,6 +6906,13 @@ rfc4648@^1.4.0:
resolved "https://registry.yarnpkg.com/rfc4648/-/rfc4648-1.5.0.tgz#1ba940ec1649685ec4d88788dc57fb8e18855055"
integrity sha512-FA6W9lDNeX8WbMY31io1xWg+TpZCbeDKsBo0ocwACZiWnh9TUAyk9CCuBQuOPmYnwwdEQZmraQ2ZK7yJsxErBg==
+rimraf@^2.6.3:
+ version "2.7.1"
+ resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"
+ integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==
+ dependencies:
+ glob "^7.1.3"
+
rimraf@^3.0.0, rimraf@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
@@ -7520,6 +7599,13 @@ tmatch@^2.0.1:
resolved "https://registry.yarnpkg.com/tmatch/-/tmatch-2.0.1.tgz#0c56246f33f30da1b8d3d72895abaf16660f38cf"
integrity sha1-DFYkbzPzDaG409colauvFmYPOM8=
+tmp@^0.0.33:
+ version "0.0.33"
+ resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
+ integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
+ dependencies:
+ os-tmpdir "~1.0.2"
+
tmpl@1.0.x:
version "1.0.4"
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
@@ -7765,7 +7851,7 @@ unist-util-stringify-position@^2.0.0:
dependencies:
"@types/unist" "^2.0.2"
-universalify@^0.1.2:
+universalify@^0.1.0, universalify@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==