Skip to content

Commit 95f95f5

Browse files
committed
Merge branch 'ld-main' into feat/svelte-sdk-example
2 parents e1ca46e + 6ad7e51 commit 95f95f5

File tree

6 files changed

+1132
-12
lines changed

6 files changed

+1132
-12
lines changed

.github/workflows/react-native-detox.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ on:
1616
- 'packages/shared/common/**'
1717
- 'packages/shared/sdk-client/**'
1818
- 'packages/sdk/react-native/**'
19-
19+
- '.github/**'
2020
jobs:
2121
detox-android:
22-
runs-on: ubuntu-latest
22+
runs-on: ubuntu-22.04
2323
permissions:
2424
id-token: write
2525
contents: read

packages/telemetry/browser-telemetry/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
"bugs": {
4444
"url": "https://github.com/launchdarkly/js-core/issues"
4545
},
46-
"dependencies": {
47-
"rrweb": "2.0.0-alpha.4",
48-
"tracekit": "^0.4.6"
49-
},
5046
"devDependencies": {
5147
"@jest/globals": "^29.7.0",
5248
"@launchdarkly/js-client-sdk": "0.3.2",

packages/telemetry/browser-telemetry/src/BrowserTelemetryImpl.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as TraceKit from 'tracekit';
2-
31
/**
42
* A limited selection of type information is provided by the browser client SDK.
53
* This is only a type dependency and these types should be compatible between
@@ -23,6 +21,7 @@ import makeInspectors from './inspectors';
2321
import { ParsedOptions, ParsedStackOptions } from './options';
2422
import randomUuidV4 from './randomUuidV4';
2523
import parse from './stack/StackParser';
24+
import { getTraceKit } from './vendor/TraceKit';
2625

2726
// TODO: Use a ring buffer for the breadcrumbs/pending events instead of shifting. (SDK-914)
2827

@@ -54,13 +53,18 @@ function safeValue(u: unknown): string | boolean | number | undefined {
5453
}
5554

5655
function configureTraceKit(options: ParsedStackOptions) {
56+
const TraceKit = getTraceKit();
5757
// Include before + after + source line.
5858
// TraceKit only takes a total context size, so we have to over capture and then reduce the lines.
5959
// So, for instance if before is 3 and after is 4 we need to capture 4 and 4 and then drop a line
6060
// from the before context.
6161
// The typing for this is a bool, but it accepts a number.
6262
const beforeAfterMax = Math.max(options.source.afterLines, options.source.beforeLines);
63-
(TraceKit as any).linesOfContext = beforeAfterMax * 2 + 1;
63+
// The assignment here has bene split to prevent esbuild from complaining about an assigment to
64+
// an import. TraceKit exports a single object and the interface requires modifying an exported
65+
// var.
66+
const anyObj = TraceKit as any;
67+
anyObj.linesOfContext = beforeAfterMax * 2 + 1;
6468
}
6569

6670
export default class BrowserTelemetryImpl implements BrowserTelemetry {
@@ -130,6 +134,7 @@ export default class BrowserTelemetryImpl implements BrowserTelemetry {
130134
this._pendingEvents.forEach((event) => {
131135
this._client?.track(event.type, event.data);
132136
});
137+
this._pendingEvents = [];
133138
}
134139

135140
inspectors(): LDInspection[] {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
import { BrowserTelemetry } from './api/BrowserTelemetry';
2+
import { Options } from './api/Options';
3+
import BrowserTelemetryImpl from './BrowserTelemetryImpl';
4+
import parse from './options';
5+
16
export * from './api';
7+
8+
export function initializeTelemetry(options?: Options): BrowserTelemetry {
9+
const parsedOptions = parse(options || {});
10+
return new BrowserTelemetryImpl(parsedOptions);
11+
}

packages/telemetry/browser-telemetry/src/stack/StackParser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { computeStackTrace } from 'tracekit';
2-
31
import { StackFrame } from '../api/stack/StackFrame';
42
import { StackTrace } from '../api/stack/StackTrace';
53
import { ParsedStackOptions } from '../options';
4+
import { getTraceKit } from '../vendor/TraceKit';
65

76
/**
87
* In the browser we will not always be able to determine the source file that code originates
@@ -195,7 +194,7 @@ export function getSrcLines(
195194
* @returns The stack trace for the given error.
196195
*/
197196
export default function parse(error: Error, options: ParsedStackOptions): StackTrace {
198-
const parsed = computeStackTrace(error);
197+
const parsed = getTraceKit().computeStackTrace(error);
199198
const frames: StackFrame[] = parsed.stack.reverse().map((inFrame) => ({
200199
fileName: processUrlToFileName(inFrame.url, window.location.origin),
201200
function: inFrame.func,

0 commit comments

Comments
 (0)