posthog-js 1.154.2 → 1.154.4

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.
@@ -8,6 +8,7 @@ export interface SurveyAppearance {
8
8
  submitButtonColor?: string;
9
9
  textColor?: string;
10
10
  submitButtonText?: string;
11
+ submitButtonTextColor?: string;
11
12
  descriptionTextColor?: string;
12
13
  ratingButtonColor?: string;
13
14
  ratingButtonActiveColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,+BAAiB,CAAA;AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAwCD,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,wDAAkC,CAAA;IAClC,oDAA8B,CAAA;IAC9B,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACjB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AAED,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACnC,6DAA8B,CAAA;IAC9B,0CAAW,CAAA;IACX,+DAAgC,CAAA;IAChC,qEAAsC,CAAA;AAC1C,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC","sourcesContent":["/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n // text color is deprecated, use auto contrast text color instead\n textColor?: string\n // deprecate submit button text eventually\n submitButtonText?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n autoDisappear?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType\n thankYouMessageCloseButtonText?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n shuffleQuestions?: boolean\n surveyPopupDelaySeconds?: number\n // widget options\n widgetType?: 'button' | 'tab' | 'selector'\n widgetSelector?: string\n widgetLabel?: string\n widgetColor?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\nexport type SurveyQuestionDescriptionContentType = 'html' | 'text'\n\ninterface SurveyQuestionBase {\n question: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n optional?: boolean\n buttonText?: string\n originalQuestionIndex: number\n branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link?: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: 3 | 5 | 7 | 10\n lowerBoundLabel: string\n upperBoundLabel: string\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: boolean\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport enum SurveyQuestionBranchingType {\n NextQuestion = 'next_question',\n End = 'end',\n ResponseBased = 'response_based',\n SpecificQuestion = 'specific_question',\n}\n\ninterface NextQuestionBranching {\n type: SurveyQuestionBranchingType.NextQuestion\n}\n\ninterface EndBranching {\n type: SurveyQuestionBranchingType.End\n}\n\ninterface ResponseBasedBranching {\n type: SurveyQuestionBranchingType.ResponseBased\n responseValues: Record<string, any>\n}\n\ninterface SpecificQuestionBranching {\n type: SurveyQuestionBranchingType.SpecificQuestion\n index: number\n}\n\nexport interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyUrlMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\n\nexport interface SurveyElement {\n text?: string\n $el_text?: string\n tag_name?: string\n href?: string\n attr_id?: string\n attr_class?: string[]\n nth_child?: number\n nth_of_type?: number\n attributes?: Record<string, any>\n event_id?: number\n order?: number\n group_id?: number\n}\nexport interface SurveyRenderReason {\n visible: boolean\n disabledReason?: string\n}\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n linked_flag_key: string | null\n targeting_flag_key: string | null\n internal_targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: SurveyUrlMatchType\n events: {\n repeatedActivation?: boolean\n values: {\n name: string\n }[]\n } | null\n actions: {\n values: ActionType[]\n } | null\n } | null\n start_date: string | null\n end_date: string | null\n current_iteration: number | null\n current_iteration_start_date: string | null\n}\n\nexport interface ActionType {\n count?: number\n created_at: string\n deleted?: boolean\n id: number\n name: string | null\n steps?: ActionStepType[]\n tags?: string[]\n is_action?: true\n action_id?: number // alias of id to make it compatible with event definitions uuid\n}\n\n/** Sync with plugin-server/src/types.ts */\nexport type ActionStepStringMatching = 'contains' | 'exact' | 'regex'\n\nexport interface ActionStepType {\n event?: string | null\n selector?: string | null\n /** @deprecated Only `selector` should be used now. */\n tag_name?: string\n text?: string | null\n /** @default StringMatching.Exact */\n text_matching?: ActionStepStringMatching | null\n href?: string | null\n /** @default ActionStepStringMatching.Exact */\n href_matching?: ActionStepStringMatching | null\n url?: string | null\n /** @default StringMatching.Contains */\n url_matching?: ActionStepStringMatching | null\n}\n"]}
1
+ {"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqCH,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,yBAAW,CAAA;IACX,+BAAiB,CAAA;AACrB,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAwCD,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC1B,mCAAa,CAAA;IACb,wDAAkC,CAAA;IAClC,oDAA8B,CAAA;IAC9B,uCAAiB,CAAA;IACjB,mCAAa,CAAA;AACjB,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AAED,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACnC,6DAA8B,CAAA;IAC9B,0CAAW,CAAA;IACX,+DAAgC,CAAA;IAChC,qEAAsC,CAAA;AAC1C,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC","sourcesContent":["/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n // text color is deprecated, use auto contrast text color instead\n textColor?: string\n // deprecate submit button text eventually\n submitButtonText?: string\n submitButtonTextColor?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n autoDisappear?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType\n thankYouMessageCloseButtonText?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n shuffleQuestions?: boolean\n surveyPopupDelaySeconds?: number\n // widget options\n widgetType?: 'button' | 'tab' | 'selector'\n widgetSelector?: string\n widgetLabel?: string\n widgetColor?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\nexport type SurveyQuestionDescriptionContentType = 'html' | 'text'\n\ninterface SurveyQuestionBase {\n question: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n optional?: boolean\n buttonText?: string\n originalQuestionIndex: number\n branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link?: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: 3 | 5 | 7 | 10\n lowerBoundLabel: string\n upperBoundLabel: string\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: boolean\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport enum SurveyQuestionBranchingType {\n NextQuestion = 'next_question',\n End = 'end',\n ResponseBased = 'response_based',\n SpecificQuestion = 'specific_question',\n}\n\ninterface NextQuestionBranching {\n type: SurveyQuestionBranchingType.NextQuestion\n}\n\ninterface EndBranching {\n type: SurveyQuestionBranchingType.End\n}\n\ninterface ResponseBasedBranching {\n type: SurveyQuestionBranchingType.ResponseBased\n responseValues: Record<string, any>\n}\n\ninterface SpecificQuestionBranching {\n type: SurveyQuestionBranchingType.SpecificQuestion\n index: number\n}\n\nexport interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyUrlMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\n\nexport interface SurveyElement {\n text?: string\n $el_text?: string\n tag_name?: string\n href?: string\n attr_id?: string\n attr_class?: string[]\n nth_child?: number\n nth_of_type?: number\n attributes?: Record<string, any>\n event_id?: number\n order?: number\n group_id?: number\n}\nexport interface SurveyRenderReason {\n visible: boolean\n disabledReason?: string\n}\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n linked_flag_key: string | null\n targeting_flag_key: string | null\n internal_targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: SurveyUrlMatchType\n events: {\n repeatedActivation?: boolean\n values: {\n name: string\n }[]\n } | null\n actions: {\n values: ActionType[]\n } | null\n } | null\n start_date: string | null\n end_date: string | null\n current_iteration: number | null\n current_iteration_start_date: string | null\n}\n\nexport interface ActionType {\n count?: number\n created_at: string\n deleted?: boolean\n id: number\n name: string | null\n steps?: ActionStepType[]\n tags?: string[]\n is_action?: true\n action_id?: number // alias of id to make it compatible with event definitions uuid\n}\n\n/** Sync with plugin-server/src/types.ts */\nexport type ActionStepStringMatching = 'contains' | 'exact' | 'regex'\n\nexport interface ActionStepType {\n event?: string | null\n selector?: string | null\n /** @deprecated Only `selector` should be used now. */\n tag_name?: string\n text?: string | null\n /** @default StringMatching.Exact */\n text_matching?: ActionStepStringMatching | null\n href?: string | null\n /** @default ActionStepStringMatching.Exact */\n href_matching?: ActionStepStringMatching | null\n url?: string | null\n /** @default StringMatching.Contains */\n url_matching?: ActionStepStringMatching | null\n}\n"]}
@@ -118,7 +118,7 @@ export var cookieStore = {
118
118
  }
119
119
  return cookie;
120
120
  },
121
- set: function (name, value, days, cross_subdomain, is_secure, debug) {
121
+ set: function (name, value, days, cross_subdomain, is_secure) {
122
122
  if (!document) {
123
123
  return;
124
124
  }
@@ -144,9 +144,6 @@ export var cookieStore = {
144
144
  if (new_cookie_val.length > 4096 * 0.9) {
145
145
  logger.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length);
146
146
  }
147
- if (debug) {
148
- logger.info('cookie set', new_cookie_val);
149
- }
150
147
  document.cookie = new_cookie_val;
151
148
  return new_cookie_val;
152
149
  }
@@ -213,11 +210,8 @@ export var localStore = {
213
210
  }
214
211
  return null;
215
212
  },
216
- set: function (name, value, _days, _cross_subdomain, _secure, debug) {
213
+ set: function (name, value) {
217
214
  try {
218
- if (debug) {
219
- logger.info('localStorage set', name, value);
220
- }
221
215
  window === null || window === void 0 ? void 0 : window.localStorage.setItem(name, JSON.stringify(value));
222
216
  }
223
217
  catch (err) {
@@ -350,11 +344,8 @@ export var sessionStore = {
350
344
  }
351
345
  return null;
352
346
  },
353
- set: function (name, value, _days, _cross_subdomain, _secure, debug) {
347
+ set: function (name, value) {
354
348
  try {
355
- if (debug) {
356
- logger.info('sessionStorage set', name, value);
357
- }
358
349
  window === null || window === void 0 ? void 0 : window.sessionStorage.setItem(name, JSON.stringify(value));
359
350
  }
360
351
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAE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,CAAC,CAAA;aACjD;YACD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;SAC9D;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;IAED,MAAM,EAAE,UAAU,IAAI;QAClB,IAAI;YACA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;SAC1C;QAAC,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SAC1B;IACL,CAAC;CACJ,CAAA","sourcesContent":["import { extend } from './utils'\nimport { PersistentStore, Properties } from './types'\nimport { DISTINCT_ID, ENABLE_PERSON_PROCESSING, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants'\n\nimport { isNull, isUndefined } from './utils/type-utils'\nimport { logger } from './utils/logger'\nimport { window, document } from './utils/globals'\nimport { uuidv7 } from './uuidv7'\n\nconst Y1970 = 'Thu, 01 Jan 1970 00:00:00 GMT'\n// we store the discovered subdomain in memory because it might be read multiple times\nlet firstNonPublicSubDomain = ''\n\n// helper to allow tests to clear this \"cache\"\nexport const resetSubDomainCache = () => {\n firstNonPublicSubDomain = ''\n}\n\n/**\n * Browsers don't offer a way to check if something is a public suffix\n * e.g. `.com.au`, `.io`, `.org.uk`\n *\n * But they do reject cookies set on public suffixes\n * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited\n *\n * So, we can use this to check if a domain is a public suffix\n * by trying to set a cookie on a subdomain of the provided hostname\n * until the browser accepts it\n *\n * inspired by https://github.com/AngusFu/browser-root-domain\n */\nexport function seekFirstNonPublicSubDomain(hostname: string, cookieJar = document): string {\n if (firstNonPublicSubDomain) {\n return firstNonPublicSubDomain\n }\n\n if (!cookieJar) {\n return ''\n }\n if (['localhost', '127.0.0.1'].includes(hostname)) return ''\n\n const list = hostname.split('.')\n let len = Math.min(list.length, 8) // paranoia - we know this number should be small\n const key = 'dmn_chk_' + uuidv7()\n const R = new RegExp('(^|;)\\\\s*' + key + '=1')\n\n while (!firstNonPublicSubDomain && len--) {\n const candidate = list.slice(len).join('.')\n const candidateCookieValue = key + '=1;domain=.' + candidate\n\n // try to set cookie\n cookieJar.cookie = candidateCookieValue\n\n if (R.test(cookieJar.cookie)) {\n // the cookie was accepted by the browser, remove the test cookie\n cookieJar.cookie = candidateCookieValue + ';expires=' + Y1970\n firstNonPublicSubDomain = candidate\n }\n }\n\n return firstNonPublicSubDomain\n}\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\nconst originalCookieDomainFn = (hostname: string): string => {\n const matches = hostname.match(DOMAIN_MATCH_REGEX)\n return matches ? matches[0] : ''\n}\n\nexport function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string {\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n let matchedSubDomain = seekFirstNonPublicSubDomain(hostname)\n\n if (!matchedSubDomain) {\n const originalMatch = originalCookieDomainFn(hostname)\n if (originalMatch !== matchedSubDomain) {\n logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain)\n }\n matchedSubDomain = originalMatch\n }\n\n return matchedSubDomain ? '; domain=.' + matchedSubDomain : ''\n }\n return ''\n}\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n is_supported: () => !!document,\n\n error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n get: function (name) {\n if (!document) {\n return\n }\n\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch (err) {}\n return null\n },\n\n parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return cookie\n },\n\n set: function (name, value, days, cross_subdomain, is_secure, debug) {\n if (!document) {\n return\n }\n try {\n let expires = '',\n secure = ''\n\n const cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain)\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n\n // 4096 bytes is the size at which some browsers (e.g. firefox) will not store a cookie, warn slightly before that\n if (new_cookie_val.length > 4096 * 0.9) {\n logger.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length)\n }\n\n if (debug) {\n logger.info('cookie set', new_cookie_val)\n }\n\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch (err) {\n return\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n cookieStore.set(name, '', -1, cross_subdomain)\n } catch (err) {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\n\nexport const localStore: PersistentStore = {\n is_supported: function () {\n if (!isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore.set(key, val)\n if (localStore.get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore.remove(key)\n } catch (err) {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n get: function (name) {\n try {\n return window?.localStorage.getItem(name)\n } catch (err) {\n localStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(localStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, _days, _cross_subdomain, _secure, debug) {\n try {\n if (debug) {\n logger.info('localStorage set', name, value)\n }\n window?.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window?.localStorage.removeItem(name)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED, ENABLE_PERSON_PROCESSING]\n\nexport const localPlusCookieStore: PersistentStore = {\n ...localStore,\n parse: function (name) {\n try {\n let cookieProperties: Properties = {}\n try {\n // See if there's a cookie stored with data.\n cookieProperties = cookieStore.parse(name) || {}\n } catch (err) {}\n const value = extend(cookieProperties, JSON.parse(localStore.get(name) || '{}'))\n localStore.set(name, value)\n return value\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, days, cross_subdomain, is_secure, debug) {\n try {\n localStore.set(name, value, undefined, undefined, debug)\n const cookiePersistedProperties: Record<string, any> = {}\n COOKIE_PERSISTED_PROPERTIES.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore.set(name, cookiePersistedProperties, days, cross_subdomain, is_secure, debug)\n }\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n window?.localStorage.removeItem(name)\n cookieStore.remove(name, cross_subdomain)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n is_supported: function () {\n return true\n },\n\n error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n get: function (name) {\n return memoryStorage[name] || null\n },\n\n parse: function (name) {\n return memoryStorage[name] || null\n },\n\n set: function (name, value) {\n memoryStorage[name] = value\n },\n\n remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n is_supported: function () {\n if (!isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore.set(key, val)\n if (sessionStore.get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore.remove(key)\n } catch (err) {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n get: function (name) {\n try {\n return window?.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(sessionStore.get(name)) || null\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, _days, _cross_subdomain, _secure, debug) {\n try {\n if (debug) {\n logger.info('sessionStorage set', name, value)\n }\n window?.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window?.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n },\n}\n"]}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/storage.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,UAAU,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAE7G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utils'\nimport { PersistentStore, Properties } from './types'\nimport { DISTINCT_ID, ENABLE_PERSON_PROCESSING, SESSION_ID, SESSION_RECORDING_IS_SAMPLED } from './constants'\n\nimport { isNull, isUndefined } from './utils/type-utils'\nimport { logger } from './utils/logger'\nimport { window, document } from './utils/globals'\nimport { uuidv7 } from './uuidv7'\n\nconst Y1970 = 'Thu, 01 Jan 1970 00:00:00 GMT'\n// we store the discovered subdomain in memory because it might be read multiple times\nlet firstNonPublicSubDomain = ''\n\n// helper to allow tests to clear this \"cache\"\nexport const resetSubDomainCache = () => {\n firstNonPublicSubDomain = ''\n}\n\n/**\n * Browsers don't offer a way to check if something is a public suffix\n * e.g. `.com.au`, `.io`, `.org.uk`\n *\n * But they do reject cookies set on public suffixes\n * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited\n *\n * So, we can use this to check if a domain is a public suffix\n * by trying to set a cookie on a subdomain of the provided hostname\n * until the browser accepts it\n *\n * inspired by https://github.com/AngusFu/browser-root-domain\n */\nexport function seekFirstNonPublicSubDomain(hostname: string, cookieJar = document): string {\n if (firstNonPublicSubDomain) {\n return firstNonPublicSubDomain\n }\n\n if (!cookieJar) {\n return ''\n }\n if (['localhost', '127.0.0.1'].includes(hostname)) return ''\n\n const list = hostname.split('.')\n let len = Math.min(list.length, 8) // paranoia - we know this number should be small\n const key = 'dmn_chk_' + uuidv7()\n const R = new RegExp('(^|;)\\\\s*' + key + '=1')\n\n while (!firstNonPublicSubDomain && len--) {\n const candidate = list.slice(len).join('.')\n const candidateCookieValue = key + '=1;domain=.' + candidate\n\n // try to set cookie\n cookieJar.cookie = candidateCookieValue\n\n if (R.test(cookieJar.cookie)) {\n // the cookie was accepted by the browser, remove the test cookie\n cookieJar.cookie = candidateCookieValue + ';expires=' + Y1970\n firstNonPublicSubDomain = candidate\n }\n }\n\n return firstNonPublicSubDomain\n}\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\nconst originalCookieDomainFn = (hostname: string): string => {\n const matches = hostname.match(DOMAIN_MATCH_REGEX)\n return matches ? matches[0] : ''\n}\n\nexport function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string {\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n let matchedSubDomain = seekFirstNonPublicSubDomain(hostname)\n\n if (!matchedSubDomain) {\n const originalMatch = originalCookieDomainFn(hostname)\n if (originalMatch !== matchedSubDomain) {\n logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain)\n }\n matchedSubDomain = originalMatch\n }\n\n return matchedSubDomain ? '; domain=.' + matchedSubDomain : ''\n }\n return ''\n}\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n is_supported: () => !!document,\n\n error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n get: function (name) {\n if (!document) {\n return\n }\n\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch (err) {}\n return null\n },\n\n parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return cookie\n },\n\n set: function (name, value, days, cross_subdomain, is_secure) {\n if (!document) {\n return\n }\n try {\n let expires = '',\n secure = ''\n\n const cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain)\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n\n // 4096 bytes is the size at which some browsers (e.g. firefox) will not store a cookie, warn slightly before that\n if (new_cookie_val.length > 4096 * 0.9) {\n logger.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length)\n }\n\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch (err) {\n return\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n cookieStore.set(name, '', -1, cross_subdomain)\n } catch (err) {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\n\nexport const localStore: PersistentStore = {\n is_supported: function () {\n if (!isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore.set(key, val)\n if (localStore.get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore.remove(key)\n } catch (err) {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n get: function (name) {\n try {\n return window?.localStorage.getItem(name)\n } catch (err) {\n localStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(localStore.get(name)) || {}\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window?.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window?.localStorage.removeItem(name)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [DISTINCT_ID, SESSION_ID, SESSION_RECORDING_IS_SAMPLED, ENABLE_PERSON_PROCESSING]\n\nexport const localPlusCookieStore: PersistentStore = {\n ...localStore,\n parse: function (name) {\n try {\n let cookieProperties: Properties = {}\n try {\n // See if there's a cookie stored with data.\n cookieProperties = cookieStore.parse(name) || {}\n } catch (err) {}\n const value = extend(cookieProperties, JSON.parse(localStore.get(name) || '{}'))\n localStore.set(name, value)\n return value\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value, days, cross_subdomain, is_secure, debug) {\n try {\n localStore.set(name, value, undefined, undefined, debug)\n const cookiePersistedProperties: Record<string, any> = {}\n COOKIE_PERSISTED_PROPERTIES.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore.set(name, cookiePersistedProperties, days, cross_subdomain, is_secure, debug)\n }\n } catch (err) {\n localStore.error(err)\n }\n },\n\n remove: function (name, cross_subdomain) {\n try {\n window?.localStorage.removeItem(name)\n cookieStore.remove(name, cross_subdomain)\n } catch (err) {\n localStore.error(err)\n }\n },\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n is_supported: function () {\n return true\n },\n\n error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n get: function (name) {\n return memoryStorage[name] || null\n },\n\n parse: function (name) {\n return memoryStorage[name] || null\n },\n\n set: function (name, value) {\n memoryStorage[name] = value\n },\n\n remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n is_supported: function () {\n if (!isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore.set(key, val)\n if (sessionStore.get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore.remove(key)\n } catch (err) {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n get: function (name) {\n try {\n return window?.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n return null\n },\n\n parse: function (name) {\n try {\n return JSON.parse(sessionStore.get(name)) || null\n } catch (err) {\n // noop\n }\n return null\n },\n\n set: function (name, value) {\n try {\n window?.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore.error(err)\n }\n },\n\n remove: function (name) {\n try {\n window?.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore.error(err)\n }\n },\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.154.2",
3
+ "version": "1.154.4",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",