@posthog/core 1.27.9 → 1.28.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.
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/logs/index.d.ts +94 -4
- package/dist/logs/index.d.ts.map +1 -1
- package/dist/logs/index.js +147 -4
- package/dist/logs/index.mjs +148 -5
- package/dist/logs/logs-utils.d.ts +2 -1
- package/dist/logs/logs-utils.d.ts.map +1 -1
- package/dist/logs/types.d.ts +140 -8
- package/dist/logs/types.d.ts.map +1 -1
- package/dist/posthog-core-stateless.d.ts +34 -0
- package/dist/posthog-core-stateless.d.ts.map +1 -1
- package/dist/posthog-core-stateless.js +39 -0
- package/dist/posthog-core-stateless.mjs +39 -0
- package/dist/surveys/events.d.ts +22 -0
- package/dist/surveys/events.d.ts.map +1 -0
- package/dist/surveys/events.js +95 -0
- package/dist/surveys/events.mjs +43 -0
- package/dist/surveys/index.d.ts +4 -0
- package/dist/surveys/index.d.ts.map +1 -0
- package/dist/surveys/index.js +83 -0
- package/dist/surveys/index.mjs +4 -0
- package/dist/surveys/translations.d.ts +38 -0
- package/dist/surveys/translations.d.ts.map +1 -0
- package/dist/surveys/translations.js +207 -0
- package/dist/surveys/translations.mjs +158 -0
- package/dist/testing/test-utils.d.ts.map +1 -1
- package/dist/testing/test-utils.js +1 -0
- package/dist/testing/test-utils.mjs +1 -0
- package/dist/types.d.ts +31 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +3 -0
- package/dist/utils/logger.mjs +3 -0
- package/package.json +26 -2
- package/src/index.ts +12 -1
- package/src/logs/index.spec.ts +891 -17
- package/src/logs/index.ts +337 -13
- package/src/logs/logs-utils.spec.ts +2 -1
- package/src/logs/logs-utils.ts +1 -1
- package/src/logs/types.ts +150 -25
- package/src/posthog-core-stateless.ts +64 -0
- package/src/surveys/events.spec.ts +52 -0
- package/src/surveys/events.ts +80 -0
- package/src/surveys/index.ts +18 -0
- package/src/surveys/translations.spec.ts +205 -0
- package/src/surveys/translations.ts +244 -0
- package/src/testing/test-utils.ts +1 -0
- package/src/types.ts +38 -2
- package/src/utils/logger.ts +6 -2
package/src/types.ts
CHANGED
|
@@ -344,6 +344,18 @@ export type PostHogRemoteConfig = {
|
|
|
344
344
|
| {
|
|
345
345
|
[key: string]: JsonType
|
|
346
346
|
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Logs feature remote config. When a map, `captureConsoleLogs` (boolean)
|
|
350
|
+
* is the local opt-in flag for `console.*` autocapture (read by the JS
|
|
351
|
+
* SDK's `PostHogLogs` extension to decide whether to load the autocapture
|
|
352
|
+
* bundle).
|
|
353
|
+
*/
|
|
354
|
+
logs?:
|
|
355
|
+
| boolean
|
|
356
|
+
| {
|
|
357
|
+
[key: string]: JsonType
|
|
358
|
+
}
|
|
347
359
|
}
|
|
348
360
|
|
|
349
361
|
export type FeatureFlagValue = string | boolean
|
|
@@ -606,16 +618,34 @@ export interface SurveyValidationRule {
|
|
|
606
618
|
errorMessage?: string
|
|
607
619
|
}
|
|
608
620
|
|
|
621
|
+
export interface SurveyTranslation {
|
|
622
|
+
name?: string
|
|
623
|
+
thankYouMessageHeader?: string
|
|
624
|
+
thankYouMessageDescription?: string
|
|
625
|
+
thankYouMessageCloseButtonText?: string
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
export interface SurveyQuestionTranslation {
|
|
629
|
+
question?: string
|
|
630
|
+
description?: string | null
|
|
631
|
+
buttonText?: string
|
|
632
|
+
link?: string | null
|
|
633
|
+
lowerBoundLabel?: string
|
|
634
|
+
upperBoundLabel?: string
|
|
635
|
+
choices?: string[]
|
|
636
|
+
}
|
|
637
|
+
|
|
609
638
|
type SurveyQuestionBase = {
|
|
610
639
|
question: string
|
|
611
640
|
id: string
|
|
612
|
-
description?: string
|
|
641
|
+
description?: string | null
|
|
613
642
|
descriptionContentType?: SurveyQuestionDescriptionContentType
|
|
614
643
|
optional?: boolean
|
|
615
644
|
buttonText?: string
|
|
616
645
|
originalQuestionIndex: number
|
|
617
646
|
branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching
|
|
618
647
|
validation?: SurveyValidationRule[]
|
|
648
|
+
translations?: Record<string, SurveyQuestionTranslation>
|
|
619
649
|
}
|
|
620
650
|
|
|
621
651
|
export type BasicSurveyQuestion = SurveyQuestionBase & {
|
|
@@ -624,7 +654,7 @@ export type BasicSurveyQuestion = SurveyQuestionBase & {
|
|
|
624
654
|
|
|
625
655
|
export type LinkSurveyQuestion = SurveyQuestionBase & {
|
|
626
656
|
type: SurveyQuestionType.Link
|
|
627
|
-
link?: string
|
|
657
|
+
link?: string | null
|
|
628
658
|
}
|
|
629
659
|
|
|
630
660
|
export type RatingSurveyQuestion = SurveyQuestionBase & {
|
|
@@ -686,6 +716,10 @@ export type SurveyResponse = {
|
|
|
686
716
|
surveys: Survey[]
|
|
687
717
|
}
|
|
688
718
|
|
|
719
|
+
export type SurveyResponseValue = string | number | string[] | null
|
|
720
|
+
|
|
721
|
+
export type SurveyResponses = Record<string, SurveyResponseValue>
|
|
722
|
+
|
|
689
723
|
export type SurveyCallback = (surveys: Survey[]) => void
|
|
690
724
|
|
|
691
725
|
export enum SurveyMatchType {
|
|
@@ -728,6 +762,7 @@ export type Survey = {
|
|
|
728
762
|
name: string
|
|
729
763
|
description?: string
|
|
730
764
|
type: SurveyType
|
|
765
|
+
translations?: Record<string, SurveyTranslation>
|
|
731
766
|
feature_flag_keys?: {
|
|
732
767
|
key: string
|
|
733
768
|
value?: string
|
|
@@ -790,6 +825,7 @@ export type ActionStepType = {
|
|
|
790
825
|
}
|
|
791
826
|
|
|
792
827
|
export type Logger = {
|
|
828
|
+
debug: (...args: any[]) => void
|
|
793
829
|
info: (...args: any[]) => void
|
|
794
830
|
warn: (...args: any[]) => void
|
|
795
831
|
error: (...args: any[]) => void
|
package/src/utils/logger.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { Logger } from '../types'
|
|
|
2
2
|
|
|
3
3
|
// We want to make sure to get the original console methods as soon as possible
|
|
4
4
|
type ConsoleLike = {
|
|
5
|
+
debug: (...args: any[]) => void
|
|
5
6
|
log: (...args: any[]) => void
|
|
6
7
|
warn: (...args: any[]) => void
|
|
7
8
|
error: (...args: any[]) => void
|
|
8
|
-
debug: (...args: any[]) => void
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function createConsole(consoleLike: ConsoleLike = console): ConsoleLike {
|
|
@@ -23,7 +23,7 @@ export const _createLogger = (
|
|
|
23
23
|
maybeCall: (fn: () => void) => void,
|
|
24
24
|
consoleLike: ConsoleLike
|
|
25
25
|
): Logger => {
|
|
26
|
-
function _log(level: 'log' | 'warn' | 'error', ...args: any[]) {
|
|
26
|
+
function _log(level: 'debug' | 'log' | 'warn' | 'error', ...args: any[]) {
|
|
27
27
|
maybeCall(() => {
|
|
28
28
|
const consoleMethod = consoleLike[level]
|
|
29
29
|
consoleMethod(prefix, ...args)
|
|
@@ -31,6 +31,10 @@ export const _createLogger = (
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const logger: Logger = {
|
|
34
|
+
debug: (...args: any[]) => {
|
|
35
|
+
_log('debug', ...args)
|
|
36
|
+
},
|
|
37
|
+
|
|
34
38
|
info: (...args: any[]) => {
|
|
35
39
|
_log('log', ...args)
|
|
36
40
|
},
|