id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
17,300 | ae5a35d95fd27320fb4a5ddd3daf3bb0 | swh:1:cnt:7d0b5deeedd2208c114e44841617ae9cb3c9499a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=167-174/ | 60fb6d91d9f7691b482e45c642407f67f7df994a | metrics-platform | analytics | js/src/Context.js | copyAttributes | function | /**
* @param {MetricsPlatform.Context.ContextAttributes} from
* @param {MetricsPlatform.Context.ContextAttributes} to
* @memberof MetricsPlatform.Context
*/
function copyAttributes( from, to ) {
VALID_ATTRIBUTE_NAMES.forEach( ( name ) => copyAttributeByName( from, to, name ) );
} |
17,301 | 5758904b3ff823524b8af2a459dbd552 | swh:1:cnt:680cf380cc68222b6f68c7504bf8c59edad421fd;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=4-13/ | 0491bdf453902170c2467bfa88924024ebe6e34b | metrics-platform | analytics | js/src/ContextController.js | ContextController | function | /**
* Add context attributes requested in stream configuration.
*
* @param {MetricsPlatform.Integration} integration
* @constructor
* @memberof MetricsPlatform.Context
*/
function ContextController( integration ) {
this.integration = integration;
} |
17,302 | a16e93bc20f9f1d1f1416a6c286d4e73 | swh:1:cnt:f0de4a221252d09787798885f1bd315e9922d4db;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=22-74/ | 726e8f0516bfe601d7dcfee6131a1e3ccdb24841 | metrics-platform | analytics | js/src/DefaultEventSubmitter.js | DefaultEventSubmitter | function | // (s)
// API
// ===
/**
* The default event submitter used by {@link MetricsClient}.
*
* This event submitter maintains an unbounded internal queue of events, which is drained every
* 5 seconds or when the page is hidden. When the queue is drained, all events in the queue are
* submitted to the event intake ser... |
17,303 | bebf825f1459b6514dbafe2696f3f13a | swh:1:cnt:7b84e09cfb0e6ac8a0330fcaf47de7a59bfd767d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=5-24/ | 94a68f571ec2027e874efae52207b9b4b2d90e6b | metrics-platform | analytics | js/src/DefaultIntegration.js | DefaultIntegration | function | /**
* @implements {MetricsPlatform.ExternalIntegration}
* @memberof MetricsPlatform
*/
/**
* @param {string} [streamConfigsOrigin] The origin of the MediaWiki instance to fetch the stream
* configs from. `https://meta.mediawiki.org` by default
* @constructor
* @implements {MetricsPlatform.Integration}
* @memb... |
17,304 | 825d6adb6a663530d4715fb68ec11079 | swh:1:cnt:7b84e09cfb0e6ac8a0330fcaf47de7a59bfd767d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=26-48/ | 94a68f571ec2027e874efae52207b9b4b2d90e6b | metrics-platform | analytics | js/src/DefaultIntegration.js | getStreamConfigsUrl | function | /**
*
* @param {string} origin
* @return {string}
*/
function getStreamConfigsUrl( origin ) {
const result = new URL( origin );
result.pathname = '/w/api.php';
[
[ 'action', 'streamconfigs' ],
[ 'format', 'json' ],
[ 'formatversion', '2' ],
// Querystring parameters specific to the EventStreamConfigs ... |
17,305 | 62c2f39245fb801a35fd1811e25835a3 | swh:1:cnt:98fff2fc042a88638275d2212be35a825705d39f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=1-6/ | 5740cb968071c1583f54f505fa236d0f5ec5cf95 | metrics-platform | analytics | js/src/DefaultLogger.js | DefaultLogger | function | /**
* @constructor
* @implements {MetricsPlatform.Logger}
* @memberof MetricsPlatform
*/
function DefaultLogger() {} |
17,306 | 0e963f56b1071eafd2d3ffc8633200de | swh:1:cnt:1f46336b192470fca5947492c9ae9c8b97954ba4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=28-45/ | ad93e9d93181d483828c1ff5654cac28c8ebd654 | metrics-platform | analytics | js/src/ExternalMetricsClient.js | ExternalMetricsClient | function | /**
* @param {MetricsPlatform.Integration} integration
* @param {MetricsPlatform.Logger} logger
* @param {MetricsPlatform.EventSubmitter} [eventSubmitter]
* @constructor
* @extends {MetricsPlatform.MetricsClient}
* @memberof MetricsPlatform
*/
function ExternalMetricsClient( integration, logger, eventSubmitter )... |
17,307 | 2be89854c78690178998901eb30e2ce6 | swh:1:cnt:4e75512e835545267c20349a82a6d4fbc6b21b76;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=1-46/ | 2caf5a84115f9c87d653dba8245d690ee4b379a3 | metrics-platform | analytics | js/src/Instrument.js | Instrument | function | /**
* Provides a convenient API for writing an instrument.
*
* This class provides the same methods as {@link MetricsClient} but bound to the stream
* name/schema ID pair, allowing developers to minimize repetition.
*
* Further, each method will mix in a value for `funnel_event_sequence_position` to each submitte... |
17,308 | 41fd2c8cca1e13bfc11b09dc3d38dc6a | swh:1:cnt:518b406343f81a0b077495d4760a67724175023c;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=8-108/ | 95824a4c7b04e480259de03ca044e22d2135b9bd | metrics-platform | analytics | js/src/MetricsClient.js | MetricsClient | function | /**
* @namespace EventPlatform
*/
/**
* @typedef {Object} EventData
* @property {string} $schema
* @property {EventPlatform.EventMetaData} [meta]
* @property {string} [client_dt]
* @property {string} [dt]
* @memberof EventPlatform
*/
/**
* @typedef {Object} EventMetaData
* @property {string} [domain]
* @p... |
17,309 | d5cea821fea99bccfffdedd645832625 | swh:1:cnt:518b406343f81a0b077495d4760a67724175023c;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=110-140/ | 95824a4c7b04e480259de03ca044e22d2135b9bd | metrics-platform | analytics | js/src/MetricsClient.js | getStreamConfigInternal | function | /**
* @ignore
*
* @param {EventPlatform.StreamConfigs|false} streamConfigs
* @param {string} streamName
* @return {EventPlatform.StreamConfig|undefined}
*/
function getStreamConfigInternal( streamConfigs, streamName ) {
// If streamConfigs are false, then stream config usage is not enabled.
// Always return an ... |
17,310 | 795a46debffee3977352dea9343fdfce | swh:1:cnt:518b406343f81a0b077495d4760a67724175023c;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=154-191/ | 95824a4c7b04e480259de03ca044e22d2135b9bd | metrics-platform | analytics | js/src/MetricsClient.js | getEventNameToStreamNamesMap | function | /**
* @ignore
*
* @param {StreamConfigs} streamConfigs
* @return {Map<string, string[]>}
*/
function getEventNameToStreamNamesMap( streamConfigs ) {
/** @type {Map<string, string[]>} */
const result = {};
for ( const streamName in streamConfigs ) {
const streamConfig = streamConfigs[ streamName ];
if (
... |
17,311 | 48a37cce1aa7b2bc4831314afb337d58 | swh:1:cnt:f126b3cc1bda346df1c370f380e952bcff3726de;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=3-19/ | 64b0fd8006b2306bf00849b613cf5db2ace6b9b6 | metrics-platform | analytics | js/src/NodeEventSubmitter.js | NodeEventSubmitter | function | /**
* A simple event submitter for use in server-side environments or environments requiring
* simplicity.
*
* This event submitter submits the event to the event intake service immediately. The request is
* made using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
*
* @param {strin... |
17,312 | ba091157c712d249d35d3f55cee36851 | swh:1:cnt:bdfa1b27bed58711f6f249e9df6bcc0e4200f3ae;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=3-14/ | 62f02cfb0332f66f54444dbdbc0bdf346da1099f | metrics-platform | analytics | js/src/SamplingController.js | SamplingController | function | // (2^32) - 1
/**
* Evaluate events for presence in sample based on the stream configuration.
*
* @param {MetricsPlatform.Integration} integration
* @constructor
* @memberof MetricsPlatform
*/
function SamplingController( integration ) {
this.integration = integration;
} |
17,313 | 87796b5b6837ccfc3447e75d8c749607 | swh:1:cnt:6ebb0f2b9a5d4b1ad2c5ff6265cd4f25fa1727f7;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=68-103/ | e032847cd325be0570149225821c6387def3ad1d | metrics-platform | analytics | js/src/StreamConfig.js | isValidSample | function | /**
* @typedef {Object} StreamProducerConfig
* @property {string[]} [events]
* @property {EventPlatform.StreamSampleConfig} [sampling]
* @property {EventPlatform.StreamProducerContextAttribute[]} [provide_values]
* @memberof EventPlatform
*/
/**
* @typedef {Object} StreamConfig
* @property {string} [schema_tit... |
17,314 | faea627a6a37d982885f9d9bc8041d90 | swh:1:cnt:9fcf98df60bed00319241dc847f0bcc24433516a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=3-7/ | 7f1673e148af6629a476103746296f849ab059b9 | metrics-platform | analytics | js/test/unit/StubEventSubmitter.js | StubEventSubmitter | function | /**
* @constructor
*/
function StubEventSubmitter() {
} |
17,315 | e8b8dafd639dd78d57a9f0e8fa82c7e3 | swh:1:cnt:f3ac4d9dae56d88f562eae3484419bc61843771b;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=3-10/ | 17b9fd93435366a20be8d2ab6ec9bf2eaf6d4756 | metrics-platform | analytics | js/test/unit/TestMetricsClientIntegration.js | TestMetricsClientIntegration | function | /**
* @constructor
*/
function TestMetricsClientIntegration() {
this.pageviewId = this.generateRandomId();
this.sessionId = this.generateRandomId();
this.activeBrowsingSessionToken = this.generateRandomId();
} |
17,316 | e8859cf333dce22e4c27e43008afd5ef | swh:1:cnt:665479a22fd016f59a0263a9eb48dd708b23e3ac;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=3-6/ | e7034d873bd5ee3159897a8cf1c4472d963b71b7 | metrics-platform | analytics | js/test/unit/TestMetricsClientLogger.js | TestMetricsClientLogger | function | /**
* @constructor
*/
function TestMetricsClientLogger() {} |
17,317 | 49a872de9e88b2c2db41ddbafc67c1d6 | swh:1:cnt:e7ef8bfb0a49167e4ab429d9b259a96c99cf1d75;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-48/ | 29823786e4625941cd8b4dcf9be0ead5209f3e4b | metrics-platform | analytics | php/src/ContextController.php | ContextController | type | class ContextController {
public function __construct(
private readonly Integration $integration
) {
}
/**
* Add context attributes configured in the stream configuration.
*
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/Contextual_attributes
*/
public function addRequestedValues( array $e... |
17,318 | 90fd0c1af634ec43c0dbe653f2385b26 | swh:1:cnt:e7ef8bfb0a49167e4ab429d9b259a96c99cf1d75;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=9-12/ | 29823786e4625941cd8b4dcf9be0ead5209f3e4b | metrics-platform | analytics | php/src/ContextController.php | ContextController::__construct(
private readonly Integration $integration
) | function | public function __construct(
private readonly Integration $integration
) {
} |
17,319 | bd08bd1af920842aa93afb8b797b749f | swh:1:cnt:e7ef8bfb0a49167e4ab429d9b259a96c99cf1d75;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=14-47/ | 29823786e4625941cd8b4dcf9be0ead5209f3e4b | metrics-platform | analytics | php/src/ContextController.php | ContextController::addRequestedValues( array $event, StreamConfig $streamConfig ) | function | /**
* Add context attributes configured in the stream configuration.
*
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/Contextual_attributes
*/
public function addRequestedValues( array $event, StreamConfig $streamConfig ): array {
$requestedValues = $streamConfig->getRequestedValues();
$reques... |
17,320 | 37bc54ac30d8ed635a25480212dd6ac8 | swh:1:cnt:a97f362ce57599436124b3d2982a6d2ffaed60c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=5-14/ | 98f1e1bdfbdf3da691064b0eb539b92f3c67d28d | metrics-platform | analytics | php/src/EventSubmitter.php | EventSubmitter | type | interface EventSubmitter {
/**
* Submit an event according to the configuration of the given stream.
*
* @see https://wikitech.wikimedia.org/wiki/Event_Platform
* @see https://wikitech.wikimedia.org/wiki/Event_Platform/Instrumentation_How_To#In_PHP
*/
public function submit( string $streamName, array $even... |
17,321 | 988fc1e4119b2ed1dd2b16518fa1a676 | swh:1:cnt:a97f362ce57599436124b3d2982a6d2ffaed60c1;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-13/ | 98f1e1bdfbdf3da691064b0eb539b92f3c67d28d | metrics-platform | analytics | php/src/EventSubmitter.php | EventSubmitter::submit( string $streamName, array $event ) | function | /**
* Submit an event according to the configuration of the given stream.
*
* @see https://wikitech.wikimedia.org/wiki/Event_Platform
* @see https://wikitech.wikimedia.org/wiki/Event_Platform/Instrumentation_How_To#In_PHP
*/
public function submit( string $streamName, array $event ): void; |
17,322 | 43c20a29b98ca8d2a24ad8246998bd53 | swh:1:cnt:fa37bccaaaca03b67fe4b59ed0c80c55e93baa80;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=5-17/ | e77a8e79a39d0b38897690959dc3e78ca035dcd8 | metrics-platform | analytics | php/src/Integration.php | Integration | type | interface Integration {
/**
* Gets the value of a context attribute by name, e.g. performer_id.
*
* See `php/src/StreamConfig/data/metrics_platform_client.schema.json` for a list of the
* valid context attribute names.
*
* @param string $name
* @return mixed|null
*/
public function getContextAttribut... |
17,323 | 84970acef94510681cc2064cbdb16444 | swh:1:cnt:fa37bccaaaca03b67fe4b59ed0c80c55e93baa80;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-16/ | e77a8e79a39d0b38897690959dc3e78ca035dcd8 | metrics-platform | analytics | php/src/Integration.php | Integration::getContextAttribute( string $name ) | function | /**
* Gets the value of a context attribute by name, e.g. performer_id.
*
* See `php/src/StreamConfig/data/metrics_platform_client.schema.json` for a list of the
* valid context attribute names.
*
* @param string $name
* @return mixed|null
*/
public function getContextAttribute( string $name ); |
17,324 | d91030fb7c1015888ff694f714921dd1 | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=13-108/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient | type | class MetricsClient implements LoggerAwareInterface {
use LoggerAwareTrait;
/**
* The ID of the Metrics Platform base schema in the schemas/event/secondary repository.
*
* @var string
*/
public const BASE_SCHEMA = '/analytics/product_metrics/web/base/1.5.0';
/** @var ContextController */
private $context... |
17,325 | ded0aa5a7276ea79350713a44026fc2d | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=26-42/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient::__construct(
private readonly EventSubmitter $eventSubmitter,
private readonly Integration $integration,
private readonly StreamConfigFactory $streamConfigFactory,
?LoggerInterface $logger = null,
?ContextController $contextController = null
) | function | /**
* @param EventSubmitter $eventSubmitter
* @param Integration $integration
* @param StreamConfigFactory $streamConfigFactory
* @param ?LoggerInterface $logger
* @param ?ContextController $contextController
*/
public function __construct(
private readonly EventSubmitter $eventSubmitter,
private reado... |
17,326 | d0eebf30c8fae54689c5b87518b23af8 | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=53-85/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient::submitInteraction(
string $streamName,
string $schemaId,
string $action,
array $interactionData = []
) | function | /**
* Submit an interaction event to a stream.
*
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/PHP_API
*/
public function submitInteraction(
string $streamName,
string $schemaId,
string $action,
array $interactionData = []
): void {
// See https://gitlab.wikimedia.org/repos/data-engine... |
17,327 | 14924dea22ba75e5c9b4f04ed6d4d0db | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=44-51/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient::submit( string $streamName, array $eventData ) | function | /**
* Submit an event to a stream.
*
* @stable
*/
public function submit( string $streamName, array $eventData ): void {
$this->eventSubmitter->submit( $streamName, $eventData );
} |
17,328 | 141aad184e212a9f33e4f36201f5bcef | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=87-97/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient::submitClick(
string $streamName,
array $interactionData
) | function | /**
* Submit a click event to a stream.
*
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/PHP_API
*/
public function submitClick(
string $streamName,
array $interactionData
): void {
$this->submitInteraction( $streamName, self::BASE_SCHEMA, 'click', $interactionData );
} |
17,329 | 486dae3750c502da3ba41ccc50013ace | swh:1:cnt:fb82809df5ef22d5e50860e5eb51dac0ce9477cf;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=99-107/ | c9aa00dfd0ff19ef0eec97a434543a17e7a47c5d | metrics-platform | analytics | php/src/MetricsClient.php | MetricsClient::getTimestamp() | function | /**
* Get an ISO 8601 timestamp for the current time, e.g. 2022-05-03T14:00:41.000Z.
*
* Note well that the timestamp contains milliseconds for consistency with other Metrics
* Platform Client implementations.
*/
private function getTimestamp(): string {
return ConvertibleTimeStamp::now( TS_ISO_8601 );
} |
17,330 | f146b4a4a797c16f9ba7dae77785e6e9 | swh:1:cnt:58ccc68c91420ddd4f5d62a2227a8fde6318c04a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=5-77/ | a099dd6b9cbdb760fac415af1553313a9697e665 | metrics-platform | analytics | php/src/StreamConfig/StreamConfig.php | StreamConfig | type | class StreamConfig {
/**
* @var string[] The context attributes that the Metrics Platform Client can add to an event
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/Contextual_attributes
*/
public const CONTEXTUAL_ATTRIBUTES = [
'agent_client_platform',
'agent_client_platform_family',
'agent_... |
17,331 | b075859f105c3a055c45b096b619903d | swh:1:cnt:58ccc68c91420ddd4f5d62a2227a8fde6318c04a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=52-58/ | a099dd6b9cbdb760fac415af1553313a9697e665 | metrics-platform | analytics | php/src/StreamConfig/StreamConfig.php | StreamConfig::__construct(
private readonly array $streamConfig
) | function | /**
* @param array $streamConfig
*/
public function __construct(
private readonly array $streamConfig
) {
} |
17,332 | 3fda5e69dad4275c3bf0340e439e6ece | swh:1:cnt:58ccc68c91420ddd4f5d62a2227a8fde6318c04a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=71-76/ | a099dd6b9cbdb760fac415af1553313a9697e665 | metrics-platform | analytics | php/src/StreamConfig/StreamConfig.php | StreamConfig::getCurationRules() | function | /**
* Gets the curation rules that should be applied to an event before submission.
*/
public function getCurationRules(): array {
return $this->streamConfig['producers']['metrics_platform_client']['curation'] ?? [];
} |
17,333 | 6187d280841e8167a041e31f983962e9 | swh:1:cnt:58ccc68c91420ddd4f5d62a2227a8fde6318c04a;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=60-69/ | a099dd6b9cbdb760fac415af1553313a9697e665 | metrics-platform | analytics | php/src/StreamConfig/StreamConfig.php | StreamConfig::getRequestedValues() | function | /**
* Gets the context attributes that should be mixed into an event before submission.
*
* @see StreamConfig::CONTEXTUAL_ATTRIBUTES
*
* @return string[]
*/
public function getRequestedValues(): array {
return $this->streamConfig['producers']['metrics_platform_client']['provide_values'] ?? [];
} |
17,334 | fecd093665f5900ddc03d9eb25344d42 | swh:1:cnt:4ba7c021e9bb2a1f558b47b000050298689baaf4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-8/ | 574f2a8e8124cdeae1a09da8f1dd0e2bfe72c8be | metrics-platform | analytics | php/src/StreamConfig/StreamConfigException.php | StreamConfigException | type | class StreamConfigException extends RuntimeException {
} |
17,335 | 87ee3883a8e4f7f653d0358819152bee | swh:1:cnt:29e956733bff371fee4523d0941c889c391ca47f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=5-89/ | b83614098d94956c5fa7f3c27e3a909036618cf9 | metrics-platform | analytics | php/src/StreamConfig/StreamConfigFactory.php | StreamConfigFactory | type | class StreamConfigFactory {
/** @var array|false */
protected $rawStreamConfigs;
/** @var array<string,string[]> */
private $eventToStreamNamesMap;
/**
* @param array|false $rawStreamConfigs
*/
public function __construct( $rawStreamConfigs ) {
$this->rawStreamConfigs = $rawStreamConfigs;
}
/**
* Ge... |
17,336 | 2afd0e32d0805a4a18862af011413173 | swh:1:cnt:29e956733bff371fee4523d0941c889c391ca47f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=13-18/ | b83614098d94956c5fa7f3c27e3a909036618cf9 | metrics-platform | analytics | php/src/StreamConfig/StreamConfigFactory.php | StreamConfigFactory::__construct( $rawStreamConfigs ) | function | /**
* @param array|false $rawStreamConfigs
*/
public function __construct( $rawStreamConfigs ) {
$this->rawStreamConfigs = $rawStreamConfigs;
} |
17,337 | 2b025dd7b95daff5c18cc35c7ceb232a | swh:1:cnt:29e956733bff371fee4523d0941c889c391ca47f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=44-54/ | b83614098d94956c5fa7f3c27e3a909036618cf9 | metrics-platform | analytics | php/src/StreamConfig/StreamConfigFactory.php | StreamConfigFactory::getStreamNamesForEvent( string $eventName ) | function | public function getStreamNamesForEvent( string $eventName ): array {
$result = [];
foreach ( $this->getEventToStreamNamesMap() as $key => $streamNames ) {
if ( str_starts_with( $eventName, $key ) ) {
$result = array_merge( $result, $streamNames );
}
}
return $result;
} |
17,338 | 65bf6aeec122408526b0427dfd28e66e | swh:1:cnt:29e956733bff371fee4523d0941c889c391ca47f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=20-42/ | b83614098d94956c5fa7f3c27e3a909036618cf9 | metrics-platform | analytics | php/src/StreamConfig/StreamConfigFactory.php | StreamConfigFactory::getStreamConfig( string $streamName ) | function | /**
* Gets the configuration for the given stream.
*
* Note well that if the raw stream configuration is falsy, then this will always return
* an empty stream configuration.
*
* @throws StreamConfigException If the given stream is not configured
* @throws StreamConfigException If the given stream configur... |
17,339 | 408fa2d0a3b415bb05e33db54ed0dd00 | swh:1:cnt:29e956733bff371fee4523d0941c889c391ca47f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=56-88/ | b83614098d94956c5fa7f3c27e3a909036618cf9 | metrics-platform | analytics | php/src/StreamConfig/StreamConfigFactory.php | StreamConfigFactory::getEventToStreamNamesMap() | function | private function getEventToStreamNamesMap(): array {
if ( $this->rawStreamConfigs === false ) {
return [];
}
if ( $this->eventToStreamNamesMap !== null ) {
return $this->eventToStreamNamesMap;
}
$this->eventToStreamNamesMap = [];
foreach ( $this->rawStreamConfigs as $streamName => $rawStreamConfig ... |
17,340 | d23967d69a0b78bb4a3d8c6fa61680b9 | swh:1:cnt:99eb20b18ea3d52ffa74e6df200db253630e46a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=9-77/ | 6db6f91d3f35d396294e6b21cb28d39e8f697d36 | metrics-platform | analytics | php/src/StreamConfig/ValidatingStreamConfigFactory.php | ValidatingStreamConfigFactory | type | class ValidatingStreamConfigFactory extends StreamConfigFactory {
/** @var stdClass */
private $schema;
/**
* @param array|false $rawStreamConfigs
* @param Validator $validator
*/
public function __construct(
$rawStreamConfigs,
private readonly Validator $validator
) {
parent::__construct( $rawStream... |
17,341 | 0112aa9ff1474b743af4d8c6132cc2ae | swh:1:cnt:99eb20b18ea3d52ffa74e6df200db253630e46a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=14-25/ | 6db6f91d3f35d396294e6b21cb28d39e8f697d36 | metrics-platform | analytics | php/src/StreamConfig/ValidatingStreamConfigFactory.php | ValidatingStreamConfigFactory::__construct(
$rawStreamConfigs,
private readonly Validator $validator
) | function | /**
* @param array|false $rawStreamConfigs
* @param Validator $validator
*/
public function __construct(
$rawStreamConfigs,
private readonly Validator $validator
) {
parent::__construct( $rawStreamConfigs );
$this->schema = (object)[ '$ref' => 'file://' . __DIR__ . '/data/metrics_platform_client.schema... |
17,342 | 87dc89dee69ccef7ce0298200446e1ad | swh:1:cnt:99eb20b18ea3d52ffa74e6df200db253630e46a4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=27-76/ | 6db6f91d3f35d396294e6b21cb28d39e8f697d36 | metrics-platform | analytics | php/src/StreamConfig/ValidatingStreamConfigFactory.php | ValidatingStreamConfigFactory::getStreamConfig( $streamName ) | function | /**
* @inheritDoc
*
* @throws StreamConfigException If the given stream configuration does not validate against
* the Metrics Platform Client configuration schema
*/
public function getStreamConfig( $streamName ): StreamConfig {
$result = parent::getStreamConfig( $streamName );
if ( $this->rawStreamCon... |
17,343 | 224c488ed93a478f3a01a02cfaae2bc7 | swh:1:cnt:dba26e5ea94dd2c5ffba4eb27bfab6f5603b682f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=11-84/ | f2767bd49b0f994ca15080109341d5a5fe082b84 | metrics-platform | analytics | php/tests/ContextControllerTest.php | ContextControllerTest | type | /**
* @covers \Wikimedia\MetricsPlatform\ContextController
*/
class ContextControllerTest extends TestCase {
private ContextController $contextController;
private StreamConfig $streamConfig;
protected function setUp(): void {
$this->contextController = new ContextController( new TestIntegration() );
$this->... |
17,344 | 5a3b55836d03f8f8b87c96bac6f85da4 | swh:1:cnt:dba26e5ea94dd2c5ffba4eb27bfab6f5603b682f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=20-30/ | f2767bd49b0f994ca15080109341d5a5fe082b84 | metrics-platform | analytics | php/tests/ContextControllerTest.php | ContextControllerTest::setUp() | function | protected function setUp(): void {
$this->contextController = new ContextController( new TestIntegration() );
$this->streamConfig = new StreamConfig( [
'schema_title' => 'test/event',
'producers' => [
'metrics_platform_client' => [
'provide_values' => StreamConfig::CONTEXTUAL_ATTRIBUTES,
],
],... |
17,345 | a6aa1fd56b695c447699179a053df7e9 | swh:1:cnt:dba26e5ea94dd2c5ffba4eb27bfab6f5603b682f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=32-83/ | f2767bd49b0f994ca15080109341d5a5fe082b84 | metrics-platform | analytics | php/tests/ContextControllerTest.php | ContextControllerTest::testAddContextValues() | function | public function testAddContextValues(): void {
$baseEvent = [
'$schema' => 'test/event',
'meta' => [ 'stream' => 'test.event' ],
];
$event = $this->contextController->addRequestedValues( $baseEvent, $this->streamConfig );
$agentData = $event['agent'];
$pageData = $event['page'];
$userData = $event['... |
17,346 | d97efa40894546b325f909061bc623e8 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=13-189/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest | type | /**
* @covers \Wikimedia\MetricsPlatform\MetricsClient
*/
class MetricsClientTest extends TestCase {
use TestHelperTrait;
private TestEventSubmitter $eventSubmitter;
private TestIntegration $integration;
private StreamConfigFactory $config;
private MetricsClient $client;
private array $streamConfigs = [
... |
17,347 | da81647dc8b175d0202ab9b4eda47369 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=42-54/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::setUp() | function | /** @inheritDoc */
protected function setUp(): void {
parent::setUp();
$this->eventSubmitter = new TestEventSubmitter();
$this->integration = new TestIntegration();
$this->config = new StreamConfigFactory( $this->streamConfigs );
$this->client = new MetricsClient(
$this->eventSubmitter,
$this->integra... |
17,348 | 93a94e3ced582598cd8a1142c021baec | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=83-102/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmitInteraction() | function | public function testSubmitInteraction(): void {
$eventName = 'test_action';
$this->client->submitInteraction(
$this->testStreamName,
MetricsClient::BASE_SCHEMA,
$eventName,
$this->getTestInteractionData()
);
[ $actualStreamName, $actualEvent ] = $this->eventSubmitter->getSubmissions()[0];
$expect... |
17,349 | 6f6eab85a36963b308d028274f181241 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=75-81/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::assertIsValidTimestamp( string $timestamp ) | function | private function assertIsValidTimestamp( string $timestamp ): void {
$this->assertStringEndsWith( 'Z', $timestamp );
$this->assertInstanceOf(
DateTimeImmutable::class,
DateTimeImmutable::createFromFormat( DateTimeImmutable::ATOM, $timestamp )
);
} |
17,350 | 55d387c5cf2b9a8a13b766948b881525 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=104-122/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmitInteractionCannotOverrideSchemaDt() | function | public function testSubmitInteractionCannotOverrideSchemaDt(): void {
$eventName = 'test_action';
$this->client->submitInteraction(
$this->testStreamName,
MetricsClient::BASE_SCHEMA,
$eventName,
[
'$schema' => 'foo',
'dt' => 'bar',
]
);
[ , $actualEvent ] = $this->eventSubmitter->getSubm... |
17,351 | 257e1eb6d1dcfcc5ce07ebd9cc341ee8 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=56-73/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmit() | function | public function testSubmit(): void {
$streamName = 'test.event';
$event = [
'$schema' => '/test/event/1.0.0',
'field_a' => 'A',
'dt' => '2021-03-15T00:00:01Z',
];
$this->client->submit( $streamName, $event );
$submission = $this->eventSubmitter->getSubmissions()[0];
$this->assertSame(
[ $stre... |
17,352 | 6a359764f0e2b78a181eb3abdb896147 | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=124-133/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmitInteractionWithUndefinedStream() | function | public function testSubmitInteractionWithUndefinedStream(): void {
$this->client->submitInteraction(
'undefined_stream',
MetricsClient::BASE_SCHEMA,
'test_action',
[]
);
$this->assertSame( [], $this->eventSubmitter->getSubmissions() );
} |
17,353 | 02a78e08ea57fdbe4b2fc67525faf0bd | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=135-147/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmitInteractionAddsRequestedValues() | function | public function testSubmitInteractionAddsRequestedValues(): void {
$this->client->submitInteraction(
'test.metrics_platform.interactions',
MetricsClient::BASE_SCHEMA,
'test_action',
[]
);
[ , $event ] = $this->eventSubmitter->getSubmissions()[0];
$this->assertArrayHasKey( 'agent', $event );
$thi... |
17,354 | eed4478fb1f853501d2de77ea40722ec | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=149-164/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::testSubmitClick() | function | public function testSubmitClick(): void {
$this->client->submitClick(
$this->testStreamName,
$this->getTestInteractionData()
);
[ $actualStreamName, $actualEvent ] = $this->eventSubmitter->getSubmissions()[0];
$expectedEvent = $this->getTestInteractionEvent( 'click' );
$this->assertSame( $this->testStr... |
17,355 | 985026b559a3b1b3c937efa69102151f | swh:1:cnt:cdfecd39039d455de56da4183dd5041c7031d394;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=166-188/ | ecef67d5fdfa3057657ee5a1269e8f3594f9bc1f | metrics-platform | analytics | php/tests/MetricsClientTest.php | MetricsClientTest::assertEventSame(
array $expectedEvent,
array $actualEvent,
bool $ignoreContextAttributes = false,
string $message = ''
) | function | private function assertEventSame(
array $expectedEvent,
array $actualEvent,
bool $ignoreContextAttributes = false,
string $message = ''
): void {
$keys = [ 'dt' ];
if ( $ignoreContextAttributes ) {
$keys = array_merge( $keys, [
'agent',
'page',
'mediawiki',
'performer',
] );
}
f... |
17,356 | bc82c21b26e340d764c485c70cb4f3e2 | swh:1:cnt:a2bcd884f8d18a184f0e74c11e785473cddb5df9;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-19/ | 1570f3fef34e19ce3474499ca2dadbec3eaf380b | metrics-platform | analytics | php/tests/TestEventSubmitter.php | TestEventSubmitter | type | class TestEventSubmitter implements EventSubmitter {
private array $submissions = [];
/** @inheritDoc */
public function submit( string $streamName, array $event ): void {
$this->submissions[] = [ $streamName, $event ];
}
public function getSubmissions(): array {
return $this->submissions;
}
} |
17,357 | 203ba5bf5ecea522a79958fd7ae6852b | swh:1:cnt:a2bcd884f8d18a184f0e74c11e785473cddb5df9;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=11-14/ | 1570f3fef34e19ce3474499ca2dadbec3eaf380b | metrics-platform | analytics | php/tests/TestEventSubmitter.php | TestEventSubmitter::submit( string $streamName, array $event ) | function | /** @inheritDoc */
public function submit( string $streamName, array $event ): void {
$this->submissions[] = [ $streamName, $event ];
} |
17,358 | 88c33fd2b5f52fa62147627949e15499 | swh:1:cnt:a2bcd884f8d18a184f0e74c11e785473cddb5df9;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=16-18/ | 1570f3fef34e19ce3474499ca2dadbec3eaf380b | metrics-platform | analytics | php/tests/TestEventSubmitter.php | TestEventSubmitter::getSubmissions() | function | public function getSubmissions(): array {
return $this->submissions;
} |
17,359 | a311569cbe89dbc9f5111fb06d5086cd | swh:1:cnt:d7d9b1360faa1cff87fc2a7b9ae1fccde0fffec3;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=8-37/ | 784714999360634e3f1908d9c5045bf7f8216f56 | metrics-platform | analytics | php/tests/TestHelperTrait.php | TestHelperTrait | type | trait TestHelperTrait {
private string $testStreamName = 'test.metrics_platform.interactions';
private function createTestInteractionEvent(): array {
return [
'$schema' => MetricsClient::BASE_SCHEMA,
'dt' => ConvertibleTimeStamp::now( TS_ISO_8601 )
];
}
private function getTestInteractionEvent( string $... |
17,360 | 51ae8f045caa0b7e28726a1fac67d9ba | swh:1:cnt:d7d9b1360faa1cff87fc2a7b9ae1fccde0fffec3;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=11-16/ | 784714999360634e3f1908d9c5045bf7f8216f56 | metrics-platform | analytics | php/tests/TestHelperTrait.php | TestHelperTrait::createTestInteractionEvent() | function | private function createTestInteractionEvent(): array {
return [
'$schema' => MetricsClient::BASE_SCHEMA,
'dt' => ConvertibleTimeStamp::now( TS_ISO_8601 )
];
} |
17,361 | cde1890e60d8370c6c7bd73d09b12662 | swh:1:cnt:d7d9b1360faa1cff87fc2a7b9ae1fccde0fffec3;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=18-23/ | 784714999360634e3f1908d9c5045bf7f8216f56 | metrics-platform | analytics | php/tests/TestHelperTrait.php | TestHelperTrait::getTestInteractionEvent( string $eventName ) | function | private function getTestInteractionEvent( string $eventName ): array {
$eventBase = $this->createTestInteractionEvent();
$interactionData = $this->getTestInteractionData();
$interactionData['action'] = $eventName;
return array_merge( $eventBase, $interactionData );
} |
17,362 | 57b759e498ae624fe9f7c733141c5f7e | swh:1:cnt:d7d9b1360faa1cff87fc2a7b9ae1fccde0fffec3;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=25-36/ | 784714999360634e3f1908d9c5045bf7f8216f56 | metrics-platform | analytics | php/tests/TestHelperTrait.php | TestHelperTrait::getTestInteractionData() | function | private function getTestInteractionData(): array {
return [
'action_subtype' => 'test_action_subtype',
'action_source' => 'test_action_source',
'action_context' => 'test_action_context',
'element_id' => 'test_element_id',
'element_friendly_name' => 'test_element_friendly_name',
'funnel_name' => 'tes... |
17,363 | c17aa6a14d2af6bff0b1f67e865ca802 | swh:1:cnt:a6c64727489a1e122a560d7150877fdd8a8c24d4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-56/ | d69a6c7a523a0b567bdd5c20fff323150bd73030 | metrics-platform | analytics | php/tests/TestIntegration.php | TestIntegration | type | class TestIntegration implements Integration {
/** @var array */
private array $contextAttributes = [
'agent_client_platform' => 'mediawiki_php',
'agent_client_platform_family' => null,
'agent_ua_string' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
'performer_is_logged_in' => true,
'performer_id'... |
17,364 | d4d268e325c38bfe27c2e5cb8ce0316b | swh:1:cnt:a6c64727489a1e122a560d7150877fdd8a8c24d4;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=49-55/ | d69a6c7a523a0b567bdd5c20fff323150bd73030 | metrics-platform | analytics | php/tests/TestIntegration.php | TestIntegration::getContextAttribute( string $name ) | function | /**
* @param string $name
* @return mixed|null
*/
public function getContextAttribute( string $name ) {
return $this->contextAttributes[ $name ] ?? null;
} |
17,365 | 218107a027d09cf6192d07cc32411028 | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=11-93/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest | type | /**
* @covers \Wikimedia\MetricsPlatform\StreamConfig\StreamConfig
* @covers \Wikimedia\MetricsPlatform\StreamConfig\StreamConfigFactory
*/
class StreamConfigFactoryTest extends TestCase {
private function getFactory( $rawStreamConfigs ): StreamConfigFactory {
return new StreamConfigFactory( $rawStreamConfigs );
... |
17,366 | d29bd711dfa44e7705b2d0150e58e77c | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=16-18/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest::getFactory( $rawStreamConfigs ) | function | private function getFactory( $rawStreamConfigs ): StreamConfigFactory {
return new StreamConfigFactory( $rawStreamConfigs );
} |
17,367 | 8c7fb85b7b8c3fdc3dfa8b3f67dba850 | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=54-92/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest::testGetStreamNamesForEvent() | function | public function testGetStreamNamesForEvent(): void {
$factory = $this->getFactory( [
'test.stream' => [],
'test.stream2' => [
'producers' => [
'metrics_platform_client' => [
'events' => [
'foo',
'bar',
],
],
],
],
'test.stream3' => [
'producers' => [
'm... |
17,368 | 713489441f1eb86564d053c7be7ac066 | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=42-52/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest::testGetStreamConfigThrows( $rawStreamConfig ) | function | /**
* @dataProvider provideStreamConfigThrows
*/
public function testGetStreamConfigThrows( $rawStreamConfig ): void {
$this->expectException( StreamConfigException::class );
$factory = $this->getFactory( [
'test.stream' => $rawStreamConfig,
] );
$factory->getStreamConfig( 'foo' );
} |
17,369 | c4aa4a66cd842d3bf386eaa198773398 | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=20-33/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest::testGetStreamConfig() | function | public function testGetStreamConfig(): void {
$factory = $this->getFactory( false );
$this->assertEquals( new StreamConfig( [] ), $factory->getStreamConfig( 'test.stream' ) );
$this->assertEquals( new StreamConfig( [] ), $factory->getStreamConfig( 'foo' ) );
// ---
$factory = $this->getFactory( [
'test.... |
17,370 | 52715d218d26ac34bf53dbce5c7873c0 | swh:1:cnt:afa284b8b2246d6ad25a87c5dde34d399855213d;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=35-40/ | 4463a9a5d360c4e375f3aecbb651f044d3050c34 | metrics-platform | analytics | php/tests/StreamConfig/StreamConfigFactoryTest.php | StreamConfigFactoryTest::provideStreamConfigThrows() | function | public static function provideStreamConfigThrows(): Generator {
yield [ false ];
yield [ true ];
yield [ 1 ];
yield [ 'foo' ];
} |
17,371 | 99ade9a25c28f80bf2edcfecf2562f3a | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=12-192/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest | type | /**
* @covers \Wikimedia\MetricsPlatform\StreamConfig\StreamConfig
* @covers \Wikimedia\MetricsPlatform\StreamConfig\ValidatingStreamConfigFactory
*/
class ValidatingStreamConfigFactoryTest extends TestCase {
private function getFactory( $rawStreamConfigs ): ValidatingStreamConfigFactory {
$validator = new Valida... |
17,372 | 4533c60537ba8a58420e161128efc147 | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=17-21/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::getFactory( $rawStreamConfigs ) | function | private function getFactory( $rawStreamConfigs ): ValidatingStreamConfigFactory {
$validator = new Validator();
return new ValidatingStreamConfigFactory( $rawStreamConfigs, $validator );
} |
17,373 | 0751de77d6bf430c45c16e125eb6b93b | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=88-107/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::testItShouldHandleValidStreamConfigs(
$rawStreamConfig,
$expectedRequestValues,
$expectedCurationRules
) | function | /**
* @dataProvider provideShouldHandleValidStreamConfigs
*/
public function testItShouldHandleValidStreamConfigs(
$rawStreamConfig,
$expectedRequestValues,
$expectedCurationRules
): void {
$streamName = 'test.stream';
$streamConfigs = [
$streamName => $rawStreamConfig,
];
$factory = $this->getF... |
17,374 | 489466ca7fb0dbba150a031447a229ec | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=23-27/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::testItShouldThrowSimple() | function | public function testItShouldThrowSimple(): void {
$this->expectException( StreamConfigException::class );
$this->getFactory( [] )->getStreamConfig( 'test.stream' );
} |
17,375 | 15e33b5292f83fa14f9fd23e3dc98309 | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=29-86/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::provideShouldHandleValidStreamConfigs() | function | public static function provideShouldHandleValidStreamConfigs(): Generator {
yield [
'rawStreamConfig' => [],
'expectedRequestValues' => [],
'expectedCurationRules' => [],
];
yield [
'rawStreamConfig' => [
'producers' => []
],
'expectedRequestValues' => [],
'expectedCurationRules' => [],
... |
17,376 | a9d7361e0961840114a7b7d5c6fa6757 | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=109-117/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::testItShouldHandleDisabledStreamConfigs() | function | public function testItShouldHandleDisabledStreamConfigs(): void {
$streamName = 'test.stream';
$streamConfigs = false;
$factory = $this->getFactory( $streamConfigs );
$streamConfig = $factory->getStreamConfig( $streamName );
$this->assertEquals( new StreamConfig( [] ), $streamConfig );
} |
17,377 | 1738f9ad2ddd92b1a4a82a838934e4f6 | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=119-172/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::provideMetricsPlatformClientConfig() | function | public static function provideMetricsPlatformClientConfig(): Generator {
yield [
'metricsPlatformClientConfig' => [
'foo' => [],
],
];
// provide_values
yield [
'metricsPlatformClientConfig' => [
'provide_values' => [
'foo',
],
],
];
yield [
'metricsPlatformClientConfig' => ... |
17,378 | baa5ed842aadf7143f00385f2cdf1076 | swh:1:cnt:250b5562697c58f55d6dd87f6e87b16e187dc772;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=174-191/ | b52854f8d12829ac248ce79fcd50941539ac7038 | metrics-platform | analytics | php/tests/StreamConfig/ValidatingStreamConfigFactoryTest.php | ValidatingStreamConfigFactoryTest::testItShouldValidateMetricsPlatformClientConfig( $metricsPlatformClientConfig ) | function | /**
* @dataProvider provideMetricsPlatformClientConfig
*/
public function testItShouldValidateMetricsPlatformClientConfig( $metricsPlatformClientConfig ): void {
$this->expectException( StreamConfigException::class );
$streamName = 'test.stream';
$rawStreamConfigs = [
$streamName => [
'producers' => ... |
17,379 | a6032d9722cf73d9a765433ae6115c56 | swh:1:cnt:96991ec14a8ec7e236decd092da3763ec66d2dad;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=8-64/ | ba2e36729e189b933a31024768783aef9939c5e2 | metrics-platform | analytics | tests/consistency/ConsistencyTest.php | ConsistencyTest | type | /**
* @coversNothing
*/
class ConsistencyTest extends TestCase {
private const IMPLEMENTATION_TO_COMMAND_MAP = [
'php' => [ 'php', 'main.php' ],
'js' => [ 'node', 'main.js' ],
];
private function getImplementations(): array {
return array_keys( self::IMPLEMENTATION_TO_COMMAND_MAP );
}
private function su... |
17,380 | a10d8150146837a71979996e2d189185 | swh:1:cnt:96991ec14a8ec7e236decd092da3763ec66d2dad;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=17-19/ | ba2e36729e189b933a31024768783aef9939c5e2 | metrics-platform | analytics | tests/consistency/ConsistencyTest.php | ConsistencyTest::getImplementations() | function | private function getImplementations(): array {
return array_keys( self::IMPLEMENTATION_TO_COMMAND_MAP );
} |
17,381 | ce80515abbd52350aafbe03239579ebf | swh:1:cnt:96991ec14a8ec7e236decd092da3763ec66d2dad;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=21-47/ | ba2e36729e189b933a31024768783aef9939c5e2 | metrics-platform | analytics | tests/consistency/ConsistencyTest.php | ConsistencyTest::submitInteraction( $impl ) | function | private function submitInteraction( $impl ): array {
$command = self::IMPLEMENTATION_TO_COMMAND_MAP[ $impl ];
$cwd = __DIR__ . "/{$impl}";
$process = new Process( $command, $cwd );
$process->run();
$this->assertTrue( $process->isSuccessful(), "The {$impl} implementation should exit without error." );
$thi... |
17,382 | 5c4b931b91e1dbffd242a5ffc23e099b | swh:1:cnt:96991ec14a8ec7e236decd092da3763ec66d2dad;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=49-63/ | ba2e36729e189b933a31024768783aef9939c5e2 | metrics-platform | analytics | tests/consistency/ConsistencyTest.php | ConsistencyTest::testConsistency() | function | public function testConsistency() {
// Check the dispatched data against the expected data.
$expectedEventRaw = file_get_contents( __DIR__ . '/expected_event.json' );
$expectedEvent = json_decode( $expectedEventRaw, true );
foreach ( self::getImplementations() as $impl ) {
$output = $this->submitInteractio... |
17,383 | 500b3a0a74b1a7afecc3240c827a80b7 | swh:1:cnt:e2ecef55d00a5951a4a86cf03279b4a7cab3ea09;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=1-5/ | a1a8bf16d544e5c02a36a961da77d8dca487193e | metrics-platform | analytics | tests/consistency/js/EventSubmitter.js | EventSubmitter | type | class EventSubmitter {
submitEvent( event ) {
console.log( JSON.stringify( event ) );
}
} |
17,384 | e089f39813e692f528d58afe155e93d7 | swh:1:cnt:e2ecef55d00a5951a4a86cf03279b4a7cab3ea09;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=2-4/ | a1a8bf16d544e5c02a36a961da77d8dca487193e | metrics-platform | analytics | tests/consistency/js/EventSubmitter.js | EventSubmitter::submitEvent | function | submitEvent( event ) {
console.log( JSON.stringify( event ) );
} |
17,385 | fbf751fb7937319dd000237774b24546 | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=1-29/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration | type | class Integration {
constructor( filename ) {
this.data = require( filename );
}
getHostname() {
return this.data.hostname;
}
logWarning( message ) {
console.warn( message );
}
clone( obj ) {
return Object.assign( {}, obj );
}
getContextAttributes() {
return this.data;
}
getPageviewId() {
re... |
17,386 | 8ebc588dce8b4f29712c5a6bb42a96af | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=2-4/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::constructor | function | constructor( filename ) {
this.data = require( filename );
} |
17,387 | 435ff2c559cdbb516a836d7e617c5438 | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=14-16/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::clone | function | clone( obj ) {
return Object.assign( {}, obj );
} |
17,388 | 22654363ccf94fb8759b26601637509c | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=10-12/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::logWarning | function | logWarning( message ) {
console.warn( message );
} |
17,389 | d32ebe82548ea1a86379d94a6c6fc437 | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=18-20/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::getContextAttributes | function | getContextAttributes() {
return this.data;
} |
17,390 | 3e58e1ea8ce430f10191801c1da9490b | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=6-8/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::getHostname | function | getHostname() {
return this.data.hostname;
} |
17,391 | 4a08ad6e6db6b3337343ba6b533548c0 | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=22-24/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::getPageviewId | function | getPageviewId() {
return this.data.performer.pageview_id;
} |
17,392 | 80fdd2706047207d7fada20879a200d8 | swh:1:cnt:9618bb8fcd8777b619d3e68cad0cadcc97adb366;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=26-28/ | 238f0fadb98db716e270c7bedc2fb9584e4f2332 | metrics-platform | analytics | tests/consistency/js/Integration.js | Integration::getSessionId | function | getSessionId() {
return this.data.performer.session_id;
} |
17,393 | 7dbc7ad6c44f1b19319beff00f962b1f | swh:1:cnt:23d4e10152edae3fac1d168e8ffb5f6b5e44e37f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-31/ | 5da69b9121787399a06ee9bd171901a65415a877 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestEventSubmitter.php | ConsistencyTestEventSubmitter | type | class ConsistencyTestEventSubmitter implements EventSubmitter {
/** @var string */
private $hostName;
public function __construct( $filename ) {
$rawContents = file_get_contents( $filename );
$contents = json_decode( $rawContents, true );
$this->hostName = $contents['hostname'];
}
/** @inheritDoc */
pub... |
17,394 | d9070b3c82f474106d35cb9c511cf3f8 | swh:1:cnt:23d4e10152edae3fac1d168e8ffb5f6b5e44e37f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=12-17/ | 5da69b9121787399a06ee9bd171901a65415a877 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestEventSubmitter.php | ConsistencyTestEventSubmitter::__construct( $filename ) | function | public function __construct( $filename ) {
$rawContents = file_get_contents( $filename );
$contents = json_decode( $rawContents, true );
$this->hostName = $contents['hostname'];
} |
17,395 | 90958313491b201098dc7a7daf4f37fd | swh:1:cnt:23d4e10152edae3fac1d168e8ffb5f6b5e44e37f;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=19-30/ | 5da69b9121787399a06ee9bd171901a65415a877 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestEventSubmitter.php | ConsistencyTestEventSubmitter::submit( string $streamName, array $event ) | function | /** @inheritDoc */
public function submit( string $streamName, array $event ): void {
$event['meta'] = [
'stream' => $streamName,
'domain' => $this->hostName,
];
// Per ConsistencyTest#dispatch, only the PHP Event Platform Client sets the http property
// of the event and so it is out of scope for the c... |
17,396 | 2f17229d44c06439c31654602dd7d3da | swh:1:cnt:12f5ff6b20c873ab94320f3935c80d9d6f4450fd;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-23/ | a40e0c50a211d78364beae72bb2d6935920230e9 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestIntegration.php | ConsistencyTestIntegration | type | class ConsistencyTestIntegration implements Integration {
/** @var array */
private $data;
public function __construct( $filename ) {
$rawContents = file_get_contents( $filename );
$this->data = json_decode( $rawContents, true );
}
public function getContextAttribute( string $name ) {
list( $primaryKey, ... |
17,397 | 323ecdb50e95de111aa958d00236dcc8 | swh:1:cnt:12f5ff6b20c873ab94320f3935c80d9d6f4450fd;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=12-16/ | a40e0c50a211d78364beae72bb2d6935920230e9 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestIntegration.php | ConsistencyTestIntegration::__construct( $filename ) | function | public function __construct( $filename ) {
$rawContents = file_get_contents( $filename );
$this->data = json_decode( $rawContents, true );
} |
17,398 | 1b18142c8f5e9289b6393bcdfda7c0b3 | swh:1:cnt:12f5ff6b20c873ab94320f3935c80d9d6f4450fd;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=18-22/ | a40e0c50a211d78364beae72bb2d6935920230e9 | metrics-platform | analytics | tests/consistency/php/ConsistencyTestIntegration.php | ConsistencyTestIntegration::getContextAttribute( string $name ) | function | public function getContextAttribute( string $name ) {
list( $primaryKey, $secondaryKey ) = explode( '_', $name, 2 );
return $this->data[$primaryKey][$secondaryKey] ?? null;
} |
17,399 | d36c36bd20b393ca516996037331f720 | swh:1:cnt:1a4e0583b7a541679558726306a0e58e2ef724d3;origin=https://gitlab.wikimedia.org/repos/data-engineering/metrics-platform.git;lines=7-14/ | 20a6f94d4c841cf5d7b1bf37c29169c9658ca098 | metrics-platform | analytics | tests/consistency/php/StreamConfigFactory.php | StreamConfigFactory | type | class StreamConfigFactory extends BaseStreamConfigFactory {
public function __construct( $filename ) {
$rawContents = file_get_contents( $filename );
$contents = json_decode( $rawContents, true );
parent::__construct( $contents["streams"] );
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.