Skip to content

Models: events, content and the app

Events, content blocks and the app’s public face, from package:crm_sdk/wire.dart.

import 'package:crm_sdk/wire.dart';
NameWhat it is
ContentBlockOne block of content.
CrmPublicLinkAppAn app’s public face for its links: what the page a link lands on without the app shows.
CrmPublicRatingBodyWhether a public help article helped a reader of the web’s help center (POST /public/v1/help/articles/{slug}/rating), who has no account.
EventBodyOne thing the guest did in the product.
EventRejectedOne event of a batch PurrCRM refused, by its place in the batch.
EventsAcceptedThe answer to a batch.
EventsBodyA batch of events, oldest first, with what every event in it shares.
ExportAttributeOne attribute and its value, in the guest’s export.
ExportCollectedOne thing the help bot kept from a conversation.
ExportContactWhat the PurrCRM service keeps about the guest, in their export.
ExportEventOne event recorded about the guest, in their export.
ExportNoteOne note staff wrote about the guest, in their export.
ExportWorkflowRunOne run of a workflow the guest was in.
ListItemOne item of a list.
SpanA run of text with one style.
crmAppKeyHeaderThe header a product’s app key travels in on every request (CrmConfig.appKey): which of PurrCRM’s apps the guest is in.
crmSdkVersionHeaderThe header the package’s version travels in on every request, so that PurrCRM knows which SDK a guest is on.
crmTestAppKeyPrefixWhat a test app’s public key begins with: the key of a live app’s test test app, which a staging build sends and whose data is kept apart from the live app’s.
crmUserIdHeaderThe header a guest’s id travels in instead of a token, for an app that takes unverified guests.
maxEventAgeHow old an event may be when it arrives.
maxEventBatchThe most events one batch carries.
maxEventPropRunesThe longest a prop’s value may be.
maxEventPropsThe most props one event carries.
class ContentBlock

One block of content. Only the fields its type names are set.

The formatting fields (size to style) are a carousel’s and a post’s alone: PurrCRM refuses them anywhere else. Each is optional, and empty (or unknown) is the renderer’s default for where the block is, which carousel_style.json gives.

factory ContentBlock.fromJson(Map<String, Object?> json)
const ContentBlock({required BlockType type, int level = 0, List<Span> spans = const <Span>[], List<ListItem> items = const <ListItem>[], String imageUrl = '', String alt = '', String label = '', String link = '', String size = '', String color = '', ContentAlign align = ContentAlign.unknown, TextWeight weight = TextWeight.unknown, CalloutTone tone = CalloutTone.unknown, String emoji = '', ImageAspect aspect = ImageAspect.unknown, ImageFit fit = ImageFit.unknown, ImageShape shape = ImageShape.unknown, ContentButtonStyle style = ContentButtonStyle.unknown})
final ContentAlign align

A text block’s or an emoji’s alignment; unknown for the screen’s.

final String alt

What a picture shows, for a guest who cannot see it.

final ImageAspect aspect

A picture’s aspect, fit and shape, as a carousel’s hero’s.

final String color

A text block’s colour, or a callout’s tint: a ColorToken’s word or a fixed #rrggbb; empty for the screen’s text colour.

final String emoji

An emoji block’s emoji, or the one before a callout’s words.

final ImageFit fit
final String imageUrl
final List<ListItem> items
final String label
final int level

A heading’s level, 1 to 3.

final String link

Where a button or a picture goes: a path in the product, opened only when its allow-list names it, or an https URL, opened in the browser.

final ImageShape shape
final String size

A word of the block’s own: a TextSize for a paragraph, a heading or a list (textSize), an ImageSize for a picture (imageSize), a SpacerSize for a spacer (spacerSize). Empty for the default.

final List<Span> spans
final ContentButtonStyle style

A button’s style; unknown is primary.

final CalloutTone tone

A callout’s tint when it has no color; unknown is info.

final BlockType type
final TextWeight weight

A paragraph’s or a heading’s weight; unknown for the default.

ImageSize get imageSize

size as a picture’s.

SpacerSize get spacerSize

size as a spacer’s.

TextSize get textSize

size as a text block’s.

class CrmPublicLinkApp

An app’s public face for its links: what the page a link lands on without the app shows. The package reads none of it; it is here so that every fixture of the CRM’s contract has its model.

factory CrmPublicLinkApp.fromJson(Map<String, Object?> json)
const CrmPublicLinkApp({required String key, required String name, required CrmPublicBrand brand, String linkBase = '', String appStoreUrl = '', String playStoreUrl = ''})
final String appStoreUrl
final CrmPublicBrand brand
final String key
final String linkBase

Where the app’s links are (CrmPublicApp.linkBase).

final String name
final String playStoreUrl
class CrmPublicRatingBody

Whether a public help article helped a reader of the web’s help center (POST /public/v1/help/articles/{slug}/rating), who has no account. The web’s, not the package’s: an app’s guest rates with ArticleRatingBody.

factory CrmPublicRatingBody.fromJson(Map<String, Object?> json)
const CrmPublicRatingBody({required bool helpful, required String visitor})
final bool helpful
final String visitor
class EventBody

One thing the guest did in the product.

factory EventBody.fromJson(Map<String, Object?> json)
const EventBody({required String id, required String name, required DateTime occurredAt, Map<String, String> props = const <String, String>{}})
final String id

A UUID drawn when it happened, so a batch sent twice is kept once.

final String name

The event’s name as the word PurrCRM knows it by: a CrmEvent’s, or one the product declared. PurrCRM refuses a batch that names one it does not know, so the tracker sends no other.

final DateTime occurredAt
Map<String, Object?> toJson()
class EventRejected

One event of a batch PurrCRM refused, by its place in the batch.

factory EventRejected.fromJson(Map<String, Object?> json)
const EventRejected({required int index, required String id, required String reason})
final String id
final int index
final String reason
Map<String, Object?> toJson()
class EventsAccepted

The answer to a batch.

factory EventsAccepted.fromJson(Map<String, Object?> json)
const EventsAccepted({required int accepted, List<EventRejected> rejected = const []})
final int accepted

How many were kept: fewer than were sent when some were sent before, were too old, were refused, or the guest has turned product events off.

final List<EventRejected> rejected

The events PurrCRM refused, each alone: a name the app does not define (the app defines its own events on PurrCRM’s site). The rest of the batch was kept.

class EventsBody

A batch of events, oldest first, with what every event in it shares.

factory EventsBody.fromJson(Map<String, Object?> json)
const EventsBody({required List<EventBody> events, required String appVersion, required CrmPlatform platform, String timeZone = '', DateTime? sentAt})
final String appVersion
final List<EventBody> events
final CrmPlatform platform
final DateTime? sentAt

Null leaves it out.

final String timeZone

The phone’s IANA zone name, for the guest’s quiet hours; empty when the phone does not say.

Map<String, Object?> toJson()
class ExportAttribute

One attribute and its value, in the guest’s export.

factory ExportAttribute.fromJson(Map<String, Object?> json)
const ExportAttribute({required String name, required String value})
final String name
final String value
class ExportCollected

One thing the help bot kept from a conversation.

factory ExportCollected.fromJson(Map<String, Object?> json)
const ExportCollected({required String conversationId, required String key, required String value})
final String conversationId
final String key

What it is: order_ref, email, or the name staff gave it.

final String value
class ExportContact

What the PurrCRM service keeps about the guest, in their export.

factory ExportContact.fromJson(Map<String, Object?> json)
const ExportContact({List<ExportAttribute> attributes = const <ExportAttribute>[], List<String> tags = const <String>[], List<ExportNote> notes = const <ExportNote>[], List<ExportEvent> events = const <ExportEvent>[], bool eventsTruncated = false, List<ExportConversation> conversations = const <ExportConversation>[], List<ExportTicket> tickets = const <ExportTicket>[], List<ExportArticleRating> articleRatings = const <ExportArticleRating>[], List<ExportReceipt> receipts = const <ExportReceipt>[], List<ExportSurveyResponse> surveyResponses = const <ExportSurveyResponse>[], List<ExportWorkflowRun> workflows = const <ExportWorkflowRun>[], List<ExportCollected> collected = const <ExportCollected>[], ExportTestPhone? testPhone, List<ExportTestSend> testSends = const <ExportTestSend>[], List<CrmExportDevice> devices = const <CrmExportDevice>[], List<CrmExportNotice> notices = const <CrmExportNotice>[], List<CrmExportSubscription> subscriptions = const <CrmExportSubscription>[], List<CrmExportConsentChange> consentHistory = const <CrmExportConsentChange>[]})
final List<ExportArticleRating> articleRatings
final List<ExportAttribute> attributes

The guest’s attributes by name, each value as a string.

final List<ExportCollected> collected
final List<CrmExportConsentChange> consentHistory
final List<ExportConversation> conversations

The guest’s conversations in the messenger, their tickets, and what they said about help articles; empty from a PurrCRM older than them.

final List<CrmExportDevice> devices

The devices the guest registered for PurrCRM’s pushes, without their tokens, and the inbox of notices it keeps; empty from a PurrCRM older than them.

final List<ExportEvent> events

The events recorded about the guest, newest first.

final bool eventsTruncated

Only the newest events are here: there were more.

final List<ExportNote> notes

What staff wrote about the guest.

final List<CrmExportNotice> notices
final List<ExportReceipt> receipts

The messages staff sent or showed the guest, and their answers to surveys; empty from a PurrCRM older than them.

final List<CrmExportSubscription> subscriptions

The guest’s choices about the app’s topics, and every change of them and of their channels’ own switches; empty from a PurrCRM older than topics.

final List<ExportSurveyResponse> surveyResponses
final List<String> tags

The names of the tags staff put on the guest.

final ExportTestPhone? testPhone

The guest’s account being a test phone, and the tests staff sent it; null and empty when it is not one, or from a PurrCRM older than them.

final List<ExportTestSend> testSends
final List<ExportTicket> tickets
final List<ExportWorkflowRun> workflows

The runs of workflows the guest was in, and what the help bot kept from their conversations; empty from a PurrCRM older than them.

class ExportEvent

One event recorded about the guest, in their export.

factory ExportEvent.fromJson(Map<String, Object?> json)
const ExportEvent({required String name, required DateTime occurredAt, Map<String, String> props = const <String, String>{}})
final String name

An app event’s name or a server event’s, kept as the word: the guest reads it, and an event the package does not know is still theirs.

final DateTime occurredAt
class ExportNote

One note staff wrote about the guest, in their export.

factory ExportNote.fromJson(Map<String, Object?> json)
const ExportNote({required String body, required DateTime createdAt})
final String body
final DateTime createdAt
class ExportWorkflowRun

One run of a workflow the guest was in.

factory ExportWorkflowRun.fromJson(Map<String, Object?> json)
const ExportWorkflowRun({required String workflow, required String state, required DateTime startedAt, String outcome = '', DateTime? endedAt})
final DateTime? endedAt
final String outcome

How it ended, once it has.

final DateTime startedAt
final String state

Where the run is, as PurrCRM says it (active, waiting, parked, ended).

final String workflow
class ListItem

One item of a list.

factory ListItem.fromJson(Map<String, Object?> json)
const ListItem({required List<Span> spans})
final List<Span> spans
class Span

A run of text with one style.

factory Span.fromJson(Map<String, Object?> json)
const Span({required String text, bool bold = false, bool italic = false, String link = '', bool underline = false, bool strike = false, bool highlight = false, String color = ''})
final bool bold
final String color
final bool highlight
final bool italic
final String link

Makes the run a link, as ContentBlock.link.

final bool strike
final String text
final bool underline

The formatting marks, a carousel’s and a post’s alone: underlined, struck through, on a wash of the accent, and the run’s own colour (a ColorToken’s word or #rrggbb) over the block’s.

const String crmAppKeyHeader

The header a product’s app key travels in on every request (CrmConfig.appKey): which of PurrCRM’s apps the guest is in.

const String crmSdkVersionHeader

The header the package’s version travels in on every request, so that PurrCRM knows which SDK a guest is on.

const String crmTestAppKeyPrefix

What a test app’s public key begins with: the key of a live app’s test test app, which a staging build sends and whose data is kept apart from the live app’s. A live app’s key never begins with it, so the key alone says which mode a build is in, before PurrCRM answers (CrmPublicApp.mode).

const String crmUserIdHeader

The header a guest’s id travels in instead of a token, for an app that takes unverified guests.

const Duration maxEventAge

How old an event may be when it arrives. The Go constant is MaxEventAge: the tracker drops what it has kept for longer than this rather than send it to be dropped.

const int maxEventBatch

The most events one batch carries. The Go constant is MaxEventBatch.

const int maxEventPropRunes

The longest a prop’s value may be. The Go constant is MaxEventPropRunes.

const int maxEventProps

The most props one event carries. The Go constant is MaxEventProps.