-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
… into staging-11 Co-authored-by: Benoît Zugmeyer <[email protected]>
- Loading branch information
Showing
12 changed files
with
276 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import type { InitConfiguration } from '../src/domain/configuration' | ||
import type { RawTelemetryConfiguration } from '../src/domain/telemetry' | ||
import type { CamelToSnakeCase, RemoveIndex } from './typeUtils' | ||
|
||
// Defines a few constants and types related to the core package configuration, so it can be used in | ||
// other packages tests. | ||
|
||
/** | ||
* An object containing every single possible configuration initialization parameters, with | ||
* arbitrary values. | ||
*/ | ||
export const EXHAUSTIVE_INIT_CONFIGURATION: Required<InitConfiguration> = { | ||
clientToken: 'yes', | ||
beforeSend: () => true, | ||
sessionSampleRate: 50, | ||
telemetrySampleRate: 60, | ||
silentMultipleInit: true, | ||
allowFallbackToLocalStorage: true, | ||
allowUntrustedEvents: true, | ||
storeContextsAcrossPages: true, | ||
trackingConsent: 'not-granted', | ||
proxy: 'proxy', | ||
site: 'site', | ||
service: 'service', | ||
env: 'env', | ||
version: 'version', | ||
useCrossSiteSessionCookie: true, | ||
usePartitionedCrossSiteSessionCookie: true, | ||
useSecureSessionCookie: true, | ||
trackSessionAcrossSubdomains: true, | ||
enableExperimentalFeatures: ['foo'], | ||
replica: { | ||
clientToken: 'yes', | ||
}, | ||
datacenter: 'datacenter', | ||
internalAnalyticsSubdomain: 'internal-analytics-subdomain.com', | ||
telemetryConfigurationSampleRate: 70, | ||
} | ||
|
||
export const SERIALIZED_EXHAUSTIVE_INIT_CONFIGURATION = { | ||
session_sample_rate: 50, | ||
telemetry_sample_rate: 60, | ||
telemetry_configuration_sample_rate: 70, | ||
use_before_send: true, | ||
use_cross_site_session_cookie: true, | ||
use_partitioned_cross_site_session_cookie: true, | ||
use_secure_session_cookie: true, | ||
use_proxy: true, | ||
silent_multiple_init: true, | ||
track_session_across_subdomains: true, | ||
allow_fallback_to_local_storage: true, | ||
store_contexts_across_pages: true, | ||
allow_untrusted_events: true, | ||
tracking_consent: 'not-granted', | ||
} | ||
|
||
/** | ||
* Maps the keys of InitConfiguration to their serialized version. | ||
*/ | ||
export type MapInitConfigurationKey<Key extends string> = | ||
// Some keys are prefixed with `use_` to indicate that they are boolean flags | ||
Key extends 'proxy' | 'beforeSend' | ||
? `use_${CamelToSnakeCase<Key>}` | ||
: // Those keys should not be serialized | ||
Key extends | ||
| 'site' | ||
| 'service' | ||
| 'clientToken' | ||
| 'env' | ||
| 'version' | ||
| 'datacenter' | ||
| 'internalAnalyticsSubdomain' | ||
| 'replica' | ||
| 'enableExperimentalFeatures' | ||
? never | ||
: // Other keys are simply snake cased | ||
CamelToSnakeCase<Key> | ||
|
||
/** | ||
* Extracts a sub-set of RawTelemetryConfiguration from the passed InitConfiguration keys, with all | ||
* properties required, to make sure they are all defined. | ||
* | ||
* This type is only used in tests because "template literal types" were introduced in (TS 4.1)[1] and we | ||
* still support TS 3.8.2. | ||
* | ||
* [1]: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types | ||
* | ||
* @example | ||
* type SerializedInitConfiguration = ExtractTelemetryConfiguration< | ||
* "session_sample_rate" | "track_user_interactions" | ||
* > | ||
* // equivalent to: | ||
* // type SerializedInitConfiguration = { | ||
* // session_sample_rate: number | undefined; | ||
* // track_user_interactions: boolean | undefined; | ||
* // } | ||
*/ | ||
export type ExtractTelemetryConfiguration<Keys extends keyof RemoveIndex<RawTelemetryConfiguration>> = { | ||
[Key in Keys]: RawTelemetryConfiguration[Key] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Remove the index signature from an object type | ||
* @example | ||
* type Foo = { a: string, b: number, [key: string]: any } | ||
* type Bar = RemoveIndex<Foo> // { a: string, b: number } | ||
*/ | ||
export type RemoveIndex<T> = { | ||
[K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K] | ||
} | ||
|
||
/** | ||
* Turn a camel case string into a snake case string | ||
* @example | ||
* type Foo = CamelToSnakeCase<'fooBarBaz'> // 'foo_bar_baz' | ||
*/ | ||
export type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` | ||
? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}` | ||
: S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule rum-events-format
updated
6 files
+14 −0 | lib/cjs/generated/rum.d.ts | |
+16 −0 | lib/cjs/generated/telemetry.d.ts | |
+14 −0 | lib/esm/generated/rum.d.ts | |
+16 −0 | lib/esm/generated/telemetry.d.ts | |
+19 −0 | schemas/rum/error-schema.json | |
+17 −0 | schemas/telemetry/configuration-schema.json |