@baukit/analytics-posthog-native 0.1.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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +214 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Patrick Koss
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# `@baukit/analytics-posthog-native`
|
|
2
|
+
|
|
3
|
+
PostHog React Native transport for `@baukit/analytics-core`. It translates only envelopes that
|
|
4
|
+
have already passed the core's consent gate, event allowlist, and scrubber.
|
|
5
|
+
|
|
6
|
+
## Self-hosted setup
|
|
7
|
+
|
|
8
|
+
Install the core and React Native SDK alongside the adapter:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add @baukit/analytics-core @baukit/analytics-posthog-native posthog-react-native
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Use the configured factory with an explicit self-hosted URL. There is deliberately no PostHog
|
|
15
|
+
Cloud default:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { AnalyticsClient } from '@baukit/analytics-core';
|
|
19
|
+
import { createPostHogNativeTransport } from '@baukit/analytics-posthog-native';
|
|
20
|
+
|
|
21
|
+
const transport = createPostHogNativeTransport({
|
|
22
|
+
apiKey: 'phc_project_key',
|
|
23
|
+
apiHost: 'https://posthog.analytics.example.com',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const analytics = new AnalyticsClient({
|
|
27
|
+
context,
|
|
28
|
+
allowlist,
|
|
29
|
+
transport,
|
|
30
|
+
uuidFactory: secureReactNativeUuidFactory,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
SDK initialization is lazy: `posthog-react-native` is loaded and constructed only when the core
|
|
35
|
+
sends its first consent-approved batch. Its initial distinct ID is bootstrapped from the core
|
|
36
|
+
envelope. App lifecycle capture, push capture, default person properties, error autocapture,
|
|
37
|
+
session replay, surveys, and feature-flag preloading are disabled. Person profiles are limited to
|
|
38
|
+
identified users.
|
|
39
|
+
|
|
40
|
+
An application that already owns a configured client can wrap it instead:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { PostHogNativeTransport } from '@baukit/analytics-posthog-native';
|
|
44
|
+
|
|
45
|
+
const transport = new PostHogNativeTransport(posthog);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
When wrapping an instance, the application remains responsible for initializing it only after
|
|
49
|
+
consent and applying equivalent privacy settings.
|
|
50
|
+
|
|
51
|
+
The adapter exports a minimal structural `PostHogNativeClient` interface for mocks and wrappers,
|
|
52
|
+
while its initializer options compile against `posthog-react-native`'s published types. This keeps
|
|
53
|
+
unit tests runnable without installing or booting a React Native runtime.
|
|
54
|
+
|
|
55
|
+
## Mapping
|
|
56
|
+
|
|
57
|
+
- `capture` flattens the core-stamped context and already-scrubbed event properties, preserving the
|
|
58
|
+
core capture time as the PostHog timestamp.
|
|
59
|
+
- `identify` passes the internal user UUID and the core's already-scrubbed traits. Those traits are
|
|
60
|
+
the only values used for PostHog person-property `$set` behavior.
|
|
61
|
+
- `alias` passes the core's known user UUID to the React Native SDK's alias method.
|
|
62
|
+
- `reset` resets the PostHog identity after the core has rotated its own anonymous UUID.
|
|
63
|
+
|
|
64
|
+
## Deliberate omissions
|
|
65
|
+
|
|
66
|
+
This package does not decide consent, generate or validate product identity, define events,
|
|
67
|
+
allowlist properties, scrub PII, buffer commands, enable automatic capture, record sessions, or add
|
|
68
|
+
provider-specific event properties. Those policy decisions stay in `@baukit/analytics-core` (or,
|
|
69
|
+
for provider project retention and deletion, in operations).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PostHogOptions, PostHogPersistedProperty } from 'posthog-react-native';
|
|
2
|
+
import type { AnalyticsEnvelope, AnalyticsEvent, Transport } from '@baukit/analytics-core';
|
|
3
|
+
/** Structural surface used so tests do not require a React Native runtime. */
|
|
4
|
+
export interface PostHogNativeClient {
|
|
5
|
+
capture(event: string, properties?: Readonly<Record<string, unknown>>, options?: {
|
|
6
|
+
readonly timestamp?: Date;
|
|
7
|
+
}): unknown;
|
|
8
|
+
identify(distinctId: string, traits?: Readonly<Record<string, unknown>>): unknown;
|
|
9
|
+
alias(alias: string): unknown;
|
|
10
|
+
reset(): unknown;
|
|
11
|
+
optIn(): Promise<void> | void;
|
|
12
|
+
optOut(): Promise<void> | void;
|
|
13
|
+
setPersistedProperty(key: PostHogPersistedProperty, value: unknown): void;
|
|
14
|
+
}
|
|
15
|
+
type GuardedPostHogNativeOption = 'bootstrap' | 'captureAppLifecycleEvents' | 'capturePushNotificationOpened' | 'capturePushNotificationSubscriptions' | 'disableSurveys' | 'enableSessionReplay' | 'errorTracking' | 'host' | 'personProfiles' | 'preloadFeatureFlags' | 'setDefaultPersonProperties' | 'defaultOptIn';
|
|
16
|
+
export type PostHogNativeInitOptions = Omit<PostHogOptions, GuardedPostHogNativeOption>;
|
|
17
|
+
export type PostHogNativeInitializer = (apiKey: string, options: PostHogOptions) => PostHogNativeClient | Promise<PostHogNativeClient>;
|
|
18
|
+
export interface PostHogNativeTransportConfig {
|
|
19
|
+
readonly apiKey: string;
|
|
20
|
+
/** Absolute URL of the product's self-hosted PostHog instance. */
|
|
21
|
+
readonly apiHost: string;
|
|
22
|
+
readonly options?: PostHogNativeInitOptions;
|
|
23
|
+
readonly initializer?: PostHogNativeInitializer;
|
|
24
|
+
readonly onError?: (error: unknown) => void;
|
|
25
|
+
}
|
|
26
|
+
type ClientFactory = (firstEnvelope: AnalyticsEnvelope) => PostHogNativeClient | Promise<PostHogNativeClient>;
|
|
27
|
+
/** Translates privacy-checked core envelopes to a PostHog React Native client. */
|
|
28
|
+
export declare class PostHogNativeTransport<E extends AnalyticsEvent = AnalyticsEvent> implements Transport<E> {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(client: PostHogNativeClient | ClientFactory, onError?: (error: unknown) => void);
|
|
31
|
+
/** Provider failures are contained and never reject into application code. */
|
|
32
|
+
send(envelopes: readonly AnalyticsEnvelope<E>[]): Promise<void>;
|
|
33
|
+
/** Opts PostHog out and purges every persisted provider queue. */
|
|
34
|
+
clearPending(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/** Creates a lazy, safely configured PostHog React Native transport. */
|
|
37
|
+
export declare function createPostHogNativeTransport<E extends AnalyticsEvent = AnalyticsEvent>(config: PostHogNativeTransportConfig): PostHogN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3
|
+
'ai_queue',
|
|
4
|
+
'logs_queue',
|
|
5
|
+
];
|
|
6
|
+
function requireNonEmpty(name, value) {
|
|
7
|
+
const normalized = value.trim();
|
|
8
|
+
if (normalized.length === 0) {
|
|
9
|
+
throw new TypeError(`${name} must not be empty`);
|
|
10
|
+
}
|
|
11
|
+
return normalized;
|
|
12
|
+
}
|
|
13
|
+
function requireApiHost(value) {
|
|
14
|
+
const apiHost = requireNonEmpty('apiHost', value).replace(/\/+$/, '');
|
|
15
|
+
if (!/^https?:\/\/[^\s/]+(?:\/.*)?$/u.test(apiHost)) {
|
|
16
|
+
throw new TypeError('apiHost must be an absolute http(s) URL');
|
|
17
|
+
}
|
|
18
|
+
return apiHost;
|
|
19
|
+
}
|
|
20
|
+
function initialIdentity(envelope) {
|
|
21
|
+
if (envelope.type === 'capture') {
|
|
22
|
+
return envelope.user_id === undefined
|
|
23
|
+
? { distinctId: envelope.anonymous_id, isIdentifiedId: false }
|
|
24
|
+
: { distinctId: envelope.user_id, isIdentifiedId: true };
|
|
25
|
+
}
|
|
26
|
+
if (envelope.type === 'reset') {
|
|
27
|
+
return envelope.previous_user_id === undefined
|
|
28
|
+
? { distinctId: envelope.previous_anonymous_id, isIdentifiedId: false }
|
|
29
|
+
: { distinctId: envelope.previous_user_id, isIdentifiedId: true };
|
|
30
|
+
}
|
|
31
|
+
return { distinctId: envelope.anonymous_id, isIdentifiedId: false };
|
|
32
|
+
}
|
|
33
|
+
function captureProperties(envelope) {
|
|
34
|
+
return {
|
|
35
|
+
...envelope.event.properties,
|
|
36
|
+
schema_version: envelope.event.schema_version,
|
|
37
|
+
app: envelope.event.app,
|
|
38
|
+
app_version: envelope.event.app_version,
|
|
39
|
+
platform: envelope.event.platform,
|
|
40
|
+
environment: envelope.event.environment,
|
|
41
|
+
locale: envelope.event.locale,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function defaultInitializer(apiKey, options) {
|
|
45
|
+
const posthogModule = await import('posthog-react-native');
|
|
46
|
+
return new posthogModule.PostHog(apiKey, options);
|
|
47
|
+
}
|
|
48
|
+
/** Translates privacy-checked core envelopes to a PostHog React Native client. */
|
|
49
|
+
export class PostHogNativeTransport {
|
|
50
|
+
#clientFactory;
|
|
51
|
+
#onError;
|
|
52
|
+
#client;
|
|
53
|
+
#clearGeneration = 0;
|
|
54
|
+
#clearRequired = false;
|
|
55
|
+
#clearOperation;
|
|
56
|
+
#providerOptedOut = true;
|
|
57
|
+
constructor(client, onError) {
|
|
58
|
+
this.#clientFactory = typeof client === 'function' ? client : () => client;
|
|
59
|
+
this.#onError = onError;
|
|
60
|
+
}
|
|
61
|
+
/** Provider failures are contained and never reject into application code. */
|
|
62
|
+
async send(envelopes) {
|
|
63
|
+
if (envelopes.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const generation = this.#clearGeneration;
|
|
67
|
+
let client;
|
|
68
|
+
try {
|
|
69
|
+
client = await this.#getClient(envelopes[0]);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.#reportError(error);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
await this.#clearOperation;
|
|
76
|
+
if (generation !== this.#clearGeneration) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (this.#clearRequired) {
|
|
80
|
+
await this.#purgeClient(client);
|
|
81
|
+
if (generation !== this.#clearGeneration) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.#clearRequired = false;
|
|
85
|
+
}
|
|
86
|
+
if (!(await this.#optIn(client))) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
for (const envelope of envelopes) {
|
|
90
|
+
if (generation !== this.#clearGeneration) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await this.#dispatch(client, envelope);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.#reportError(error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Opts PostHog out and purges every persisted provider queue. */
|
|
102
|
+
clearPending() {
|
|
103
|
+
this.#clearGeneration += 1;
|
|
104
|
+
this.#clearRequired = true;
|
|
105
|
+
this.#providerOptedOut = true;
|
|
106
|
+
const client = this.#client;
|
|
107
|
+
if (client === undefined) {
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
}
|
|
110
|
+
const generation = this.#clearGeneration;
|
|
111
|
+
const operation = client
|
|
112
|
+
.then(async (resolvedClient) => {
|
|
113
|
+
await this.#purgeClient(resolvedClient);
|
|
114
|
+
if (generation === this.#clearGeneration) {
|
|
115
|
+
this.#clearRequired = false;
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
.catch((error) => {
|
|
119
|
+
this.#reportError(error);
|
|
120
|
+
})
|
|
121
|
+
.finally(() => {
|
|
122
|
+
if (this.#clearOperation === operation) {
|
|
123
|
+
this.#clearOperation = undefined;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
this.#clearOperation = operation;
|
|
127
|
+
return operation;
|
|
128
|
+
}
|
|
129
|
+
#getClient(firstEnvelope) {
|
|
130
|
+
this.#client ??= Promise.resolve(this.#clientFactory(firstEnvelope));
|
|
131
|
+
return this.#client;
|
|
132
|
+
}
|
|
133
|
+
async #dispatch(client, envelope) {
|
|
134
|
+
switch (envelope.type) {
|
|
135
|
+
case 'capture':
|
|
136
|
+
await Promise.resolve(client.capture(envelope.event.name, captureProperties(envelope), {
|
|
137
|
+
timestamp: new Date(envelope.captured_at),
|
|
138
|
+
}));
|
|
139
|
+
break;
|
|
140
|
+
case 'identify':
|
|
141
|
+
await Promise.resolve(client.identify(envelope.user_id, envelope.traits));
|
|
142
|
+
break;
|
|
143
|
+
case 'alias':
|
|
144
|
+
await Promise.resolve(client.alias(envelope.user_id));
|
|
145
|
+
break;
|
|
146
|
+
case 'reset':
|
|
147
|
+
await Promise.resolve(client.reset());
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async #optIn(client) {
|
|
152
|
+
if (!this.#providerOptedOut) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
await Promise.resolve(client.optIn());
|
|
157
|
+
this.#providerOptedOut = false;
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
this.#reportError(error);
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async #purgeClient(client) {
|
|
166
|
+
try {
|
|
167
|
+
await Promise.resolve(client.optOut());
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
this.#reportError(error);
|
|
171
|
+
}
|
|
172
|
+
for (const key of PENDING_QUEUE_KEYS) {
|
|
173
|
+
try {
|
|
174
|
+
client.setPersistedProperty(key, []);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
this.#reportError(error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
#reportError(error) {
|
|
182
|
+
try {
|
|
183
|
+
this.#onError?.(error);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// Provider diagnostics must not affect the application journey.
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Creates a lazy, safely configured PostHog React Native transport. */
|
|
191
|
+
export function createPostHogNativeTransport(config) {
|
|
192
|
+
const apiKey = requireNonEmpty('apiKey', config.apiKey);
|
|
193
|
+
const apiHost = requireApiHost(config.apiHost);
|
|
194
|
+
const initializer = config.initializer ?? defaultInitializer;
|
|
195
|
+
return new PostHogNativeTransport((firstEnvelope) => {
|
|
196
|
+
const options = {
|
|
197
|
+
...config.options,
|
|
198
|
+
host: apiHost,
|
|
199
|
+
bootstrap: initialIdentity(firstEnvelope),
|
|
200
|
+
captureAppLifecycleEvents: false,
|
|
201
|
+
capturePushNotificationOpened: false,
|
|
202
|
+
capturePushNotificationSubscriptions: false,
|
|
203
|
+
disableSurveys: true,
|
|
204
|
+
enableSessionReplay: false,
|
|
205
|
+
errorTracking: { autocapture: false },
|
|
206
|
+
defaultOptIn: false,
|
|
207
|
+
personProfiles: 'identified_only',
|
|
208
|
+
preloadFeatureFlags: false,
|
|
209
|
+
setDefaultPersonProperties: false,
|
|
210
|
+
};
|
|
211
|
+
return initializer(apiKey, options);
|
|
212
|
+
}, config.onError);
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA0DA,MAAM,kBAAkB,GAAG;IACzB,OAAO;IACP,UAAU;IACV,YAAY;CAC0B,CAAC;AAEzC,SAAS,eAAe,CAAC,IAAY,EAAE,KAAa;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,oBAAoB,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,gCAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,eAAe,CAAC,QAA2B;IAIlD,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,OAAO,KAAK,SAAS;YACnC,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,YAAY,EAAE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AE,eAAe,CAAC,aAAa,CAAC;YACzC,yBAAyB,EAAE,KAAK;YAChC,6BAA6B,EAAE,KAAK;YACpC,oCAAoC,EAAE,KAAK;YAC3C,cAAc,EAAE,IAAI;YACpB,mBAAmB,EAAE,KAAK;YAC1B,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;YACrC,YAAY,EAAE,KAAK;YACnB,cAAc,EAAE,iBAAiB;YACjC,mBAAmB,EAAE,KAAK;YAC1B,0BAA0B,EAAE,KAAK;SAClC,CAAC;QACF,OAAO,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@baukit/analytics-posthog-native",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PostHog React Native transport for @baukit/analytics-core.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Patrick Koss",
|
|
7
|
+
"homepage": "https://github.com/PatrickKoss/baukit#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/PatrickKoss/baukit.git",
|
|
11
|
+
"directory": "typescript/packages/analytics-posthog-native"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/PatrickKoss/baukit/issues"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24.0.0"
|
|
22
|
+
},
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"posthog-react-native": "4.62.0",
|
|
37
|
+
"typescript": "6.0.3",
|
|
38
|
+
"@baukit/analytics-core": "0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@baukit/analytics-core": "^0.1.0",
|
|
42
|
+
"posthog-react-native": "^4.62.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.json",
|
|
46
|
+
"test": "vitest run --config ../../vitest.config.ts",
|
|
47
|
+
"lint": "eslint src --max-warnings=0",
|
|
48
|
+
"format:check": "prettier --check src package.json tsconfig.json"
|
|
49
|
+
}
|
|
50
|
+
}
|