types APIs
- SimpleOptions
- RootState
- User
- ChainType
- FeedbackCategoryAPI
- FeedbackStatusAPI
- FeedbackUserProfileAPI
- NavItems
- SingleNavItem
- NonNullableChildrenDeep
- SingleArticle
- ColumnType
- DataType
- Hub
- PluginConfig
- RawEventMessage
- DualStakingInfo
- StakingInfo
- SyrupInfo
- CommonStakingInfo
- LairInfo
- StakingBasic
- DualStakingBasic
- SyrupBasic
- Questionnaire
- TaskStatuses
- LoginPayload
- SignupPayload
- MutationType
- ProteinSize
- Config
- Themes
- defaults
- CoordinateSpaceInitial
- Background
- Metric
- Metadata
- TManageValue
- Domain
- Organization
- OrganizationTag
- Scan
- ScanSchema
- Query
- SavedSearch
- Role
- ScanTask
- Vulnerability
- GenericObject
- Annotation
- AnnotationList
- VideoAnnotation
- IconName
- IllustrationName
- INotification
- BottomTabScreens
- KYCScreens
- CCVPScreens
- LoginScreens
- PreAuthScreens
- SignUpScreens
- TFAScreens
- PNVScreens
- ProfileScreens
- SecurityScreens
- SMTYFScreens
- WalletScreens
- WithdrawalScreens
- StackNavigationProps
- Coin
- Country
- TransactionStatus
- SetApiActionPayloadInterface
- LoadingStateInterface
- MessageStateInterface
- UiOptionType
- ApiDiffInterface
- ApiStateInterface
- Account
- NFT
- NFTDetails
- AlertType
- DefaultTemplateOptions
- ProviderProps
- AlertTimer
- AlertInstance
- AlertOptions
- TemplateAlertOptions
- AlertContainerFactory
- ChainBase
- ChainNetwork
- WalletId
- ProposalType
- ChainEventNotification
- WebsocketMessageNames
- WebsocketNamespaces
- NotificationCategories
- InviteCodeAttributes
- IPostNotificationData
- ChainCategoryType
- Screens
- NavigationProperty
- IP
- Maybe
- Tuple
- ChainProperties
- ApiPromise
- ApiAction
- BlueprintOptions
- ContractQuery
- ContractOptions
- ContractTx
- KeyringPair
- ContractDryRunParams
- InstantiateData
- SubmittableExtrinsic
- DbState
- OnInstantiateSuccess$Code
- OnInstantiateSuccess$Hash
- InstantiateState
- ApiState
- OrFalsy
- Bytes
- AbiParam
- Registry
- Weight
- SubmittableResult
- Hash
- CodeBundleDocument
- MyCodeBundles
- ContractDocument
- MyContracts
- Database
- DbStatistics
- UserDocument
- QueuedTxOptions
- TransactionsState
- DropdownOption
- DropdownProps
- ValidFormField
- SetState
- BN
- CallResult
- ContractPromise
- RegistryError
- Abi
- TypeDef
- Validation
- FileState
- UseWeight
- ArgComponentProps
- TypeDefInfo
- UseMetadata
- AbiMessage
- AbiConstructor
- InstantiateProps
- CodeSubmittableResult
- BlueprintSubmittableResult
- BlueprintPromise
- Step2FormData
- TxOptions
- TransactionsQueue
- Keyring
- DbQuery
- UseBalance
- CodeBundle
- ValidateFn
- MetadataState
- UseStepper
- UseToggle
- Party
- Restaurant
- BoardMember
- Id
- Label
- Priority
- Avatar
- PriorityValue
- AuthSetup
- IColumn
- Board
- ITask
- TaskComment
- NewTaskComment
- WithTheme
- UserDetail
- TasksByColumn
- NewTask
- ValueOf
- APIResponse
- Nullable
- Currency
- Route
- Author
- Post
- Category
- Watch
- ComputeCallback
Other Related APIs
types#Hub TypeScript Examples
The following examples show how to use
types#Hub.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: posthog.ts From posthog-foss with MIT License | 5 votes |
export function createPosthog(server: Hub, pluginConfig: PluginConfig): DummyPostHog {
const distinctId = pluginConfig.plugin?.name || `plugin-id-${pluginConfig.plugin_id}`
let sendEvent: (data: InternalData) => Promise<void>
if (server.KAFKA_ENABLED) {
// Sending event to our Kafka>ClickHouse pipeline
sendEvent = async (data) => {
if (!server.kafkaProducer) {
throw new Error('kafkaProducer not configured!')
}
// ignore the promise, run in the background just like with celery
await server.kafkaProducer.queueMessage({
topic: server.KAFKA_CONSUMPTION_TOPIC!,
messages: [
{
key: data.uuid,
value: JSON.stringify({
distinct_id: data.distinct_id,
ip: '',
site_url: '',
data: JSON.stringify(data),
team_id: pluginConfig.team_id,
now: data.timestamp,
sent_at: data.timestamp,
uuid: data.uuid,
} as RawEventMessage),
},
],
})
}
} else {
// Sending event to our Redis>Postgres pipeline
const client = new Client(server.db, server.PLUGINS_CELERY_QUEUE)
sendEvent = async (data) => {
await client.sendTaskAsync(
'posthog.tasks.process_event.process_event_with_plugins',
[data.distinct_id, null, null, data, pluginConfig.team_id, data.timestamp, data.timestamp],
{}
)
}
}
return {
async capture(event, properties = {}) {
const { timestamp = DateTime.utc().toISO(), distinct_id = distinctId, ...otherProperties } = properties
const data: InternalData = {
distinct_id,
event,
timestamp,
properties: {
$lib: 'posthog-plugin-server',
$lib_version: version,
distinct_id,
...otherProperties,
},
team_id: pluginConfig.team_id,
uuid: new UUIDT().toString(),
}
await sendEvent(data)
},
api: createApi(server, pluginConfig),
}
}