:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from typing import cast
from requests.exceptions import HTTPError
from products.warehouse_sources.sources.onehundredms._config import OneHundredMsSourceConfig
from products.warehouse_sources.sources.onehundredms.canonical_descriptions import CANONICAL_DESCRIPTIONS
from products.warehouse_sources.sources.onehundredms.onehundredms import (
OneHundredMsResumeConfig,
onehundredms_source,
validate_credentials,
)
from products.warehouse_sources.sources.onehundredms.settings import (
AUTH_ERROR,
ENDPOINTS,
INCREMENTAL_FIELDS,
PERMISSION_ERROR,
SESSION_LOOKBACK_SECONDS,
)
from products.warehouse_sources.sources.sdk import (
CanonicalDescriptions,
DataWarehouseSourceCategory,
ExternalDataSourceType,
FieldType,
ReleaseStatus,
ResumableSource,
ResumableSourceManager,
SourceConfig,
SourceFieldInputConfig,
SourceFieldInputConfigType,
SourceInputs,
SourceRegistry,
SourceResponse,
SourceSchema,
build_endpoint_schemas,
detect,
)
@SourceRegistry.register
class OneHundredMsSource(ResumableSource[OneHundredMsSourceConfig, OneHundredMsResumeConfig]):
codebase_detection = detect(
env=("^(ONE_HUNDRED_MS|ONEHUNDREDMS)_", "^HMS_ACCESS_KEY$", "^HMS_SECRET$"),
npm=(
"@100mslive/react-sdk",
"@100mslive/hms-video-store",
"@100mslive/server-sdk",
"@100mslive/react-native-hms",
"@100mslive/roomkit-react",
"@100mslive/hls-player",
"@100mslive/hls-stats",
"@100mslive/hms-loadtest",
"@100mslive/hms-noise-suppression",
"@100mslive/hms-video",
"@100mslive/hms-video-react",
"@100mslive/hms-virtual-background",
"@100mslive/hms-whiteboard",
"@100mslive/hmsvideo-web",
"@100mslive/meeting-scribe",
"@100mslive/react-icons",
"@100mslive/react-native-room-kit",
"@100mslive/react-native-video-plugin",
"@100mslive/roomkit-web",
),
cocoapods=("HMSSDK",),
maven=("live.100ms:android-sdk",),
pub=("hmssdk_flutter",),
swiftpm=(
"github.com/100mslive/100ms-ios-sdk",
"github.com/100mslive/100ms-ios-analytics-sdk",
"github.com/100mslive/100ms-ios-broadcast-sdk",
"github.com/100mslive/100ms-ios-hls-sdk",
"github.com/100mslive/100ms-ios-sdk-staging",
"github.com/100mslive/100ms-noise-cancellation-models-ios",
"github.com/100mslive/100ms-roomkit-ios",
"github.com/100mslive/100ms-roomkit-models-ios",
),
)
lists_tables_without_credentials = True
supported_versions = ("v2",)
default_version = "v2"
api_docs_url = "https://www.100ms.live/docs/server-side/v2/release-notes/release-notes"
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.ONEHUNDREDMS
def get_non_retryable_errors(self) -> dict[str, str | None]:
return {"401 Client Error": AUTH_ERROR, "403 Client Error": PERMISSION_ERROR}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
return CANONICAL_DESCRIPTIONS
def get_schemas(
self,
config: OneHundredMsSourceConfig,
team_id: int,
with_counts: bool = False,
names: list[str] | None = None,
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
schemas = build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names, merge_only={"sessions"})
for schema in schemas:
if schema.name == "sessions":
schema.default_incremental_lookback_seconds = SESSION_LOOKBACK_SECONDS
return schemas
def validate_credentials(
self,
config: OneHundredMsSourceConfig,
team_id: int,
schema_name: str | None = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
try:
validate_credentials(config, self.resolve_api_version(api_version), schema_name)
except HTTPError as error:
if error.response is not None:
if error.response.status_code == 401:
return False, AUTH_ERROR
if error.response.status_code == 403:
return False, PERMISSION_ERROR
raise
return True, None
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[OneHundredMsResumeConfig]:
return ResumableSourceManager(inputs, OneHundredMsResumeConfig)
def source_for_pipeline(
self,
config: OneHundredMsSourceConfig,
resumable_source_manager: ResumableSourceManager[OneHundredMsResumeConfig],
inputs: SourceInputs,
) -> SourceResponse:
return onehundredms_source(
config, inputs, resumable_source_manager, self.resolve_api_version(inputs.api_version)
)
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=ExternalDataSourceType.ONEHUNDREDMS,
category=DataWarehouseSourceCategory.COMMUNICATION,
label="100ms",
caption=(
"Find your app access key and app secret in the Developer section of your "
"[100ms dashboard](https://dashboard.100ms.live/). Only completed sessions are imported."
),
iconPath="/static/services/onehundredms.png",
releaseStatus=ReleaseStatus.BETA,
fields=cast(
list[FieldType],
[
SourceFieldInputConfig(
name="app_access_key",
label="App access key",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
SourceFieldInputConfig(
name="app_secret",
label="App secret",
type=SourceFieldInputConfigType.PASSWORD,
required=True,
placeholder="",
secret=True,
),
],
),
)