posthog-js 1.90.2 → 1.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +1 -1
  6. package/dist/es.js.map +1 -1
  7. package/dist/exception-autocapture.js +1 -1
  8. package/dist/exception-autocapture.js.map +1 -1
  9. package/dist/module.d.ts +3 -4
  10. package/dist/module.js +1 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/recorder-v2.js +1 -1
  13. package/dist/recorder-v2.js.map +1 -1
  14. package/dist/recorder.js +1 -1
  15. package/dist/recorder.js.map +1 -1
  16. package/dist/surveys.js +1 -1
  17. package/dist/surveys.js.map +1 -1
  18. package/lib/package.json +1 -1
  19. package/lib/src/autocapture-utils.js +2 -1
  20. package/lib/src/autocapture-utils.js.map +1 -1
  21. package/lib/src/autocapture.js +11 -4
  22. package/lib/src/autocapture.js.map +1 -1
  23. package/lib/src/decide.js +2 -1
  24. package/lib/src/decide.js.map +1 -1
  25. package/lib/src/extensions/exception-autocapture/index.js +6 -3
  26. package/lib/src/extensions/exception-autocapture/index.js.map +1 -1
  27. package/lib/src/extensions/replay/sessionrecording.js +8 -8
  28. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  29. package/lib/src/extensions/replay/web-performance.js +1 -0
  30. package/lib/src/extensions/replay/web-performance.js.map +1 -1
  31. package/lib/src/extensions/surveys.js +10 -2
  32. package/lib/src/extensions/surveys.js.map +1 -1
  33. package/lib/src/extensions/toolbar.d.ts +2 -2
  34. package/lib/src/extensions/toolbar.js +16 -13
  35. package/lib/src/extensions/toolbar.js.map +1 -1
  36. package/lib/src/gdpr-utils.js +2 -2
  37. package/lib/src/gdpr-utils.js.map +1 -1
  38. package/lib/src/loader-exception-autocapture.js +4 -3
  39. package/lib/src/loader-exception-autocapture.js.map +1 -1
  40. package/lib/src/loader-recorder-v2.js +7 -4
  41. package/lib/src/loader-recorder-v2.js.map +1 -1
  42. package/lib/src/loader-recorder.js +6 -6
  43. package/lib/src/loader-recorder.js.map +1 -1
  44. package/lib/src/loader-surveys.js +5 -3
  45. package/lib/src/loader-surveys.js.map +1 -1
  46. package/lib/src/page-view.js +14 -11
  47. package/lib/src/page-view.js.map +1 -1
  48. package/lib/src/posthog-core.js +21 -22
  49. package/lib/src/posthog-core.js.map +1 -1
  50. package/lib/src/posthog-surveys.js +7 -4
  51. package/lib/src/posthog-surveys.js.map +1 -1
  52. package/lib/src/retry-queue.js +2 -1
  53. package/lib/src/retry-queue.js.map +1 -1
  54. package/lib/src/session-props.d.ts +1 -2
  55. package/lib/src/session-props.js +2 -2
  56. package/lib/src/session-props.js.map +1 -1
  57. package/lib/src/sessionid.js +1 -1
  58. package/lib/src/sessionid.js.map +1 -1
  59. package/lib/src/storage.d.ts +1 -1
  60. package/lib/src/storage.js +18 -8
  61. package/lib/src/storage.js.map +1 -1
  62. package/lib/src/utils/event-utils.js +16 -10
  63. package/lib/src/utils/event-utils.js.map +1 -1
  64. package/lib/src/utils/globals.d.ts +5 -4
  65. package/lib/src/utils/globals.js +7 -5
  66. package/lib/src/utils/globals.js.map +1 -1
  67. package/lib/src/utils/index.js +7 -4
  68. package/lib/src/utils/index.js.map +1 -1
  69. package/lib/src/utils/logger.js +5 -2
  70. package/lib/src/utils/logger.js.map +1 -1
  71. package/lib/src/uuidv7.js +1 -1
  72. package/lib/src/uuidv7.js.map +1 -1
  73. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"gdpr-utils.js","sourceRoot":"","sources":["../../src/gdpr-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,WAAW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AI,SAAS,CAAA;QACrF,IAAM,GAAG,GAAI,OAAO,CAAC,MAAc,CAAC,MAA4B,CAAA,CAAC,+CAA+C;QAEhH,IAAI,KAAK,EAAE;YACP,+EAA+E;YAC/E,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE;gBAC1B,UAAU,YAAA;gBACV,eAAe,iBAAA;gBACf,iBAAiB,mBAAA;gBACjB,MAAM,EAAE,GAAG;aACd,CAAC,CAAA;SACL;KACJ;IAAC,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,2DAA2D,GAAG,GAAG,CAAC,CAAA;KAClF;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["/**\n * GDPR utils\n *\n * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection\n * and privacy for all individuals within the European Union. It addresses the export of personal\n * data outside the EU. The GDPR aims primarily to give control back to citizens and residents\n * over their personal data and to simplify the regulatory environment for international business\n * by unifying the regulation within the EU.\n *\n * This set of utilities is intended to enable opt in/out functionality in the PostHog JS SDK.\n * These functions are used internally by the SDK and are not intended to be publicly exposed.\n */\n\nimport { _each, _includes } from './utils'\nimport { window } from './utils/globals'\nimport { cookieStore, localStore, localPlusCookieStore } from './storage'\nimport { GDPROptions, PersistentStore } from './types'\nimport { PostHog } from './posthog-core'\n\nimport { _isNumber, _isString } from './utils/type-utils'\nimport { logger } from './utils/logger'\n\n/**\n * A function used to capture a PostHog event (e.g. PostHogLib.capture)\n * @callback captureFunction\n * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.\n * @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.\n * @param {Function} [callback] If provided, the callback function will be called after capturing the event.\n */\n\n/** Public **/\n\nconst GDPR_DEFAULT_PERSISTENCE_PREFIX = '__ph_opt_in_out_'\n\n/**\n * Opt the user in to data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {captureFunction} [options.capture] - function used for capturing a PostHog event to record the opt-in action\n * @param {string} [options.captureEventName] - event name to be used for capturing the opt-in action\n * @param {Object} [options.captureProperties] - set of properties to be captured along with the opt-in action\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nexport function optIn(token: string, options: GDPROptions): void {\n _optInOut(true, token, options)\n}\n\n/**\n * Opt the user out of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not\n */\nexport function optOut(token: string, options: GDPROptions): void {\n _optInOut(false, token, options)\n}\n\n/**\n * Check whether the user has opted in to data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {boolean} whether the user has opted in to the given opt type\n */\nexport function hasOptedIn(token: string, options: GDPROptions): boolean {\n return _getStorageValue(token, options) === '1'\n}\n\n/**\n * Check whether the user has opted out of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {boolean} [options.respectDnt] - flag to take browser DNT setting into account\n * @returns {boolean} whether the user has opted out of the given opt type\n */\nexport function hasOptedOut(token: string, options: Partial<GDPROptions>): boolean {\n if (_hasDoNotTrackFlagOn(options)) {\n return true\n }\n return _getStorageValue(token, options) === '0'\n}\n\n/**\n * Clear the user's opt in/out status of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nexport function clearOptInOut(token: string, options: GDPROptions) {\n options = options || {}\n _getStorage(options).remove(_getStorageKey(token, options), !!options.crossSubdomainCookie)\n}\n\n/** Private **/\n\n/**\n * Get storage util\n * @param {Object} [options]\n * @param {string} [options.persistenceType]\n * @returns {object} either cookieStore or localStore\n */\nfunction _getStorage(options: GDPROptions): PersistentStore {\n options = options || {}\n if (options.persistenceType === 'localStorage') {\n return localStore\n }\n if (options.persistenceType === 'localStorage+cookie') {\n return localPlusCookieStore\n }\n return cookieStore\n}\n\n/**\n * Get the name of the cookie that is used for the given opt type (capturing, cookie, etc.)\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {string} the name of the cookie for the given opt type\n */\nfunction _getStorageKey(token: string, options: GDPROptions) {\n options = options || {}\n return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token\n}\n\n/**\n * Get the value of the cookie that is used for the given opt type (capturing, cookie, etc.)\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {string} the value of the cookie for the given opt type\n */\nfunction _getStorageValue(token: string, options: GDPROptions) {\n return _getStorage(options).get(_getStorageKey(token, options))\n}\n\n/**\n * Check whether the user has set the DNT/doNotTrack setting to true in their browser\n * @param {Object} [options]\n * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests\n * @param {boolean} [options.respectDnt] - flag to take browser DNT setting into account\n * @returns {boolean} whether the DNT setting is true\n */\nfunction _hasDoNotTrackFlagOn(options: GDPROptions) {\n if (options && options.respectDnt) {\n const win = (options && options.window) || window\n const nav = win['navigator'] || {}\n let hasDntOn = false\n _each(\n [\n nav['doNotTrack'], // standard\n (nav as any)['msDoNotTrack'],\n (win as any)['doNotTrack'],\n ],\n function (dntValue) {\n if (_includes([true, 1, '1', 'yes'], dntValue)) {\n hasDntOn = true\n }\n }\n )\n return hasDntOn\n }\n return false\n}\n\n/**\n * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type\n * @param {boolean} optValue - whether to opt the user in or out for the given opt type\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {captureFunction} [options.capture] - function used for capturing a PostHog event to record the opt-in action\n * @param {string} [options.captureEventName] - event name to be used for capturing the opt-in action\n * @param {Object} [options.captureProperties] - set of properties to be captured along with the opt-in action\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nfunction _optInOut(optValue: boolean, token: string, options: GDPROptions) {\n if (!_isString(token) || !token.length) {\n logger.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token')\n return\n }\n\n options = options || {}\n\n _getStorage(options).set(\n _getStorageKey(token, options),\n optValue ? 1 : 0,\n _isNumber(options.cookieExpiration) ? options.cookieExpiration : null,\n options.crossSubdomainCookie,\n options.secureCookie\n )\n\n if (options.capture && optValue) {\n // only capture event if opting in (optValue=true)\n options.capture(options.captureEventName || '$opt_in', options.captureProperties || {}, {\n send_instantly: true,\n })\n }\n}\n\nexport function userOptedOut(posthog: PostHog) {\n let optedOut = false\n\n try {\n const token = posthog.config.token\n const respectDnt = posthog.config.respect_dnt\n const persistenceType = posthog.config.opt_out_capturing_persistence_type\n const persistencePrefix = posthog.config.opt_out_capturing_cookie_prefix || undefined\n const win = (posthog.config as any).window as Window | undefined // used to override window during browser tests\n\n if (token) {\n // if there was an issue getting the token, continue method execution as normal\n optedOut = hasOptedOut(token, {\n respectDnt,\n persistenceType,\n persistencePrefix,\n window: win,\n })\n }\n } catch (err) {\n logger.error('Unexpected error when checking capturing opt-out status: ' + err)\n }\n return optedOut\n}\n"]}
1
+ {"version":3,"file":"gdpr-utils.js","sourceRoot":"","sources":["../../src/gdpr-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAIzE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC;;;;;;GAMG;AAEH,cAAc;AAEd,IAAM,+BAA+B,GAAG,kBAAkB,CAAA;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,OAAoB;IACrD,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AACnC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,OAAo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":["/**\n * GDPR utils\n *\n * The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection\n * and privacy for all individuals within the European Union. It addresses the export of personal\n * data outside the EU. The GDPR aims primarily to give control back to citizens and residents\n * over their personal data and to simplify the regulatory environment for international business\n * by unifying the regulation within the EU.\n *\n * This set of utilities is intended to enable opt in/out functionality in the PostHog JS SDK.\n * These functions are used internally by the SDK and are not intended to be publicly exposed.\n */\n\nimport { _each, _includes } from './utils'\nimport { window } from './utils/globals'\nimport { cookieStore, localStore, localPlusCookieStore } from './storage'\nimport { GDPROptions, PersistentStore } from './types'\nimport { PostHog } from './posthog-core'\n\nimport { _isNumber, _isString } from './utils/type-utils'\nimport { logger } from './utils/logger'\n\n/**\n * A function used to capture a PostHog event (e.g. PostHogLib.capture)\n * @callback captureFunction\n * @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.\n * @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.\n * @param {Function} [callback] If provided, the callback function will be called after capturing the event.\n */\n\n/** Public **/\n\nconst GDPR_DEFAULT_PERSISTENCE_PREFIX = '__ph_opt_in_out_'\n\n/**\n * Opt the user in to data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {captureFunction} [options.capture] - function used for capturing a PostHog event to record the opt-in action\n * @param {string} [options.captureEventName] - event name to be used for capturing the opt-in action\n * @param {Object} [options.captureProperties] - set of properties to be captured along with the opt-in action\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nexport function optIn(token: string, options: GDPROptions): void {\n _optInOut(true, token, options)\n}\n\n/**\n * Opt the user out of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not\n */\nexport function optOut(token: string, options: GDPROptions): void {\n _optInOut(false, token, options)\n}\n\n/**\n * Check whether the user has opted in to data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {boolean} whether the user has opted in to the given opt type\n */\nexport function hasOptedIn(token: string, options: GDPROptions): boolean {\n return _getStorageValue(token, options) === '1'\n}\n\n/**\n * Check whether the user has opted out of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {boolean} [options.respectDnt] - flag to take browser DNT setting into account\n * @returns {boolean} whether the user has opted out of the given opt type\n */\nexport function hasOptedOut(token: string, options: Partial<GDPROptions>): boolean {\n if (_hasDoNotTrackFlagOn(options)) {\n return true\n }\n return _getStorageValue(token, options) === '0'\n}\n\n/**\n * Clear the user's opt in/out status of data capturing and cookies/localstorage for the given token\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nexport function clearOptInOut(token: string, options: GDPROptions) {\n options = options || {}\n _getStorage(options).remove(_getStorageKey(token, options), !!options.crossSubdomainCookie)\n}\n\n/** Private **/\n\n/**\n * Get storage util\n * @param {Object} [options]\n * @param {string} [options.persistenceType]\n * @returns {object} either cookieStore or localStore\n */\nfunction _getStorage(options: GDPROptions): PersistentStore {\n options = options || {}\n if (options.persistenceType === 'localStorage') {\n return localStore\n }\n if (options.persistenceType === 'localStorage+cookie') {\n return localPlusCookieStore\n }\n return cookieStore\n}\n\n/**\n * Get the name of the cookie that is used for the given opt type (capturing, cookie, etc.)\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {string} the name of the cookie for the given opt type\n */\nfunction _getStorageKey(token: string, options: GDPROptions) {\n options = options || {}\n return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token\n}\n\n/**\n * Get the value of the cookie that is used for the given opt type (capturing, cookie, etc.)\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @returns {string} the value of the cookie for the given opt type\n */\nfunction _getStorageValue(token: string, options: GDPROptions) {\n return _getStorage(options).get(_getStorageKey(token, options))\n}\n\n/**\n * Check whether the user has set the DNT/doNotTrack setting to true in their browser\n * @param {Object} [options]\n * @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests\n * @param {boolean} [options.respectDnt] - flag to take browser DNT setting into account\n * @returns {boolean} whether the DNT setting is true\n */\nfunction _hasDoNotTrackFlagOn(options: GDPROptions) {\n if (options && options.respectDnt) {\n const win = (options && options.window) || window\n const nav = win?.navigator\n let hasDntOn = false\n _each(\n [\n nav?.doNotTrack, // standard\n (nav as any)['msDoNotTrack'],\n (win as any)['doNotTrack'],\n ],\n function (dntValue) {\n if (_includes([true, 1, '1', 'yes'], dntValue)) {\n hasDntOn = true\n }\n }\n )\n return hasDntOn\n }\n return false\n}\n\n/**\n * Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type\n * @param {boolean} optValue - whether to opt the user in or out for the given opt type\n * @param {string} token - PostHog project capturing token\n * @param {Object} [options]\n * @param {captureFunction} [options.capture] - function used for capturing a PostHog event to record the opt-in action\n * @param {string} [options.captureEventName] - event name to be used for capturing the opt-in action\n * @param {Object} [options.captureProperties] - set of properties to be captured along with the opt-in action\n * @param {string} [options.persistencePrefix=__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name\n * @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires\n * @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not\n * @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not\n */\nfunction _optInOut(optValue: boolean, token: string, options: GDPROptions) {\n if (!_isString(token) || !token.length) {\n logger.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token')\n return\n }\n\n options = options || {}\n\n _getStorage(options).set(\n _getStorageKey(token, options),\n optValue ? 1 : 0,\n _isNumber(options.cookieExpiration) ? options.cookieExpiration : null,\n options.crossSubdomainCookie,\n options.secureCookie\n )\n\n if (options.capture && optValue) {\n // only capture event if opting in (optValue=true)\n options.capture(options.captureEventName || '$opt_in', options.captureProperties || {}, {\n send_instantly: true,\n })\n }\n}\n\nexport function userOptedOut(posthog: PostHog) {\n let optedOut = false\n\n try {\n const token = posthog.config.token\n const respectDnt = posthog.config.respect_dnt\n const persistenceType = posthog.config.opt_out_capturing_persistence_type\n const persistencePrefix = posthog.config.opt_out_capturing_cookie_prefix || undefined\n const win = (posthog.config as any).window as Window | undefined // used to override window during browser tests\n\n if (token) {\n // if there was an issue getting the token, continue method execution as normal\n optedOut = hasOptedOut(token, {\n respectDnt,\n persistenceType,\n persistencePrefix,\n window: win,\n })\n }\n } catch (err) {\n logger.error('Unexpected error when checking capturing opt-out status: ' + err)\n }\n return optedOut\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { extendPostHog } from './extensions/exception-autocapture';
2
- import { _isUndefined } from './utils/type-utils';
3
- var win = _isUndefined(window) ? {} : window;
4
- win.extendPostHogWithExceptionAutoCapture = extendPostHog;
2
+ import { window } from './utils/globals';
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
+ // @ts-ignore
5
+ window.extendPostHogWithExceptionAutoCapture = extendPostHog;
5
6
  export default extendPostHog;
6
7
  //# sourceMappingURL=loader-exception-autocapture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader-exception-autocapture.js","sourceRoot":"","sources":["../../src/loader-exception-autocapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,IAAM,GAAG,GAA+B,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAAoB,CAAC,CAAC,CAAC,MAAM,CAE5F;AAAC,GAAW,CAAC,qCAAqC,GAAG,aAAa,CAAA;AAEnE,eAAe,aAAa,CAAA","sourcesContent":["import { extendPostHog } from './extensions/exception-autocapture'\n\nimport { _isUndefined } from './utils/type-utils'\n\nconst win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window\n\n;(win as any).extendPostHogWithExceptionAutoCapture = extendPostHog\n\nexport default extendPostHog\n"]}
1
+ {"version":3,"file":"loader-exception-autocapture.js","sourceRoot":"","sources":["../../src/loader-exception-autocapture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAElE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,6DAA6D;AAC7D,aAAa;AACb,MAAM,CAAC,qCAAqC,GAAG,aAAa,CAAA;AAE5D,eAAe,aAAa,CAAA","sourcesContent":["import { extendPostHog } from './extensions/exception-autocapture'\n\nimport { window } from './utils/globals'\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nwindow.extendPostHogWithExceptionAutoCapture = extendPostHog\n\nexport default extendPostHog\n"]}
@@ -55,6 +55,7 @@ import rrwebRecord from 'rrweb/es/rrweb/packages/rrweb/src/record';
55
55
  import { getRecordConsolePlugin } from 'rrweb/es/rrweb/packages/rrweb/src/plugins/console/record';
56
56
  import { _isBoolean, _isFunction, _isArray, _isUndefined, _isNull } from './utils/type-utils';
57
57
  import { logger } from './utils/logger';
58
+ import { window } from './utils/globals';
58
59
  import { defaultNetworkOptions } from './extensions/replay/config';
59
60
  var isNavigationTiming = function (entry) {
60
61
  return entry.entryType === 'navigation';
@@ -451,9 +452,11 @@ export var getRecordNetworkPlugin = function (options) {
451
452
  };
452
453
  };
453
454
  // rrweb/networ@1 ends
454
- var win = _isUndefined(window) ? {} : window;
455
- win.rrweb = { record: rrwebRecord, version: 'v2', rrwebVersion: version };
456
- win.rrwebConsoleRecord = { getRecordConsolePlugin: getRecordConsolePlugin };
457
- win.getRecordNetworkPlugin = getRecordNetworkPlugin;
455
+ if (window) {
456
+ ;
457
+ window.rrweb = { record: rrwebRecord, version: 'v2', rrwebVersion: version };
458
+ window.rrwebConsoleRecord = { getRecordConsolePlugin: getRecordConsolePlugin };
459
+ window.getRecordNetworkPlugin = getRecordNetworkPlugin;
460
+ }
458
461
  export default rrwebRecord;
459
462
  //# sourceMappingURL=loader-recorder-v2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader-recorder-v2.js","sourceRoot":"","sources":["../../src/loader-recorder-v2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,4DAA4D;AAC5D,6DAA6D;AA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Ac,CAAC,CAAA;IAC5D,IAAM,aAAa,GAAG,iBAAiB,CAAC,EAAE,EAAE,GAAG,EAAE,cAAc,CAAC,CAAA;IAChE,OAAO;QACH,mBAAmB,EAAE,CAAA;QACrB,WAAW,EAAE,CAAA;QACb,aAAa,EAAE,CAAA;IACnB,CAAC,CAAA;AACL,CAAC;AAED,4EAA4E;AAC5E,8EAA8E;AAC9E,MAAM,CAAC,IAAM,mBAAmB,GAAG,iBAAiB,CAAA;AAEpD,iCAAiC;AACjC,6DAA6D;AAC7D,aAAa;AACb,MAAM,CAAC,IAAM,sBAAsB,GAAqD,UAAC,OAAO;IAC5F,OAAO;QACH,IAAI,EAAE,mBAAmB;QACzB,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE,OAAO;KACnB,CAAA;AACL,CAAC,CAAA;AAED,sBAAsB;AAEtB,IAAM,GAAG,GAA+B,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAAoB,CAAC,CAAC,CAAC,MAAM,CAE5F;AAAC,GAAW,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAClF;AAAC,GAAW,CAAC,kBAAkB,GAAG,EAAE,sBAAsB,wBAAA,EAAE,CAC5D;AAAC,GAAW,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;AAE7D,eAAe,WAAW,CAAA","sourcesContent":["import { version } from 'rrweb/package.json'\n\n// Same as loader-globals.ts except includes rrweb2 scripts.\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport rrwebRecord from 'rrweb/es/rrweb/packages/rrweb/src/record'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getRecordConsolePlugin } from 'rrweb/es/rrweb/packages/rrweb/src/plugins/console/record'\n\n// rrweb/network@1 code starts\n// most of what is below here will be removed when rrweb release their code for this\n// see https://github.com/rrweb-io/rrweb/pull/1105\n\n/// <reference lib=\"dom\" />\n\n// NB adopted from https://github.com/rrweb-io/rrweb/pull/1105 which looks like it will be accepted into rrweb\n// however, in the PR, it throws when the performance observer data is not available\n// and assumes it is running in a browser with the Request API (i.e. not IE11)\n// copying here so that we can use it before rrweb adopt it\n\nimport type { IWindow, listenerHandler, RecordPlugin } from '@rrweb/types'\nimport { InitiatorType, NetworkRecordOptions, NetworkRequest, Headers } from './types'\nimport { _isBoolean, _isFunction, _isArray, _isUndefined, _isNull } from './utils/type-utils'\nimport { logger } from './utils/logger'\nimport { defaultNetworkOptions } from './extensions/replay/config'\n\nexport type NetworkData = {\n requests: NetworkRequest[]\n isInitial?: boolean\n}\n\ntype networkCallback = (data: NetworkData) => void\n\nconst isNavigationTiming = (entry: PerformanceEntry): entry is PerformanceNavigationTiming =>\n entry.entryType === 'navigation'\nconst isResourceTiming = (entry: PerformanceEntry): entry is PerformanceResourceTiming => entry.entryType === 'resource'\n\ntype ObservedPerformanceEntry = (PerformanceNavigationTiming | PerformanceResourceTiming) & {\n responseStatus?: number\n}\n\n// import { patch } from 'rrweb/typings/utils'\n// copied from https://github.com/rrweb-io/rrweb/blob/8aea5b00a4dfe5a6f59bd2ae72bb624f45e51e81/packages/rrweb/src/utils.ts#L129\n// which was copied from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n }\n }\n\n const original = source[name] as () => unknown\n const wrapped = replacement(original)\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (_isFunction(wrapped)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {}\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n })\n }\n\n source[name] = wrapped\n\n return () => {\n source[name] = original\n }\n } catch {\n return () => {\n //\n }\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function findLast<T>(array: Array<T>, predicate: (value: T) => boolean): T | undefined {\n const length = array.length\n for (let i = length - 1; i >= 0; i -= 1) {\n if (predicate(array[i])) {\n return array[i]\n }\n }\n return undefined\n}\n\nfunction initPerformanceObserver(cb: networkCallback, win: IWindow, options: Required<NetworkRecordOptions>) {\n if (options.recordInitialRequests) {\n const initialPerformanceEntries = win.performance\n .getEntries()\n .filter(\n (entry): entry is ObservedPerformanceEntry =>\n isNavigationTiming(entry) ||\n (isResourceTiming(entry) && options.initiatorTypes.includes(entry.initiatorType as InitiatorType))\n )\n cb({\n requests: initialPerformanceEntries.map((entry) => ({\n url: entry.name,\n initiatorType: entry.initiatorType as InitiatorType,\n status: 'responseStatus' in entry ? entry.responseStatus : undefined,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n })),\n isInitial: true,\n })\n }\n const observer = new win.PerformanceObserver((entries) => {\n const performanceEntries = entries\n .getEntries()\n .filter(\n (entry): entry is ObservedPerformanceEntry =>\n isNavigationTiming(entry) ||\n (isResourceTiming(entry) &&\n options.initiatorTypes.includes(entry.initiatorType as InitiatorType) &&\n entry.initiatorType !== 'xmlhttprequest' &&\n entry.initiatorType !== 'fetch')\n )\n cb({\n requests: performanceEntries.map((entry) => ({\n url: entry.name,\n initiatorType: entry.initiatorType as InitiatorType,\n status: 'responseStatus' in entry ? entry.responseStatus : undefined,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n })),\n })\n })\n observer.observe({ entryTypes: ['navigation', 'resource'] })\n return () => {\n observer.disconnect()\n }\n}\n\nfunction shouldRecordHeaders(type: 'request' | 'response', recordHeaders: NetworkRecordOptions['recordHeaders']) {\n return !!recordHeaders && (_isBoolean(recordHeaders) || recordHeaders[type])\n}\n\nfunction shouldRecordBody(\n type: 'request' | 'response',\n recordBody: NetworkRecordOptions['recordBody'],\n headers: Headers\n) {\n function matchesContentType(contentTypes: string[]) {\n const contentTypeHeader = Object.keys(headers).find((key) => key.toLowerCase() === 'content-type')\n const contentType = contentTypeHeader && headers[contentTypeHeader]\n return contentTypes.some((ct) => contentType?.includes(ct))\n }\n if (!recordBody) return false\n if (_isBoolean(recordBody)) return true\n if (_isArray(recordBody)) return matchesContentType(recordBody)\n const recordBodyType = recordBody[type]\n if (_isBoolean(recordBodyType)) return recordBodyType\n return matchesContentType(recordBodyType)\n}\n\nasync function getRequestPerformanceEntry(\n win: IWindow,\n initiatorType: string,\n url: string,\n after?: number,\n before?: number,\n attempt = 0\n): Promise<PerformanceResourceTiming | null> {\n if (attempt > 10) {\n logger.warn('Failed to get performance entry for request', { url, initiatorType })\n return null\n }\n const urlPerformanceEntries = win.performance.getEntriesByName(url) as PerformanceResourceTiming[]\n const performanceEntry = findLast(\n urlPerformanceEntries,\n (entry) =>\n isResourceTiming(entry) &&\n entry.initiatorType === initiatorType &&\n (!after || entry.startTime >= after) &&\n (!before || entry.startTime <= before)\n )\n if (!performanceEntry) {\n await new Promise((resolve) => setTimeout(resolve, 50 * attempt))\n return getRequestPerformanceEntry(win, initiatorType, url, after, before, attempt + 1)\n }\n return performanceEntry\n}\n\nfunction initXhrObserver(cb: networkCallback, win: IWindow, options: Required<NetworkRecordOptions>): listenerHandler {\n if (!options.initiatorTypes.includes('xmlhttprequest')) {\n return () => {\n //\n }\n }\n const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders)\n const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders)\n\n const restorePatch = patch(\n win.XMLHttpRequest.prototype,\n 'open',\n // TODO how should this be typed?\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (originalOpen: typeof XMLHttpRequest.prototype.open) => {\n return function (\n method: string,\n url: string | URL,\n async = true,\n username?: string | null,\n password?: string | null\n ) {\n // because this function is returned in its actual context `this` _is_ an XMLHttpRequest\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const xhr = this as XMLHttpRequest\n\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url)\n const networkRequest: Partial<NetworkRequest> = {}\n let after: number | undefined\n let before: number | undefined\n const requestHeaders: Headers = {}\n const originalSetRequestHeader = xhr.setRequestHeader.bind(xhr)\n xhr.setRequestHeader = (header: string, value: string) => {\n requestHeaders[header] = value\n return originalSetRequestHeader(header, value)\n }\n if (recordRequestHeaders) {\n networkRequest.requestHeaders = requestHeaders\n }\n const originalSend = xhr.send.bind(xhr)\n xhr.send = (body) => {\n if (shouldRecordBody('request', options.recordBody, requestHeaders)) {\n if (_isUndefined(body) || _isNull(body)) {\n networkRequest.requestBody = null\n } else {\n networkRequest.requestBody = body\n }\n }\n after = win.performance.now()\n return originalSend(body)\n }\n xhr.addEventListener('readystatechange', () => {\n if (xhr.readyState !== xhr.DONE) {\n return\n }\n before = win.performance.now()\n const responseHeaders: Headers = {}\n const rawHeaders = xhr.getAllResponseHeaders()\n const headers = rawHeaders.trim().split(/[\\r\\n]+/)\n headers.forEach((line) => {\n const parts = line.split(': ')\n const header = parts.shift()\n const value = parts.join(': ')\n if (header) {\n responseHeaders[header] = value\n }\n })\n if (recordResponseHeaders) {\n networkRequest.responseHeaders = responseHeaders\n }\n if (shouldRecordBody('response', options.recordBody, responseHeaders)) {\n if (_isUndefined(xhr.response) || _isNull(xhr.response)) {\n networkRequest.responseBody = null\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n networkRequest.responseBody = xhr.response\n }\n }\n getRequestPerformanceEntry(win, 'xmlhttprequest', req.url, after, before)\n .then((entry) => {\n if (_isNull(entry)) {\n return\n }\n const request: NetworkRequest = {\n url: entry.name,\n method: req.method,\n initiatorType: entry.initiatorType as InitiatorType,\n status: xhr.status,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n requestHeaders: networkRequest.requestHeaders,\n requestBody: networkRequest.requestBody,\n responseHeaders: networkRequest.responseHeaders,\n responseBody: networkRequest.responseBody,\n }\n cb({ requests: [request] })\n })\n .catch(() => {\n //\n })\n })\n originalOpen.call(xhr, method, url, async, username, password)\n }\n }\n )\n return () => {\n restorePatch()\n }\n}\n\nfunction initFetchObserver(\n cb: networkCallback,\n win: IWindow,\n options: Required<NetworkRecordOptions>\n): listenerHandler {\n if (!options.initiatorTypes.includes('fetch')) {\n return () => {\n //\n }\n }\n const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders)\n const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders)\n // TODO how should this be typed?\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const restorePatch = patch(win, 'fetch', (originalFetch: typeof fetch) => {\n return async function (url: URL | RequestInfo, init?: RequestInit | undefined) {\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url, init)\n let res: Response | undefined\n const networkRequest: Partial<NetworkRequest> = {}\n let after: number | undefined\n let before: number | undefined\n try {\n const requestHeaders: Headers = {}\n req.headers.forEach((value, header) => {\n requestHeaders[header] = value\n })\n if (recordRequestHeaders) {\n networkRequest.requestHeaders = requestHeaders\n }\n if (shouldRecordBody('request', options.recordBody, requestHeaders)) {\n if (_isUndefined(req.body) || _isNull(req.body)) {\n networkRequest.requestBody = null\n } else {\n networkRequest.requestBody = req.body\n }\n }\n after = win.performance.now()\n res = await originalFetch(req)\n before = win.performance.now()\n const responseHeaders: Headers = {}\n res.headers.forEach((value, header) => {\n responseHeaders[header] = value\n })\n if (recordResponseHeaders) {\n networkRequest.responseHeaders = responseHeaders\n }\n if (shouldRecordBody('response', options.recordBody, responseHeaders)) {\n let body: string | undefined\n try {\n body = await res.clone().text()\n } catch {\n //\n }\n if (_isUndefined(res.body) || _isNull(res.body)) {\n networkRequest.responseBody = null\n } else {\n networkRequest.responseBody = body\n }\n }\n return res\n } finally {\n getRequestPerformanceEntry(win, 'fetch', req.url, after, before)\n .then((entry) => {\n if (_isNull(entry)) {\n return\n }\n const request: NetworkRequest = {\n url: entry.name,\n method: req.method,\n initiatorType: entry.initiatorType as InitiatorType,\n status: res?.status,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n requestHeaders: networkRequest.requestHeaders,\n requestBody: networkRequest.requestBody,\n responseHeaders: networkRequest.responseHeaders,\n responseBody: networkRequest.responseBody,\n }\n cb({ requests: [request] })\n })\n .catch(() => {\n //\n })\n }\n }\n })\n return () => {\n restorePatch()\n }\n}\n\nfunction initNetworkObserver(\n callback: networkCallback,\n win: IWindow, // top window or in an iframe\n options: NetworkRecordOptions\n): listenerHandler {\n if (!('performance' in win)) {\n return () => {\n //\n }\n }\n const networkOptions = (\n options ? Object.assign({}, defaultNetworkOptions, options) : defaultNetworkOptions\n ) as Required<NetworkRecordOptions>\n\n const cb: networkCallback = (data) => {\n const requests: NetworkRequest[] = []\n data.requests.forEach((request) => {\n const maskedRequest = networkOptions.maskRequestFn(request)\n if (maskedRequest) {\n requests.push(maskedRequest)\n }\n })\n\n if (requests.length > 0 || data.isInitial) {\n callback({ ...data, requests })\n }\n }\n const performanceObserver = initPerformanceObserver(cb, win, networkOptions)\n const xhrObserver = initXhrObserver(cb, win, networkOptions)\n const fetchObserver = initFetchObserver(cb, win, networkOptions)\n return () => {\n performanceObserver()\n xhrObserver()\n fetchObserver()\n }\n}\n\n// use the plugin name so that when this functionality is adopted into rrweb\n// we can remove this plugin and use the core functionality with the same data\nexport const NETWORK_PLUGIN_NAME = 'rrweb/network@1'\n\n// TODO how should this be typed?\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nexport const getRecordNetworkPlugin: (options?: NetworkRecordOptions) => RecordPlugin = (options) => {\n return {\n name: NETWORK_PLUGIN_NAME,\n observer: initNetworkObserver,\n options: options,\n }\n}\n\n// rrweb/networ@1 ends\n\nconst win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window\n\n;(win as any).rrweb = { record: rrwebRecord, version: 'v2', rrwebVersion: version }\n;(win as any).rrwebConsoleRecord = { getRecordConsolePlugin }\n;(win as any).getRecordNetworkPlugin = getRecordNetworkPlugin\n\nexport default rrwebRecord\n"]}
1
+ {"version":3,"file":"loader-recorder-v2.js","sourceRoot":"","sources":["../../src/loader-recorder-v2.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,4DAA4D;AAC5D,6DAA6D;AAC7D,aAAa;AACb,OAAO,WAAW,MAAM,0CAA0C,CAAA;AAClE,6DAA6D;AAC7D,aAAa;AACb,OAAO,EAAE,sBAAsB,EAAE,MAAM,0DAA0D,CAAA;AAejG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AASlE,IAAM,kBAAkB,GAAG,UAAC,KAAuB;IAC/C,OAAA,KAAK,CAAC,SAAS,KAAK,YAAY;AAAhC,CAAgC,CAAA;AACpC,IAAM,gBAAgB,GAAG,UAAC,KAAuB,IAAyC,OAAA,KAAK,CAAC,SAAS,KAAK,UAAU,EAA9B,CAA8B,CAAA;AAMxH,8CAA8C;AAC9C,+HAA+H;AAC/H,kJAAkJ;AAClJ,MAAM,UAAU,KAAK,CACjB,MAA8B,EAC9B,IAAY,EACZ,WAA4C;IAE5C,IAAI;QACA,IAAI,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE;YACnB,OAAO;gBACH,EAAE;YACN,CAAC,CAAA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BAAsB,GAAG,sBAAsB,CAAA;CACnE;AAED,eAAe,WAAW,CAAA","sourcesContent":["import { version } from 'rrweb/package.json'\n\n// Same as loader-globals.ts except includes rrweb2 scripts.\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport rrwebRecord from 'rrweb/es/rrweb/packages/rrweb/src/record'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getRecordConsolePlugin } from 'rrweb/es/rrweb/packages/rrweb/src/plugins/console/record'\n\n// rrweb/network@1 code starts\n// most of what is below here will be removed when rrweb release their code for this\n// see https://github.com/rrweb-io/rrweb/pull/1105\n\n/// <reference lib=\"dom\" />\n\n// NB adopted from https://github.com/rrweb-io/rrweb/pull/1105 which looks like it will be accepted into rrweb\n// however, in the PR, it throws when the performance observer data is not available\n// and assumes it is running in a browser with the Request API (i.e. not IE11)\n// copying here so that we can use it before rrweb adopt it\n\nimport type { IWindow, listenerHandler, RecordPlugin } from '@rrweb/types'\nimport { InitiatorType, NetworkRecordOptions, NetworkRequest, Headers } from './types'\nimport { _isBoolean, _isFunction, _isArray, _isUndefined, _isNull } from './utils/type-utils'\nimport { logger } from './utils/logger'\nimport { window } from './utils/globals'\nimport { defaultNetworkOptions } from './extensions/replay/config'\n\nexport type NetworkData = {\n requests: NetworkRequest[]\n isInitial?: boolean\n}\n\ntype networkCallback = (data: NetworkData) => void\n\nconst isNavigationTiming = (entry: PerformanceEntry): entry is PerformanceNavigationTiming =>\n entry.entryType === 'navigation'\nconst isResourceTiming = (entry: PerformanceEntry): entry is PerformanceResourceTiming => entry.entryType === 'resource'\n\ntype ObservedPerformanceEntry = (PerformanceNavigationTiming | PerformanceResourceTiming) & {\n responseStatus?: number\n}\n\n// import { patch } from 'rrweb/typings/utils'\n// copied from https://github.com/rrweb-io/rrweb/blob/8aea5b00a4dfe5a6f59bd2ae72bb624f45e51e81/packages/rrweb/src/utils.ts#L129\n// which was copied from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts\nexport function patch(\n source: { [key: string]: any },\n name: string,\n replacement: (...args: unknown[]) => unknown\n): () => void {\n try {\n if (!(name in source)) {\n return () => {\n //\n }\n }\n\n const original = source[name] as () => unknown\n const wrapped = replacement(original)\n\n // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work\n // otherwise it'll throw \"TypeError: Object.defineProperties called on non-object\"\n if (_isFunction(wrapped)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n wrapped.prototype = wrapped.prototype || {}\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original,\n },\n })\n }\n\n source[name] = wrapped\n\n return () => {\n source[name] = original\n }\n } catch {\n return () => {\n //\n }\n // This can throw if multiple fill happens on a global object like XMLHttpRequest\n // Fixes https://github.com/getsentry/sentry-javascript/issues/2043\n }\n}\n\nexport function findLast<T>(array: Array<T>, predicate: (value: T) => boolean): T | undefined {\n const length = array.length\n for (let i = length - 1; i >= 0; i -= 1) {\n if (predicate(array[i])) {\n return array[i]\n }\n }\n return undefined\n}\n\nfunction initPerformanceObserver(cb: networkCallback, win: IWindow, options: Required<NetworkRecordOptions>) {\n if (options.recordInitialRequests) {\n const initialPerformanceEntries = win.performance\n .getEntries()\n .filter(\n (entry): entry is ObservedPerformanceEntry =>\n isNavigationTiming(entry) ||\n (isResourceTiming(entry) && options.initiatorTypes.includes(entry.initiatorType as InitiatorType))\n )\n cb({\n requests: initialPerformanceEntries.map((entry) => ({\n url: entry.name,\n initiatorType: entry.initiatorType as InitiatorType,\n status: 'responseStatus' in entry ? entry.responseStatus : undefined,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n })),\n isInitial: true,\n })\n }\n const observer = new win.PerformanceObserver((entries) => {\n const performanceEntries = entries\n .getEntries()\n .filter(\n (entry): entry is ObservedPerformanceEntry =>\n isNavigationTiming(entry) ||\n (isResourceTiming(entry) &&\n options.initiatorTypes.includes(entry.initiatorType as InitiatorType) &&\n entry.initiatorType !== 'xmlhttprequest' &&\n entry.initiatorType !== 'fetch')\n )\n cb({\n requests: performanceEntries.map((entry) => ({\n url: entry.name,\n initiatorType: entry.initiatorType as InitiatorType,\n status: 'responseStatus' in entry ? entry.responseStatus : undefined,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n })),\n })\n })\n observer.observe({ entryTypes: ['navigation', 'resource'] })\n return () => {\n observer.disconnect()\n }\n}\n\nfunction shouldRecordHeaders(type: 'request' | 'response', recordHeaders: NetworkRecordOptions['recordHeaders']) {\n return !!recordHeaders && (_isBoolean(recordHeaders) || recordHeaders[type])\n}\n\nfunction shouldRecordBody(\n type: 'request' | 'response',\n recordBody: NetworkRecordOptions['recordBody'],\n headers: Headers\n) {\n function matchesContentType(contentTypes: string[]) {\n const contentTypeHeader = Object.keys(headers).find((key) => key.toLowerCase() === 'content-type')\n const contentType = contentTypeHeader && headers[contentTypeHeader]\n return contentTypes.some((ct) => contentType?.includes(ct))\n }\n if (!recordBody) return false\n if (_isBoolean(recordBody)) return true\n if (_isArray(recordBody)) return matchesContentType(recordBody)\n const recordBodyType = recordBody[type]\n if (_isBoolean(recordBodyType)) return recordBodyType\n return matchesContentType(recordBodyType)\n}\n\nasync function getRequestPerformanceEntry(\n win: IWindow,\n initiatorType: string,\n url: string,\n after?: number,\n before?: number,\n attempt = 0\n): Promise<PerformanceResourceTiming | null> {\n if (attempt > 10) {\n logger.warn('Failed to get performance entry for request', { url, initiatorType })\n return null\n }\n const urlPerformanceEntries = win.performance.getEntriesByName(url) as PerformanceResourceTiming[]\n const performanceEntry = findLast(\n urlPerformanceEntries,\n (entry) =>\n isResourceTiming(entry) &&\n entry.initiatorType === initiatorType &&\n (!after || entry.startTime >= after) &&\n (!before || entry.startTime <= before)\n )\n if (!performanceEntry) {\n await new Promise((resolve) => setTimeout(resolve, 50 * attempt))\n return getRequestPerformanceEntry(win, initiatorType, url, after, before, attempt + 1)\n }\n return performanceEntry\n}\n\nfunction initXhrObserver(cb: networkCallback, win: IWindow, options: Required<NetworkRecordOptions>): listenerHandler {\n if (!options.initiatorTypes.includes('xmlhttprequest')) {\n return () => {\n //\n }\n }\n const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders)\n const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders)\n\n const restorePatch = patch(\n win.XMLHttpRequest.prototype,\n 'open',\n // TODO how should this be typed?\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (originalOpen: typeof XMLHttpRequest.prototype.open) => {\n return function (\n method: string,\n url: string | URL,\n async = true,\n username?: string | null,\n password?: string | null\n ) {\n // because this function is returned in its actual context `this` _is_ an XMLHttpRequest\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const xhr = this as XMLHttpRequest\n\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url)\n const networkRequest: Partial<NetworkRequest> = {}\n let after: number | undefined\n let before: number | undefined\n const requestHeaders: Headers = {}\n const originalSetRequestHeader = xhr.setRequestHeader.bind(xhr)\n xhr.setRequestHeader = (header: string, value: string) => {\n requestHeaders[header] = value\n return originalSetRequestHeader(header, value)\n }\n if (recordRequestHeaders) {\n networkRequest.requestHeaders = requestHeaders\n }\n const originalSend = xhr.send.bind(xhr)\n xhr.send = (body) => {\n if (shouldRecordBody('request', options.recordBody, requestHeaders)) {\n if (_isUndefined(body) || _isNull(body)) {\n networkRequest.requestBody = null\n } else {\n networkRequest.requestBody = body\n }\n }\n after = win.performance.now()\n return originalSend(body)\n }\n xhr.addEventListener('readystatechange', () => {\n if (xhr.readyState !== xhr.DONE) {\n return\n }\n before = win.performance.now()\n const responseHeaders: Headers = {}\n const rawHeaders = xhr.getAllResponseHeaders()\n const headers = rawHeaders.trim().split(/[\\r\\n]+/)\n headers.forEach((line) => {\n const parts = line.split(': ')\n const header = parts.shift()\n const value = parts.join(': ')\n if (header) {\n responseHeaders[header] = value\n }\n })\n if (recordResponseHeaders) {\n networkRequest.responseHeaders = responseHeaders\n }\n if (shouldRecordBody('response', options.recordBody, responseHeaders)) {\n if (_isUndefined(xhr.response) || _isNull(xhr.response)) {\n networkRequest.responseBody = null\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n networkRequest.responseBody = xhr.response\n }\n }\n getRequestPerformanceEntry(win, 'xmlhttprequest', req.url, after, before)\n .then((entry) => {\n if (_isNull(entry)) {\n return\n }\n const request: NetworkRequest = {\n url: entry.name,\n method: req.method,\n initiatorType: entry.initiatorType as InitiatorType,\n status: xhr.status,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n requestHeaders: networkRequest.requestHeaders,\n requestBody: networkRequest.requestBody,\n responseHeaders: networkRequest.responseHeaders,\n responseBody: networkRequest.responseBody,\n }\n cb({ requests: [request] })\n })\n .catch(() => {\n //\n })\n })\n originalOpen.call(xhr, method, url, async, username, password)\n }\n }\n )\n return () => {\n restorePatch()\n }\n}\n\nfunction initFetchObserver(\n cb: networkCallback,\n win: IWindow,\n options: Required<NetworkRecordOptions>\n): listenerHandler {\n if (!options.initiatorTypes.includes('fetch')) {\n return () => {\n //\n }\n }\n const recordRequestHeaders = shouldRecordHeaders('request', options.recordHeaders)\n const recordResponseHeaders = shouldRecordHeaders('response', options.recordHeaders)\n // TODO how should this be typed?\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const restorePatch = patch(win, 'fetch', (originalFetch: typeof fetch) => {\n return async function (url: URL | RequestInfo, init?: RequestInit | undefined) {\n // check IE earlier than this, we only initialize if Request is present\n // eslint-disable-next-line compat/compat\n const req = new Request(url, init)\n let res: Response | undefined\n const networkRequest: Partial<NetworkRequest> = {}\n let after: number | undefined\n let before: number | undefined\n try {\n const requestHeaders: Headers = {}\n req.headers.forEach((value, header) => {\n requestHeaders[header] = value\n })\n if (recordRequestHeaders) {\n networkRequest.requestHeaders = requestHeaders\n }\n if (shouldRecordBody('request', options.recordBody, requestHeaders)) {\n if (_isUndefined(req.body) || _isNull(req.body)) {\n networkRequest.requestBody = null\n } else {\n networkRequest.requestBody = req.body\n }\n }\n after = win.performance.now()\n res = await originalFetch(req)\n before = win.performance.now()\n const responseHeaders: Headers = {}\n res.headers.forEach((value, header) => {\n responseHeaders[header] = value\n })\n if (recordResponseHeaders) {\n networkRequest.responseHeaders = responseHeaders\n }\n if (shouldRecordBody('response', options.recordBody, responseHeaders)) {\n let body: string | undefined\n try {\n body = await res.clone().text()\n } catch {\n //\n }\n if (_isUndefined(res.body) || _isNull(res.body)) {\n networkRequest.responseBody = null\n } else {\n networkRequest.responseBody = body\n }\n }\n return res\n } finally {\n getRequestPerformanceEntry(win, 'fetch', req.url, after, before)\n .then((entry) => {\n if (_isNull(entry)) {\n return\n }\n const request: NetworkRequest = {\n url: entry.name,\n method: req.method,\n initiatorType: entry.initiatorType as InitiatorType,\n status: res?.status,\n startTime: Math.round(entry.startTime),\n endTime: Math.round(entry.responseEnd),\n requestHeaders: networkRequest.requestHeaders,\n requestBody: networkRequest.requestBody,\n responseHeaders: networkRequest.responseHeaders,\n responseBody: networkRequest.responseBody,\n }\n cb({ requests: [request] })\n })\n .catch(() => {\n //\n })\n }\n }\n })\n return () => {\n restorePatch()\n }\n}\n\nfunction initNetworkObserver(\n callback: networkCallback,\n win: IWindow, // top window or in an iframe\n options: NetworkRecordOptions\n): listenerHandler {\n if (!('performance' in win)) {\n return () => {\n //\n }\n }\n const networkOptions = (\n options ? Object.assign({}, defaultNetworkOptions, options) : defaultNetworkOptions\n ) as Required<NetworkRecordOptions>\n\n const cb: networkCallback = (data) => {\n const requests: NetworkRequest[] = []\n data.requests.forEach((request) => {\n const maskedRequest = networkOptions.maskRequestFn(request)\n if (maskedRequest) {\n requests.push(maskedRequest)\n }\n })\n\n if (requests.length > 0 || data.isInitial) {\n callback({ ...data, requests })\n }\n }\n const performanceObserver = initPerformanceObserver(cb, win, networkOptions)\n const xhrObserver = initXhrObserver(cb, win, networkOptions)\n const fetchObserver = initFetchObserver(cb, win, networkOptions)\n return () => {\n performanceObserver()\n xhrObserver()\n fetchObserver()\n }\n}\n\n// use the plugin name so that when this functionality is adopted into rrweb\n// we can remove this plugin and use the core functionality with the same data\nexport const NETWORK_PLUGIN_NAME = 'rrweb/network@1'\n\n// TODO how should this be typed?\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nexport const getRecordNetworkPlugin: (options?: NetworkRecordOptions) => RecordPlugin = (options) => {\n return {\n name: NETWORK_PLUGIN_NAME,\n observer: initNetworkObserver,\n options: options,\n }\n}\n\n// rrweb/networ@1 ends\n\nif (window) {\n ;(window as any).rrweb = { record: rrwebRecord, version: 'v2', rrwebVersion: version }\n ;(window as any).rrwebConsoleRecord = { getRecordConsolePlugin }\n ;(window as any).getRecordNetworkPlugin = getRecordNetworkPlugin\n}\n\nexport default rrwebRecord\n"]}
@@ -6,11 +6,11 @@ import rrwebRecord from 'rrweb-v1/es/rrweb/packages/rrweb/src/record';
6
6
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
7
  // @ts-ignore
8
8
  import { getRecordConsolePlugin } from 'rrweb-v1/es/rrweb/packages/rrweb/src/plugins/console/record';
9
- import { _isUndefined } from './utils/type-utils';
10
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
- // @ts-ignore
12
- var win = _isUndefined(window) ? {} : window;
13
- win.rrweb = { record: rrwebRecord, version: 'v1', rrwebVersion: version };
14
- win.rrwebConsoleRecord = { getRecordConsolePlugin: getRecordConsolePlugin };
9
+ import { window } from './utils/globals';
10
+ if (window) {
11
+ ;
12
+ window.rrweb = { record: rrwebRecord, version: 'v1', rrwebVersion: version };
13
+ window.rrwebConsoleRecord = { getRecordConsolePlugin: getRecordConsolePlugin };
14
+ }
15
15
  export default rrwebRecord;
16
16
  //# sourceMappingURL=loader-recorder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader-recorder.js","sourceRoot":"","sources":["../../src/loader-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE/C,2DAA2D;AAC3D,6DAA6D;AAC7D,aAAa;AACb,OAAO,WAAW,MAAM,6CAA6C,CAAA;AACrE,6DAA6D;AAC7D,aAAa;AACb,OAAO,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAA;AAEpG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,6DAA6D;AAC7D,aAAa;AAEb,IAAM,GAAG,GAA+B,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAAoB,CAAC,CAAC,CAAC,MAAM,CAE5F;AAAC,GAAW,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAClF;AAAC,GAAW,CAAC,kBAAkB,GAAG,EAAE,sBAAsB,wBAAA,EAAE,CAAA;AAE7D,eAAe,WAAW,CAAA","sourcesContent":["import { version } from 'rrweb-v1/package.json'\n\n// Same as loader-globals.ts except includes rrweb scripts.\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport rrwebRecord from 'rrweb-v1/es/rrweb/packages/rrweb/src/record'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getRecordConsolePlugin } from 'rrweb-v1/es/rrweb/packages/rrweb/src/plugins/console/record'\n\nimport { _isUndefined } from './utils/type-utils'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\n\nconst win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window\n\n;(win as any).rrweb = { record: rrwebRecord, version: 'v1', rrwebVersion: version }\n;(win as any).rrwebConsoleRecord = { getRecordConsolePlugin }\n\nexport default rrwebRecord\n"]}
1
+ {"version":3,"file":"loader-recorder.js","sourceRoot":"","sources":["../../src/loader-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE/C,2DAA2D;AAC3D,6DAA6D;AAC7D,aAAa;AACb,OAAO,WAAW,MAAM,6CAA6C,CAAA;AACrE,6DAA6D;AAC7D,aAAa;AACb,OAAO,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAA;AAEpG,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,IAAI,MAAM,EAAE;IACR,CAAC;IAAC,MAAc,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CACrF;IAAC,MAAc,CAAC,kBAAkB,GAAG,EAAE,sBAAsB,wBAAA,EAAE,CAAA;CACnE;AAED,eAAe,WAAW,CAAA","sourcesContent":["import { version } from 'rrweb-v1/package.json'\n\n// Same as loader-globals.ts except includes rrweb scripts.\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport rrwebRecord from 'rrweb-v1/es/rrweb/packages/rrweb/src/record'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getRecordConsolePlugin } from 'rrweb-v1/es/rrweb/packages/rrweb/src/plugins/console/record'\n\nimport { window } from './utils/globals'\n\nif (window) {\n ;(window as any).rrweb = { record: rrwebRecord, version: 'v1', rrwebVersion: version }\n ;(window as any).rrwebConsoleRecord = { getRecordConsolePlugin }\n}\n\nexport default rrwebRecord\n"]}
@@ -1,6 +1,8 @@
1
1
  import { generateSurveys } from './extensions/surveys';
2
- import { _isUndefined } from './utils/type-utils';
3
- var win = _isUndefined(window) ? {} : window;
4
- win.extendPostHogWithSurveys = generateSurveys;
2
+ import { window } from './utils/globals';
3
+ if (window) {
4
+ ;
5
+ window.extendPostHogWithSurveys = generateSurveys;
6
+ }
5
7
  export default generateSurveys;
6
8
  //# sourceMappingURL=loader-surveys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader-surveys.js","sourceRoot":"","sources":["../../src/loader-surveys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,IAAM,GAAG,GAA+B,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,EAAoB,CAAC,CAAC,CAAC,MAAM,CAE5F;AAAC,GAAW,CAAC,wBAAwB,GAAG,eAAe,CAAA;AAExD,eAAe,eAAe,CAAA","sourcesContent":["import { generateSurveys } from './extensions/surveys'\n\nimport { _isUndefined } from './utils/type-utils'\n\nconst win: Window & typeof globalThis = _isUndefined(window) ? ({} as typeof window) : window\n\n;(win as any).extendPostHogWithSurveys = generateSurveys\n\nexport default generateSurveys\n"]}
1
+ {"version":3,"file":"loader-surveys.js","sourceRoot":"","sources":["../../src/loader-surveys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,IAAI,MAAM,EAAE;IACR,CAAC;IAAC,MAAc,CAAC,wBAAwB,GAAG,eAAe,CAAA;CAC9D;AAED,eAAe,eAAe,CAAA","sourcesContent":["import { generateSurveys } from './extensions/surveys'\n\nimport { window } from './utils/globals'\n\nif (window) {\n ;(window as any).extendPostHogWithSurveys = generateSurveys\n}\n\nexport default generateSurveys\n"]}
@@ -33,8 +33,9 @@ var PageViewManager = /** @class */ (function () {
33
33
  };
34
34
  }
35
35
  PageViewManager.prototype._createPageViewData = function () {
36
+ var _a;
36
37
  return {
37
- pathname: window.location.pathname,
38
+ pathname: (_a = window === null || window === void 0 ? void 0 : window.location.pathname) !== null && _a !== void 0 ? _a : '',
38
39
  };
39
40
  };
40
41
  PageViewManager.prototype.doPageView = function () {
@@ -96,26 +97,28 @@ var PageViewManager = /** @class */ (function () {
96
97
  };
97
98
  };
98
99
  PageViewManager.prototype.startMeasuringScrollPosition = function () {
99
- window.addEventListener('scroll', this._updateScrollData);
100
- window.addEventListener('scrollend', this._updateScrollData);
101
- window.addEventListener('resize', this._updateScrollData);
100
+ window === null || window === void 0 ? void 0 : window.addEventListener('scroll', this._updateScrollData);
101
+ window === null || window === void 0 ? void 0 : window.addEventListener('scrollend', this._updateScrollData);
102
+ window === null || window === void 0 ? void 0 : window.addEventListener('resize', this._updateScrollData);
102
103
  };
103
104
  PageViewManager.prototype.stopMeasuringScrollPosition = function () {
104
- window.removeEventListener('scroll', this._updateScrollData);
105
- window.removeEventListener('scrollend', this._updateScrollData);
106
- window.removeEventListener('resize', this._updateScrollData);
105
+ window === null || window === void 0 ? void 0 : window.removeEventListener('scroll', this._updateScrollData);
106
+ window === null || window === void 0 ? void 0 : window.removeEventListener('scrollend', this._updateScrollData);
107
+ window === null || window === void 0 ? void 0 : window.removeEventListener('resize', this._updateScrollData);
107
108
  };
108
109
  PageViewManager.prototype._scrollHeight = function () {
109
- return Math.max(0, window.document.documentElement.scrollHeight - window.document.documentElement.clientHeight);
110
+ return window
111
+ ? Math.max(0, window.document.documentElement.scrollHeight - window.document.documentElement.clientHeight)
112
+ : 0;
110
113
  };
111
114
  PageViewManager.prototype._scrollY = function () {
112
- return window.scrollY || window.pageYOffset || window.document.documentElement.scrollTop || 0;
115
+ return window ? window.scrollY || window.pageYOffset || window.document.documentElement.scrollTop || 0 : 0;
113
116
  };
114
117
  PageViewManager.prototype._contentHeight = function () {
115
- return window.document.documentElement.scrollHeight || 0;
118
+ return (window === null || window === void 0 ? void 0 : window.document.documentElement.scrollHeight) || 0;
116
119
  };
117
120
  PageViewManager.prototype._contentY = function () {
118
- var clientHeight = window.document.documentElement.clientHeight || 0;
121
+ var clientHeight = (window === null || window === void 0 ? void 0 : window.document.documentElement.clientHeight) || 0;
119
122
  return this._scrollY() + clientHeight;
120
123
  };
121
124
  return PageViewManager;
@@ -1 +1 @@
1
- {"version":3,"file":"page-view.js","s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IAAI,CAAC,CAAA;IAC5D,CAAC;IAED,mCAAS,GAAT;QACI,IAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,YAAY,IAAI,CAAC,CAAA;QACtE,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAA;IACzC,CAAC;IACL,sBAAC;AAAD,CAAC,AApID,IAoIC;;AAED,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import { window } from './utils/globals'\n\ninterface PageViewData {\n pathname: string\n // scroll is how far down the page the user has scrolled,\n // content is how far down the page the user can view content\n // (e.g. if the page is 1000 tall, but the user's screen is only 500 tall,\n // and they don't scroll at all, then scroll is 0 and content is 500)\n maxScrollHeight?: number\n maxScrollY?: number\n lastScrollY?: number\n maxContentHeight?: number\n maxContentY?: number\n lastContentY?: number\n}\n\ninterface ScrollProperties {\n $prev_pageview_last_scroll?: number\n $prev_pageview_last_scroll_percentage?: number\n $prev_pageview_max_scroll?: number\n $prev_pageview_max_scroll_percentage?: number\n $prev_pageview_last_content?: number\n $prev_pageview_last_content_percentage?: number\n $prev_pageview_max_content?: number\n $prev_pageview_max_content_percentage?: number\n}\n\ninterface PageViewEventProperties extends ScrollProperties {\n $prev_pageview_pathname?: string\n}\n\nexport class PageViewManager {\n _pageViewData: PageViewData | undefined\n _hasSeenPageView = false\n\n _createPageViewData(): PageViewData {\n return {\n pathname: window.location.pathname,\n }\n }\n\n doPageView(): PageViewEventProperties {\n let prevPageViewData: PageViewData | undefined\n // if there were events created before the first PageView, we would have created a\n // pageViewData for them. If this happened, we don't want to create a new pageViewData\n if (!this._hasSeenPageView) {\n this._hasSeenPageView = true\n prevPageViewData = undefined\n if (!this._pageViewData) {\n this._pageViewData = this._createPageViewData()\n }\n } else {\n prevPageViewData = this._pageViewData\n this._pageViewData = this._createPageViewData()\n }\n\n // update the scroll properties for the new page, but wait until the next tick\n // of the event loop\n setTimeout(this._updateScrollData, 0)\n\n return {\n $prev_pageview_pathname: prevPageViewData?.pathname,\n ...this._calculatePrevPageScrollProperties(prevPageViewData),\n }\n }\n\n doPageLeave(): PageViewEventProperties {\n const prevPageViewData = this._pageViewData\n return {\n $prev_pageview_pathname: prevPageViewData?.pathname,\n ...this._calculatePrevPageScrollProperties(prevPageViewData),\n }\n }\n\n _calculatePrevPageScrollProperties(prevPageViewData: PageViewData | undefined): ScrollProperties {\n if (\n !prevPageViewData ||\n prevPageViewData.maxScrollHeight == null ||\n prevPageViewData.lastScrollY == null ||\n prevPageViewData.maxScrollY == null ||\n prevPageViewData.maxContentHeight == null ||\n prevPageViewData.lastContentY == null ||\n prevPageViewData.maxContentY == null\n ) {\n return {}\n }\n\n let { maxScrollHeight, lastScrollY, maxScrollY, maxContentHeight, lastContentY, maxContentY } = prevPageViewData\n\n // Use ceil, so that e.g. scrolling 999.5px of a 1000px page is considered 100% scrolled\n maxScrollHeight = Math.ceil(maxScrollHeight)\n lastScrollY = Math.ceil(lastScrollY)\n maxScrollY = Math.ceil(maxScrollY)\n maxContentHeight = Math.ceil(maxContentHeight)\n lastContentY = Math.ceil(lastContentY)\n maxContentY = Math.ceil(maxContentY)\n\n // if the maximum scroll height is near 0, then the percentage is 1\n const lastScrollPercentage = maxScrollHeight <= 1 ? 1 : clamp(lastScrollY / maxScrollHeight, 0, 1)\n const maxScrollPercentage = maxScrollHeight <= 1 ? 1 : clamp(maxScrollY / maxScrollHeight, 0, 1)\n const lastContentPercentage = maxContentHeight <= 1 ? 1 : clamp(lastContentY / maxContentHeight, 0, 1)\n const maxContentPercentage = maxContentHeight <= 1 ? 1 : clamp(maxContentY / maxContentHeight, 0, 1)\n\n return {\n $prev_pageview_last_scroll: lastScrollY,\n $prev_pageview_last_scroll_percentage: lastScrollPercentage,\n $prev_pageview_max_scroll: maxScrollY,\n $prev_pageview_max_scroll_percentage: maxScrollPercentage,\n $prev_pageview_last_content: lastContentY,\n $prev_pageview_last_content_percentage: lastContentPercentage,\n $prev_pageview_max_content: maxContentY,\n $prev_pageview_max_content_percentage: maxContentPercentage,\n }\n }\n\n _updateScrollData = () => {\n if (!this._pageViewData) {\n this._pageViewData = this._createPageViewData()\n }\n const pageViewData = this._pageViewData\n\n const scrollY = this._scrollY()\n const scrollHeight = this._scrollHeight()\n const contentY = this._contentY()\n const contentHeight = this._contentHeight()\n\n pageViewData.lastScrollY = scrollY\n pageViewData.maxScrollY = Math.max(scrollY, pageViewData.maxScrollY ?? 0)\n pageViewData.maxScrollHeight = Math.max(scrollHeight, pageViewData.maxScrollHeight ?? 0)\n\n pageViewData.lastContentY = contentY\n pageViewData.maxContentY = Math.max(contentY, pageViewData.maxContentY ?? 0)\n pageViewData.maxContentHeight = Math.max(contentHeight, pageViewData.maxContentHeight ?? 0)\n }\n\n startMeasuringScrollPosition() {\n window.addEventListener('scroll', this._updateScrollData)\n window.addEventListener('scrollend', this._updateScrollData)\n window.addEventListener('resize', this._updateScrollData)\n }\n\n stopMeasuringScrollPosition() {\n window.removeEventListener('scroll', this._updateScrollData)\n window.removeEventListener('scrollend', this._updateScrollData)\n window.removeEventListener('resize', this._updateScrollData)\n }\n\n _scrollHeight(): number {\n return Math.max(0, window.document.documentElement.scrollHeight - window.document.documentElement.clientHeight)\n }\n\n _scrollY(): number {\n return window.scrollY || window.pageYOffset || window.document.documentElement.scrollTop || 0\n }\n\n _contentHeight(): number {\n return window.document.documentElement.scrollHeight || 0\n }\n\n _contentY(): number {\n const clientHeight = window.document.documentElement.clientHeight || 0\n return this._scrollY() + clientHeight\n }\n}\n\nfunction clamp(x: number, min: number, max: number) {\n return Math.max(min, Math.min(x, max))\n}\n"]}
1
+ {"version":3,"file":"page-view.js","sourceRoot":"","sources":["../../src/page-view.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAA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AAM,CAAC,OAAO,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9G,CAAC;IAED,wCAAc,GAAd;QACI,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,eAAe,CAAC,YAAY,KAAI,CAAC,CAAA;IAC7D,CAAC;IAED,mCAAS,GAAT;QACI,IAAM,YAAY,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,eAAe,CAAC,YAAY,KAAI,CAAC,CAAA;QACvE,OAAO,IAAI,CAAC,QAAQ,EAAE,GAAG,YAAY,CAAA;IACzC,CAAC;IACL,sBAAC;AAAD,CAAC,AAtID,IAsIC;;AAED,SAAS,KAAK,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import { window } from './utils/globals'\n\ninterface PageViewData {\n pathname: string\n // scroll is how far down the page the user has scrolled,\n // content is how far down the page the user can view content\n // (e.g. if the page is 1000 tall, but the user's screen is only 500 tall,\n // and they don't scroll at all, then scroll is 0 and content is 500)\n maxScrollHeight?: number\n maxScrollY?: number\n lastScrollY?: number\n maxContentHeight?: number\n maxContentY?: number\n lastContentY?: number\n}\n\ninterface ScrollProperties {\n $prev_pageview_last_scroll?: number\n $prev_pageview_last_scroll_percentage?: number\n $prev_pageview_max_scroll?: number\n $prev_pageview_max_scroll_percentage?: number\n $prev_pageview_last_content?: number\n $prev_pageview_last_content_percentage?: number\n $prev_pageview_max_content?: number\n $prev_pageview_max_content_percentage?: number\n}\n\ninterface PageViewEventProperties extends ScrollProperties {\n $prev_pageview_pathname?: string\n}\n\nexport class PageViewManager {\n _pageViewData: PageViewData | undefined\n _hasSeenPageView = false\n\n _createPageViewData(): PageViewData {\n return {\n pathname: window?.location.pathname ?? '',\n }\n }\n\n doPageView(): PageViewEventProperties {\n let prevPageViewData: PageViewData | undefined\n // if there were events created before the first PageView, we would have created a\n // pageViewData for them. If this happened, we don't want to create a new pageViewData\n if (!this._hasSeenPageView) {\n this._hasSeenPageView = true\n prevPageViewData = undefined\n if (!this._pageViewData) {\n this._pageViewData = this._createPageViewData()\n }\n } else {\n prevPageViewData = this._pageViewData\n this._pageViewData = this._createPageViewData()\n }\n\n // update the scroll properties for the new page, but wait until the next tick\n // of the event loop\n setTimeout(this._updateScrollData, 0)\n\n return {\n $prev_pageview_pathname: prevPageViewData?.pathname,\n ...this._calculatePrevPageScrollProperties(prevPageViewData),\n }\n }\n\n doPageLeave(): PageViewEventProperties {\n const prevPageViewData = this._pageViewData\n return {\n $prev_pageview_pathname: prevPageViewData?.pathname,\n ...this._calculatePrevPageScrollProperties(prevPageViewData),\n }\n }\n\n _calculatePrevPageScrollProperties(prevPageViewData: PageViewData | undefined): ScrollProperties {\n if (\n !prevPageViewData ||\n prevPageViewData.maxScrollHeight == null ||\n prevPageViewData.lastScrollY == null ||\n prevPageViewData.maxScrollY == null ||\n prevPageViewData.maxContentHeight == null ||\n prevPageViewData.lastContentY == null ||\n prevPageViewData.maxContentY == null\n ) {\n return {}\n }\n\n let { maxScrollHeight, lastScrollY, maxScrollY, maxContentHeight, lastContentY, maxContentY } = prevPageViewData\n\n // Use ceil, so that e.g. scrolling 999.5px of a 1000px page is considered 100% scrolled\n maxScrollHeight = Math.ceil(maxScrollHeight)\n lastScrollY = Math.ceil(lastScrollY)\n maxScrollY = Math.ceil(maxScrollY)\n maxContentHeight = Math.ceil(maxContentHeight)\n lastContentY = Math.ceil(lastContentY)\n maxContentY = Math.ceil(maxContentY)\n\n // if the maximum scroll height is near 0, then the percentage is 1\n const lastScrollPercentage = maxScrollHeight <= 1 ? 1 : clamp(lastScrollY / maxScrollHeight, 0, 1)\n const maxScrollPercentage = maxScrollHeight <= 1 ? 1 : clamp(maxScrollY / maxScrollHeight, 0, 1)\n const lastContentPercentage = maxContentHeight <= 1 ? 1 : clamp(lastContentY / maxContentHeight, 0, 1)\n const maxContentPercentage = maxContentHeight <= 1 ? 1 : clamp(maxContentY / maxContentHeight, 0, 1)\n\n return {\n $prev_pageview_last_scroll: lastScrollY,\n $prev_pageview_last_scroll_percentage: lastScrollPercentage,\n $prev_pageview_max_scroll: maxScrollY,\n $prev_pageview_max_scroll_percentage: maxScrollPercentage,\n $prev_pageview_last_content: lastContentY,\n $prev_pageview_last_content_percentage: lastContentPercentage,\n $prev_pageview_max_content: maxContentY,\n $prev_pageview_max_content_percentage: maxContentPercentage,\n }\n }\n\n _updateScrollData = () => {\n if (!this._pageViewData) {\n this._pageViewData = this._createPageViewData()\n }\n const pageViewData = this._pageViewData\n\n const scrollY = this._scrollY()\n const scrollHeight = this._scrollHeight()\n const contentY = this._contentY()\n const contentHeight = this._contentHeight()\n\n pageViewData.lastScrollY = scrollY\n pageViewData.maxScrollY = Math.max(scrollY, pageViewData.maxScrollY ?? 0)\n pageViewData.maxScrollHeight = Math.max(scrollHeight, pageViewData.maxScrollHeight ?? 0)\n\n pageViewData.lastContentY = contentY\n pageViewData.maxContentY = Math.max(contentY, pageViewData.maxContentY ?? 0)\n pageViewData.maxContentHeight = Math.max(contentHeight, pageViewData.maxContentHeight ?? 0)\n }\n\n startMeasuringScrollPosition() {\n window?.addEventListener('scroll', this._updateScrollData)\n window?.addEventListener('scrollend', this._updateScrollData)\n window?.addEventListener('resize', this._updateScrollData)\n }\n\n stopMeasuringScrollPosition() {\n window?.removeEventListener('scroll', this._updateScrollData)\n window?.removeEventListener('scrollend', this._updateScrollData)\n window?.removeEventListener('resize', this._updateScrollData)\n }\n\n _scrollHeight(): number {\n return window\n ? Math.max(0, window.document.documentElement.scrollHeight - window.document.documentElement.clientHeight)\n : 0\n }\n\n _scrollY(): number {\n return window ? window.scrollY || window.pageYOffset || window.document.documentElement.scrollTop || 0 : 0\n }\n\n _contentHeight(): number {\n return window?.document.documentElement.scrollHeight || 0\n }\n\n _contentY(): number {\n const clientHeight = window?.document.documentElement.clientHeight || 0\n return this._scrollY() + clientHeight\n }\n}\n\nfunction clamp(x: number, min: number, max: number) {\n return Math.max(min, Math.min(x, max))\n}\n"]}
@@ -47,7 +47,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
47
47
  };
48
48
  import Config from './config';
49
49
  import { _copyAndTruncateStrings, _each, _eachArray, _extend, _isBlockedUA, _register_event, _safewrap_class, isCrossDomainCookie, } from './utils';
50
- import { window } from './utils/globals';
50
+ import { assignableWindow, window } from './utils/globals';
51
51
  import { autocapture } from './autocapture';
52
52
  import { PostHogFeatureFlags } from './posthog-featureflags';
53
53
  import { PostHogPersistence } from './posthog-persistence';
@@ -100,11 +100,11 @@ var PRIMARY_INSTANCE_NAME = 'posthog';
100
100
  */
101
101
  // http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
102
102
  // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
103
- var USE_XHR = window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest();
103
+ var USE_XHR = (window === null || window === void 0 ? void 0 : window.XMLHttpRequest) && 'withCredentials' in new XMLHttpRequest();
104
104
  // IE<10 does not support cross-origin XHR's but script tags
105
105
  // with defer won't block window.onload; ENQUEUE_REQUESTS
106
106
  // should only be true for Opera<12
107
- var ENQUEUE_REQUESTS = !USE_XHR && userAgent.indexOf('MSIE') === -1 && userAgent.indexOf('Mozilla') === -1;
107
+ var ENQUEUE_REQUESTS = !USE_XHR && (userAgent === null || userAgent === void 0 ? void 0 : userAgent.indexOf('MSIE')) === -1 && (userAgent === null || userAgent === void 0 ? void 0 : userAgent.indexOf('Mozilla')) === -1;
108
108
  export var defaultConfig = function () {
109
109
  var _a;
110
110
  return ({
@@ -336,7 +336,7 @@ var PostHog = /** @class */ (function () {
336
336
  //
337
337
  PostHog.prototype._init = function (token, config, name, initComplete) {
338
338
  var _this = this;
339
- var _a, _b, _c, _d, _e, _f, _g;
339
+ var _a, _b, _c, _d, _e, _f, _g, _h;
340
340
  if (config === void 0) { config = {}; }
341
341
  this.__loaded = true;
342
342
  this.config = {}; // will be set right below
@@ -442,8 +442,7 @@ var PostHog = /** @class */ (function () {
442
442
  }
443
443
  // Set up event handler for pageleave
444
444
  // Use `onpagehide` if available, see https://calendar.perfplanet.com/2020/beaconing-in-practice/#beaconing-reliability-avoiding-abandons
445
- window.addEventListener &&
446
- window.addEventListener('onpagehide' in self ? 'pagehide' : 'unload', this._handle_unload.bind(this));
445
+ (_h = window === null || window === void 0 ? void 0 : window.addEventListener) === null || _h === void 0 ? void 0 : _h.call(window, 'onpagehide' in self ? 'pagehide' : 'unload', this._handle_unload.bind(this));
447
446
  // Make sure that we also call the initComplete callback at the end of
448
447
  // the synchronous code as well.
449
448
  updateInitComplete('syncCode')();
@@ -491,7 +490,7 @@ var PostHog = /** @class */ (function () {
491
490
  this._start_queue_if_opted_in();
492
491
  // this happens after so a user can call identify in
493
492
  // the loaded callback
494
- if (this.config.capture_pageview) {
493
+ if (this.config.capture_pageview && document) {
495
494
  this.capture('$pageview', { title: document.title }, { send_instantly: true });
496
495
  }
497
496
  // Call decide to get what features are enabled and other settings.
@@ -598,7 +597,7 @@ var PostHog = /** @class */ (function () {
598
597
  if (!USE_XHR) {
599
598
  options.method = 'GET';
600
599
  }
601
- var useSendBeacon = 'sendBeacon' in window.navigator && options.transport === 'sendBeacon';
600
+ var useSendBeacon = window && 'sendBeacon' in window.navigator && options.transport === 'sendBeacon';
602
601
  url = addParamsToURL(url, options.urlQueryArgs || {}, {
603
602
  ip: this.config.ip,
604
603
  });
@@ -606,14 +605,14 @@ var PostHog = /** @class */ (function () {
606
605
  // beacon documentation https://w3c.github.io/beacon/
607
606
  // beacons format the message and use the type property
608
607
  try {
609
- window.navigator.sendBeacon(url, encodePostData(data, __assign(__assign({}, options), { sendBeacon: true })));
608
+ window === null || window === void 0 ? void 0 : window.navigator.sendBeacon(url, encodePostData(data, __assign(__assign({}, options), { sendBeacon: true })));
610
609
  }
611
610
  catch (e) {
612
611
  // send beacon is a best-effort, fire-and-forget mechanism on page unload,
613
612
  // we don't want to throw errors here
614
613
  }
615
614
  }
616
- else if (USE_XHR) {
615
+ else if (USE_XHR || !document) {
617
616
  try {
618
617
  xhr({
619
618
  url: url,
@@ -758,7 +757,7 @@ var PostHog = /** @class */ (function () {
758
757
  logger.error('No event name provided to posthog.capture');
759
758
  return;
760
759
  }
761
- if (_isBlockedUA(userAgent, this.config.custom_blocked_useragents)) {
760
+ if (userAgent && _isBlockedUA(userAgent, this.config.custom_blocked_useragents)) {
762
761
  return;
763
762
  }
764
763
  // update persistence
@@ -841,7 +840,7 @@ var PostHog = /** @class */ (function () {
841
840
  }
842
841
  properties = _extend(properties, performanceProperties);
843
842
  }
844
- if (event_name === '$pageview') {
843
+ if (event_name === '$pageview' && document) {
845
844
  properties['title'] = document.title;
846
845
  }
847
846
  if (event_name === '$performance_event') {
@@ -1837,12 +1836,12 @@ var PostHog = /** @class */ (function () {
1837
1836
  };
1838
1837
  PostHog.prototype.debug = function (debug) {
1839
1838
  if (debug === false) {
1840
- window.console.log("You've disabled debug mode.");
1839
+ window === null || window === void 0 ? void 0 : window.console.log("You've disabled debug mode.");
1841
1840
  localStorage && localStorage.removeItem('ph_debug');
1842
1841
  this.set_config({ debug: false });
1843
1842
  }
1844
1843
  else {
1845
- window.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`.");
1844
+ window === null || window === void 0 ? void 0 : window.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`.");
1846
1845
  localStorage && localStorage.setItem('ph_debug', 'true');
1847
1846
  this.set_config({ debug: true });
1848
1847
  }
@@ -1891,8 +1890,7 @@ var override_ph_init_func = function () {
1891
1890
  ;
1892
1891
  posthog_master = instance;
1893
1892
  if (init_type === InitType.INIT_SNIPPET) {
1894
- ;
1895
- window[PRIMARY_INSTANCE_NAME] = posthog_master;
1893
+ assignableWindow[PRIMARY_INSTANCE_NAME] = posthog_master;
1896
1894
  }
1897
1895
  extend_mp();
1898
1896
  return instance;
@@ -1913,7 +1911,7 @@ var add_dom_loaded_handler = function () {
1913
1911
  inst._dom_loaded();
1914
1912
  });
1915
1913
  }
1916
- if (document.addEventListener) {
1914
+ if (document === null || document === void 0 ? void 0 : document.addEventListener) {
1917
1915
  if (document.readyState === 'complete') {
1918
1916
  // safari 4 can fire the DOMContentLoaded event before loading all
1919
1917
  // external JS (including this file). you will see some copypasta
@@ -1926,15 +1924,16 @@ var add_dom_loaded_handler = function () {
1926
1924
  }
1927
1925
  }
1928
1926
  // fallback handler, always will work
1929
- _register_event(window, 'load', dom_loaded_handler, true);
1927
+ if (window) {
1928
+ _register_event(window, 'load', dom_loaded_handler, true);
1929
+ }
1930
1930
  };
1931
1931
  export function init_from_snippet() {
1932
1932
  init_type = InitType.INIT_SNIPPET;
1933
- if (_isUndefined(window.posthog)) {
1934
- ;
1935
- window.posthog = [];
1933
+ if (_isUndefined(assignableWindow.posthog)) {
1934
+ assignableWindow.posthog = [];
1936
1935
  }
1937
- posthog_master = window.posthog;
1936
+ posthog_master = assignableWindow.posthog;
1938
1937
  if (posthog_master['__loaded'] || (posthog_master['config'] && posthog_master['persistence'])) {
1939
1938
  // lib has already been loaded at least once; we don't want to override the global object this time so bomb early
1940
1939
  logger.critical('PostHog library has already been downloaded at least once.');