@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.
Files changed (51) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/logs/index.d.ts +94 -4
  4. package/dist/logs/index.d.ts.map +1 -1
  5. package/dist/logs/index.js +147 -4
  6. package/dist/logs/index.mjs +148 -5
  7. package/dist/logs/logs-utils.d.ts +2 -1
  8. package/dist/logs/logs-utils.d.ts.map +1 -1
  9. package/dist/logs/types.d.ts +140 -8
  10. package/dist/logs/types.d.ts.map +1 -1
  11. package/dist/posthog-core-stateless.d.ts +34 -0
  12. package/dist/posthog-core-stateless.d.ts.map +1 -1
  13. package/dist/posthog-core-stateless.js +39 -0
  14. package/dist/posthog-core-stateless.mjs +39 -0
  15. package/dist/surveys/events.d.ts +22 -0
  16. package/dist/surveys/events.d.ts.map +1 -0
  17. package/dist/surveys/events.js +95 -0
  18. package/dist/surveys/events.mjs +43 -0
  19. package/dist/surveys/index.d.ts +4 -0
  20. package/dist/surveys/index.d.ts.map +1 -0
  21. package/dist/surveys/index.js +83 -0
  22. package/dist/surveys/index.mjs +4 -0
  23. package/dist/surveys/translations.d.ts +38 -0
  24. package/dist/surveys/translations.d.ts.map +1 -0
  25. package/dist/surveys/translations.js +207 -0
  26. package/dist/surveys/translations.mjs +158 -0
  27. package/dist/testing/test-utils.d.ts.map +1 -1
  28. package/dist/testing/test-utils.js +1 -0
  29. package/dist/testing/test-utils.mjs +1 -0
  30. package/dist/types.d.ts +31 -2
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/utils/logger.d.ts +1 -1
  33. package/dist/utils/logger.d.ts.map +1 -1
  34. package/dist/utils/logger.js +3 -0
  35. package/dist/utils/logger.mjs +3 -0
  36. package/package.json +26 -2
  37. package/src/index.ts +12 -1
  38. package/src/logs/index.spec.ts +891 -17
  39. package/src/logs/index.ts +337 -13
  40. package/src/logs/logs-utils.spec.ts +2 -1
  41. package/src/logs/logs-utils.ts +1 -1
  42. package/src/logs/types.ts +150 -25
  43. package/src/posthog-core-stateless.ts +64 -0
  44. package/src/surveys/events.spec.ts +52 -0
  45. package/src/surveys/events.ts +80 -0
  46. package/src/surveys/index.ts +18 -0
  47. package/src/surveys/translations.spec.ts +205 -0
  48. package/src/surveys/translations.ts +244 -0
  49. package/src/testing/test-utils.ts +1 -0
  50. package/src/types.ts +38 -2
  51. 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
@@ -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
  },