@volley/vwr-loader 1.0.6 → 1.2.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.
Files changed (102) hide show
  1. package/README.md +7 -8
  2. package/dist/__mocks__/@datadog/browser-logs.d.ts +58 -0
  3. package/dist/__mocks__/@datadog/browser-logs.d.ts.map +1 -0
  4. package/dist/__mocks__/@datadog/browser-logs.js +34 -0
  5. package/dist/__mocks__/@datadog/browser-logs.js.map +1 -0
  6. package/dist/__mocks__/@datadog/browser-rum.d.ts +25 -0
  7. package/dist/__mocks__/@datadog/browser-rum.d.ts.map +1 -0
  8. package/dist/__mocks__/@datadog/browser-rum.js +25 -0
  9. package/dist/__mocks__/@datadog/browser-rum.js.map +1 -0
  10. package/dist/amplitudeFlagFetcher.d.ts +8 -3
  11. package/dist/amplitudeFlagFetcher.d.ts.map +1 -1
  12. package/dist/amplitudeFlagFetcher.js +14 -12
  13. package/dist/amplitudeFlagFetcher.js.map +1 -1
  14. package/dist/assets/profiler-BRmTNL9s.js +2 -0
  15. package/dist/assets/profiler-BRmTNL9s.js.map +1 -0
  16. package/dist/assets/startRecording-CuFdVhxx.js +3 -0
  17. package/dist/assets/startRecording-CuFdVhxx.js.map +1 -0
  18. package/dist/cli.js +47 -34
  19. package/dist/cli.js.map +1 -1
  20. package/dist/datadog.d.ts +19 -0
  21. package/dist/datadog.d.ts.map +1 -0
  22. package/dist/datadog.js +39 -0
  23. package/dist/datadog.js.map +1 -0
  24. package/dist/envDefaults.d.ts.map +1 -1
  25. package/dist/envDefaults.js +27 -12
  26. package/dist/envDefaults.js.map +1 -1
  27. package/dist/errors/InitializationError.d.ts +74 -0
  28. package/dist/errors/InitializationError.d.ts.map +1 -0
  29. package/dist/errors/InitializationError.js +77 -0
  30. package/dist/errors/InitializationError.js.map +1 -0
  31. package/dist/errors/ensureError.d.ts +2 -0
  32. package/dist/errors/ensureError.d.ts.map +1 -0
  33. package/dist/errors/ensureError.js +7 -0
  34. package/dist/errors/ensureError.js.map +1 -0
  35. package/dist/errors/index.d.ts +12 -0
  36. package/dist/errors/index.d.ts.map +1 -0
  37. package/dist/errors/index.js +10 -0
  38. package/dist/errors/index.js.map +1 -0
  39. package/dist/getDeviceId.d.ts +1 -32
  40. package/dist/getDeviceId.d.ts.map +1 -1
  41. package/dist/getDeviceId.js +18 -16
  42. package/dist/getDeviceId.js.map +1 -1
  43. package/dist/getEnvironment.d.ts +3 -4
  44. package/dist/getEnvironment.d.ts.map +1 -1
  45. package/dist/getEnvironment.js +11 -6
  46. package/dist/getEnvironment.js.map +1 -1
  47. package/dist/getShellVersion.d.ts +2 -20
  48. package/dist/getShellVersion.d.ts.map +1 -1
  49. package/dist/getShellVersion.js +41 -8
  50. package/dist/getShellVersion.js.map +1 -1
  51. package/dist/index.d.ts +0 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/loadVwr.d.ts +4 -4
  55. package/dist/loadVwr.d.ts.map +1 -1
  56. package/dist/loadVwr.js +151 -37
  57. package/dist/loadVwr.js.map +1 -1
  58. package/dist/logger.d.ts +11 -6
  59. package/dist/logger.d.ts.map +1 -1
  60. package/dist/logger.js +107 -4
  61. package/dist/logger.js.map +1 -1
  62. package/dist/main.js +9 -1
  63. package/dist/main.js.map +1 -1
  64. package/dist/test-setup.d.ts +2 -0
  65. package/dist/test-setup.d.ts.map +1 -0
  66. package/dist/test-setup.js +5 -0
  67. package/dist/test-setup.js.map +1 -0
  68. package/dist/types.d.ts +87 -0
  69. package/dist/types.d.ts.map +1 -0
  70. package/dist/types.js +5 -0
  71. package/dist/types.js.map +1 -0
  72. package/dist/vwrConfig.d.ts +14 -2
  73. package/dist/vwrConfig.d.ts.map +1 -1
  74. package/dist/vwrConfig.js +74 -29
  75. package/dist/vwrConfig.js.map +1 -1
  76. package/package.json +59 -53
  77. package/src/__mocks__/@datadog/browser-logs.ts +35 -0
  78. package/src/__mocks__/@datadog/browser-rum.ts +27 -0
  79. package/src/amplitudeFlagFetcher.test.ts +28 -34
  80. package/src/amplitudeFlagFetcher.ts +22 -14
  81. package/src/datadog.ts +55 -0
  82. package/src/envDefaults.ts +32 -13
  83. package/src/errors/InitializationError.ts +105 -0
  84. package/src/errors/ensureError.ts +6 -0
  85. package/src/errors/index.ts +16 -0
  86. package/src/getDeviceId.test.ts +29 -23
  87. package/src/getDeviceId.ts +25 -72
  88. package/src/getEnvironment.test.ts +68 -108
  89. package/src/getEnvironment.ts +12 -8
  90. package/src/getShellVersion.test.ts +134 -9
  91. package/src/getShellVersion.ts +44 -26
  92. package/src/index.ts +0 -1
  93. package/src/loadVwr.test.ts +394 -0
  94. package/src/loadVwr.ts +243 -58
  95. package/src/logger.ts +118 -11
  96. package/src/main.test.ts +157 -0
  97. package/src/main.ts +79 -11
  98. package/src/test-setup.ts +5 -0
  99. package/src/types.ts +88 -0
  100. package/src/vite-env.d.ts +2 -0
  101. package/src/vwrConfig.test.ts +104 -34
  102. package/src/vwrConfig.ts +115 -37
package/README.md CHANGED
@@ -36,8 +36,8 @@ pnpm build-loader --platform IOS_MOBILE --env dev --output ./dist-ios
36
36
  - `--env`: Environment (`local`, `dev`, `staging`, `prod`)
37
37
  - `--output`: Output directory for `index.html` and `main.js`
38
38
  - `--hubUrl`: Override Hub URL (optional)
39
- - `--vwrUrl`: Override VWR URL (optional)
40
39
  - `--amplitudeKey`: Override Amplitude deployment key (optional)
40
+ - `--configUrl`: Override VWR Config URL (optional)
41
41
 
42
42
  ### Fetching Amplitude Flags
43
43
 
@@ -66,11 +66,11 @@ The package includes a `vwr-loader.html` template that can be used as the entry
66
66
  3. Handles device ID resolution across platforms
67
67
  4. Validates that build-time config was properly injected
68
68
 
69
- **Build-time placeholders** (must be replaced during build):
70
- - `__PLATFORM__` - Platform name (samsung-tv, lg-tv, firetv, etc.)
71
- - `__AMPLITUDE_KEY__` - Amplitude deployment key
72
- - `__HUB_URL__` - Hub application URL
73
- - `__VWR_URL__` - Default VWR bundle URL
69
+ **Build-time configuration** (injected via Vite `define`):
70
+ - `VITE_PLATFORM` - Platform name (SAMSUNG_TV, LG_TV, FIRE_TV, etc.)
71
+ - `VITE_AMPLITUDE_DEPLOYMENT_KEY` - Amplitude deployment key
72
+ - `VITE_HUB_URL` - Hub application URL
73
+ - `VITE_CONFIG_URL` - VWR config base URL
74
74
 
75
75
  ## CLI: build-loader
76
76
 
@@ -93,7 +93,6 @@ npx build-loader --platform <platform> --output <path> [--env <env>] [options]
93
93
  |--------|-------------|
94
94
  | `--env` | Environment: `local`, `dev`, `staging`, `prod` |
95
95
  | `--hubUrl` | Override Hub URL |
96
- | `--vwrUrl` | Override VWR URL |
97
96
  | `--configUrl` | Override VWR Config URL |
98
97
  | `--configFile` | Override VWR Config filename |
99
98
  | `--amplitudeKey` | Override Amplitude deployment key |
@@ -139,7 +138,7 @@ Requires Chrome 66+ or equivalent browser with support for:
139
138
  - Fetch API
140
139
  - async/await
141
140
  - AbortController
142
- - crypto.randomUUID (for fallback device ID generation)
141
+ - uuidv4 library (for fallback device ID generation)
143
142
 
144
143
  ## API Reference
145
144
 
@@ -0,0 +1,58 @@
1
+ export declare const datadogLogs: {
2
+ init: import("vitest").Mock<any, any>;
3
+ logger: {
4
+ debug: import("vitest").Mock<any, any>;
5
+ info: import("vitest").Mock<any, any>;
6
+ warn: import("vitest").Mock<any, any>;
7
+ error: import("vitest").Mock<any, any>;
8
+ log: import("vitest").Mock<any, any>;
9
+ setLevel: import("vitest").Mock<any, any>;
10
+ setHandler: import("vitest").Mock<any, any>;
11
+ setContext: import("vitest").Mock<any, any>;
12
+ addContext: import("vitest").Mock<any, any>;
13
+ removeContext: import("vitest").Mock<any, any>;
14
+ clearContext: import("vitest").Mock<any, any>;
15
+ getContext: import("vitest").Mock<[], {}>;
16
+ };
17
+ createLogger: import("vitest").Mock<[], {
18
+ debug: import("vitest").Mock<any, any>;
19
+ info: import("vitest").Mock<any, any>;
20
+ warn: import("vitest").Mock<any, any>;
21
+ error: import("vitest").Mock<any, any>;
22
+ log: import("vitest").Mock<any, any>;
23
+ setLevel: import("vitest").Mock<any, any>;
24
+ setHandler: import("vitest").Mock<any, any>;
25
+ setContext: import("vitest").Mock<any, any>;
26
+ addContext: import("vitest").Mock<any, any>;
27
+ removeContext: import("vitest").Mock<any, any>;
28
+ clearContext: import("vitest").Mock<any, any>;
29
+ getContext: import("vitest").Mock<[], {}>;
30
+ }>;
31
+ getLogger: import("vitest").Mock<[], {
32
+ debug: import("vitest").Mock<any, any>;
33
+ info: import("vitest").Mock<any, any>;
34
+ warn: import("vitest").Mock<any, any>;
35
+ error: import("vitest").Mock<any, any>;
36
+ log: import("vitest").Mock<any, any>;
37
+ setLevel: import("vitest").Mock<any, any>;
38
+ setHandler: import("vitest").Mock<any, any>;
39
+ setContext: import("vitest").Mock<any, any>;
40
+ addContext: import("vitest").Mock<any, any>;
41
+ removeContext: import("vitest").Mock<any, any>;
42
+ clearContext: import("vitest").Mock<any, any>;
43
+ getContext: import("vitest").Mock<[], {}>;
44
+ }>;
45
+ setUser: import("vitest").Mock<any, any>;
46
+ setUserProperty: import("vitest").Mock<any, any>;
47
+ removeUserProperty: import("vitest").Mock<any, any>;
48
+ clearUser: import("vitest").Mock<any, any>;
49
+ getUser: import("vitest").Mock<[], {}>;
50
+ setGlobalContext: import("vitest").Mock<any, any>;
51
+ setGlobalContextProperty: import("vitest").Mock<any, any>;
52
+ removeGlobalContextProperty: import("vitest").Mock<any, any>;
53
+ clearGlobalContext: import("vitest").Mock<any, any>;
54
+ getGlobalContext: import("vitest").Mock<[], {}>;
55
+ getInitConfiguration: import("vitest").Mock<[], {}>;
56
+ getInternalContext: import("vitest").Mock<[], {}>;
57
+ };
58
+ //# sourceMappingURL=browser-logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-logs.d.ts","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-logs.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBvB,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { vi } from "vitest";
2
+ const mockLogger = {
3
+ debug: vi.fn(),
4
+ info: vi.fn(),
5
+ warn: vi.fn(),
6
+ error: vi.fn(),
7
+ log: vi.fn(),
8
+ setLevel: vi.fn(),
9
+ setHandler: vi.fn(),
10
+ setContext: vi.fn(),
11
+ addContext: vi.fn(),
12
+ removeContext: vi.fn(),
13
+ clearContext: vi.fn(),
14
+ getContext: vi.fn(() => ({})),
15
+ };
16
+ export const datadogLogs = {
17
+ init: vi.fn(),
18
+ logger: mockLogger,
19
+ createLogger: vi.fn(() => mockLogger),
20
+ getLogger: vi.fn(() => mockLogger),
21
+ setUser: vi.fn(),
22
+ setUserProperty: vi.fn(),
23
+ removeUserProperty: vi.fn(),
24
+ clearUser: vi.fn(),
25
+ getUser: vi.fn(() => ({})),
26
+ setGlobalContext: vi.fn(),
27
+ setGlobalContextProperty: vi.fn(),
28
+ removeGlobalContextProperty: vi.fn(),
29
+ clearGlobalContext: vi.fn(),
30
+ getGlobalContext: vi.fn(() => ({})),
31
+ getInitConfiguration: vi.fn(() => ({})),
32
+ getInternalContext: vi.fn(() => ({})),
33
+ };
34
+ //# sourceMappingURL=browser-logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-logs.js","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3B,MAAM,UAAU,GAAG;IACf,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE,CAAC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AAC,CAAC,EAAE,CAAC,CAAC;CACxC,CAAA"}
@@ -0,0 +1,25 @@
1
+ export declare const datadogRum: {
2
+ init: import("vitest").Mock<any, any>;
3
+ startSessionReplayRecording: import("vitest").Mock<any, any>;
4
+ stopSessionReplayRecording: import("vitest").Mock<any, any>;
5
+ addAction: import("vitest").Mock<any, any>;
6
+ addError: import("vitest").Mock<any, any>;
7
+ addTiming: import("vitest").Mock<any, any>;
8
+ setUser: import("vitest").Mock<any, any>;
9
+ setUserProperty: import("vitest").Mock<any, any>;
10
+ removeUserProperty: import("vitest").Mock<any, any>;
11
+ clearUser: import("vitest").Mock<any, any>;
12
+ setGlobalContext: import("vitest").Mock<any, any>;
13
+ setGlobalContextProperty: import("vitest").Mock<any, any>;
14
+ removeGlobalContextProperty: import("vitest").Mock<any, any>;
15
+ clearGlobalContext: import("vitest").Mock<any, any>;
16
+ getGlobalContext: import("vitest").Mock<[], {}>;
17
+ getUser: import("vitest").Mock<[], {}>;
18
+ getInitConfiguration: import("vitest").Mock<[], {}>;
19
+ getInternalContext: import("vitest").Mock<[], {}>;
20
+ addFeatureFlagEvaluation: import("vitest").Mock<any, any>;
21
+ startView: import("vitest").Mock<any, any>;
22
+ stopView: import("vitest").Mock<any, any>;
23
+ };
24
+ export type RumGlobal = typeof datadogRum;
25
+ //# sourceMappingURL=browser-rum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-rum.d.ts","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-rum.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;CAsBtB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { vi } from "vitest";
2
+ export const datadogRum = {
3
+ init: vi.fn(),
4
+ startSessionReplayRecording: vi.fn(),
5
+ stopSessionReplayRecording: vi.fn(),
6
+ addAction: vi.fn(),
7
+ addError: vi.fn(),
8
+ addTiming: vi.fn(),
9
+ setUser: vi.fn(),
10
+ setUserProperty: vi.fn(),
11
+ removeUserProperty: vi.fn(),
12
+ clearUser: vi.fn(),
13
+ setGlobalContext: vi.fn(),
14
+ setGlobalContextProperty: vi.fn(),
15
+ removeGlobalContextProperty: vi.fn(),
16
+ clearGlobalContext: vi.fn(),
17
+ getGlobalContext: vi.fn(() => ({})),
18
+ getUser: vi.fn(() => ({})),
19
+ getInitConfiguration: vi.fn(() => ({})),
20
+ getInternalContext: vi.fn(() => ({})),
21
+ addFeatureFlagEvaluation: vi.fn(),
22
+ startView: vi.fn(),
23
+ stopView: vi.fn(),
24
+ };
25
+ //# sourceMappingURL=browser-rum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-rum.js","sourceRoot":"","sources":["../../../src/__mocks__/@datadog/browser-rum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3B,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,2BAA2B,EAAE,EAAE,CAAC,EAAE,EAAE;IACpC,0BAA0B,EAAE,EAAE,CAAC,EAAE,EAAE;IACnC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;IACjB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;IAChB,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;IACxB,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;IACzB,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;IACjC,2BAA2B,EAAE,EAAE,CAAC,EAAE,EAAE;IACpC,kBAAkB,EAAE,EAAE,CAAC,EAAE,EAAE;IAC3B,gBAAgB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACnC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1B,oBAAoB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACvC,kBAAkB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,wBAAwB,EAAE,EAAE,CAAC,EAAE,EAAE;IACjC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;IAClB,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE;CACpB,CAAA"}
@@ -1,4 +1,3 @@
1
- import { type Logger } from "./logger";
2
1
  export interface AmplitudeConfig {
3
2
  apiKey: string;
4
3
  apiUrl?: string;
@@ -7,6 +6,11 @@ export interface AmplitudeConfig {
7
6
  export interface FlagResult {
8
7
  "vwr-enabled": boolean;
9
8
  }
9
+ export declare class FlagFetchError extends Error {
10
+ readonly cause?: Error | undefined;
11
+ readonly name = "FlagFetchError";
12
+ constructor(message: string, cause?: Error | undefined);
13
+ }
10
14
  /**
11
15
  * Fetch feature flags from Amplitude Experiment REST API.
12
16
  *
@@ -19,7 +23,8 @@ export interface FlagResult {
19
23
  * @param config - Amplitude configuration
20
24
  * @param shellVersion - Shell version for flag targeting
21
25
  * @param logger - Optional logger, defaults to console
22
- * @returns Flag values with safe defaults on error
26
+ * @returns Flag values on success
27
+ * @throws FlagFetchError on timeout or network error
23
28
  */
24
- export declare function fetchAmplitudeFlags(deviceId: string, platform: string, config: AmplitudeConfig, shellVersion: string, logger?: Logger): Promise<FlagResult>;
29
+ export declare function fetchAmplitudeFlags(deviceId: string, platform: string, config: AmplitudeConfig, shellVersion: string): Promise<FlagResult>;
25
30
  //# sourceMappingURL=amplitudeFlagFetcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"amplitudeFlagFetcher.d.ts","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACvB,aAAa,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,EACpB,MAAM,GAAE,MAAsB,GAC/B,OAAO,CAAC,UAAU,CAAC,CAgErB"}
1
+ {"version":3,"file":"amplitudeFlagFetcher.d.ts","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,UAAU;IACvB,aAAa,EAAE,OAAO,CAAA;CACzB;AAED,qBAAa,cAAe,SAAQ,KAAK;aAKjB,KAAK,CAAC,EAAE,KAAK;IAJjC,SAAgB,IAAI,oBAAmB;gBAGnC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,KAAK,YAAA;CAKpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACrC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,UAAU,CAAC,CA8DrB"}
@@ -1,4 +1,11 @@
1
- import { defaultLogger } from "./logger";
1
+ export class FlagFetchError extends Error {
2
+ constructor(message, cause) {
3
+ super(message);
4
+ this.cause = cause;
5
+ this.name = "FlagFetchError";
6
+ Object.setPrototypeOf(this, FlagFetchError.prototype);
7
+ }
8
+ }
2
9
  /**
3
10
  * Fetch feature flags from Amplitude Experiment REST API.
4
11
  *
@@ -11,9 +18,10 @@ import { defaultLogger } from "./logger";
11
18
  * @param config - Amplitude configuration
12
19
  * @param shellVersion - Shell version for flag targeting
13
20
  * @param logger - Optional logger, defaults to console
14
- * @returns Flag values with safe defaults on error
21
+ * @returns Flag values on success
22
+ * @throws FlagFetchError on timeout or network error
15
23
  */
16
- export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersion, logger = defaultLogger) {
24
+ export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersion) {
17
25
  var _a, _b, _c;
18
26
  const { apiKey, apiUrl = "https://api.lab.amplitude.com/v1/vardata", timeout = 2000, } = config;
19
27
  // Build context with user_properties
@@ -51,17 +59,11 @@ export async function fetchAmplitudeFlags(deviceId, platform, config, shellVersi
51
59
  }
52
60
  catch (error) {
53
61
  clearTimeout(timeoutId);
54
- // Provide clear warning message for abort vs other errors
62
+ // Provide clear error message for abort vs other errors
55
63
  if (error instanceof Error && error.name === "AbortError") {
56
- logger.warn(`[Shell] Amplitude flag fetch aborted because it took longer than ${timeout}ms`);
57
- }
58
- else {
59
- logger.warn("[Shell] Amplitude flag fetch failed:", { error });
64
+ throw new FlagFetchError(`Amplitude flag fetch timed out after ${timeout}ms`);
60
65
  }
61
- // Return safe defaults - runs legacy path
62
- return {
63
- "vwr-enabled": false,
64
- };
66
+ throw new FlagFetchError("Amplitude flag fetch failed", error instanceof Error ? error : undefined);
65
67
  }
66
68
  }
67
69
  //# sourceMappingURL=amplitudeFlagFetcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"amplitudeFlagFetcher.js","sourceRoot":"","sources":["../src/amplitudeFlagFetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA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AC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC7C,CAAA;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ var $=Object.defineProperty,J=Object.defineProperties;var K=Object.getOwnPropertyDescriptors;var E=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var N=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,M=(e,t)=>{for(var n in t||(t={}))R.call(t,n)&&N(e,n,t[n]);if(E)for(var n of E(t))j.call(t,n)&&N(e,n,t[n]);return e},V=(e,t)=>J(e,K(t));var A=(e,t)=>{var n={};for(var s in e)R.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&E)for(var s of E(e))t.indexOf(s)<0&&j.call(e,s)&&(n[s]=e[s]);return n};import{V as W,Y as B,Z as ee,X as te,_ as ne,$ as se,a0 as k,w as L,a1 as re,a2 as ae,Q as oe,a3 as F,O as ie,l as ce,a4 as le}from"../main.js";function ue(e,t,n,s){const u=o=>{t.notify(14,{error:o}),te("Error reported to customer",{"error.message":o.message})},f=W([e.profilingEndpointBuilder],u),p=n(s);return{async send(g){var v=g,{event:o}=v,P=A(v,["event"]);const a=new FormData,m=B(o);if(!m)throw new Error("Failed to serialize event");a.append("event",new Blob([m],{type:"application/json"}),"event.json");let y=m.length;for(const[w,I]of ee(P)){const d=B(I);if(!d)throw new Error("Failed to serialize attachment");const h=await de(p,d);y+=h.outputBytesCount,a.append(w,new Blob([h.output]),w)}f.send({data:a,bytesCount:y})}}}function de(e,t){return new Promise(n=>{e.write(t),e.finish(s=>{n(s)})})}function fe(e){let t=0;for(const n of e)n.stackId!==void 0&&t++;return t}const pe=/\/(?![vV]\d{1,2}\/)([^/\d?]*\d+[^/?]*)/g;function me(e){return e?e.replace(pe,"/?"):"/"}const U=(e,t)=>e||me(t);function ve(e,t,n){const s={application:{id:t}};n&&(s.session={id:n});const{ids:u,names:f}=we(e.views);u.length&&(s.view={id:u,name:f});const p=e.longTasks.map(o=>o.id).filter(o=>o!==void 0);return p.length&&(s.long_task={id:p}),s}function we(e){const t={ids:[],names:[]};for(const n of e)t.ids.push(n.viewId),n.viewName&&t.names.push(n.viewName);return t.names=Array.from(new Set(t.names)),t}function he(e,t,n){return{event:be(e,t,n),"wall-time.json":e}}function be(e,t,n){const s=ne(t),u=ve(e,t.applicationId,n),f=ge(s);return V(M({},u),{attachments:["wall-time.json"],start:new Date(e.startClocks.timeStamp).toISOString(),end:new Date(e.endClocks.timeStamp).toISOString(),family:"chrome",runtime:"chrome",format:"json",version:4,tags_profiler:f.join(","),_dd:{clock_drift:se()}})}function ge(e){return e.concat(["language:javascript","runtime:chrome","family:chrome","host:browser"])}const ye={sampleIntervalMs:10,collectIntervalMs:6e4,minProfileDurationMs:5e3,minNumberOfSamples:50};function Pe(e,t,n,s,u,f,p,o=ye){const P=ue(e,t,f,6);let g;const v=[];let a={state:"stopped",stateReason:"initializing"};t.subscribe(9,()=>{w("session-expired").catch(k)}),t.subscribe(10,()=>{a.state==="stopped"&&a.stateReason==="session-expired"&&m()});function m(){if(a.state==="running")return;const r=p.findView();g=r?{startClocks:r.startClocks,viewId:r.id,viewName:U(r.name,document.location.pathname)}:void 0,v.push(L(e,window,"visibilitychange",C).stop,L(e,window,"beforeunload",q).stop),d()}async function y(){await w("stopped-by-user")}async function w(r){await z(r),v.forEach(i=>i()),s.set({status:"stopped",error_reason:void 0})}function I(r){if(r.state==="running")return{cleanupTasks:r.cleanupTasks};const i=[],l=t.subscribe(2,c=>{const b={viewId:c.id,viewName:U(c.name,document.location.pathname),startClocks:c.startClocks};S(b),g=b});return i.push(l.unsubscribe),{cleanupTasks:i}}function d(){const r=re().Profiler;if(!r)throw s.set({status:"error",error_reason:"not-supported-by-browser"}),new Error("RUM Profiler is not supported in this browser.");h(a).catch(k);const{cleanupTasks:i}=I(a);let l;try{l=new r({sampleInterval:o.sampleIntervalMs,maxBufferSize:Math.round(o.collectIntervalMs*1.5/o.sampleIntervalMs)})}catch(c){c instanceof Error&&c.message.includes("disabled by Document Policy")?(ae.warn("[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.",c),s.set({status:"error",error_reason:"missing-document-policy-header"})):s.set({status:"error",error_reason:"unexpected-exception"});return}s.set({status:"running",error_reason:void 0}),a={state:"running",startClocks:F(),profiler:l,timeoutId:oe(d,o.collectIntervalMs),views:[],cleanupTasks:i,longTasks:[]},S(g),l.addEventListener("samplebufferfull",D)}async function h(r){if(r.state!=="running")return;ie(r.timeoutId),r.profiler.removeEventListener("samplebufferfull",D);const{startClocks:i,views:l}=r;await r.profiler.stop().then(c=>{const b=F(),_=ce(i.timeStamp,b.timeStamp),O=u.findLongTasks(i.relative,_),Y=_<o.minProfileDurationMs,Z=fe(c.samples)<o.minNumberOfSamples;O.length===0&&(Y||Z)||x(Object.assign(c,{startClocks:i,endClocks:b,clocksOrigin:le(),longTasks:O,views:l,sampleInterval:o.sampleIntervalMs}))}).catch(k)}async function z(r){a.state==="running"&&(await T(),a={state:"stopped",stateReason:r})}async function H(){a.state==="running"&&(await T(),a={state:"paused"})}async function T(){a.state==="running"&&(a.cleanupTasks.forEach(r=>r()),await h(a))}function S(r){a.state!=="running"||!r||a.views.push(r)}function x(r){var i;const l=(i=n.findTrackedSession())===null||i===void 0?void 0:i.id,c=he(r,e,l);P.send(c)}function D(){d()}function C(){document.visibilityState==="hidden"&&a.state==="running"?H().catch(k):document.visibilityState==="visible"&&a.state==="paused"&&d()}function q(){d()}function G(){return a.state==="stopped"}function X(){return a.state==="running"}function Q(){return a.state==="paused"}return{start:m,stop:y,isStopped:G,isRunning:X,isPaused:Q}}export{ye as DEFAULT_RUM_PROFILER_CONFIGURATION,Pe as createRumProfiler};
2
+ //# sourceMappingURL=profiler-BRmTNL9s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiler-BRmTNL9s.js","sources":["../../../../node_modules/.pnpm/@datadog+browser-rum-core@6.25.2/node_modules/@datadog/browser-rum-core/esm/transport/formDataTransport.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getNumberOfSamples.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getDefaultViewName.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/utils/getCustomOrDefaultViewName.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/transport/buildProfileEventAttributes.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/transport/assembly.js","../../../../node_modules/.pnpm/@datadog+browser-rum@6.25.2_@datadog+browser-logs@6.25.2/node_modules/@datadog/browser-rum/esm/domain/profiling/profiler.js"],"sourcesContent":["import { addTelemetryDebug, createHttpRequest, jsonStringify, objectEntries } from '@datadog/browser-core';\nexport function createFormDataTransport(configuration, lifeCycle, createEncoder, streamId) {\n const reportError = (error) => {\n lifeCycle.notify(14 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error });\n // monitor-until: forever, to keep an eye on the errors reported to customers\n addTelemetryDebug('Error reported to customer', { 'error.message': error.message });\n };\n const httpRequest = createHttpRequest([configuration.profilingEndpointBuilder], reportError);\n const encoder = createEncoder(streamId);\n return {\n async send({ event, ...attachments }) {\n const formData = new FormData();\n const serializedEvent = jsonStringify(event);\n if (!serializedEvent) {\n throw new Error('Failed to serialize event');\n }\n formData.append('event', new Blob([serializedEvent], { type: 'application/json' }), 'event.json');\n let bytesCount = serializedEvent.length;\n for (const [key, value] of objectEntries(attachments)) {\n const serializedValue = jsonStringify(value);\n if (!serializedValue) {\n throw new Error('Failed to serialize attachment');\n }\n const result = await encode(encoder, serializedValue);\n bytesCount += result.outputBytesCount;\n formData.append(key, new Blob([result.output]), key);\n }\n httpRequest.send({\n data: formData,\n bytesCount,\n });\n },\n };\n}\nfunction encode(encoder, data) {\n return new Promise((resolve) => {\n encoder.write(data);\n encoder.finish((encoderResult) => {\n resolve(encoderResult);\n });\n });\n}\n//# sourceMappingURL=formDataTransport.js.map","/**\n * Counts number of samples when the thread was not idle (stackId is defined)\n *\n * @param samples - Array of collected samples\n * @returns Number of samples\n */\nexport function getNumberOfSamples(samples) {\n let numberOfSamples = 0;\n for (const sample of samples) {\n if (sample.stackId !== undefined) {\n numberOfSamples++;\n }\n }\n return numberOfSamples;\n}\n//# sourceMappingURL=getNumberOfSamples.js.map","// This is the regex used to extract the path from the url (from SimpleUrlGroupingProcessor.java)\n// It's a bit different from the one in the java code because we removed the lookbehind unsupported by Safari.\nconst PATH_MIXED_ALPHANUMERICS = /\\/(?![vV]\\d{1,2}\\/)([^/\\d?]*\\d+[^/?]*)/g;\nexport function getDefaultViewName(viewPathUrl) {\n if (!viewPathUrl) {\n return '/';\n }\n // Replace all the mixed alphanumerics with a ?\n return viewPathUrl.replace(PATH_MIXED_ALPHANUMERICS, '/?');\n}\n//# sourceMappingURL=getDefaultViewName.js.map","import { getDefaultViewName } from './getDefaultViewName';\nexport const getCustomOrDefaultViewName = (customViewName, viewPathUrl) => customViewName || getDefaultViewName(viewPathUrl);\n//# sourceMappingURL=getCustomOrDefaultViewName.js.map","/**\n * Builds attributes for the Profile Event.\n *\n * @param profilerTrace - Profiler trace\n * @param applicationId - application id.\n * @param sessionId - session id.\n * @returns Additional attributes.\n */\nexport function buildProfileEventAttributes(profilerTrace, applicationId, sessionId) {\n const attributes = {\n application: {\n id: applicationId,\n },\n };\n if (sessionId) {\n attributes.session = {\n id: sessionId,\n };\n }\n // Extract view ids and names from the profiler trace and add them as attributes of the profile event.\n // This will be used to filter the profiles by @view.id and/or @view.name.\n const { ids, names } = extractViewIdsAndNames(profilerTrace.views);\n if (ids.length) {\n attributes.view = {\n id: ids,\n name: names,\n };\n }\n const longTaskIds = profilerTrace.longTasks.map((longTask) => longTask.id).filter((id) => id !== undefined);\n if (longTaskIds.length) {\n attributes.long_task = { id: longTaskIds };\n }\n return attributes;\n}\nfunction extractViewIdsAndNames(views) {\n const result = { ids: [], names: [] };\n for (const view of views) {\n result.ids.push(view.viewId);\n if (view.viewName) {\n result.names.push(view.viewName);\n }\n }\n // Remove duplicates\n result.names = Array.from(new Set(result.names));\n return result;\n}\n//# sourceMappingURL=buildProfileEventAttributes.js.map","import { buildTags, currentDrift } from '@datadog/browser-core';\nimport { buildProfileEventAttributes } from './buildProfileEventAttributes';\nexport function assembleProfilingPayload(profilerTrace, configuration, sessionId) {\n const event = buildProfileEvent(profilerTrace, configuration, sessionId);\n return {\n event,\n 'wall-time.json': profilerTrace,\n };\n}\nfunction buildProfileEvent(profilerTrace, configuration, sessionId) {\n const tags = buildTags(configuration); // TODO: get that from the tagContext hook\n const profileAttributes = buildProfileEventAttributes(profilerTrace, configuration.applicationId, sessionId);\n const profileEventTags = buildProfileEventTags(tags);\n const profileEvent = {\n ...profileAttributes,\n attachments: ['wall-time.json'],\n start: new Date(profilerTrace.startClocks.timeStamp).toISOString(),\n end: new Date(profilerTrace.endClocks.timeStamp).toISOString(),\n family: 'chrome',\n runtime: 'chrome',\n format: 'json',\n version: 4, // Ingestion event version (not the version application tag)\n tags_profiler: profileEventTags.join(','),\n _dd: {\n clock_drift: currentDrift(),\n },\n };\n return profileEvent;\n}\n/**\n * Builds tags for the Profile Event.\n *\n * @param tags - RUM tags\n * @returns Combined tags for the Profile Event.\n */\nfunction buildProfileEventTags(tags) {\n // Tags already contains the common tags for all events. (service, env, version, etc.)\n // Here we are adding some specific-to-profiling tags.\n const profileEventTags = tags.concat(['language:javascript', 'runtime:chrome', 'family:chrome', 'host:browser']);\n return profileEventTags;\n}\n//# sourceMappingURL=assembly.js.map","import { addEventListener, clearTimeout, setTimeout, monitorError, display, getGlobalObject, clocksOrigin, clocksNow, elapsed, } from '@datadog/browser-core';\nimport { createFormDataTransport } from '@datadog/browser-rum-core';\nimport { getNumberOfSamples } from './utils/getNumberOfSamples';\nimport { getCustomOrDefaultViewName } from './utils/getCustomOrDefaultViewName';\nimport { assembleProfilingPayload } from './transport/assembly';\nexport const DEFAULT_RUM_PROFILER_CONFIGURATION = {\n sampleIntervalMs: 10, // Sample stack trace every 10ms\n collectIntervalMs: 60000, // Collect data every minute\n minProfileDurationMs: 5000, // Require at least 5 seconds of profile data to reduce noise and cost\n minNumberOfSamples: 50, // Require at least 50 samples (~500 ms) to report a profile to reduce noise and cost\n};\nexport function createRumProfiler(configuration, lifeCycle, session, profilingContextManager, longTaskContexts, createEncoder, viewHistory, profilerConfiguration = DEFAULT_RUM_PROFILER_CONFIGURATION) {\n const transport = createFormDataTransport(configuration, lifeCycle, createEncoder, 6 /* DeflateEncoderStreamId.PROFILING */);\n let lastViewEntry;\n // Global clean-up tasks for listeners that are not specific to a profiler instance (eg. visibility change, before unload)\n const globalCleanupTasks = [];\n let instance = { state: 'stopped', stateReason: 'initializing' };\n // Stops the profiler when session expires\n lifeCycle.subscribe(9 /* LifeCycleEventType.SESSION_EXPIRED */, () => {\n stopProfiling('session-expired').catch(monitorError);\n });\n // Start the profiler again when session is renewed\n lifeCycle.subscribe(10 /* LifeCycleEventType.SESSION_RENEWED */, () => {\n if (instance.state === 'stopped' && instance.stateReason === 'session-expired') {\n start(); // Only restart the profiler if it was stopped due to session expiration. Avoid restarting the profiler if it was stopped manually by the user.\n }\n });\n // Public API to start the profiler.\n function start() {\n if (instance.state === 'running') {\n return;\n }\n const viewEntry = viewHistory.findView();\n // Add initial view\n // Note: `viewEntry.name` is only filled when users use manual view creation via `startView` method.\n lastViewEntry = viewEntry\n ? {\n startClocks: viewEntry.startClocks,\n viewId: viewEntry.id,\n viewName: getCustomOrDefaultViewName(viewEntry.name, document.location.pathname),\n }\n : undefined;\n // Add global clean-up tasks for listeners that are not specific to a profiler instance (eg. visibility change, before unload)\n globalCleanupTasks.push(addEventListener(configuration, window, \"visibilitychange\" /* DOM_EVENT.VISIBILITY_CHANGE */, handleVisibilityChange).stop, addEventListener(configuration, window, \"beforeunload\" /* DOM_EVENT.BEFORE_UNLOAD */, handleBeforeUnload).stop);\n // Start profiler instance\n startNextProfilerInstance();\n }\n // Public API to manually stop the profiler.\n async function stop() {\n await stopProfiling('stopped-by-user');\n }\n async function stopProfiling(reason) {\n // Stop current profiler instance\n await stopProfilerInstance(reason);\n // Cleanup global listeners\n globalCleanupTasks.forEach((task) => task());\n // Update Profiling status once the Profiler has been stopped.\n profilingContextManager.set({ status: 'stopped', error_reason: undefined });\n }\n /**\n * Whenever a new Profiler instance is started, we need to add event listeners to surroundings (RUM Events, Long Tasks, etc) to enrich the Profiler data.\n * If the instance is already running, we can keep the same event listeners.\n */\n function addEventListeners(existingInstance) {\n if (existingInstance.state === 'running') {\n // Instance is already running, so we can keep same event listeners.\n return {\n cleanupTasks: existingInstance.cleanupTasks,\n };\n }\n // Store clean-up tasks for this instance (tasks to be executed when the Profiler is stopped or paused.)\n const cleanupTasks = [];\n // Whenever the View is updated, we add a views entry to the profiler instance.\n const viewUpdatedSubscription = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, (view) => {\n const viewEntry = {\n viewId: view.id,\n // Note: `viewName` is only filled when users use manual view creation via `startView` method.\n viewName: getCustomOrDefaultViewName(view.name, document.location.pathname),\n startClocks: view.startClocks,\n };\n collectViewEntry(viewEntry);\n // Update last view entry\n lastViewEntry = viewEntry;\n });\n cleanupTasks.push(viewUpdatedSubscription.unsubscribe);\n return {\n cleanupTasks,\n };\n }\n function startNextProfilerInstance() {\n // These APIs might be unavailable in some browsers\n const globalThisProfiler = getGlobalObject().Profiler;\n if (!globalThisProfiler) {\n profilingContextManager.set({ status: 'error', error_reason: 'not-supported-by-browser' });\n throw new Error('RUM Profiler is not supported in this browser.');\n }\n // Don't wait for data collection to start next instance\n collectProfilerInstance(instance).catch(monitorError);\n const { cleanupTasks } = addEventListeners(instance);\n let profiler;\n try {\n // We have to create new Profiler each time we start a new instance\n profiler = new globalThisProfiler({\n sampleInterval: profilerConfiguration.sampleIntervalMs,\n // Keep buffer size at 1.5 times of minimum required to collect data for a profiling instance\n maxBufferSize: Math.round((profilerConfiguration.collectIntervalMs * 1.5) / profilerConfiguration.sampleIntervalMs),\n });\n }\n catch (e) {\n if (e instanceof Error && e.message.includes('disabled by Document Policy')) {\n // Missing Response Header (`js-profiling`) that is required to enable the profiler.\n // We should suggest the user to enable the Response Header in their server configuration.\n display.warn('[DD_RUM] Profiler startup failed. Ensure your server includes the `Document-Policy: js-profiling` response header when serving HTML pages.', e);\n profilingContextManager.set({ status: 'error', error_reason: 'missing-document-policy-header' });\n }\n else {\n profilingContextManager.set({ status: 'error', error_reason: 'unexpected-exception' });\n }\n return;\n }\n profilingContextManager.set({ status: 'running', error_reason: undefined });\n // Kick-off the new instance\n instance = {\n state: 'running',\n startClocks: clocksNow(),\n profiler,\n timeoutId: setTimeout(startNextProfilerInstance, profilerConfiguration.collectIntervalMs),\n views: [],\n cleanupTasks,\n longTasks: [],\n };\n // Add last view entry\n collectViewEntry(lastViewEntry);\n // Add event handler case we overflow the buffer\n profiler.addEventListener('samplebufferfull', handleSampleBufferFull);\n }\n async function collectProfilerInstance(lastInstance) {\n if (lastInstance.state !== 'running') {\n return;\n }\n // Cleanup instance\n clearTimeout(lastInstance.timeoutId);\n lastInstance.profiler.removeEventListener('samplebufferfull', handleSampleBufferFull);\n // Store instance data snapshot in local variables to use in async callback\n const { startClocks, views } = lastInstance;\n // Stop current profiler to get trace\n await lastInstance.profiler\n .stop()\n .then((trace) => {\n const endClocks = clocksNow();\n const duration = elapsed(startClocks.timeStamp, endClocks.timeStamp);\n const longTasks = longTaskContexts.findLongTasks(startClocks.relative, duration);\n const isBelowDurationThreshold = duration < profilerConfiguration.minProfileDurationMs;\n const isBelowSampleThreshold = getNumberOfSamples(trace.samples) < profilerConfiguration.minNumberOfSamples;\n if (longTasks.length === 0 && (isBelowDurationThreshold || isBelowSampleThreshold)) {\n // Skip very short profiles to reduce noise and cost, but keep them if they contain long tasks.\n return;\n }\n handleProfilerTrace(\n // Enrich trace with time and instance data\n Object.assign(trace, {\n startClocks,\n endClocks,\n clocksOrigin: clocksOrigin(),\n longTasks,\n views,\n sampleInterval: profilerConfiguration.sampleIntervalMs,\n }));\n })\n .catch(monitorError);\n }\n async function stopProfilerInstance(stateReason) {\n if (instance.state !== 'running') {\n return;\n }\n await onPauseOrStopProfilerInstance();\n instance = { state: 'stopped', stateReason };\n }\n async function pauseProfilerInstance() {\n if (instance.state !== 'running') {\n return;\n }\n await onPauseOrStopProfilerInstance();\n instance = { state: 'paused' };\n }\n async function onPauseOrStopProfilerInstance() {\n if (instance.state !== 'running') {\n return;\n }\n // Cleanup tasks\n instance.cleanupTasks.forEach((cleanupTask) => cleanupTask());\n await collectProfilerInstance(instance);\n }\n function collectViewEntry(viewEntry) {\n if (instance.state !== 'running' || !viewEntry) {\n return;\n }\n // Add entry to views\n instance.views.push(viewEntry);\n }\n function handleProfilerTrace(trace) {\n var _a;\n // Find current session to assign it to the Profile.\n const sessionId = (_a = session.findTrackedSession()) === null || _a === void 0 ? void 0 : _a.id;\n const payload = assembleProfilingPayload(trace, configuration, sessionId);\n void transport.send(payload);\n }\n function handleSampleBufferFull() {\n startNextProfilerInstance();\n }\n function handleVisibilityChange() {\n if (document.visibilityState === 'hidden' && instance.state === 'running') {\n // Pause when tab is hidden. We use paused state to distinguish between\n // paused by visibility change and stopped by user.\n // If profiler is paused by the visibility change, we should resume when\n // tab becomes visible again. That's not the case when user stops the profiler.\n pauseProfilerInstance().catch(monitorError);\n }\n else if (document.visibilityState === 'visible' && instance.state === 'paused') {\n // Resume when tab becomes visible again\n startNextProfilerInstance();\n }\n }\n function handleBeforeUnload() {\n // `unload` can in some cases be triggered while the page is still active (link to a different protocol like mailto:).\n // We can immediately flush (by starting a new profiler instance) to make sure we receive the data, and at the same time keep the profiler active.\n // In case of the regular unload, the profiler will be shut down anyway.\n startNextProfilerInstance();\n }\n function isStopped() {\n return instance.state === 'stopped';\n }\n function isRunning() {\n return instance.state === 'running';\n }\n function isPaused() {\n return instance.state === 'paused';\n }\n return { start, stop, isStopped, isRunning, isPaused };\n}\n//# sourceMappingURL=profiler.js.map"],"names":["createFormDataTransport","configuration","lifeCycle","createEncoder","streamId","reportError","error","addTelemetryDebug","httpRequest","createHttpRequest","encoder","_a","_b","event","attachments","__objRest","formData","serializedEvent","jsonStringify","bytesCount","key","value","objectEntries","serializedValue","result","encode","data","resolve","encoderResult","getNumberOfSamples","samples","numberOfSamples","sample","PATH_MIXED_ALPHANUMERICS","getDefaultViewName","viewPathUrl","getCustomOrDefaultViewName","customViewName","buildProfileEventAttributes","profilerTrace","applicationId","sessionId","attributes","ids","names","extractViewIdsAndNames","longTaskIds","longTask","id","views","view","assembleProfilingPayload","buildProfileEvent","tags","buildTags","profileAttributes","profileEventTags","buildProfileEventTags","__spreadProps","__spreadValues","currentDrift","DEFAULT_RUM_PROFILER_CONFIGURATION","createRumProfiler","session","profilingContextManager","longTaskContexts","viewHistory","profilerConfiguration","transport","lastViewEntry","globalCleanupTasks","instance","stopProfiling","monitorError","start","viewEntry","addEventListener","handleVisibilityChange","handleBeforeUnload","startNextProfilerInstance","stop","reason","stopProfilerInstance","task","addEventListeners","existingInstance","cleanupTasks","viewUpdatedSubscription","collectViewEntry","globalThisProfiler","getGlobalObject","collectProfilerInstance","profiler","e","display","clocksNow","setTimeout","handleSampleBufferFull","lastInstance","clearTimeout","startClocks","trace","endClocks","duration","elapsed","longTasks","isBelowDurationThreshold","isBelowSampleThreshold","handleProfilerTrace","clocksOrigin","stateReason","onPauseOrStopProfilerInstance","pauseProfilerInstance","cleanupTask","payload","isStopped","isRunning","isPaused"],"mappings":"+tBACO,SAASA,GAAwBC,EAAeC,EAA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C,EAAS,QAAU,YAIvBA,EAAS,aAAa,QAAS0C,GAAgBA,EAAW,CAAE,EAC5D,MAAMtB,EAAwBpB,CAAQ,EAC1C,CACA,SAASiB,EAAiBb,EAAW,CAC7BJ,EAAS,QAAU,WAAa,CAACI,GAIrCJ,EAAS,MAAM,KAAKI,CAAS,CACjC,CACA,SAASiC,EAAoBP,EAAO,CAChC,IAAI1F,EAEJ,MAAM8B,GAAa9B,EAAKoD,EAAQ,mBAAkB,KAAQ,MAAQpD,IAAO,OAAS,OAASA,EAAG,GACxFuG,EAAU/D,GAAyBkD,EAAOpG,EAAewC,CAAS,EACnE2B,EAAU,KAAK8C,CAAO,CAC/B,CACA,SAASjB,GAAyB,CAC9BlB,EAAyB,CAC7B,CACA,SAASF,GAAyB,CAC1B,SAAS,kBAAoB,UAAYN,EAAS,QAAU,UAK5DyC,EAAqB,EAAG,MAAMvC,CAAY,EAErC,SAAS,kBAAoB,WAAaF,EAAS,QAAU,UAElEQ,EAAyB,CAEjC,CACA,SAASD,GAAqB,CAI1BC,EAAyB,CAC7B,CACA,SAASoC,GAAY,CACjB,OAAO5C,EAAS,QAAU,SAC9B,CACA,SAAS6C,GAAY,CACjB,OAAO7C,EAAS,QAAU,SAC9B,CACA,SAAS8C,GAAW,CAChB,OAAO9C,EAAS,QAAU,QAC9B,CACA,MAAO,CAAE,MAAAG,EAAO,KAAAM,EAAM,UAAAmC,EAAW,UAAAC,EAAW,SAAAC,CAAQ,CACxD","x_google_ignoreList":[0,1,2,3,4,5,6]}
@@ -0,0 +1,3 @@
1
+ var mt=Object.defineProperty;var P=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var F=(t,n,e)=>n in t?mt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e,y=(t,n)=>{for(var e in n||(n={}))St.call(n,e)&&F(t,e,n[e]);if(P)for(var e of P(n))Tt.call(n,e)&&F(t,e,n[e]);return t};import{s as _,C as q,b as Et,N as h,a as yt,c as H,d as It,i as Nt,g as J,r as wt,e as Mt,P as bt,f as vt,h as Ct,j as K,k as j,t as N,l as Rt,m as xt,n as Q,o as Z,p as tt,q as D,u as b,v as I,w as _t,x as Dt,y as w,z as x,R as Ot,A as Lt,B as C,D as At,E as Vt,F as zt,G as L,H as kt,I as Pt,J as Ft,K as Ht,L as Ut,M as Bt,O as Gt,Q as $t,S as Yt,T as Xt,U as Wt,V as qt,W as Jt,X as Kt}from"../main.js";const T={FullSnapshot:2,IncrementalSnapshot:3,Meta:4,Focus:6,ViewEnd:7,VisualViewport:8,FrustrationRecord:9},M={Document:0,DocumentType:1,Element:2,Text:3,CDATA:4,DocumentFragment:11},g={Mutation:0,MouseMove:1,MouseInteraction:2,Scroll:3,ViewportResize:4,Input:5,TouchMove:6,MediaInteraction:7,StyleSheetRule:8},m={MouseUp:0,MouseDown:1,Click:2,ContextMenu:3,DblClick:4,Focus:5,Blur:6,TouchStart:7,TouchEnd:9},U={Play:0,Pause:1};function A(t,n){const e=t.tagName,o=t.value;if(_(t,n)){const s=t.type;return e==="INPUT"&&(s==="button"||s==="submit"||s==="reset")?o:!o||e==="OPTION"?void 0:q}if(e==="OPTION"||e==="SELECT")return t.value;if(!(e!=="INPUT"&&e!=="TEXTAREA"))return o}const jt=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,Qt=/^[A-Za-z]+:|^\/\//,Zt=/^["']?data:.*,/i;function te(t,n){return t.replace(jt,(e,o,s,r,u,i)=>{const a=s||u||i;if(!n||!a||Qt.test(a)||Zt.test(a))return e;const c=o||r||"";return`url(${c}${ee(a,n)}${c})`})}function ee(t,n){try{return Et(t,n).href}catch(e){return t}}const ne=/[^a-z1-6-_]/;function oe(t){const n=t.toLowerCase().trim();return ne.test(n)?"div":n}function et(t){return t.tagName.toLowerCase()}function B(t,n){return`data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${n}' style='background-color:silver'%3E%3C/svg%3E`}function nt(t){if(!(t===void 0||t.length===0))return t.map(n=>{const e=n.cssRules||n.rules;return{cssRules:Array.from(e,r=>r.cssText),disabled:n.disabled||void 0,media:n.media.length>0?Array.from(n.media):void 0}})}const se=1e6;function ot(t,n,e,o){if(n===h.HIDDEN)return null;const s=t.getAttribute(e),r=t.tagName;if(yt(r,e,s,n,o)){if(r==="IMG"){const u=t;if(u.naturalWidth>0)return B(u.naturalWidth,u.naturalHeight);const{width:i,height:a}=t.getBoundingClientRect();return i>0||a>0?B(i,a):H}return r==="SOURCE"?H:q}return s&&It(s,se)}function re(t,n,e){return y(y({},ie(t,n,e)),ue(t,n,e))}function ie(t,n,e){if(n===h.HIDDEN)return{};const o={},s=et(t);for(let u=0;u<t.attributes.length;u+=1){const a=t.attributes.item(u).name,c=ot(t,n,a,e.scope.configuration);c!==null&&(o[a]=c)}if(t.value&&(s==="textarea"||s==="select"||s==="option"||s==="input")){const u=A(t,n);u!==void 0&&(o.value=u)}if(s==="option"){const u=t;u.selected&&!_(u,n)?o.selected="":delete o.selected}const r=t;return s==="input"&&(r.type==="radio"||r.type==="checkbox")&&(r.checked&&!_(r,n)?o.checked="":delete o.checked),o}function ue(t,n,e){if(n===h.HIDDEN)return{};const o={},s=t.ownerDocument,r=et(t);if(r==="link"){const a=Array.from(s.styleSheets).find(d=>d.href===t.href),c=O(a);c&&a&&(e.addMetric("cssText",c.length),o._cssText=c)}if(r==="style"&&t.sheet){const a=O(t.sheet);a&&(e.addMetric("cssText",a.length),o._cssText=a)}if(r==="audio"||r==="video"){const a=t;o.rr_mediaState=a.paused?"paused":"played"}let u,i;switch(e.kind){case 0:u=Math.round(t.scrollTop),i=Math.round(t.scrollLeft),(u||i)&&e.scope.elementsScrollPositions.set(t,{scrollTop:u,scrollLeft:i});break;case 1:e.scope.elementsScrollPositions.has(t)&&({scrollTop:u,scrollLeft:i}=e.scope.elementsScrollPositions.get(t));break}return i&&(o.rr_scrollLeft=i),u&&(o.rr_scrollTop=u),o}function O(t){if(!t)return null;let n;try{n=t.rules||t.cssRules}catch(o){}if(!n)return null;const e=Array.from(n,Nt()?ae:st).join("");return te(e,t.href)}function ae(t){if(de(t)&&t.selectorText.includes(":")){const n=/(\[[\w-]+[^\\])(:[^\]]+\])/g;return t.cssText.replace(n,"$1\\$2")}return st(t)}function st(t){return ce(t)&&O(t.styleSheet)||t.cssText}function ce(t){return"styleSheet"in t}function de(t){return"selectorText"in t}function V(t,n,e){switch(t.nodeType){case t.DOCUMENT_NODE:return le(t,n,e);case t.DOCUMENT_FRAGMENT_NODE:return fe(t,n,e);case t.DOCUMENT_TYPE_NODE:return pe(t,e);case t.ELEMENT_NODE:return he(t,n,e);case t.TEXT_NODE:return me(t,n,e);case t.CDATA_SECTION_NODE:return Se(t,e);default:return null}}function z(t,n,e){const o=[];return j(t,s=>{const r=V(s,n,e);r&&o.push(r)}),o}function le(t,n,e){return{type:M.Document,id:e.assignId(t),childNodes:z(t,n,e),adoptedStyleSheets:nt(t.adoptedStyleSheets)}}function fe(t,n,e){const o=K(t);return o&&e.scope.shadowRootsController.addShadowRoot(t,e.scope),{type:M.DocumentFragment,id:e.assignId(t),childNodes:z(t,n,e),isShadowRoot:o,adoptedStyleSheets:o?nt(t.adoptedStyleSheets):void 0}}function pe(t,n){return{type:M.DocumentType,id:n.assignId(t),name:t.name,publicId:t.publicId,systemId:t.systemId}}function he(t,n,e){const o=oe(t.tagName),s=ge(t)||void 0,r=wt(Mt(t),n);if(r===h.HIDDEN){const{width:c,height:d}=t.getBoundingClientRect();return{type:M.Element,id:e.assignId(t),tagName:o,attributes:{rr_width:`${c}px`,rr_height:`${d}px`,[vt]:bt},childNodes:[],isSVG:s}}if(r===h.IGNORE)return null;const u=e.assignId(t),i=re(t,r,e);let a=[];return Ct(t)&&o!=="style"&&(a=z(t,r,e)),{type:M.Element,id:u,tagName:o,attributes:i,childNodes:a,isSVG:s}}function ge(t){return t.tagName==="svg"||t instanceof SVGElement}function me(t,n,e){const o=J(t,n);return o===void 0?null:{type:M.Text,id:e.assignId(t),textContent:o}}function Se(t,n){return{type:M.CDATA,id:n.assignId(t),textContent:""}}function Te(t,n){const e=n.scope.configuration.defaultPrivacyLevel;return V(t,e,n)}function rt(){return{cssText:{count:0,max:0,sum:0},serializationDuration:{count:0,max:0,sum:0}}}function G(t,n,e){t[n].count+=1,t[n].max=Math.max(t[n].max,e),t[n].sum+=e}function Ee(t,n){for(const e of["cssText","serializationDuration"])t[e].count+=n[e].count,t[e].max=Math.max(t[e].max,n[e].max),t[e].sum+=n[e].sum}function it(t,n,e,o,s){const r=[],u=rt(),i={add(c){r.push(c)},addMetric(c,d){G(u,c,d)},assignId(c){const d=o.nodeIds.getOrInsert(c);return i.serializedNodeIds&&i.serializedNodeIds.add(d),d},kind:t,scope:o},a=N();s(i),G(u,"serializationDuration",Rt(a,N()));for(const c of r)n(c);e(u)}const $=25;function ye(t){return Math.abs(t.pageTop-t.offsetTop-window.scrollY)>$||Math.abs(t.pageLeft-t.offsetLeft-window.scrollX)>$}const Ie=(t,n)=>{const e=window.visualViewport,o={layoutViewportX:t,layoutViewportY:n,visualViewportX:t,visualViewportY:n};if(e)ye(e)?(o.layoutViewportX=Math.round(t+e.offsetLeft),o.layoutViewportY=Math.round(n+e.offsetTop)):(o.visualViewportX=Math.round(t-e.offsetLeft),o.visualViewportY=Math.round(n-e.offsetTop));else return o;return o},ut=t=>({scale:t.scale,offsetLeft:t.offsetLeft,offsetTop:t.offsetTop,pageLeft:t.pageLeft,pageTop:t.pageTop,height:t.height,width:t.width});function Ne(t,n,e,o,s){Y(N(),0,n,e,s);const{unsubscribe:r}=t.subscribe(2,u=>{o(),Y(u.startClocks.timeStamp,1,n,e,s)});return{stop:r}}function Y(t,n,e,o,s){it(n,e,o,s,r=>{const{width:u,height:i}=xt();r.add({data:{height:i,href:window.location.href,width:u},type:T.Meta,timestamp:t}),r.add({data:{has_focus:document.hasFocus()},type:T.Focus,timestamp:t}),r.add({data:{node:Te(document,r),initialOffset:{left:Z(),top:Q()}},type:T.FullSnapshot,timestamp:t}),window.visualViewport&&r.add({data:ut(window.visualViewport),type:T.VisualViewport,timestamp:t})})}function we(){return k(1)}function Me(){return k(0)}function be(){return Ce(0)}function ve(){return k(0)}function Ce(t){return at(()=>new Map,t)}function k(t){return at(()=>new WeakMap,t)}function at(t,n){let e=t(),o=n;const s=r=>e.get(r);return{clear(){e=t(),o=n},get:s,getOrInsert(r){let u=s(r);return u===void 0&&(u=o++,e.set(r,u)),u},get size(){return o-n}}}function Re(t,n,e){const o=we(),s=Me(),r=be(),u=ve();return{configuration:t,elementsScrollPositions:n,eventIds:o,nodeIds:s,shadowRootsController:e,stringIds:r,styleSheetIds:u}}function xe(){const t=new WeakMap;return{set(n,e){n===document&&!document.scrollingElement||t.set(n===document?document.scrollingElement:n,e)},get(n){return t.get(n)},has(n){return t.has(n)}}}function ct(t){return!!t.changedTouches}function R(t){return t.composed===!0&&tt(t.target)?t.composedPath()[0]:t.target}function S(t,n){return{data:y({source:t},n),type:T.IncrementalSnapshot,timestamp:N()}}const _e=50;function De(t,n){const{throttled:e,cancel:o}=D(r=>{const u=R(r),i=n.nodeIds.get(u);if(i===void 0)return;const a=dt(r);if(!a)return;const c={id:i,timeOffset:0,x:a.x,y:a.y};t(S(ct(r)?g.TouchMove:g.MouseMove,{positions:[c]}))},_e,{trailing:!1}),{stop:s}=b(n.configuration,document,["mousemove","touchmove"],e,{capture:!0,passive:!0});return{stop:()=>{s(),o()}}}function dt(t){let{clientX:n,clientY:e}=ct(t)?t.changedTouches[0]:t;if(window.visualViewport){const{visualViewportX:o,visualViewportY:s}=Ie(n,e);n=o,e=s}if(!(!Number.isFinite(n)||!Number.isFinite(e)))return{x:n,y:e}}const X={pointerup:m.MouseUp,mousedown:m.MouseDown,click:m.Click,contextmenu:m.ContextMenu,dblclick:m.DblClick,focus:m.Focus,blur:m.Blur,touchstart:m.TouchStart,touchend:m.TouchEnd};function Oe(t,n){const e=o=>{const s=R(o),r=n.nodeIds.get(s);if(r===void 0||I(s,n.configuration.defaultPrivacyLevel)===h.HIDDEN)return;const u=X[o.type];let i;if(u!==m.Blur&&u!==m.Focus){const a=dt(o);if(!a)return;i={id:r,type:u,x:a.x,y:a.y}}else i={id:r,type:u};t(y({id:n.eventIds.getOrInsert(o)},S(g.MouseInteraction,i)))};return b(n.configuration,document,Object.keys(X),e,{capture:!0,passive:!0})}const Le=100;function lt(t,n,e){const{throttled:o,cancel:s}=D(u=>{const i=R(u);if(!i)return;const a=e.nodeIds.get(i);if(a===void 0||I(i,e.configuration.defaultPrivacyLevel)===h.HIDDEN)return;const c=i===document?{scrollTop:Q(),scrollLeft:Z()}:{scrollTop:Math.round(i.scrollTop),scrollLeft:Math.round(i.scrollLeft)};e.elementsScrollPositions.set(i,c),n(S(g.Scroll,{id:a,x:c.scrollLeft,y:c.scrollTop}))},Le),{stop:r}=_t(e.configuration,t,"scroll",o,{capture:!0,passive:!0});return{stop:()=>{r(),s()}}}const Ae=200;function Ve(t,n){const e=Dt(n.configuration).subscribe(o=>{t(S(g.ViewportResize,o))});return{stop:()=>{e.unsubscribe()}}}function ze(t,n){const e=window.visualViewport;if(!e)return{stop:w};const{throttled:o,cancel:s}=D(()=>{t({data:ut(e),type:T.VisualViewport,timestamp:N()})},Ae,{trailing:!1}),{stop:r}=b(n.configuration,e,["resize","scroll"],o,{capture:!0,passive:!0});return{stop:()=>{r(),s()}}}function ke(t,n){return b(n.configuration,document,["play","pause"],e=>{const o=R(e);if(!o)return;const s=n.nodeIds.get(o);s===void 0||I(o,n.configuration.defaultPrivacyLevel)===h.HIDDEN||t(S(g.MediaInteraction,{id:s,type:e.type==="play"?U.Play:U.Pause}))},{capture:!0,passive:!0})}function Pe(t,n){function e(r,u){if(!r||!r.ownerNode)return;const i=n.nodeIds.get(r.ownerNode);i!==void 0&&u(i)}const o=[x(CSSStyleSheet.prototype,"insertRule",({target:r,parameters:[u,i]})=>{e(r,a=>t(S(g.StyleSheetRule,{id:a,adds:[{rule:u,index:i}]})))}),x(CSSStyleSheet.prototype,"deleteRule",({target:r,parameters:[u]})=>{e(r,i=>t(S(g.StyleSheetRule,{id:i,removes:[{index:u}]})))})];typeof CSSGroupingRule!="undefined"?s(CSSGroupingRule):(s(CSSMediaRule),s(CSSSupportsRule));function s(r){o.push(x(r.prototype,"insertRule",({target:u,parameters:[i,a]})=>{e(u.parentStyleSheet,c=>{const d=W(u);d&&(d.push(a||0),t(S(g.StyleSheetRule,{id:c,adds:[{rule:i,index:d}]})))})}),x(r.prototype,"deleteRule",({target:u,parameters:[i]})=>{e(u.parentStyleSheet,a=>{const c=W(u);c&&(c.push(i),t(S(g.StyleSheetRule,{id:a,removes:[{index:c}]})))})}))}return{stop:()=>{o.forEach(r=>r.stop())}}}function W(t){const n=[];let e=t;for(;e.parentRule;){const u=Array.from(e.parentRule.cssRules).indexOf(e);n.unshift(u),e=e.parentRule}if(!e.parentStyleSheet)return;const s=Array.from(e.parentStyleSheet.cssRules).indexOf(e);return n.unshift(s),n}function Fe(t,n){return b(n.configuration,window,["focus","blur"],()=>{t({data:{has_focus:document.hasFocus()},type:T.Focus,timestamp:N()})})}function He(t,n,e){const o=t.subscribe(12,s=>{var r,u;s.rawRumEvent.type===Ot.ACTION&&s.rawRumEvent.action.type===Lt.CLICK&&(!((u=(r=s.rawRumEvent.action.frustration)===null||r===void 0?void 0:r.type)===null||u===void 0)&&u.length)&&"events"in s.domainContext&&s.domainContext.events&&s.domainContext.events.length&&n({timestamp:s.rawRumEvent.date,type:T.FrustrationRecord,data:{frustrationTypes:s.rawRumEvent.action.frustration.type,recordIds:s.domainContext.events.map(i=>e.eventIds.getOrInsert(i))}})});return{stop:()=>{o.unsubscribe()}}}function Ue(t,n,e){const o=t.subscribe(5,()=>{e(),n({timestamp:N(),type:T.ViewEnd})});return{stop:()=>{o.unsubscribe()}}}function ft(t,n,e){const o=e.configuration.defaultPrivacyLevel,s=new WeakMap,r=t!==document,{stop:u}=b(e.configuration,t,r?["change"]:["input","change"],d=>{const l=R(d);(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement)&&a(l)},{capture:!0,passive:!0});let i;if(r)i=w;else{const d=[C(HTMLInputElement.prototype,"value",a),C(HTMLInputElement.prototype,"checked",a),C(HTMLSelectElement.prototype,"value",a),C(HTMLTextAreaElement.prototype,"value",a),C(HTMLSelectElement.prototype,"selectedIndex",a)];i=()=>{d.forEach(l=>l.stop())}}return{stop:()=>{i(),u()}};function a(d){const l=I(d,o);if(l===h.HIDDEN)return;const f=d.type;let p;if(f==="radio"||f==="checkbox"){if(_(d,l))return;p={isChecked:d.checked}}else{const v=A(d,l);if(v===void 0)return;p={text:v}}c(d,p);const E=d.name;f==="radio"&&E&&d.checked&&document.querySelectorAll(`input[type="radio"][name="${CSS.escape(E)}"]`).forEach(v=>{v!==d&&c(v,{isChecked:!1})})}function c(d,l){const f=e.nodeIds.get(d);if(f===void 0)return;const p=s.get(d);(!p||p.text!==l.text||p.isChecked!==l.isChecked)&&(s.set(d,l),n(S(g.Input,y({id:f},l))))}}const Be=100,Ge=16;function $e(t){let n=w,e=[];function o(){n(),t(e),e=[]}const{throttled:s,cancel:r}=D(o,Ge,{leading:!1});return{addMutations:u=>{e.length===0&&(n=At(s,{timeout:Be})),e.push(...u)},flush:o,stop:()=>{n(),r()}}}function pt(t,n,e,o){const s=Vt();if(!s)return{stop:w,flush:w};const r=$e(i=>{it(2,n,e,o,a=>Ye(i.concat(u.takeRecords()),a))}),u=new s(zt(r.addMutations));return u.observe(t,{attributeOldValue:!0,attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),{stop:()=>{u.disconnect(),r.stop()},flush:()=>{r.flush()}}}function Ye(t,n){const e=new Map;t.filter(c=>c.type==="childList").forEach(c=>{c.removedNodes.forEach(d=>{ht(d,n.scope.shadowRootsController.removeShadowRoot)})});const o=t.filter(c=>c.target.isConnected&&Ke(c.target,n.scope.nodeIds)&&I(c.target,n.scope.configuration.defaultPrivacyLevel,e)!==h.HIDDEN),{adds:s,removes:r,hasBeenSerialized:u}=Xe(o.filter(c=>c.type==="childList"),e,n),i=We(o.filter(c=>c.type==="characterData"&&!u(c.target)),e,n),a=qe(o.filter(c=>c.type==="attributes"&&!u(c.target)),e,n);!i.length&&!a.length&&!r.length&&!s.length||n.add(S(g.Mutation,{adds:s,removes:r,texts:i,attributes:a}))}function Xe(t,n,e){const o=new Set,s=new Map;for(const d of t)d.addedNodes.forEach(l=>{o.add(l)}),d.removedNodes.forEach(l=>{o.has(l)||s.set(l,d.target),o.delete(l)});const r=Array.from(o);Je(r),e.serializedNodeIds=new Set;const u=[];for(const d of r){if(a(d))continue;const l=I(d.parentNode,e.scope.configuration.defaultPrivacyLevel,n);if(l===h.HIDDEN||l===h.IGNORE)continue;const f=V(d,l,e);if(!f)continue;const p=L(d);u.push({nextId:c(d),parentId:e.scope.nodeIds.get(p),node:f})}const i=[];return s.forEach((d,l)=>{const f=e.scope.nodeIds.get(d),p=e.scope.nodeIds.get(l);f!==void 0&&p!==void 0&&i.push({parentId:f,id:p})}),{adds:u,removes:i,hasBeenSerialized:a};function a(d){var l;const f=e.scope.nodeIds.get(d);return f!==void 0&&((l=e.serializedNodeIds)===null||l===void 0?void 0:l.has(f))}function c(d){let l=d.nextSibling;for(;l;){const f=e.scope.nodeIds.get(l);if(f!==void 0)return f;l=l.nextSibling}return null}}function We(t,n,e){var o;const s=[],r=new Set,u=t.filter(i=>r.has(i.target)?!1:(r.add(i.target),!0));for(const i of u){if(i.target.textContent===i.oldValue)continue;const c=e.scope.nodeIds.get(i.target);if(c===void 0)continue;const d=I(L(i.target),e.scope.configuration.defaultPrivacyLevel,n);d===h.HIDDEN||d===h.IGNORE||s.push({id:c,value:(o=J(i.target,d))!==null&&o!==void 0?o:null})}return s}function qe(t,n,e){const o=[],s=new Map,r=t.filter(i=>{const a=s.get(i.target);return a&&a.has(i.attributeName)?!1:(a?a.add(i.attributeName):s.set(i.target,new Set([i.attributeName])),!0)}),u=new Map;for(const i of r){if(i.target.getAttribute(i.attributeName)===i.oldValue)continue;const c=e.scope.nodeIds.get(i.target);if(c===void 0)continue;const d=I(i.target,e.scope.configuration.defaultPrivacyLevel,n),l=ot(i.target,d,i.attributeName,e.scope.configuration);let f;if(i.attributeName==="value"){const E=A(i.target,d);if(E===void 0)continue;f=E}else typeof l=="string"?f=l:f=null;let p=u.get(i.target);p||(p={id:c,attributes:{}},o.push(p),u.set(i.target,p)),p.attributes[i.attributeName]=f}return o}function Je(t){t.sort((n,e)=>{const o=n.compareDocumentPosition(e);return o&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:o&Node.DOCUMENT_POSITION_CONTAINS||o&Node.DOCUMENT_POSITION_FOLLOWING?1:o&Node.DOCUMENT_POSITION_PRECEDING?-1:0})}function ht(t,n){tt(t)&&n(t.shadowRoot),j(t,e=>ht(e,n))}function Ke(t,n){let e=t;for(;e;){if(n.get(e)===void 0&&!K(e))return!1;e=L(e)}return!0}const je=(t,n)=>{const e=new Map;return{addShadowRoot:(s,r)=>{if(e.has(s))return;const u=pt(s,t,n,r),i=ft(s,t,r),a=lt(s,t,r);e.set(s,{flush:()=>u.flush(),stop:()=>{u.stop(),i.stop(),a.stop()}})},removeShadowRoot:s=>{const r=e.get(s);r&&(r.stop(),e.delete(s))},stop:()=>{e.forEach(({stop:s})=>s())},flush:()=>{e.forEach(({flush:s})=>s())}}};function Qe(t){const{emitRecord:n,emitStats:e,configuration:o,lifeCycle:s}=t;if(!n||!e)throw new Error("emit functions are required");const r=f=>{n(f),kt("record",{record:f});const p=t.viewHistory.findView();Pt(p.id)},u=je(r,e),i=Re(o,xe(),u),{stop:a}=Ne(s,r,e,c,i);function c(){u.flush(),d.flush()}const d=pt(document,r,e,i),l=[d,De(r,i),Oe(r,i),lt(document,r,i),Ve(r,i),ft(document,r,i),ke(r,i),Pe(r,i),Fe(r,i),ze(r,i),He(s,r,i),Ue(s,r,c)];return{stop:()=>{u.stop(),l.forEach(f=>f.stop()),a()},flushMutations:c,shadowRootsController:u}}function Ze(t,n,e,o){const s=new FormData;s.append("segment",new Blob([t],{type:"application/octet-stream"}),`${n.session.id}-${n.start}`);const r=y({raw_segment_size:o,compressed_segment_size:t.byteLength},n),u=JSON.stringify(r);return s.append("event",new Blob([u],{type:"application/json"})),{data:s,bytesCount:t.byteLength,cssText:e.cssText,isFullSnapshot:n.index_in_view===0,rawSize:o,recordCount:n.records_count,serializationDuration:e.serializationDuration}}function tn({context:t,creationReason:n,encoder:e}){let o=0;const s=t.view.id,r=Ft(s),u=y({start:1/0,end:-1/0,creation_reason:n,records_count:0,has_full_snapshot:!1,index_in_view:r,source:"browser"},t),i=rt();Ht(s);function a(l,f){u.start=Math.min(u.start,l.timestamp),u.end=Math.max(u.end,l.timestamp),u.records_count+=1,u.has_full_snapshot||(u.has_full_snapshot=l.type===T.FullSnapshot);const p=e.isEmpty?'{"records":[':",";e.write(p+JSON.stringify(l),E=>{o+=E,f(o)})}function c(l){Ee(i,l)}function d(l){if(e.isEmpty)throw new Error("Empty segment flushed");e.write(`],${JSON.stringify(u).slice(1)}
2
+ `),e.finish(f=>{Ut(u.view.id,f.rawBytesCount),l(u,i,f)})}return{addRecord:a,addStats:c,flush:d}}const en=5*Yt;let gt=6e4;function nn(t,n,e,o,s,r){return on(t,()=>sn(n.applicationId,e,o),s,r)}function on(t,n,e,o){let s={status:0,nextSegmentCreationReason:"init"};const{unsubscribe:r}=t.subscribe(2,()=>{i("view_change")}),{unsubscribe:u}=t.subscribe(11,a=>{i(a.reason)});function i(a){s.status===1&&(s.segment.flush((c,d,l)=>{const f=Ze(l.output,c,d,l.rawBytesCount);Bt(a)?e.sendOnExit(f):e.send(f)}),Gt(s.expirationTimeoutId)),a!=="stop"?s={status:0,nextSegmentCreationReason:a}:s={status:2}}return{addRecord:a=>{if(s.status!==2){if(s.status===0){const c=n();if(!c)return;s={status:1,segment:tn({encoder:o,context:c,creationReason:s.nextSegmentCreationReason}),expirationTimeoutId:$t(()=>{i("segment_duration_limit")},en)}}s.segment.addRecord(a,c=>{c>gt&&i("segment_bytes_limit")})}},addStats:a=>{s.status===1&&s.segment.addStats(a)},stop:()=>{i("stop"),r(),u()}}}function sn(t,n,e){const o=n.findTrackedSession(),s=e.findView();if(!(!o||!s))return{application:{id:t},session:{id:o.id},view:{id:s.id}}}function rn(t,n){if(!t.metricsEnabled)return{stop:w};const{unsubscribe:e}=n.subscribe(o=>{if(o.type==="failure"||o.type==="queue-full"||o.type==="success"&&o.payload.isFullSnapshot){const s=un(o.type,o.bandwidth,o.payload);Xt("Segment network request metrics",{metrics:s})}});return{stop:e}}function un(t,n,e){return{cssText:{count:e.cssText.count,max:e.cssText.max,sum:e.cssText.sum},isFullSnapshot:e.isFullSnapshot,ongoingRequests:{count:n.ongoingRequestCount,totalSize:n.ongoingByteCount},recordCount:e.recordCount,result:t,serializationDuration:{count:e.serializationDuration.count,max:e.serializationDuration.max,sum:e.serializationDuration.sum},size:{compressed:e.bytesCount,raw:e.rawSize}}}function an(t){const n=Wt();return{addRecord:e=>{const o=t.findView();n.send("record",e,o.id)}}}function ln(t,n,e,o,s,r,u){const i=[],a=p=>{t.notify(14,{error:p}),Kt("Error reported to customer",{"error.message":p.message})},c=u||qt([n.sessionReplayEndpointBuilder],a,gt);let d,l;if(Jt())({addRecord:d}=an(o)),l=w;else{const p=nn(t,n,e,o,c,s);d=p.addRecord,l=p.addStats,i.push(p.stop);const E=rn(r,c.observable);i.push(E.stop)}const{stop:f}=Qe({emitRecord:d,emitStats:l,configuration:n,lifeCycle:t,viewHistory:o});return i.push(f),{stop:()=>{i.forEach(p=>p())}}}export{ln as startRecording};
3
+ //# sourceMappingURL=startRecording-CuFdVhxx.js.map