1.0.0 • Published 1 year ago

@mailvideo/embed v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

@mailvideo/embed

npm (@mailvideo/embed)

This package embeds mailvideo iframe to handle video in your application.

Install

pnpm i @mailvideo/embed

Features

  • It can create new or existing video and share it with your users.
  • View video statistics.

Prerequisites

You need to contact mailvideo to get a public key to be able to use this plugin.

Example

Usage

import { loadMailVideo } from '@mailvideo/embed';

const mailvideo = await loadMailVideo({
	publishableKey: 'your-public-key',
	tenantId: 2,
	accountId: 5,
});

const [video, error] = await mailvideo.pickVideo();

if (video) {
	// a video was created/selected
	console.log(video);
	return;
}

if (error === 'user-cancelled') {
	// user cancelled the dialog
	return;
}
// something went wrong
console.error(error);

Methods

loadMailVideo

Loads the mailvideo script and returns a promise that resolves to a MailVideo object.

loadMailVideo options

NameDescriptionTypeDefault
publishableKeyYour public keystringRequired
localeThe locale to use for the mailvideo iframe.stringen
verboseIf true, all information will be console logged.booleanfalse
tenantIdThe tenant id to use for the mailvideo iframe.string/numberRequired
accountIdThe account id to use for the mailvideo iframe.string/numberRequired
preloadIf this is true, then the iframe will be preloaded and appended to the body, and hidden.boolean/HTMLDivElementfalse
canCreateMailVideoTeamIf the user can read all users in it's tenant/team. This is used if a mailvideo team has not yet been created for the tenant/team.booleantrue

pickVideo

Opens a popup dialog or inject iframe into a custom container to create a new video or select an existing video.

PickVideoOptions

NameDescriptionTypeDefault
personThe person to use for the mailvideo iframe.PersonDataundefined
companyThe company to use for the mailvideo iframe.CompanyDataundefined
activityThe activity to use for the mailvideo iframe.ActivityDataundefined
divElementThe div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page.HTMLDivElementundefined
logMailVideoSentIf your system has API endpoint to log events, then mailvideo will log when a user sends a video.booleantrue
logMailVideoSeenIf your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient.booleantrue

PickVideoResponse

NameDescriptionType
idThe video idstring
titleThe video titlestring
linkThe video linkstring
embedCodeThe video embed codestring
emailHTMLCodeThe video email html codestring

pickVideoTemplate

This is the same as pickVideo, execpt it is used for email templates. When setting person, company or activity options, you put the wildcards that you replace in the email template. For example if you have a wildcard called {{personId}} You will do the following:

const [video] = await mailvideo.pickVideoTemplate({
	person: {
		id: '{{personId}}',
	},
});
video.link; // => https://share.mailvideo.com/watch/sakdjdsf873453?personId={{personId}}

PickVideoTemplateOptions

NameDescriptionTypeDefault
accountIdTemplateThis will replace the accountId of the user that created the template. So we can correctly show who sent video.stringundefined
personThe person to use for the mailvideo iframe.PersonTemplateDataundefined
companyThe company to use for the mailvideo iframe.CompanyTemplateDataundefined
activityThe activity to use for the mailvideo iframe.ActivityTempalteDataundefined
divElementThe div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page.HTMLDivElementundefined
logMailVideoSentIf your system has API endpoint to log events, then mailvideo will log when a user sends a video.booleantrue
logMailVideoSeenIf your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient.booleantrue

PickVideoTemplateResponse

NameDescriptionType
idThe video idstring
titleThe video titlestring
linkThe video linkstring
embedCodeThe video embed codestring
emailHTMLCodeThe video email html codestring

openPlatform

Open the library of videos for a specific company/person/activity or just for the entire platform. You can see all sent videos to that company/person. Also you can manage exiting videos.

OpenPlatformOptions

NameDescriptionTypeDefault
personThe person to use for the mailvideo iframe.PersonDataundefined
companyThe company to use for the mailvideo iframe.CompanyDataundefined
activityThe activity to use for the mailvideo iframe.ActivityDataundefined
divElementThe div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page.HTMLDivElementundefined
logMailVideoSentIf your system has API endpoint to log events, then mailvideo will log when a user sends a video.booleantrue
logMailVideoSeenIf your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient.booleantrue

openVideo

Open a specific video to edit or see analytics.

OpenVideoOptions

NameDescriptionTypeDefault
videoIdThe id of the video to viewstringrequired
divElementThe div element to use for the mailvideo iframe. If not specified it will open a popup dialog in the middle of the page.HTMLDivElementundefined
logMailVideoSentIf your system has API endpoint to log events, then mailvideo will log when a user sends a video.booleantrue
logMailVideoSeenIf your system has API endpoint to log events, then mailvideo will logwhen a video has been seen by the recipient.booleantrue

Interfaces

interface PersonData {
	id: string | number;
	name: string;
	email?: string;
}

interface CompanyData {
	id: string | number;
	name: string;
}

interface ActivityData {
	id: string | number;
	name: string;
}

interface PersonTemplateData {
	id: string;
	name?: string;
	email?: string;
}

interface CompanyTemplateData {
	id: string;
	name?: string;
}

interface ActivityTemplateData {
	id: string;
	name?: string;
}
1.1.0-beta.15

1 year ago

1.1.0-beta.16

1 year ago

1.1.0-beta.17

1 year ago

1.1.0-beta.13

1 year ago

1.1.0-beta.12

1 year ago

1.1.0-beta.11

1 year ago

1.1.0-beta.10

1 year ago

1.1.0-beta.9

1 year ago

1.1.0-beta.8

1 year ago

1.1.0-beta.7

1 year ago

1.1.0-beta.6

1 year ago

1.1.0-beta.5

1 year ago

1.1.0-beta.4

1 year ago

1.1.0-beta.2

1 year ago

1.1.0-beta.1

1 year ago

1.1.0-beta.3

1 year ago

1.1.0-beta.0

2 years ago

1.0.0

2 years ago

1.0.0-beta.6

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.5

2 years ago

1.0.0-beta.2

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.1

2 years ago

1.0.0-beta.0

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.1

2 years ago