@posthog/browser-common 0.0.0 → 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 ADDED
@@ -0,0 +1,353 @@
1
+ Copyright 2020 Posthog / Hiberly, Inc.
2
+
3
+ Copyright 2015 Mixpanel, Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this work except in compliance with the License.
7
+ You may obtain a copy of the License below, or at:
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ Apache License
18
+ Version 2.0, January 2004
19
+ http://www.apache.org/licenses/
20
+
21
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
+
23
+ 1. Definitions.
24
+
25
+ "License" shall mean the terms and conditions for use, reproduction,
26
+ and distribution as defined by Sections 1 through 9 of this document.
27
+
28
+ "Licensor" shall mean the copyright owner or entity authorized by
29
+ the copyright owner that is granting the License.
30
+
31
+ "Legal Entity" shall mean the union of the acting entity and all
32
+ other entities that control, are controlled by, or are under common
33
+ control with that entity. For the purposes of this definition,
34
+ "control" means (i) the power, direct or indirect, to cause the
35
+ direction or management of such entity, whether by contract or
36
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
37
+ outstanding shares, or (iii) beneficial ownership of such entity.
38
+
39
+ "You" (or "Your") shall mean an individual or Legal Entity
40
+ exercising permissions granted by this License.
41
+
42
+ "Source" form shall mean the preferred form for making modifications,
43
+ including but not limited to software source code, documentation
44
+ source, and configuration files.
45
+
46
+ "Object" form shall mean any form resulting from mechanical
47
+ transformation or translation of a Source form, including but
48
+ not limited to compiled object code, generated documentation,
49
+ and conversions to other media types.
50
+
51
+ "Work" shall mean the work of authorship, whether in Source or
52
+ Object form, made available under the License, as indicated by a
53
+ copyright notice that is included in or attached to the work
54
+ (an example is provided in the Appendix below).
55
+
56
+ "Derivative Works" shall mean any work, whether in Source or Object
57
+ form, that is based on (or derived from) the Work and for which the
58
+ editorial revisions, annotations, elaborations, or other modifications
59
+ represent, as a whole, an original work of authorship. For the purposes
60
+ of this License, Derivative Works shall not include works that remain
61
+ separable from, or merely link (or bind by name) to the interfaces of,
62
+ the Work and Derivative Works thereof.
63
+
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+
78
+ "Contributor" shall mean Licensor and any individual or Legal Entity
79
+ on behalf of whom a Contribution has been received by Licensor and
80
+ subsequently incorporated within the Work.
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to reproduce, prepare Derivative Works of,
86
+ publicly display, publicly perform, sublicense, and distribute the
87
+ Work and such Derivative Works in Source or Object form.
88
+
89
+ 3. Grant of Patent License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ (except as stated in this section) patent license to make, have made,
93
+ use, offer to sell, sell, import, and otherwise transfer the Work,
94
+ where such license applies only to those patent claims licensable
95
+ by such Contributor that are necessarily infringed by their
96
+ Contribution(s) alone or by combination of their Contribution(s)
97
+ with the Work to which such Contribution(s) was submitted. If You
98
+ institute patent litigation against any entity (including a
99
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
100
+ or a Contribution incorporated within the Work constitutes direct
101
+ or contributory patent infringement, then any patent licenses
102
+ granted to You under this License for that Work shall terminate
103
+ as of the date such litigation is filed.
104
+
105
+ 4. Redistribution. You may reproduce and distribute copies of the
106
+ Work or Derivative Works thereof in any medium, with or without
107
+ modifications, and in Source or Object form, provided that You
108
+ meet the following conditions:
109
+
110
+ (a) You must give any other recipients of the Work or
111
+ Derivative Works a copy of this License; and
112
+
113
+ (b) You must cause any modified files to carry prominent notices
114
+ stating that You changed the files; and
115
+
116
+ (c) You must retain, in the Source form of any Derivative Works
117
+ that You distribute, all copyright, patent, trademark, and
118
+ attribution notices from the Source form of the Work,
119
+ excluding those notices that do not pertain to any part of
120
+ the Derivative Works; and
121
+
122
+ (d) If the Work includes a "NOTICE" text file as part of its
123
+ distribution, then any Derivative Works that You distribute must
124
+ include a readable copy of the attribution notices contained
125
+ within such NOTICE file, excluding those notices that do not
126
+ pertain to any part of the Derivative Works, in at least one
127
+ of the following places: within a NOTICE text file distributed
128
+ as part of the Derivative Works; within the Source form or
129
+ documentation, if provided along with the Derivative Works; or,
130
+ within a display generated by the Derivative Works, if and
131
+ wherever such third-party notices normally appear. The contents
132
+ of the NOTICE file are for informational purposes only and
133
+ do not modify the License. You may add Your own attribution
134
+ notices within Derivative Works that You distribute, alongside
135
+ or as an addendum to the NOTICE text from the Work, provided
136
+ that such additional attribution notices cannot be construed
137
+ as modifying the License.
138
+
139
+ You may add Your own copyright statement to Your modifications and
140
+ may provide additional or different license terms and conditions
141
+ for use, reproduction, or distribution of Your modifications, or
142
+ for any such Derivative Works as a whole, provided Your use,
143
+ reproduction, and distribution of the Work otherwise complies with
144
+ the conditions stated in this License.
145
+
146
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
147
+ any Contribution intentionally submitted for inclusion in the Work
148
+ by You to the Licensor shall be under the terms and conditions of
149
+ this License, without any additional terms or conditions.
150
+ Notwithstanding the above, nothing herein shall supersede or modify
151
+ the terms of any separate license agreement you may have executed
152
+ with Licensor regarding such Contributions.
153
+
154
+ 6. Trademarks. This License does not grant permission to use the trade
155
+ names, trademarks, service marks, or product names of the Licensor,
156
+ except as required for reasonable and customary use in describing the
157
+ origin of the Work and reproducing the content of the NOTICE file.
158
+
159
+ 7. Disclaimer of Warranty. Unless required by applicable law or
160
+ agreed to in writing, Licensor provides the Work (and each
161
+ Contributor provides its Contributions) on an "AS IS" BASIS,
162
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
163
+ implied, including, without limitation, any warranties or conditions
164
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
165
+ PARTICULAR PURPOSE. You are solely responsible for determining the
166
+ appropriateness of using or redistributing the Work and assume any
167
+ risks associated with Your exercise of permissions under this License.
168
+
169
+ 8. Limitation of Liability. In no event and under no legal theory,
170
+ whether in tort (including negligence), contract, or otherwise,
171
+ unless required by applicable law (such as deliberate and grossly
172
+ negligent acts) or agreed to in writing, shall any Contributor be
173
+ liable to You for damages, including any direct, indirect, special,
174
+ incidental, or consequential damages of any character arising as a
175
+ result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill,
177
+ work stoppage, computer failure or malfunction, or any and all
178
+ other commercial damages or losses), even if such Contributor
179
+ has been advised of the possibility of such damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing
182
+ the Work or Derivative Works thereof, You may choose to offer,
183
+ and charge a fee for, acceptance of support, warranty, indemnity,
184
+ or other liability obligations and/or rights consistent with this
185
+ License. However, in accepting such obligations, You may act only
186
+ on Your own behalf and on Your sole responsibility, not on behalf
187
+ of any other Contributor, and only if You agree to indemnify,
188
+ defend, and hold each Contributor harmless for any liability
189
+ incurred by, or claims asserted against, such Contributor by reason
190
+ of your accepting any such warranty or additional liability.
191
+
192
+ END OF TERMS AND CONDITIONS
193
+
194
+ APPENDIX: How to apply the Apache License to your work.
195
+
196
+ To apply the Apache License to your work, attach the following
197
+ boilerplate notice, with the fields enclosed by brackets "[]"
198
+ replaced with your own identifying information. (Don't include
199
+ the brackets!) The text should be enclosed in the appropriate
200
+ comment syntax for the file format. We also recommend that a
201
+ file or class name and description of purpose be included on the
202
+ same "printed page" as the copyright notice for easier
203
+ identification within third-party archives.
204
+
205
+ Copyright [yyyy] [name of copyright owner]
206
+
207
+ Licensed under the Apache License, Version 2.0 (the "License");
208
+ you may not use this file except in compliance with the License.
209
+ You may obtain a copy of the License at
210
+
211
+ http://www.apache.org/licenses/LICENSE-2.0
212
+
213
+ Unless required by applicable law or agreed to in writing, software
214
+ distributed under the License is distributed on an "AS IS" BASIS,
215
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
216
+ See the License for the specific language governing permissions and
217
+ limitations under the License.
218
+
219
+
220
+ ---
221
+
222
+ Some files in this codebase contain code from getsentry/sentry-javascript.
223
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
224
+
225
+ MIT License
226
+
227
+ Copyright (c) 2012 Functional Software, Inc. dba Sentry
228
+
229
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
230
+ this software and associated documentation files (the "Software"), to deal in
231
+ the Software without restriction, including without limitation the rights to
232
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
233
+ of the Software, and to permit persons to whom the Software is furnished to do
234
+ so, subject to the following conditions:
235
+
236
+ The above copyright notice and this permission notice shall be included in all
237
+ copies or substantial portions of the Software.
238
+
239
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
240
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
241
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
242
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
243
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
244
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
245
+ SOFTWARE.
246
+
247
+ ---
248
+
249
+ Some files in this codebase contain code from getsentry/sentry-react-native.
250
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
251
+
252
+ The MIT License (MIT)
253
+
254
+ Copyright (c) 2017 Sentry
255
+
256
+ Permission is hereby granted, free of charge, to any person obtaining a copy
257
+ of this software and associated documentation files (the "Software"), to deal
258
+ in the Software without restriction, including without limitation the rights
259
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
260
+ copies of the Software, and to permit persons to whom the Software is
261
+ furnished to do so, subject to the following conditions:
262
+
263
+ The above copyright notice and this permission notice shall be included in all
264
+ copies or substantial portions of the Software.
265
+
266
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
267
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
268
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
269
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
270
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
271
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
272
+ SOFTWARE.
273
+
274
+ ---
275
+
276
+ Some files in this codebase contain code from facebook/metro by Meta Platforms, Inc. and affiliates.
277
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
278
+
279
+ MIT License
280
+
281
+ Copyright (c) Meta Platforms, Inc. and affiliates.
282
+
283
+ Permission is hereby granted, free of charge, to any person obtaining a copy
284
+ of this software and associated documentation files (the "Software"), to deal
285
+ in the Software without restriction, including without limitation the rights
286
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
287
+ copies of the Software, and to permit persons to whom the Software is
288
+ furnished to do so, subject to the following conditions:
289
+
290
+ The above copyright notice and this permission notice shall be included in all
291
+ copies or substantial portions of the Software.
292
+
293
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
294
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
295
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
296
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
297
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
298
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
299
+ SOFTWARE.
300
+
301
+ ---
302
+
303
+ Some files in this codebase contain code from expo/expo by 650 Industries, Inc. (aka Expo).
304
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
305
+
306
+ The MIT License (MIT)
307
+
308
+ Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
309
+
310
+ Permission is hereby granted, free of charge, to any person obtaining a copy
311
+ of this software and associated documentation files (the "Software"), to deal
312
+ in the Software without restriction, including without limitation the rights
313
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
314
+ copies of the Software, and to permit persons to whom the Software is
315
+ furnished to do so, subject to the following conditions:
316
+
317
+ The above copyright notice and this permission notice shall be included in all
318
+ copies or substantial portions of the Software.
319
+
320
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
321
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
322
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
323
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
324
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
325
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
326
+ SOFTWARE.
327
+
328
+ ---
329
+
330
+ Some files in this codebase contain code from agentcathq/agentcat-typescript-sdk (formerly MCPCat/mcpcat-typescript-sdk).
331
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
332
+
333
+ MIT License
334
+
335
+ Copyright (c) 2025 AgentCat, Inc. (formerly MCPcat)
336
+
337
+ Permission is hereby granted, free of charge, to any person obtaining a copy
338
+ of this software and associated documentation files (the "Software"), to deal
339
+ in the Software without restriction, including without limitation the rights
340
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
341
+ copies of the Software, and to permit persons to whom the Software is
342
+ furnished to do so, subject to the following conditions:
343
+
344
+ The above copyright notice and this permission notice shall be included in all
345
+ copies or substantial portions of the Software.
346
+
347
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
348
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
349
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
350
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
351
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
352
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
353
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,118 @@
1
1
  # @posthog/browser-common
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ Internal shared browser utilities and extension primitives for PostHog JavaScript
4
+ SDKs. This package is published so unbundled SDK outputs can resolve it at
5
+ runtime, but it is not a public API surface and does not provide compatibility
6
+ guarantees outside PostHog SDK packages.
4
7
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
8
+ The shared extension contract includes the interface an extension implements
9
+ (`Extension`), the host capabilities it is handed (`Client`), and small shared
10
+ runtime primitives such as `Publisher`.
6
11
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
12
+ An extension written against this contract runs unchanged across major versions of the web SDK:
8
13
 
9
- ## Purpose
14
+ - **v1** is synchronous; extensions are registered statically.
15
+ - **v2** is asynchronous; extensions are loaded dynamically.
10
16
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@posthog/browser-common`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
17
+ Each SDK provides a _client adapter_ that implements `Client` over its own
18
+ internals, so extension code never depends on a specific SDK.
15
19
 
16
- ## What is OIDC Trusted Publishing?
20
+ ## Concepts
17
21
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
22
+ ### `Extension`
19
23
 
20
- ## Setup Instructions
24
+ What you implement. The host calls only `setup` and `dispose`:
21
25
 
22
- To properly configure OIDC trusted publishing for this package:
26
+ ```ts
27
+ import type { Disposable, Extension } from '@posthog/browser-common'
23
28
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
29
+ export function webContext(): Extension {
30
+ let removeProperties: Disposable | undefined
28
31
 
29
- ## DO NOT USE THIS PACKAGE
32
+ return {
33
+ name: 'webContext',
34
+ setup(client) {
35
+ removeProperties = client.registerDynamicEventProperties(() => ({
36
+ $current_url: window.location.href,
37
+ }))
38
+ },
39
+ dispose() {
40
+ removeProperties?.dispose()
41
+ },
42
+ }
43
+ }
44
+ ```
30
45
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
46
+ `setup(client)` may be async (read async state before you're ready); `dispose()`
47
+ may be async (final flush). Static config the app sets goes in your constructor,
48
+ not on the `Client`.
36
49
 
37
- ## More Information
50
+ Anything in `setup` that returns a `Disposable` must be held by the extension
51
+ and disposed in `dispose()`.
38
52
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
53
+ ### `Client`
42
54
 
43
- ---
55
+ What an extension is given in `setup` — the host's capability surface:
44
56
 
45
- **Maintained for OIDC setup purposes only**
57
+ - **identity & session** (synchronous reads): `distinctId`, `anonymousId`, `groups`, `session`
58
+ - **events**: `capture(...)`, `registerDynamicEventProperties(...)` (contribute properties), `onEvent(...)` (observe)
59
+ - **transport**: `apiRequest(path, init?)`
60
+ - **server config**: `getRemoteConfig()` (current), `onRemoteConfig(...)` (changes)
61
+ - **lifecycle**: `onNewSession(...)`
62
+ - **registry**: `getExtension(token)`
63
+ - **storage & logging**: `kv`, `logger`
64
+
65
+ Synchronous members are always-ready in-memory reads; everything that does I/O
66
+ or waits for readiness (`capture`, `apiRequest`, `kv`, `getRemoteConfig`) is
67
+ asynchronous.
68
+
69
+ ### `Publisher`
70
+
71
+ Use `Publisher<T>` when an extension provides its own event stream to other
72
+ extensions or to app-facing controls. Keep the publisher private, expose only its
73
+ `listener`, and dispose it when the extension is torn down:
74
+
75
+ ```ts
76
+ import { Publisher, type Listener } from '@posthog/browser-common'
77
+
78
+ const changes = new Publisher<FeatureFlagsChange>()
79
+
80
+ export const onChange: Listener<FeatureFlagsChange> = changes.listener
81
+
82
+ changes.publish({ flag: 'beta-ui', value: true })
83
+ changes.dispose()
84
+ ```
85
+
86
+ ## Cross-extension dependencies
87
+
88
+ Extensions depend on one another through tokens, never implementation imports:
89
+
90
+ ```ts
91
+ import { FeatureFlags } from './feature-flags/token'
92
+
93
+ const flags = client.getExtension(FeatureFlags) // FeatureFlagsExtension | undefined
94
+ if (flags && (await flags.getFeatureFlag('beta-ui'))) {
95
+ /* … */
96
+ }
97
+ ```
98
+
99
+ A token is implementation-free, so importing it never pulls the provider's code
100
+ into your bundle — each extension stays independently tree-shakable and lazily
101
+ loadable. An extension that provides a capability declares its token(s) in
102
+ `provides`.
103
+
104
+ ## Authoring
105
+
106
+ See the **`develop-extension`** skill
107
+ ([`.agents/skills/develop-extension/SKILL.md`](./.agents/skills/develop-extension/SKILL.md))
108
+ for the full guide: the capability cheatsheet, the rules (enrichers are
109
+ synchronous, dispose your disposables, design for asynchronous readiness,
110
+ cross-extension state goes through `getExtension`, not shared storage), and the
111
+ v1 → `Client` porting map.
112
+
113
+ ## Status
114
+
115
+ Early and internal. The package currently defines the extension contract and
116
+ the shared `Publisher` helper. Additional shared runtime helpers — key-value
117
+ stores, the registry implementation, and a test `Client` — will land alongside
118
+ the first ported extension.
@@ -0,0 +1,136 @@
1
+ import type { Logger } from '@posthog/core';
2
+ import type { Disposable } from './disposable';
3
+ import type { KeyValueStore } from './persistence';
4
+ import type { Listener } from './pubsub';
5
+ import type { ExtensionToken } from './token';
6
+ /** The current session, stamped on events to tie them to a session and a browser tab. */
7
+ export interface SessionContext {
8
+ /** The stable session identifier attached to events captured during this session. */
9
+ sessionId: string;
10
+ /** The logical browser tab/window identifier attached alongside the session id. */
11
+ windowId: string;
12
+ /** When the session started, as a Unix timestamp in milliseconds. */
13
+ sessionStartTimestamp: number;
14
+ }
15
+ /** Why a new session started (a `reset` also starts a new session). */
16
+ export type NewSessionReason = 'initial' | 'reset' | 'idleTimeout' | 'maxLength' | 'crossTabAdoption';
17
+ /** Details emitted when the client starts or adopts a new session. */
18
+ export interface NewSessionInfo extends SessionContext {
19
+ /** The condition that caused this session to begin. */
20
+ reason: NewSessionReason;
21
+ }
22
+ /** A captured event, as observed by `onEvent`. */
23
+ export interface CapturedEventInfo {
24
+ /** The event name supplied to {@link Client.capture}. */
25
+ event: string;
26
+ /** The final event properties after client defaults and dynamic properties are applied. */
27
+ properties: Record<string, unknown>;
28
+ }
29
+ /** Per-call capture overrides, mirroring the client's public capture options. */
30
+ export interface CaptureOptions {
31
+ /** Override the event timestamp sent to PostHog. */
32
+ timestamp?: Date;
33
+ /** Override the event UUID used for de-duplication. */
34
+ uuid?: string;
35
+ /** Person properties to set, emitted as `$set`. */
36
+ set?: Record<string, unknown>;
37
+ /** Person properties to set if unset, emitted as `$set_once`. */
38
+ setOnce?: Record<string, unknown>;
39
+ }
40
+ /** A minimal response from {@link Client.apiRequest}. */
41
+ export interface ApiResponse {
42
+ /** Whether the request completed with a 2xx status, or was queued for best-effort unload transport. */
43
+ ok: boolean;
44
+ /** The HTTP status code returned by the transport, or a client-defined best-effort status for unload sends. */
45
+ status: number;
46
+ /** Parse the response body as JSON; may be unavailable for best-effort unload requests. */
47
+ json(): Promise<unknown>;
48
+ /** Read the response body as text; may be unavailable for best-effort unload requests. */
49
+ text(): Promise<string>;
50
+ }
51
+ /** Options for sending a request through {@link Client.apiRequest}. */
52
+ export interface ApiRequestInit {
53
+ /** HTTP method to use; defaults to the client's normal request method for the endpoint. */
54
+ method?: 'GET' | 'POST';
55
+ /** JSON-serialized by the client. */
56
+ body?: unknown;
57
+ /** Query string parameters appended to the request URL. */
58
+ query?: Record<string, string>;
59
+ /**
60
+ * Mark this as a teardown send (pagehide / shutdown): the client picks the
61
+ * most reliable fire-and-forget transport available — `sendBeacon`, fetch
62
+ * `keepalive`, or sync XHR. The response is best-effort: `.json()` may be
63
+ * unusable (e.g. `sendBeacon` only reports "queued"), so callers must not
64
+ * depend on it.
65
+ */
66
+ unload?: boolean;
67
+ /** Abort the request if it does not complete within this many milliseconds. */
68
+ timeoutMs?: number;
69
+ }
70
+ /**
71
+ * Server-provided configuration, as returned by the remote config response
72
+ * (sampling rates, suppression rules, feature enablement, quotas, …). A loose
73
+ * record by design — each extension reads only the keys it owns.
74
+ */
75
+ export type RemoteConfig = Record<string, unknown>;
76
+ /**
77
+ * The host SDK's capability surface as seen by an extension — the client an
78
+ * extension is handed in `setup`. Each SDK (v1, v2) provides it as a client
79
+ * adapter over its own internals.
80
+ *
81
+ * Synchronous members are always-ready in-memory reads (identity, session);
82
+ * asynchronous members do I/O or wait for something to become ready
83
+ * (`capture`, `apiRequest`, `kv`, `getRemoteConfig`).
84
+ */
85
+ export interface Client {
86
+ /** The id events are currently attributed to — the anonymous id, or the identified user's id after `identify`. */
87
+ readonly distinctId: string;
88
+ /** The anonymous device id; used before `identify` and carried on identify events as `$anon_distinct_id`. */
89
+ readonly anonymousId: string;
90
+ /** Active group memberships (group type → group key), attached to events as `$groups`. */
91
+ readonly groups: Record<string, string>;
92
+ /** The current session, created on first read if needed; reading does not extend or rotate it. */
93
+ readonly session: SessionContext;
94
+ /** Records an analytics event through the client's normal pipeline. */
95
+ capture(event: string, properties?: Record<string, unknown> | null, options?: CaptureOptions): Promise<void>;
96
+ /**
97
+ * Registers a producer of properties merged into every captured event.
98
+ * Returns a {@link Disposable} that removes it; an extension disposes it in
99
+ * its own `dispose`. May be called more than once. The producer runs inline
100
+ * during event build, so it must be cheap and synchronous; it may return
101
+ * different properties each time (e.g. the current URL), and is recomputed
102
+ * per event rather than stored.
103
+ */
104
+ registerDynamicEventProperties(producer: () => Record<string, unknown>): Disposable;
105
+ /**
106
+ * Sends a request to a PostHog endpoint; the client owns auth, headers, and
107
+ * transport (fetch / XHR / keepalive). `path` is relative to the configured
108
+ * API host, e.g. `/s/`, `/flags/`, `/api/surveys/`.
109
+ */
110
+ apiRequest(path: string, init?: ApiRequestInit): Promise<ApiResponse>;
111
+ /**
112
+ * Resolves with the client's remote config once available, or `undefined`
113
+ * if the fetch failed (never rejects, never hangs).
114
+ * Re-readable: each call resolves with the current config, awaiting the
115
+ * first fetch if none has landed. `await` it in `setup` to block until
116
+ * config is known, or `.then()` it to reconfigure once it arrives; later
117
+ * changes arrive via `onRemoteConfig`.
118
+ */
119
+ getRemoteConfig(): Promise<RemoteConfig | undefined>;
120
+ /** Fires when server-provided config arrives or changes. */
121
+ readonly onRemoteConfig: Listener<RemoteConfig>;
122
+ /** Fires for every captured event — hot path, keep handlers cheap and synchronous. */
123
+ readonly onEvent: Listener<CapturedEventInfo>;
124
+ /** Fires when a new session starts, including on reset (discriminate via `reason`). */
125
+ readonly onNewSession: Listener<NewSessionInfo>;
126
+ /**
127
+ * Resolves another registered extension by a capability token it provides, or
128
+ * `undefined` if nothing registered provides it (not installed, or not loaded
129
+ * yet). Lets one extension use another without importing its implementation.
130
+ */
131
+ getExtension<T>(token: ExtensionToken<T>): T | undefined;
132
+ /** Async key-value storage scoped to this client instance and extension. */
133
+ readonly kv: KeyValueStore;
134
+ /** Logger that follows the host client's debug/noise policy. */
135
+ readonly logger: Logger;
136
+ }
package/dist/client.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
File without changes
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Something with an async-capable teardown. `dispose` may be async so
3
+ * teardown can do final work — e.g. a last flush of buffered data — that the
4
+ * client can await before it finishes shutting down.
5
+ */
6
+ export interface Disposable {
7
+ /**
8
+ * Release resources owned by this object. Implementations should be
9
+ * idempotent so callers can safely dispose during both extension teardown
10
+ * and client shutdown.
11
+ */
12
+ dispose(): void | Promise<void>;
13
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
File without changes
@@ -0,0 +1,45 @@
1
+ import type { Disposable } from './disposable';
2
+ import type { Client } from './client';
3
+ import type { ExtensionToken } from './token';
4
+ /**
5
+ * A shared browser extension. The client calls only two things: `setup(client)`
6
+ * to start it and `dispose()` (from {@link Disposable}) to stop it. Everything
7
+ * an extension consumes flows the other way, through {@link Client}.
8
+ *
9
+ * `setup` may be async so an extension can read async-KV state or remote config
10
+ * before it is ready; the client awaits it. `name` is used for de-duplication
11
+ * and diagnostics. The `Disposable`s an extension creates in `setup` —
12
+ * enrichers, event listeners, timers — are its own to release: hold them and
13
+ * dispose them in `dispose`. The host disposes the extension; it does not track
14
+ * the extension's individual subscriptions.
15
+ *
16
+ * An extension that exposes app-facing controls extends `Extension` with named
17
+ * methods that share its state, e.g.:
18
+ *
19
+ * ```ts
20
+ * interface SessionReplayExtension extends Extension {
21
+ * startRecording(): void
22
+ * stopRecording(): void
23
+ * isActive(): boolean
24
+ * }
25
+ * ```
26
+ *
27
+ * The client still only calls `setup` and `dispose`; the controls are for the
28
+ * application that constructed the extension.
29
+ */
30
+ export interface Extension extends Disposable {
31
+ /** Stable extension name used for diagnostics and de-duplication within a client instance. */
32
+ readonly name: string;
33
+ /**
34
+ * Capability tokens this extension answers to, so others can resolve it via
35
+ * `client.getExtension(token)`. The extension must be assignable to each
36
+ * token's provided type. Most extensions provide nothing.
37
+ */
38
+ readonly provides?: readonly ExtensionToken<unknown>[];
39
+ /**
40
+ * Start the extension with the host client's capability surface. Called once
41
+ * after construction; return a promise when setup needs asynchronous state
42
+ * such as persisted data or remote config.
43
+ */
44
+ setup(client: Client): void | Promise<void>;
45
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
File without changes
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Public surface for browser extensions shared across PostHog JavaScript SDK
3
+ * clients.
4
+ */
5
+ export type { Extension } from './extension';
6
+ export type { Disposable } from './disposable';
7
+ export type { ExtensionToken } from './token';
8
+ export type { Listener } from './pubsub';
9
+ export { Publisher } from './pubsub';
10
+ export type { Client, SessionContext, NewSessionReason, NewSessionInfo, CapturedEventInfo, CaptureOptions, ApiResponse, ApiRequestInit, RemoteConfig, } from './client';
11
+ export type { KeyValueStore } from './persistence';
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ Publisher: ()=>external_pubsub_js_namespaceObject.Publisher
28
+ });
29
+ const external_pubsub_js_namespaceObject = require("./pubsub.js");
30
+ exports.Publisher = __webpack_exports__.Publisher;
31
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
32
+ "Publisher"
33
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
34
+ Object.defineProperty(exports, '__esModule', {
35
+ value: true
36
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { Publisher } from "./pubsub.mjs";
2
+ export { Publisher };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Async key-value store for small extension state. Backed by whatever the
3
+ * client provides — a synchronous store resolves immediately, an asynchronous
4
+ * one (e.g. IndexedDB) does real I/O — so reads and writes are always awaited.
5
+ *
6
+ * The store is namespaced to the client instance, so keys are local to the
7
+ * extension and never collide with core SDK state. Values must be
8
+ * JSON-serializable; setting `null`/`undefined` removes the key.
9
+ */
10
+ export interface KeyValueStore {
11
+ /**
12
+ * Read a value by key.
13
+ *
14
+ * @returns The stored value, or `undefined` when the key is missing.
15
+ */
16
+ get<T = unknown>(key: string): Promise<T | undefined>;
17
+ /**
18
+ * Store a JSON-serializable value by key. Passing `null` or `undefined`
19
+ * removes the key instead of persisting that value.
20
+ */
21
+ set(key: string, value: unknown): Promise<void>;
22
+ /** Remove a value by key. Resolves successfully when the key is already absent. */
23
+ remove(key: string): Promise<void>;
24
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
File without changes
@@ -0,0 +1,28 @@
1
+ import type { Disposable } from './disposable';
2
+ /**
3
+ * Call it with a handler to start listening; dispose the returned
4
+ * {@link Disposable} to stop. There is one `Listener` per event type, so every
5
+ * event carries its own payload type. The handler is called synchronously for
6
+ * each future payload, and the returned disposable unregisters it.
7
+ */
8
+ export type Listener<T> = (handler: (payload: T) => void) => Disposable;
9
+ /**
10
+ * Publish/subscribe helper for client events exposed to extensions. A client
11
+ * owns the publisher, calls {@link Publisher.publish} to fire payloads, and
12
+ * exposes only {@link Publisher.listener} to extensions so they can subscribe
13
+ * without gaining publish access. Calling {@link Publisher.dispose} drops all
14
+ * listeners.
15
+ */
16
+ export declare class Publisher<T> implements Disposable {
17
+ /** Subscriptions currently registered with this publisher. */
18
+ private _subscriptions;
19
+ /**
20
+ * Register a handler for future payloads. The returned disposable
21
+ * subscription unregisters this handler.
22
+ */
23
+ readonly listener: Listener<T>;
24
+ /** Notify every currently registered listener with the provided payload. */
25
+ publish(payload: T): void;
26
+ /** Drop all registered listeners. Safe to call more than once. */
27
+ dispose(): void;
28
+ }
package/dist/pubsub.js ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ Publisher: ()=>Publisher
28
+ });
29
+ class Publisher {
30
+ publish(payload) {
31
+ const subscriptions = this._subscriptions.slice();
32
+ subscriptions.forEach((subscription)=>{
33
+ if (subscription.isActive) subscription.handler(payload);
34
+ });
35
+ }
36
+ dispose() {
37
+ this._subscriptions.forEach((subscription)=>{
38
+ subscription.isActive = false;
39
+ });
40
+ this._subscriptions = [];
41
+ }
42
+ constructor(){
43
+ this._subscriptions = [];
44
+ this.listener = (handler)=>{
45
+ const subscription = {
46
+ handler,
47
+ isActive: true
48
+ };
49
+ this._subscriptions.push(subscription);
50
+ return {
51
+ dispose: ()=>{
52
+ if (!subscription.isActive) return;
53
+ subscription.isActive = false;
54
+ const index = this._subscriptions.indexOf(subscription);
55
+ if (-1 !== index) this._subscriptions.splice(index, 1);
56
+ }
57
+ };
58
+ };
59
+ }
60
+ }
61
+ exports.Publisher = __webpack_exports__.Publisher;
62
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
63
+ "Publisher"
64
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
65
+ Object.defineProperty(exports, '__esModule', {
66
+ value: true
67
+ });
@@ -0,0 +1,33 @@
1
+ class Publisher {
2
+ publish(payload) {
3
+ const subscriptions = this._subscriptions.slice();
4
+ subscriptions.forEach((subscription)=>{
5
+ if (subscription.isActive) subscription.handler(payload);
6
+ });
7
+ }
8
+ dispose() {
9
+ this._subscriptions.forEach((subscription)=>{
10
+ subscription.isActive = false;
11
+ });
12
+ this._subscriptions = [];
13
+ }
14
+ constructor(){
15
+ this._subscriptions = [];
16
+ this.listener = (handler)=>{
17
+ const subscription = {
18
+ handler,
19
+ isActive: true
20
+ };
21
+ this._subscriptions.push(subscription);
22
+ return {
23
+ dispose: ()=>{
24
+ if (!subscription.isActive) return;
25
+ subscription.isActive = false;
26
+ const index = this._subscriptions.indexOf(subscription);
27
+ if (-1 !== index) this._subscriptions.splice(index, 1);
28
+ }
29
+ };
30
+ };
31
+ }
32
+ }
33
+ export { Publisher };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A typed, implementation-free key for resolving an extension that provides a
3
+ * capability. Declared as a shared `const` next to the providing extension's
4
+ * interface:
5
+ *
6
+ * ```ts
7
+ * export interface FeatureFlagsExtension extends Extension { … }
8
+ * export const FeatureFlags: ExtensionToken<FeatureFlagsExtension> = { name: 'featureFlags' }
9
+ * ```
10
+ *
11
+ * A token holds no implementation, so importing one never pulls the provider's
12
+ * code into the consumer's bundle. The registry is keyed by token identity
13
+ * (the shared object reference), so provider and consumer must import the same
14
+ * exported token; `name` is for diagnostics only.
15
+ */
16
+ export interface ExtensionToken<T> {
17
+ /** Human-readable capability name used only for diagnostics. */
18
+ readonly name: string;
19
+ /** Phantom: carries the provided type for inference; never present at runtime. */
20
+ readonly __provides?: T;
21
+ }
package/dist/token.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.r = (exports1)=>{
5
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
6
+ value: 'Module'
7
+ });
8
+ Object.defineProperty(exports1, '__esModule', {
9
+ value: true
10
+ });
11
+ };
12
+ })();
13
+ var __webpack_exports__ = {};
14
+ __webpack_require__.r(__webpack_exports__);
15
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
16
+ Object.defineProperty(exports, '__esModule', {
17
+ value: true
18
+ });
package/dist/token.mjs ADDED
File without changes
package/package.json CHANGED
@@ -1,10 +1,47 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for @posthog/browser-common",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
3
+ "version": "0.1.0",
4
+ "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/PostHog/posthog-js.git",
9
+ "directory": "packages/browser-common"
10
+ },
11
+ "sideEffects": false,
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "main": "dist/index.js",
17
+ "module": "dist/index.mjs",
18
+ "types": "dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "require": "./dist/index.js",
23
+ "import": "./dist/index.mjs"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "@posthog/core": "^1.43.1"
28
+ },
29
+ "devDependencies": {
30
+ "@rslib/core": "0.10.6",
31
+ "@types/jest": "^29.5.14",
32
+ "jest": "29.7.0",
33
+ "ts-jest": "29.4.11",
34
+ "typescript": "5.8.2",
35
+ "@posthog-tooling/tsconfig-base": "1.1.1"
36
+ },
37
+ "scripts": {
38
+ "clean": "rimraf dist",
39
+ "lint": "eslint src tests",
40
+ "lint:fix": "eslint src tests --fix",
41
+ "build": "rslib build",
42
+ "dev": "rslib build -w",
43
+ "test:unit": "jest -c jest.config.cjs",
44
+ "check-types": "pnpm build",
45
+ "package": "pnpm pack --out $PACKAGE_DEST/%s.tgz"
46
+ }
47
+ }