posthog-js 1.81.2 → 1.81.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.
- package/dist/array.full.js +2 -2
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +2 -2
- package/dist/array.js.map +1 -1
- package/dist/es.js +2 -2
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +4 -0
- package/dist/module.js +2 -2
- package/dist/module.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/surveys.d.ts +7 -14
- package/lib/src/extensions/surveys.js +371 -93
- package/lib/src/extensions/surveys.js.map +1 -1
- package/lib/src/posthog-core.js +7 -1
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-surveys-types.d.ts +4 -0
- package/lib/src/posthog-surveys-types.js.map +1 -1
- package/lib/src/posthog-surveys.js +1 -1
- package/lib/src/posthog-surveys.js.map +1 -1
- package/package.json +1 -1
|
@@ -10,11 +10,15 @@ export interface SurveyAppearance {
|
|
|
10
10
|
submitButtonText?: string;
|
|
11
11
|
descriptionTextColor?: string;
|
|
12
12
|
ratingButtonColor?: string;
|
|
13
|
+
ratingButtonActiveColor?: string;
|
|
13
14
|
ratingButtonHoverColor?: string;
|
|
14
15
|
whiteLabel?: boolean;
|
|
15
16
|
displayThankYouMessage?: boolean;
|
|
16
17
|
thankYouMessageHeader?: string;
|
|
17
18
|
thankYouMessageDescription?: string;
|
|
19
|
+
borderColor?: string;
|
|
20
|
+
position?: 'left' | 'right' | 'center';
|
|
21
|
+
placeholder?: string;
|
|
18
22
|
maxWidth?: string;
|
|
19
23
|
zIndex?: string;
|
|
20
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"posthog-surveys-types.js","sourceRoot":"","sources":["../../src/posthog-surveys-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IAClB,iCAAmB,CAAA;IACnB,+BAAiB,CAAA;IACjB,wCAA0B,CAAA;IAC1B,6BAAe,CAAA;IACf,yBAAW,CAAA;AACf,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAgCD,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","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 textColor?: string\n submitButtonText?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: 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 Button = 'button',\n FullScreen = 'full_screen',\n Email = 'email',\n API = 'api',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\ninterface SurveyQuestionBase {\n question: string\n description?: string | null\n required?: boolean\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: number\n lowerBoundLabel: string\n upperBoundLabel: string\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\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 interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\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 questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: { url?: string; selector?: string; seenSurveyWaitPeriodInDays?: number } | null\n start_date: string | null\n end_date: string | null\n}\n"]}
|
|
@@ -11,7 +11,7 @@ var PostHogSurveys = /** @class */ (function () {
|
|
|
11
11
|
this.instance._send_request("".concat(this.instance.config.api_host, "/api/surveys/?token=").concat(this.instance.config.token), {}, { method: 'GET' }, function (response) {
|
|
12
12
|
var _a;
|
|
13
13
|
var _b;
|
|
14
|
-
var surveys = response.surveys;
|
|
14
|
+
var surveys = response.surveys || [];
|
|
15
15
|
(_b = _this.instance.persistence) === null || _b === void 0 ? void 0 : _b.register((_a = {}, _a[SURVEYS] = surveys, _a));
|
|
16
16
|
return callback(surveys);
|
|
17
17
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-surveys.js","sourceRoot":"","sources":["../../src/posthog-surveys.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGrC;IAGI,wBAAY,QAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;IA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C,MAAM,CAAC,kBAAkB,EAAE;oBACvD,OAAO,IAAI,CAAA;iBACd;gBACD,IAAM,eAAe,GAAG,MAAM,CAAC,eAAe;oBAC1C,CAAC,CAAC,KAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,eAAe,CAAC;oBACrE,CAAC,CAAC,IAAI,CAAA;gBACV,IAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB;oBAChD,CAAC,CAAC,KAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,kBAAkB,CAAC;oBACxE,CAAC,CAAC,IAAI,CAAA;gBACV,OAAO,eAAe,IAAI,kBAAkB,CAAA;YAChD,CAAC,CAAC,CAAA;YAEF,OAAO,QAAQ,CAAC,uBAAuB,CAAC,CAAA;QAC5C,CAAC,EAAE,WAAW,CAAC,CAAA;IACnB,CAAC;IACL,qBAAC;AAAD,CAAC,AA1DD,IA0DC","sourcesContent":["import { PostHog } from './posthog-core'\nimport { SURVEYS } from './constants'\nimport { SurveyCallback } from './posthog-surveys-types'\n\nexport class PostHogSurveys {\n instance: PostHog\n\n constructor(instance: PostHog) {\n this.instance = instance\n }\n\n getSurveys(callback: SurveyCallback, forceReload = false) {\n const existingSurveys = this.instance.get_property(SURVEYS)\n if (!existingSurveys || forceReload) {\n this.instance._send_request(\n `${this.instance.config.api_host}/api/surveys/?token=${this.instance.config.token}`,\n {},\n { method: 'GET' },\n (response) => {\n const surveys = response.surveys || []\n this.instance.persistence?.register({ [SURVEYS]: surveys })\n return callback(surveys)\n }\n )\n } else {\n return callback(existingSurveys)\n }\n }\n\n getActiveMatchingSurveys(callback: SurveyCallback, forceReload = false) {\n this.getSurveys((surveys) => {\n const activeSurveys = surveys.filter((survey) => {\n return !!(survey.start_date && !survey.end_date)\n })\n const conditionMatchedSurveys = activeSurveys.filter((survey) => {\n if (!survey.conditions) {\n return true\n }\n const urlCheck = survey.conditions?.url\n ? window.location.href.indexOf(survey.conditions.url) > -1\n : true\n const selectorCheck = survey.conditions?.selector\n ? document.querySelector(survey.conditions.selector)\n : true\n return urlCheck && selectorCheck\n })\n const targetingMatchedSurveys = conditionMatchedSurveys.filter((survey) => {\n if (!survey.linked_flag_key && !survey.targeting_flag_key) {\n return true\n }\n const linkedFlagCheck = survey.linked_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.instance.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n return linkedFlagCheck && targetingFlagCheck\n })\n\n return callback(targetingMatchedSurveys)\n }, forceReload)\n }\n}\n"]}
|
package/package.json
CHANGED