posthog-node 3.6.3 → 4.0.0-beta.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.
@@ -0,0 +1,64 @@
1
+ export const apiImplementation = ({
2
+ localFlags,
3
+ decideFlags,
4
+ decideFlagPayloads,
5
+ decideStatus = 200,
6
+ }: {
7
+ localFlags?: any
8
+ decideFlags?: any
9
+ decideFlagPayloads?: any
10
+ decideStatus?: number
11
+ }) => {
12
+ return (url: any): Promise<any> => {
13
+ if ((url as any).includes('/decide/')) {
14
+ return Promise.resolve({
15
+ status: decideStatus,
16
+ text: () => Promise.resolve('ok'),
17
+ json: () => {
18
+ if (decideStatus !== 200) {
19
+ return Promise.resolve(decideFlags)
20
+ } else {
21
+ return Promise.resolve({
22
+ featureFlags: decideFlags,
23
+ featureFlagPayloads: decideFlagPayloads,
24
+ })
25
+ }
26
+ },
27
+ }) as any
28
+ }
29
+
30
+ if ((url as any).includes('api/feature_flag/local_evaluation?token=TEST_API_KEY&send_cohorts')) {
31
+ return Promise.resolve({
32
+ status: 200,
33
+ text: () => Promise.resolve('ok'),
34
+ json: () => Promise.resolve(localFlags),
35
+ }) as any
36
+ }
37
+
38
+ if ((url as any).includes('batch/')) {
39
+ return Promise.resolve({
40
+ status: 200,
41
+ text: () => Promise.resolve('ok'),
42
+ json: () =>
43
+ Promise.resolve({
44
+ status: 'ok',
45
+ }),
46
+ }) as any
47
+ }
48
+
49
+ return Promise.resolve({
50
+ status: 400,
51
+ text: () => Promise.resolve('ok'),
52
+ json: () =>
53
+ Promise.resolve({
54
+ status: 'ok',
55
+ }),
56
+ }) as any
57
+ }
58
+ }
59
+
60
+ export const anyLocalEvalCall = [
61
+ 'http://example.com/api/feature_flag/local_evaluation?token=TEST_API_KEY&send_cohorts',
62
+ expect.any(Object),
63
+ ]
64
+ export const anyDecideCall = ['http://example.com/decide/?v=3', expect.any(Object)]