Skip to content

Commit 0b65d8a

Browse files
committed
chore: Scaffold browser telemetry
1 parent aee09c8 commit 0b65d8a

File tree

14 files changed

+292
-1
lines changed

14 files changed

+292
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: telemetry/browser-telemetry
2+
3+
on:
4+
push:
5+
branches: [main, 'feat/**']
6+
paths-ignore:
7+
- '**.md' #Do not need to run CI for markdown changes.
8+
pull_request:
9+
branches: [main, 'feat/**']
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
build-test-browser-telemetry:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20.x
21+
registry-url: 'https://registry.npmjs.org'
22+
- id: shared
23+
name: Shared CI Steps
24+
uses: ./actions/ci
25+
with:
26+
workspace_name: '@launchdarkly/browser-telemetry'
27+
workspace_path: packages/telemetry/browser-telemetry

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"packages/tooling/jest/example/react-native-example",
2626
"packages/sdk/browser",
2727
"packages/sdk/browser/contract-tests/entity",
28-
"packages/sdk/browser/contract-tests/adapter"
28+
"packages/sdk/browser/contract-tests/adapter",
29+
"packages/telemetry/browser-telemetry"
2930
],
3031
"private": true,
3132
"scripts": {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Telemetry integration for LaunchDarkly browser SDKs.
2+
3+
# ⛔️⛔️⛔️⛔️
4+
5+
> [!WARNING]
6+
> This is an alpha version. The API is not stabilized and will introduce breaking changes.
7+
8+
TODO Add badges
9+
10+
## LaunchDarkly overview
11+
12+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
13+
14+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
15+
16+
## Compatibility
17+
18+
TODO
19+
20+
## Setup
21+
22+
TODO
23+
24+
## Contributing
25+
26+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.
27+
28+
## About LaunchDarkly
29+
30+
- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
31+
- Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
32+
- Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
33+
- Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
34+
- Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan).
35+
- Disable parts of your application to facilitate maintenance, without taking everything offline.
36+
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
37+
- Explore LaunchDarkly
38+
- [launchdarkly.com](https://www.launchdarkly.com/ 'LaunchDarkly Main Website') for more information
39+
- [docs.launchdarkly.com](https://docs.launchdarkly.com/ 'LaunchDarkly Documentation') for our documentation and SDK reference guides
40+
- [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ 'LaunchDarkly API Documentation') for our API documentation
41+
- [blog.launchdarkly.com](https://blog.launchdarkly.com/ 'LaunchDarkly Blog Documentation') for the latest product updates
42+
43+
[node-otel-ci-badge]: https://github.com/launchdarkly/js-core/actions/workflows/node-otel.yml/badge.svg
44+
[node-otel-ci]: https://github.com/launchdarkly/js-core/actions/workflows/node-otel.yml
45+
[node-otel-npm-badge]: https://img.shields.io/npm/v/@launchdarkly/node-server-sdk-otel.svg?style=flat-square
46+
[node-otel-npm-link]: https://www.npmjs.com/package/@launchdarkly/node-server-sdk-otel
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
it('runs tests', () => {
2+
// Placeholder so CI can run tests.
3+
expect(true).toBeTruthy();
4+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"verbose": true,
3+
"testEnvironment": "jest-environment-jsdom",
4+
"testPathIgnorePatterns": ["./dist", "./src"],
5+
"testMatch": ["**.test.ts"],
6+
"setupFiles": ["./setup-jest.js"],
7+
"transform": {
8+
"^.+\\.ts$": [
9+
"ts-jest",
10+
{
11+
"tsConfig": "tsconfig.test.json"
12+
}
13+
],
14+
"^.+.tsx?$": ["ts-jest", {}]
15+
}
16+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "@launchdarkly/browser-telemetry",
3+
"version": "0.0.9",
4+
"type": "module",
5+
"main": "./dist/index.cjs",
6+
"module": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"require": {
11+
"types": "./dist/index.d.cts",
12+
"require": "./dist/index.cjs"
13+
},
14+
"import": {
15+
"types": "./dist/index.d.ts",
16+
"import": "./dist/index.js"
17+
}
18+
}
19+
},
20+
"files": [
21+
"dist"
22+
],
23+
"description": "Telemetry integration for LaunchDarkly browser SDKs.",
24+
"scripts": {
25+
"test": "npx jest --runInBand",
26+
"build": "tsup",
27+
"prettier": "prettier --write 'src/*.@(js|ts|tsx|json)'",
28+
"check": "yarn && yarn prettier && yarn lint && tsc && yarn test",
29+
"lint": "npx eslint . --ext .ts"
30+
},
31+
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/telemetry/browser-telemetry",
32+
"repository": {
33+
"type": "git",
34+
"url": "git+https://github.com/launchdarkly/js-core.git"
35+
},
36+
"keywords": [
37+
"launchdarkly",
38+
"analytics",
39+
"telemetry"
40+
],
41+
"license": "Apache-2.0",
42+
"bugs": {
43+
"url": "https://github.com/launchdarkly/js-core/issues"
44+
},
45+
"dependencies": {
46+
"rrweb": "2.0.0-alpha.4",
47+
"tracekit": "^0.4.6"
48+
},
49+
"peerDependencies": {
50+
"launchdarkly-js-client-sdk": "^3.4.0"
51+
},
52+
"devDependencies": {
53+
"@jest/globals": "^29.7.0",
54+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
55+
"@types/jest": "^29.5.11",
56+
"@typescript-eslint/eslint-plugin": "^6.20.0",
57+
"@typescript-eslint/parser": "^6.20.0",
58+
"eslint": "^8.45.0",
59+
"eslint-config-airbnb-base": "^15.0.0",
60+
"eslint-config-airbnb-typescript": "^17.1.0",
61+
"eslint-config-prettier": "^8.8.0",
62+
"eslint-plugin-import": "^2.27.5",
63+
"eslint-plugin-jest": "^27.6.3",
64+
"eslint-plugin-prettier": "^5.0.0",
65+
"jest": "^29.7.0",
66+
"jest-environment-jsdom": "^29.7.0",
67+
"launchdarkly-js-test-helpers": "^2.2.0",
68+
"prettier": "^3.0.0",
69+
"rimraf": "^5.0.5",
70+
"ts-jest": "^29.1.1",
71+
"tsup": "^8.3.5",
72+
"typedoc": "0.25.0",
73+
"typescript": "^5.5.3"
74+
}
75+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { TextEncoder, TextDecoder } = require('node:util');
2+
const crypto = require('node:crypto');
3+
4+
global.TextEncoder = TextEncoder;
5+
6+
Object.assign(window, { TextDecoder, TextEncoder });
7+
8+
// Based on:
9+
// https://stackoverflow.com/a/71750830
10+
11+
Object.defineProperty(global.self, 'crypto', {
12+
value: {
13+
getRandomValues: (arr) => crypto.randomBytes(arr.length),
14+
subtle: {
15+
digest: (algorithm, data) => {
16+
return new Promise((resolve) =>
17+
resolve(
18+
crypto.createHash(algorithm.toLowerCase().replace('-', '')).update(data).digest(),
19+
),
20+
);
21+
},
22+
},
23+
},
24+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Empty function for typedoc.
3+
*/
4+
export function empty() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["/**/*.ts", "/**/*.tsx"],
4+
"exclude": ["node_modules"]
5+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"declaration": true,
5+
"declarationMap": true,
6+
"lib": ["ES2017", "dom"],
7+
"module": "ESNext",
8+
"moduleResolution": "node",
9+
"noImplicitOverride": true,
10+
"resolveJsonModule": true,
11+
"rootDir": ".",
12+
"outDir": "dist",
13+
"skipLibCheck": true,
14+
"sourceMap": false,
15+
"strict": true,
16+
"stripInternal": true,
17+
"target": "ES2017",
18+
"types": ["node", "jest"],
19+
"allowJs": true
20+
},
21+
"include": ["src"],
22+
"exclude": [
23+
"vite.config.ts",
24+
"__tests__",
25+
"dist",
26+
"docs",
27+
"example",
28+
"node_modules",
29+
"babel.config.js",
30+
"setup-jest.js",
31+
"rollup.config.js",
32+
"**/*.test.ts*"
33+
]
34+
}

0 commit comments

Comments
 (0)