posthog-react-native 3.15.0 → 3.15.1

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 (149) hide show
  1. package/lib/posthog-core/src/eventemitter.d.ts +8 -8
  2. package/lib/posthog-core/src/eventemitter.js +1 -0
  3. package/lib/posthog-core/src/eventemitter.js.map +1 -0
  4. package/lib/posthog-core/src/featureFlagUtils.d.ts +34 -34
  5. package/lib/posthog-core/src/featureFlagUtils.js +1 -0
  6. package/lib/posthog-core/src/featureFlagUtils.js.map +1 -0
  7. package/lib/posthog-core/src/index.d.ts +242 -239
  8. package/lib/posthog-core/src/index.js +1 -0
  9. package/lib/posthog-core/src/index.js.map +1 -0
  10. package/lib/posthog-core/src/lz-string.d.ts +8 -8
  11. package/lib/posthog-core/src/lz-string.js +1 -0
  12. package/lib/posthog-core/src/lz-string.js.map +1 -0
  13. package/lib/posthog-core/src/types.d.ts +422 -423
  14. package/lib/posthog-core/src/types.js +1 -0
  15. package/lib/posthog-core/src/types.js.map +1 -0
  16. package/lib/posthog-core/src/utils.d.ts +19 -19
  17. package/lib/posthog-core/src/utils.js +1 -0
  18. package/lib/posthog-core/src/utils.js.map +1 -0
  19. package/lib/posthog-core/src/vendor/uuidv7.d.ts +179 -179
  20. package/lib/posthog-core/src/vendor/uuidv7.js +7 -0
  21. package/lib/posthog-core/src/vendor/uuidv7.js.map +1 -0
  22. package/lib/posthog-react-native/index.d.ts +10 -10
  23. package/lib/posthog-react-native/index.js +1 -0
  24. package/lib/posthog-react-native/index.js.map +1 -0
  25. package/lib/posthog-react-native/src/PostHogContext.d.ts +5 -5
  26. package/lib/posthog-react-native/src/PostHogContext.js +1 -0
  27. package/lib/posthog-react-native/src/PostHogContext.js.map +1 -0
  28. package/lib/posthog-react-native/src/PostHogProvider.d.ts +14 -14
  29. package/lib/posthog-react-native/src/PostHogProvider.js +1 -0
  30. package/lib/posthog-react-native/src/PostHogProvider.js.map +1 -0
  31. package/lib/posthog-react-native/src/autocapture.d.ts +4 -4
  32. package/lib/posthog-react-native/src/autocapture.js +1 -0
  33. package/lib/posthog-react-native/src/autocapture.js.map +1 -0
  34. package/lib/posthog-react-native/src/frameworks/wix-navigation.d.ts +3 -3
  35. package/lib/posthog-react-native/src/frameworks/wix-navigation.js +1 -0
  36. package/lib/posthog-react-native/src/frameworks/wix-navigation.js.map +1 -0
  37. package/lib/posthog-react-native/src/hooks/useFeatureFlag.d.ts +5 -5
  38. package/lib/posthog-react-native/src/hooks/useFeatureFlag.js +1 -0
  39. package/lib/posthog-react-native/src/hooks/useFeatureFlag.js.map +1 -0
  40. package/lib/posthog-react-native/src/hooks/useFeatureFlags.d.ts +3 -3
  41. package/lib/posthog-react-native/src/hooks/useFeatureFlags.js +1 -0
  42. package/lib/posthog-react-native/src/hooks/useFeatureFlags.js.map +1 -0
  43. package/lib/posthog-react-native/src/hooks/useNavigationTracker.d.ts +6 -6
  44. package/lib/posthog-react-native/src/hooks/useNavigationTracker.js +1 -0
  45. package/lib/posthog-react-native/src/hooks/useNavigationTracker.js.map +1 -0
  46. package/lib/posthog-react-native/src/hooks/usePostHog.d.ts +2 -2
  47. package/lib/posthog-react-native/src/hooks/usePostHog.js +1 -0
  48. package/lib/posthog-react-native/src/hooks/usePostHog.js.map +1 -0
  49. package/lib/posthog-react-native/src/legacy.d.ts +4 -4
  50. package/lib/posthog-react-native/src/legacy.js +1 -0
  51. package/lib/posthog-react-native/src/legacy.js.map +1 -0
  52. package/lib/posthog-react-native/src/native-deps.d.ts +4 -4
  53. package/lib/posthog-react-native/src/native-deps.js +1 -0
  54. package/lib/posthog-react-native/src/native-deps.js.map +1 -0
  55. package/lib/posthog-react-native/src/optional/OptionalAsyncStorage.d.ts +2 -2
  56. package/lib/posthog-react-native/src/optional/OptionalAsyncStorage.js +1 -0
  57. package/lib/posthog-react-native/src/optional/OptionalAsyncStorage.js.map +1 -0
  58. package/lib/posthog-react-native/src/optional/OptionalExpoApplication.d.ts +2 -2
  59. package/lib/posthog-react-native/src/optional/OptionalExpoApplication.js +1 -0
  60. package/lib/posthog-react-native/src/optional/OptionalExpoApplication.js.map +1 -0
  61. package/lib/posthog-react-native/src/optional/OptionalExpoDevice.d.ts +2 -2
  62. package/lib/posthog-react-native/src/optional/OptionalExpoDevice.js +1 -0
  63. package/lib/posthog-react-native/src/optional/OptionalExpoDevice.js.map +1 -0
  64. package/lib/posthog-react-native/src/optional/OptionalExpoFileSystem.d.ts +2 -2
  65. package/lib/posthog-react-native/src/optional/OptionalExpoFileSystem.js +1 -0
  66. package/lib/posthog-react-native/src/optional/OptionalExpoFileSystem.js.map +1 -0
  67. package/lib/posthog-react-native/src/optional/OptionalExpoLocalization.d.ts +2 -2
  68. package/lib/posthog-react-native/src/optional/OptionalExpoLocalization.js +1 -0
  69. package/lib/posthog-react-native/src/optional/OptionalExpoLocalization.js.map +1 -0
  70. package/lib/posthog-react-native/src/optional/OptionalReactNativeDeviceInfo.d.ts +2 -2
  71. package/lib/posthog-react-native/src/optional/OptionalReactNativeDeviceInfo.js +1 -0
  72. package/lib/posthog-react-native/src/optional/OptionalReactNativeDeviceInfo.js.map +1 -0
  73. package/lib/posthog-react-native/src/optional/OptionalReactNativeLocalize.d.ts +13 -13
  74. package/lib/posthog-react-native/src/optional/OptionalReactNativeLocalize.js +1 -0
  75. package/lib/posthog-react-native/src/optional/OptionalReactNativeLocalize.js.map +1 -0
  76. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigation.d.ts +2 -2
  77. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigation.js +1 -0
  78. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigation.js.map +1 -0
  79. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigationWix.d.ts +2 -2
  80. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigationWix.js +1 -0
  81. package/lib/posthog-react-native/src/optional/OptionalReactNativeNavigationWix.js.map +1 -0
  82. package/lib/posthog-react-native/src/optional/OptionalReactNativeSafeArea.d.ts +2 -2
  83. package/lib/posthog-react-native/src/optional/OptionalReactNativeSafeArea.js +1 -0
  84. package/lib/posthog-react-native/src/optional/OptionalReactNativeSafeArea.js.map +1 -0
  85. package/lib/posthog-react-native/src/optional/OptionalSessionReplay.d.ts +2 -2
  86. package/lib/posthog-react-native/src/optional/OptionalSessionReplay.js +1 -0
  87. package/lib/posthog-react-native/src/optional/OptionalSessionReplay.js.map +1 -0
  88. package/lib/posthog-react-native/src/posthog-rn.d.ts +71 -71
  89. package/lib/posthog-react-native/src/posthog-rn.js +1 -0
  90. package/lib/posthog-react-native/src/posthog-rn.js.map +1 -0
  91. package/lib/posthog-react-native/src/storage.d.ts +21 -21
  92. package/lib/posthog-react-native/src/storage.js +1 -0
  93. package/lib/posthog-react-native/src/storage.js.map +1 -0
  94. package/lib/posthog-react-native/src/surveys/PostHogSurveyProvider.d.ts +16 -16
  95. package/lib/posthog-react-native/src/surveys/PostHogSurveyProvider.js +1 -0
  96. package/lib/posthog-react-native/src/surveys/PostHogSurveyProvider.js.map +1 -0
  97. package/lib/posthog-react-native/src/surveys/components/BottomSection.d.ts +9 -9
  98. package/lib/posthog-react-native/src/surveys/components/BottomSection.js +1 -0
  99. package/lib/posthog-react-native/src/surveys/components/BottomSection.js.map +1 -0
  100. package/lib/posthog-react-native/src/surveys/components/Cancel.d.ts +6 -6
  101. package/lib/posthog-react-native/src/surveys/components/Cancel.js +1 -0
  102. package/lib/posthog-react-native/src/surveys/components/Cancel.js.map +1 -0
  103. package/lib/posthog-react-native/src/surveys/components/ConfirmationMessage.d.ts +13 -13
  104. package/lib/posthog-react-native/src/surveys/components/ConfirmationMessage.js +1 -0
  105. package/lib/posthog-react-native/src/surveys/components/ConfirmationMessage.js.map +1 -0
  106. package/lib/posthog-react-native/src/surveys/components/QuestionHeader.d.ts +7 -7
  107. package/lib/posthog-react-native/src/surveys/components/QuestionHeader.js +1 -0
  108. package/lib/posthog-react-native/src/surveys/components/QuestionHeader.js.map +1 -0
  109. package/lib/posthog-react-native/src/surveys/components/QuestionTypes.d.ts +27 -27
  110. package/lib/posthog-react-native/src/surveys/components/QuestionTypes.js +1 -0
  111. package/lib/posthog-react-native/src/surveys/components/QuestionTypes.js.map +1 -0
  112. package/lib/posthog-react-native/src/surveys/components/SurveyModal.d.ts +10 -10
  113. package/lib/posthog-react-native/src/surveys/components/SurveyModal.js +1 -0
  114. package/lib/posthog-react-native/src/surveys/components/SurveyModal.js.map +1 -0
  115. package/lib/posthog-react-native/src/surveys/components/Surveys.d.ts +14 -14
  116. package/lib/posthog-react-native/src/surveys/components/Surveys.js +1 -0
  117. package/lib/posthog-react-native/src/surveys/components/Surveys.js.map +1 -0
  118. package/lib/posthog-react-native/src/surveys/getActiveMatchingSurveys.d.ts +2 -2
  119. package/lib/posthog-react-native/src/surveys/getActiveMatchingSurveys.js +1 -0
  120. package/lib/posthog-react-native/src/surveys/getActiveMatchingSurveys.js.map +1 -0
  121. package/lib/posthog-react-native/src/surveys/icons.d.ts +8 -10
  122. package/lib/posthog-react-native/src/surveys/icons.js +1 -0
  123. package/lib/posthog-react-native/src/surveys/icons.js.map +1 -0
  124. package/lib/posthog-react-native/src/surveys/index.d.ts +6 -6
  125. package/lib/posthog-react-native/src/surveys/index.js +1 -0
  126. package/lib/posthog-react-native/src/surveys/index.js.map +1 -0
  127. package/lib/posthog-react-native/src/surveys/surveys-utils.d.ts +13 -13
  128. package/lib/posthog-react-native/src/surveys/surveys-utils.js +1 -0
  129. package/lib/posthog-react-native/src/surveys/surveys-utils.js.map +1 -0
  130. package/lib/posthog-react-native/src/surveys/useActivatedSurveys.d.ts +3 -3
  131. package/lib/posthog-react-native/src/surveys/useActivatedSurveys.js +1 -0
  132. package/lib/posthog-react-native/src/surveys/useActivatedSurveys.js.map +1 -0
  133. package/lib/posthog-react-native/src/surveys/useSurveyStorage.d.ts +8 -8
  134. package/lib/posthog-react-native/src/surveys/useSurveyStorage.js +1 -0
  135. package/lib/posthog-react-native/src/surveys/useSurveyStorage.js.map +1 -0
  136. package/lib/posthog-react-native/src/types.d.ts +112 -112
  137. package/lib/posthog-react-native/src/types.js +1 -0
  138. package/lib/posthog-react-native/src/types.js.map +1 -0
  139. package/lib/posthog-react-native/src/version.d.ts +1 -1
  140. package/lib/posthog-react-native/src/version.js +1 -0
  141. package/lib/posthog-react-native/src/version.js.map +1 -0
  142. package/lib/posthog-react-native/tsconfig.tsbuildinfo +1 -0
  143. package/package.json +8 -9
  144. package/lib/index.cjs.js +0 -4677
  145. package/lib/index.cjs.js.map +0 -1
  146. package/lib/index.d.ts +0 -875
  147. package/lib/index.esm.js +0 -4659
  148. package/lib/index.esm.js.map +0 -1
  149. package/lib/posthog-react-native/test/test-utils.d.ts +0 -2
@@ -1,423 +1,422 @@
1
- /// <reference types="react-native" />
2
- export type PostHogCoreOptions = {
3
- /** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
4
- host?: string;
5
- /** The number of events to queue before sending to PostHog (flushing) */
6
- flushAt?: number;
7
- /** The interval in milliseconds between periodic flushes */
8
- flushInterval?: number;
9
- /** The maximum number of queued messages to be flushed as part of a single batch (must be higher than `flushAt`) */
10
- maxBatchSize?: number;
11
- /** The maximum number of cached messages either in memory or on the local storage.
12
- * Defaults to 1000, (must be higher than `flushAt`)
13
- */
14
- maxQueueSize?: number;
15
- /** If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) */
16
- disabled?: boolean;
17
- /** If set to false the SDK will not track until the `optIn` function is called. */
18
- defaultOptIn?: boolean;
19
- /** Whether to track that `getFeatureFlag` was called (used by Experiments) */
20
- sendFeatureFlagEvent?: boolean;
21
- /** Whether to load feature flags when initialized or not */
22
- preloadFeatureFlags?: boolean;
23
- /**
24
- * Whether to load remote config when initialized or not
25
- * Experimental support
26
- * Default: false - Remote config is loaded by default
27
- */
28
- disableRemoteConfig?: boolean;
29
- /**
30
- * Whether to load surveys when initialized or not
31
- * Experimental support
32
- * Default: false - Surveys are loaded by default, but requires the `PostHogSurveyProvider` to be used
33
- */
34
- disableSurveys?: boolean;
35
- /** Option to bootstrap the library with given distinctId and feature flags */
36
- bootstrap?: {
37
- distinctId?: string;
38
- isIdentifiedId?: boolean;
39
- featureFlags?: Record<string, FeatureFlagValue>;
40
- featureFlagPayloads?: Record<string, JsonType>;
41
- };
42
- /** How many times we will retry HTTP requests. Defaults to 3. */
43
- fetchRetryCount?: number;
44
- /** The delay between HTTP request retries, Defaults to 3 seconds. */
45
- fetchRetryDelay?: number;
46
- /** Timeout in milliseconds for any calls. Defaults to 10 seconds. */
47
- requestTimeout?: number;
48
- /** Timeout in milliseconds for feature flag calls. Defaults to 10 seconds for stateful clients, and 3 seconds for stateless. */
49
- featureFlagsRequestTimeoutMs?: number;
50
- /** Timeout in milliseconds for remote config calls. Defaults to 3 seconds. */
51
- remoteConfigRequestTimeoutMs?: number;
52
- /** For Session Analysis how long before we expire a session (defaults to 30 mins) */
53
- sessionExpirationTimeSeconds?: number;
54
- /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
55
- captureMode?: 'json' | 'form';
56
- disableGeoip?: boolean;
57
- /** Special flag to indicate ingested data is for a historical migration. */
58
- historicalMigration?: boolean;
59
- };
60
- export declare enum PostHogPersistedProperty {
61
- AnonymousId = "anonymous_id",
62
- DistinctId = "distinct_id",
63
- Props = "props",
64
- FeatureFlagDetails = "feature_flag_details",
65
- FeatureFlags = "feature_flags",
66
- FeatureFlagPayloads = "feature_flag_payloads",
67
- BootstrapFeatureFlagDetails = "bootstrap_feature_flag_details",
68
- BootstrapFeatureFlags = "bootstrap_feature_flags",
69
- BootstrapFeatureFlagPayloads = "bootstrap_feature_flag_payloads",
70
- OverrideFeatureFlags = "override_feature_flags",
71
- Queue = "queue",
72
- OptedOut = "opted_out",
73
- SessionId = "session_id",
74
- SessionLastTimestamp = "session_timestamp",
75
- PersonProperties = "person_properties",
76
- GroupProperties = "group_properties",
77
- InstalledAppBuild = "installed_app_build",
78
- InstalledAppVersion = "installed_app_version",
79
- SessionReplay = "session_replay",
80
- DecideEndpointWasHit = "decide_endpoint_was_hit",
81
- SurveyLastSeenDate = "survey_last_seen_date",
82
- SurveysSeen = "surveys_seen",
83
- Surveys = "surveys",
84
- RemoteConfig = "remote_config"
85
- }
86
- export type PostHogFetchOptions = {
87
- method: 'GET' | 'POST' | 'PUT' | 'PATCH';
88
- mode?: 'no-cors';
89
- credentials?: 'omit';
90
- headers: {
91
- [key: string]: string;
92
- };
93
- body?: string;
94
- signal?: AbortSignal;
95
- };
96
- export type PostHogCaptureOptions = {
97
- /** If provided overrides the auto-generated event ID */
98
- uuid?: string;
99
- /** If provided overrides the auto-generated timestamp */
100
- timestamp?: Date;
101
- disableGeoip?: boolean;
102
- };
103
- export type PostHogFetchResponse = {
104
- status: number;
105
- text: () => Promise<string>;
106
- json: () => Promise<any>;
107
- };
108
- export type PostHogQueueItem = {
109
- message: any;
110
- callback?: (err: any) => void;
111
- };
112
- export type PostHogEventProperties = {
113
- [key: string]: any;
114
- };
115
- export type PostHogAutocaptureElement = {
116
- $el_text?: string;
117
- tag_name: string;
118
- href?: string;
119
- nth_child?: number;
120
- nth_of_type?: number;
121
- order?: number;
122
- } & {
123
- [key: string]: any;
124
- };
125
- export type PostHogRemoteConfig = {
126
- sessionRecording?: boolean | {
127
- [key: string]: JsonType;
128
- };
129
- /**
130
- * Whether surveys are enabled
131
- */
132
- surveys?: boolean | Survey[];
133
- /**
134
- * Indicates if the team has any flags enabled (if not we don't need to load them)
135
- */
136
- hasFeatureFlags?: boolean;
137
- };
138
- export type FeatureFlagValue = string | boolean;
139
- export type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
140
- featureFlags: {
141
- [key: string]: FeatureFlagValue;
142
- };
143
- featureFlagPayloads: {
144
- [key: string]: JsonType;
145
- };
146
- flags: {
147
- [key: string]: FeatureFlagDetail;
148
- };
149
- errorsWhileComputingFlags: boolean;
150
- sessionRecording?: boolean | {
151
- [key: string]: JsonType;
152
- };
153
- quotaLimited?: string[];
154
- requestId?: string;
155
- };
156
- export type PostHogFeatureFlagsResponse = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
157
- /**
158
- * Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
159
- *
160
- * @template T - The base type containing all properties
161
- * @template K - Union type of keys from T that should be required
162
- *
163
- * @example
164
- * interface User {
165
- * id: number;
166
- * name: string;
167
- * email?: string;
168
- * age?: number;
169
- * }
170
- *
171
- * // Makes 'id' and 'name' required, but 'email' and 'age' optional
172
- * type RequiredUser = PartialWithRequired<User, 'id' | 'name'>;
173
- *
174
- * const user: RequiredUser = {
175
- * id: 1, // Must be provided
176
- * name: "John" // Must be provided
177
- * // email and age are optional
178
- * };
179
- */
180
- export type PartialWithRequired<T, K extends keyof T> = {
181
- [P in K]: T[P];
182
- } & {
183
- [P in Exclude<keyof T, K>]?: T[P];
184
- };
185
- /**
186
- * These are the fields we care about from PostHogDecideResponse for feature flags.
187
- */
188
- export type PostHogFeatureFlagDetails = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
189
- /**
190
- * Models the response from the v3 `/decide` endpoint.
191
- */
192
- export type PostHogV3DecideResponse = Omit<PostHogDecideResponse, 'flags'>;
193
- export type PostHogV4DecideResponse = Omit<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>;
194
- /**
195
- * The format of the flags object in persisted storage
196
- *
197
- * When we pull flags from persistence, we can normalize them to PostHogFeatureFlagDetails
198
- * so that we can support v3 and v4 of the API.
199
- */
200
- export type PostHogFlagsStorageFormat = Pick<PostHogFeatureFlagDetails, 'flags'>;
201
- /**
202
- * Models legacy flags and payloads return type for many public methods.
203
- */
204
- export type PostHogFlagsAndPayloadsResponse = Partial<Pick<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>>;
205
- export type JsonType = string | number | boolean | null | {
206
- [key: string]: JsonType;
207
- } | Array<JsonType>;
208
- export type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
209
- export type FeatureFlagDetail = {
210
- key: string;
211
- enabled: boolean;
212
- variant: string | undefined;
213
- reason: EvaluationReason | undefined;
214
- metadata: FeatureFlagMetadata | undefined;
215
- };
216
- export type FeatureFlagMetadata = {
217
- id: number | undefined;
218
- version: number | undefined;
219
- description: string | undefined;
220
- payload: string | undefined;
221
- };
222
- export type EvaluationReason = {
223
- code: string | undefined;
224
- condition_index: number | undefined;
225
- description: string | undefined;
226
- };
227
- export type SurveyAppearance = {
228
- backgroundColor?: string;
229
- submitButtonColor?: string;
230
- submitButtonText?: string;
231
- submitButtonTextColor?: string;
232
- ratingButtonColor?: string;
233
- ratingButtonActiveColor?: string;
234
- autoDisappear?: boolean;
235
- displayThankYouMessage?: boolean;
236
- thankYouMessageHeader?: string;
237
- thankYouMessageDescription?: string;
238
- thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
239
- thankYouMessageCloseButtonText?: string;
240
- borderColor?: string;
241
- position?: SurveyPosition;
242
- placeholder?: string;
243
- shuffleQuestions?: boolean;
244
- surveyPopupDelaySeconds?: number;
245
- widgetType?: SurveyWidgetType;
246
- widgetSelector?: string;
247
- widgetLabel?: string;
248
- widgetColor?: string;
249
- };
250
- export declare enum SurveyPosition {
251
- Left = "left",
252
- Right = "right",
253
- Center = "center"
254
- }
255
- export declare enum SurveyWidgetType {
256
- Button = "button",
257
- Tab = "tab",
258
- Selector = "selector"
259
- }
260
- export declare enum SurveyType {
261
- Popover = "popover",
262
- API = "api",
263
- Widget = "widget"
264
- }
265
- export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
266
- export declare enum SurveyQuestionDescriptionContentType {
267
- Html = "html",
268
- Text = "text"
269
- }
270
- type SurveyQuestionBase = {
271
- question: string;
272
- id?: string;
273
- description?: string;
274
- descriptionContentType?: SurveyQuestionDescriptionContentType;
275
- optional?: boolean;
276
- buttonText?: string;
277
- originalQuestionIndex: number;
278
- branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
279
- };
280
- export type BasicSurveyQuestion = SurveyQuestionBase & {
281
- type: SurveyQuestionType.Open;
282
- };
283
- export type LinkSurveyQuestion = SurveyQuestionBase & {
284
- type: SurveyQuestionType.Link;
285
- link?: string;
286
- };
287
- export type RatingSurveyQuestion = SurveyQuestionBase & {
288
- type: SurveyQuestionType.Rating;
289
- display: SurveyRatingDisplay;
290
- scale: 3 | 5 | 7 | 10;
291
- lowerBoundLabel: string;
292
- upperBoundLabel: string;
293
- };
294
- export declare enum SurveyRatingDisplay {
295
- Number = "number",
296
- Emoji = "emoji"
297
- }
298
- export type MultipleSurveyQuestion = SurveyQuestionBase & {
299
- type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
300
- choices: string[];
301
- hasOpenChoice?: boolean;
302
- shuffleOptions?: boolean;
303
- };
304
- export declare enum SurveyQuestionType {
305
- Open = "open",
306
- MultipleChoice = "multiple_choice",
307
- SingleChoice = "single_choice",
308
- Rating = "rating",
309
- Link = "link"
310
- }
311
- export declare enum SurveyQuestionBranchingType {
312
- NextQuestion = "next_question",
313
- End = "end",
314
- ResponseBased = "response_based",
315
- SpecificQuestion = "specific_question"
316
- }
317
- export type NextQuestionBranching = {
318
- type: SurveyQuestionBranchingType.NextQuestion;
319
- };
320
- export type EndBranching = {
321
- type: SurveyQuestionBranchingType.End;
322
- };
323
- export type ResponseBasedBranching = {
324
- type: SurveyQuestionBranchingType.ResponseBased;
325
- responseValues: Record<string, any>;
326
- };
327
- export type SpecificQuestionBranching = {
328
- type: SurveyQuestionBranchingType.SpecificQuestion;
329
- index: number;
330
- };
331
- export type SurveyResponse = {
332
- surveys: Survey[];
333
- };
334
- export type SurveyCallback = (surveys: Survey[]) => void;
335
- export declare enum SurveyMatchType {
336
- Regex = "regex",
337
- NotRegex = "not_regex",
338
- Exact = "exact",
339
- IsNot = "is_not",
340
- Icontains = "icontains",
341
- NotIcontains = "not_icontains"
342
- }
343
- export type SurveyElement = {
344
- text?: string;
345
- $el_text?: string;
346
- tag_name?: string;
347
- href?: string;
348
- attr_id?: string;
349
- attr_class?: string[];
350
- nth_child?: number;
351
- nth_of_type?: number;
352
- attributes?: Record<string, any>;
353
- event_id?: number;
354
- order?: number;
355
- group_id?: number;
356
- };
357
- export type SurveyRenderReason = {
358
- visible: boolean;
359
- disabledReason?: string;
360
- };
361
- export type Survey = {
362
- id: string;
363
- name: string;
364
- description?: string;
365
- type: SurveyType;
366
- feature_flag_keys?: {
367
- key: string;
368
- value?: string;
369
- }[];
370
- linked_flag_key?: string;
371
- targeting_flag_key?: string;
372
- internal_targeting_flag_key?: string;
373
- questions: SurveyQuestion[];
374
- appearance?: SurveyAppearance;
375
- conditions?: {
376
- url?: string;
377
- selector?: string;
378
- seenSurveyWaitPeriodInDays?: number;
379
- urlMatchType?: SurveyMatchType;
380
- events?: {
381
- repeatedActivation?: boolean;
382
- values?: {
383
- name: string;
384
- }[];
385
- };
386
- actions?: {
387
- values: SurveyActionType[];
388
- };
389
- deviceTypes?: string[];
390
- deviceTypesMatchType?: SurveyMatchType;
391
- };
392
- start_date?: string;
393
- end_date?: string;
394
- current_iteration?: number;
395
- current_iteration_start_date?: string;
396
- };
397
- export type SurveyActionType = {
398
- id: number;
399
- name?: string;
400
- steps?: ActionStepType[];
401
- };
402
- /** Sync with plugin-server/src/types.ts */
403
- export declare enum ActionStepStringMatching {
404
- Contains = "contains",
405
- Exact = "exact",
406
- Regex = "regex"
407
- }
408
- export type ActionStepType = {
409
- event?: string;
410
- selector?: string;
411
- /** @deprecated Only `selector` should be used now. */
412
- tag_name?: string;
413
- text?: string;
414
- /** @default StringMatching.Exact */
415
- text_matching?: ActionStepStringMatching;
416
- href?: string;
417
- /** @default ActionStepStringMatching.Exact */
418
- href_matching?: ActionStepStringMatching;
419
- url?: string;
420
- /** @default StringMatching.Contains */
421
- url_matching?: ActionStepStringMatching;
422
- };
423
- export {};
1
+ export type PostHogCoreOptions = {
2
+ /** PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' */
3
+ host?: string;
4
+ /** The number of events to queue before sending to PostHog (flushing) */
5
+ flushAt?: number;
6
+ /** The interval in milliseconds between periodic flushes */
7
+ flushInterval?: number;
8
+ /** The maximum number of queued messages to be flushed as part of a single batch (must be higher than `flushAt`) */
9
+ maxBatchSize?: number;
10
+ /** The maximum number of cached messages either in memory or on the local storage.
11
+ * Defaults to 1000, (must be higher than `flushAt`)
12
+ */
13
+ maxQueueSize?: number;
14
+ /** If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) */
15
+ disabled?: boolean;
16
+ /** If set to false the SDK will not track until the `optIn` function is called. */
17
+ defaultOptIn?: boolean;
18
+ /** Whether to track that `getFeatureFlag` was called (used by Experiments) */
19
+ sendFeatureFlagEvent?: boolean;
20
+ /** Whether to load feature flags when initialized or not */
21
+ preloadFeatureFlags?: boolean;
22
+ /**
23
+ * Whether to load remote config when initialized or not
24
+ * Experimental support
25
+ * Default: false - Remote config is loaded by default
26
+ */
27
+ disableRemoteConfig?: boolean;
28
+ /**
29
+ * Whether to load surveys when initialized or not
30
+ * Experimental support
31
+ * Default: false - Surveys are loaded by default, but requires the `PostHogSurveyProvider` to be used
32
+ */
33
+ disableSurveys?: boolean;
34
+ /** Option to bootstrap the library with given distinctId and feature flags */
35
+ bootstrap?: {
36
+ distinctId?: string;
37
+ isIdentifiedId?: boolean;
38
+ featureFlags?: Record<string, FeatureFlagValue>;
39
+ featureFlagPayloads?: Record<string, JsonType>;
40
+ };
41
+ /** How many times we will retry HTTP requests. Defaults to 3. */
42
+ fetchRetryCount?: number;
43
+ /** The delay between HTTP request retries, Defaults to 3 seconds. */
44
+ fetchRetryDelay?: number;
45
+ /** Timeout in milliseconds for any calls. Defaults to 10 seconds. */
46
+ requestTimeout?: number;
47
+ /** Timeout in milliseconds for feature flag calls. Defaults to 10 seconds for stateful clients, and 3 seconds for stateless. */
48
+ featureFlagsRequestTimeoutMs?: number;
49
+ /** Timeout in milliseconds for remote config calls. Defaults to 3 seconds. */
50
+ remoteConfigRequestTimeoutMs?: number;
51
+ /** For Session Analysis how long before we expire a session (defaults to 30 mins) */
52
+ sessionExpirationTimeSeconds?: number;
53
+ /** Whether to post events to PostHog in JSON or compressed format. Defaults to 'json' */
54
+ captureMode?: 'json' | 'form';
55
+ disableGeoip?: boolean;
56
+ /** Special flag to indicate ingested data is for a historical migration. */
57
+ historicalMigration?: boolean;
58
+ };
59
+ export declare enum PostHogPersistedProperty {
60
+ AnonymousId = "anonymous_id",
61
+ DistinctId = "distinct_id",
62
+ Props = "props",
63
+ FeatureFlagDetails = "feature_flag_details",
64
+ FeatureFlags = "feature_flags",
65
+ FeatureFlagPayloads = "feature_flag_payloads",
66
+ BootstrapFeatureFlagDetails = "bootstrap_feature_flag_details",
67
+ BootstrapFeatureFlags = "bootstrap_feature_flags",
68
+ BootstrapFeatureFlagPayloads = "bootstrap_feature_flag_payloads",
69
+ OverrideFeatureFlags = "override_feature_flags",
70
+ Queue = "queue",
71
+ OptedOut = "opted_out",
72
+ SessionId = "session_id",
73
+ SessionLastTimestamp = "session_timestamp",
74
+ PersonProperties = "person_properties",
75
+ GroupProperties = "group_properties",
76
+ InstalledAppBuild = "installed_app_build",
77
+ InstalledAppVersion = "installed_app_version",
78
+ SessionReplay = "session_replay",
79
+ DecideEndpointWasHit = "decide_endpoint_was_hit",
80
+ SurveyLastSeenDate = "survey_last_seen_date",
81
+ SurveysSeen = "surveys_seen",
82
+ Surveys = "surveys",
83
+ RemoteConfig = "remote_config"
84
+ }
85
+ export type PostHogFetchOptions = {
86
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH';
87
+ mode?: 'no-cors';
88
+ credentials?: 'omit';
89
+ headers: {
90
+ [key: string]: string;
91
+ };
92
+ body?: string;
93
+ signal?: AbortSignal;
94
+ };
95
+ export type PostHogCaptureOptions = {
96
+ /** If provided overrides the auto-generated event ID */
97
+ uuid?: string;
98
+ /** If provided overrides the auto-generated timestamp */
99
+ timestamp?: Date;
100
+ disableGeoip?: boolean;
101
+ };
102
+ export type PostHogFetchResponse = {
103
+ status: number;
104
+ text: () => Promise<string>;
105
+ json: () => Promise<any>;
106
+ };
107
+ export type PostHogQueueItem = {
108
+ message: any;
109
+ callback?: (err: any) => void;
110
+ };
111
+ export type PostHogEventProperties = {
112
+ [key: string]: any;
113
+ };
114
+ export type PostHogAutocaptureElement = {
115
+ $el_text?: string;
116
+ tag_name: string;
117
+ href?: string;
118
+ nth_child?: number;
119
+ nth_of_type?: number;
120
+ order?: number;
121
+ } & {
122
+ [key: string]: any;
123
+ };
124
+ export type PostHogRemoteConfig = {
125
+ sessionRecording?: boolean | {
126
+ [key: string]: JsonType;
127
+ };
128
+ /**
129
+ * Whether surveys are enabled
130
+ */
131
+ surveys?: boolean | Survey[];
132
+ /**
133
+ * Indicates if the team has any flags enabled (if not we don't need to load them)
134
+ */
135
+ hasFeatureFlags?: boolean;
136
+ };
137
+ export type FeatureFlagValue = string | boolean;
138
+ export type PostHogDecideResponse = Omit<PostHogRemoteConfig, 'surveys' | 'hasFeatureFlags'> & {
139
+ featureFlags: {
140
+ [key: string]: FeatureFlagValue;
141
+ };
142
+ featureFlagPayloads: {
143
+ [key: string]: JsonType;
144
+ };
145
+ flags: {
146
+ [key: string]: FeatureFlagDetail;
147
+ };
148
+ errorsWhileComputingFlags: boolean;
149
+ sessionRecording?: boolean | {
150
+ [key: string]: JsonType;
151
+ };
152
+ quotaLimited?: string[];
153
+ requestId?: string;
154
+ };
155
+ export type PostHogFeatureFlagsResponse = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
156
+ /**
157
+ * Creates a type with all properties of T, but makes only K properties required while the rest remain optional.
158
+ *
159
+ * @template T - The base type containing all properties
160
+ * @template K - Union type of keys from T that should be required
161
+ *
162
+ * @example
163
+ * interface User {
164
+ * id: number;
165
+ * name: string;
166
+ * email?: string;
167
+ * age?: number;
168
+ * }
169
+ *
170
+ * // Makes 'id' and 'name' required, but 'email' and 'age' optional
171
+ * type RequiredUser = PartialWithRequired<User, 'id' | 'name'>;
172
+ *
173
+ * const user: RequiredUser = {
174
+ * id: 1, // Must be provided
175
+ * name: "John" // Must be provided
176
+ * // email and age are optional
177
+ * };
178
+ */
179
+ export type PartialWithRequired<T, K extends keyof T> = {
180
+ [P in K]: T[P];
181
+ } & {
182
+ [P in Exclude<keyof T, K>]?: T[P];
183
+ };
184
+ /**
185
+ * These are the fields we care about from PostHogDecideResponse for feature flags.
186
+ */
187
+ export type PostHogFeatureFlagDetails = PartialWithRequired<PostHogDecideResponse, 'flags' | 'featureFlags' | 'featureFlagPayloads' | 'requestId'>;
188
+ /**
189
+ * Models the response from the v3 `/decide` endpoint.
190
+ */
191
+ export type PostHogV3DecideResponse = Omit<PostHogDecideResponse, 'flags'>;
192
+ export type PostHogV4DecideResponse = Omit<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>;
193
+ /**
194
+ * The format of the flags object in persisted storage
195
+ *
196
+ * When we pull flags from persistence, we can normalize them to PostHogFeatureFlagDetails
197
+ * so that we can support v3 and v4 of the API.
198
+ */
199
+ export type PostHogFlagsStorageFormat = Pick<PostHogFeatureFlagDetails, 'flags'>;
200
+ /**
201
+ * Models legacy flags and payloads return type for many public methods.
202
+ */
203
+ export type PostHogFlagsAndPayloadsResponse = Partial<Pick<PostHogDecideResponse, 'featureFlags' | 'featureFlagPayloads'>>;
204
+ export type JsonType = string | number | boolean | null | {
205
+ [key: string]: JsonType;
206
+ } | Array<JsonType>;
207
+ export type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
208
+ export type FeatureFlagDetail = {
209
+ key: string;
210
+ enabled: boolean;
211
+ variant: string | undefined;
212
+ reason: EvaluationReason | undefined;
213
+ metadata: FeatureFlagMetadata | undefined;
214
+ };
215
+ export type FeatureFlagMetadata = {
216
+ id: number | undefined;
217
+ version: number | undefined;
218
+ description: string | undefined;
219
+ payload: string | undefined;
220
+ };
221
+ export type EvaluationReason = {
222
+ code: string | undefined;
223
+ condition_index: number | undefined;
224
+ description: string | undefined;
225
+ };
226
+ export type SurveyAppearance = {
227
+ backgroundColor?: string;
228
+ submitButtonColor?: string;
229
+ submitButtonText?: string;
230
+ submitButtonTextColor?: string;
231
+ ratingButtonColor?: string;
232
+ ratingButtonActiveColor?: string;
233
+ autoDisappear?: boolean;
234
+ displayThankYouMessage?: boolean;
235
+ thankYouMessageHeader?: string;
236
+ thankYouMessageDescription?: string;
237
+ thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType;
238
+ thankYouMessageCloseButtonText?: string;
239
+ borderColor?: string;
240
+ position?: SurveyPosition;
241
+ placeholder?: string;
242
+ shuffleQuestions?: boolean;
243
+ surveyPopupDelaySeconds?: number;
244
+ widgetType?: SurveyWidgetType;
245
+ widgetSelector?: string;
246
+ widgetLabel?: string;
247
+ widgetColor?: string;
248
+ };
249
+ export declare enum SurveyPosition {
250
+ Left = "left",
251
+ Right = "right",
252
+ Center = "center"
253
+ }
254
+ export declare enum SurveyWidgetType {
255
+ Button = "button",
256
+ Tab = "tab",
257
+ Selector = "selector"
258
+ }
259
+ export declare enum SurveyType {
260
+ Popover = "popover",
261
+ API = "api",
262
+ Widget = "widget"
263
+ }
264
+ export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion;
265
+ export declare enum SurveyQuestionDescriptionContentType {
266
+ Html = "html",
267
+ Text = "text"
268
+ }
269
+ type SurveyQuestionBase = {
270
+ question: string;
271
+ id?: string;
272
+ description?: string;
273
+ descriptionContentType?: SurveyQuestionDescriptionContentType;
274
+ optional?: boolean;
275
+ buttonText?: string;
276
+ originalQuestionIndex: number;
277
+ branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching;
278
+ };
279
+ export type BasicSurveyQuestion = SurveyQuestionBase & {
280
+ type: SurveyQuestionType.Open;
281
+ };
282
+ export type LinkSurveyQuestion = SurveyQuestionBase & {
283
+ type: SurveyQuestionType.Link;
284
+ link?: string;
285
+ };
286
+ export type RatingSurveyQuestion = SurveyQuestionBase & {
287
+ type: SurveyQuestionType.Rating;
288
+ display: SurveyRatingDisplay;
289
+ scale: 3 | 5 | 7 | 10;
290
+ lowerBoundLabel: string;
291
+ upperBoundLabel: string;
292
+ };
293
+ export declare enum SurveyRatingDisplay {
294
+ Number = "number",
295
+ Emoji = "emoji"
296
+ }
297
+ export type MultipleSurveyQuestion = SurveyQuestionBase & {
298
+ type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice;
299
+ choices: string[];
300
+ hasOpenChoice?: boolean;
301
+ shuffleOptions?: boolean;
302
+ };
303
+ export declare enum SurveyQuestionType {
304
+ Open = "open",
305
+ MultipleChoice = "multiple_choice",
306
+ SingleChoice = "single_choice",
307
+ Rating = "rating",
308
+ Link = "link"
309
+ }
310
+ export declare enum SurveyQuestionBranchingType {
311
+ NextQuestion = "next_question",
312
+ End = "end",
313
+ ResponseBased = "response_based",
314
+ SpecificQuestion = "specific_question"
315
+ }
316
+ export type NextQuestionBranching = {
317
+ type: SurveyQuestionBranchingType.NextQuestion;
318
+ };
319
+ export type EndBranching = {
320
+ type: SurveyQuestionBranchingType.End;
321
+ };
322
+ export type ResponseBasedBranching = {
323
+ type: SurveyQuestionBranchingType.ResponseBased;
324
+ responseValues: Record<string, any>;
325
+ };
326
+ export type SpecificQuestionBranching = {
327
+ type: SurveyQuestionBranchingType.SpecificQuestion;
328
+ index: number;
329
+ };
330
+ export type SurveyResponse = {
331
+ surveys: Survey[];
332
+ };
333
+ export type SurveyCallback = (surveys: Survey[]) => void;
334
+ export declare enum SurveyMatchType {
335
+ Regex = "regex",
336
+ NotRegex = "not_regex",
337
+ Exact = "exact",
338
+ IsNot = "is_not",
339
+ Icontains = "icontains",
340
+ NotIcontains = "not_icontains"
341
+ }
342
+ export type SurveyElement = {
343
+ text?: string;
344
+ $el_text?: string;
345
+ tag_name?: string;
346
+ href?: string;
347
+ attr_id?: string;
348
+ attr_class?: string[];
349
+ nth_child?: number;
350
+ nth_of_type?: number;
351
+ attributes?: Record<string, any>;
352
+ event_id?: number;
353
+ order?: number;
354
+ group_id?: number;
355
+ };
356
+ export type SurveyRenderReason = {
357
+ visible: boolean;
358
+ disabledReason?: string;
359
+ };
360
+ export type Survey = {
361
+ id: string;
362
+ name: string;
363
+ description?: string;
364
+ type: SurveyType;
365
+ feature_flag_keys?: {
366
+ key: string;
367
+ value?: string;
368
+ }[];
369
+ linked_flag_key?: string;
370
+ targeting_flag_key?: string;
371
+ internal_targeting_flag_key?: string;
372
+ questions: SurveyQuestion[];
373
+ appearance?: SurveyAppearance;
374
+ conditions?: {
375
+ url?: string;
376
+ selector?: string;
377
+ seenSurveyWaitPeriodInDays?: number;
378
+ urlMatchType?: SurveyMatchType;
379
+ events?: {
380
+ repeatedActivation?: boolean;
381
+ values?: {
382
+ name: string;
383
+ }[];
384
+ };
385
+ actions?: {
386
+ values: SurveyActionType[];
387
+ };
388
+ deviceTypes?: string[];
389
+ deviceTypesMatchType?: SurveyMatchType;
390
+ };
391
+ start_date?: string;
392
+ end_date?: string;
393
+ current_iteration?: number;
394
+ current_iteration_start_date?: string;
395
+ };
396
+ export type SurveyActionType = {
397
+ id: number;
398
+ name?: string;
399
+ steps?: ActionStepType[];
400
+ };
401
+ /** Sync with plugin-server/src/types.ts */
402
+ export declare enum ActionStepStringMatching {
403
+ Contains = "contains",
404
+ Exact = "exact",
405
+ Regex = "regex"
406
+ }
407
+ export type ActionStepType = {
408
+ event?: string;
409
+ selector?: string;
410
+ /** @deprecated Only `selector` should be used now. */
411
+ tag_name?: string;
412
+ text?: string;
413
+ /** @default StringMatching.Exact */
414
+ text_matching?: ActionStepStringMatching;
415
+ href?: string;
416
+ /** @default ActionStepStringMatching.Exact */
417
+ href_matching?: ActionStepStringMatching;
418
+ url?: string;
419
+ /** @default StringMatching.Contains */
420
+ url_matching?: ActionStepStringMatching;
421
+ };
422
+ export {};