videomail-client 15.1.0 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ export type { BrowserStats } from "./types/BrowserStats";
4
4
  export type { VideomailCommand } from "./types/command";
5
5
  export type { VideomailCommandArgs } from "./types/command";
6
6
  export type { DeliveryRecord } from "./types/Delivery";
7
+ export type { CapacitorDeviceMetadata } from "./types/device";
7
8
  export type { EmailAddress, EmailAddresses } from "./types/EmailAddress";
8
9
  export type { FullVideomailErrorData, VideomailErrorData } from "./types/error";
9
10
  export type { VideomailEvents } from "./types/events";
@@ -16,4 +17,5 @@ export type { RecordingStats } from "./types/RecordingStats";
16
17
  export type { VideomailThread } from "./types/thread";
17
18
  export type { PartialVideomail, Videomail } from "./types/Videomail";
18
19
  export type { VideoTypeType } from "./types/VideoType";
20
+ export { default as getCapacitorDeviceMetadata } from "./util/getCapacitorDeviceMetadata";
19
21
  export { VideoType };
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import { deserializeError, serializeError } from "serialize-error";
2
2
  import superagent from "superagent";
3
3
  import defined from "defined";
4
4
  import { UAParser } from "ua-parser-js";
5
+ import { Device } from "@capacitor/device";
5
6
  import get_form_data from "get-form-data";
6
7
  import { createNanoEvents } from "nanoevents";
7
8
  import deepmerge from "deepmerge";
@@ -3620,7 +3621,7 @@ const constants = {
3620
3621
  }
3621
3622
  };
3622
3623
  var package_namespaceObject = {
3623
- rE: "15.1.0"
3624
+ rE: "15.3.0"
3624
3625
  };
3625
3626
  function isAudioEnabled(options) {
3626
3627
  return Boolean(options.audio.enabled);
@@ -3982,6 +3983,41 @@ function findOriginalExc(exc) {
3982
3983
  return exc;
3983
3984
  }
3984
3985
  const error_findOriginalExc = findOriginalExc;
3986
+ async function getCapacitorDeviceMetadata() {
3987
+ const errors = [];
3988
+ let battery;
3989
+ let info;
3990
+ let languageCode;
3991
+ let languageTag;
3992
+ try {
3993
+ info = await Device.getInfo();
3994
+ } catch (exc) {
3995
+ errors.push(serializeError(exc));
3996
+ }
3997
+ try {
3998
+ battery = await Device.getBatteryInfo();
3999
+ } catch (exc) {
4000
+ errors.push(serializeError(exc));
4001
+ }
4002
+ try {
4003
+ languageCode = await Device.getLanguageCode();
4004
+ } catch (exc) {
4005
+ errors.push(serializeError(exc));
4006
+ }
4007
+ try {
4008
+ languageTag = await Device.getLanguageTag();
4009
+ } catch (exc) {
4010
+ errors.push(serializeError(exc));
4011
+ }
4012
+ const metadata = {};
4013
+ if (battery) metadata.battery = battery;
4014
+ if (errors.length > 0) metadata.errors = errors;
4015
+ if (info) metadata.info = info;
4016
+ if (languageCode) metadata.languageCode = languageCode;
4017
+ if (languageTag) metadata.languageTag = languageTag;
4018
+ return metadata;
4019
+ }
4020
+ const util_getCapacitorDeviceMetadata = getCapacitorDeviceMetadata;
3985
4021
  function Despot_define_property(obj, key, value) {
3986
4022
  if (key in obj) Object.defineProperty(obj, key, {
3987
4023
  value: value,
@@ -4406,35 +4442,33 @@ class Resource {
4406
4442
  [constants.WHITELIST_KEY_LABEL]: this.options.whitelistKey
4407
4443
  };
4408
4444
  const url = `${this.options.apiUrl}/client-error/`;
4409
- try {
4410
- const fullVideomailErrorData = {
4411
- browser: err.browser,
4412
- code: err.code,
4413
- cookie: err.cookie,
4414
- cpu: err.cpu,
4415
- device: err.device,
4416
- engine: err.engine,
4417
- err: err.err ? serializeError(err.err) : void 0,
4418
- explanation: err.explanation,
4419
- location: err.location,
4420
- logLines: err.logLines,
4421
- orientation: err.orientation,
4422
- os: err.os,
4423
- screen: err.screen,
4424
- whitelistKey: err.whitelistKey,
4425
- status: err.status,
4426
- title: err.title,
4427
- message: err.message,
4428
- stack: err.stack,
4429
- versions: {
4430
- videomailClient: package_namespaceObject.rE,
4431
- videomailNinjaFormPlugin: this.options.versions?.videomailNinjaFormPlugin
4432
- }
4433
- };
4434
- await superagent(FormMethod.POST, url).query(queryParams).set("Timezone-Id", this.timezoneId).withCredentials().send(fullVideomailErrorData).timeout(this.options.timeouts.connection);
4435
- } catch (exc) {
4436
- console.error(exc);
4437
- }
4445
+ const capacitorDevice = await util_getCapacitorDeviceMetadata();
4446
+ const fullVideomailErrorData = {
4447
+ capacitorDevice,
4448
+ browser: err.browser,
4449
+ code: err.code,
4450
+ cookie: err.cookie,
4451
+ cpu: err.cpu,
4452
+ device: err.device,
4453
+ engine: err.engine,
4454
+ err: err.err ? serializeError(err.err) : void 0,
4455
+ explanation: err.explanation,
4456
+ location: err.location,
4457
+ logLines: err.logLines,
4458
+ orientation: err.orientation,
4459
+ os: err.os,
4460
+ screen: err.screen,
4461
+ whitelistKey: err.whitelistKey,
4462
+ status: err.status,
4463
+ title: err.title,
4464
+ message: err.message,
4465
+ stack: err.stack,
4466
+ versions: {
4467
+ videomailClient: package_namespaceObject.rE,
4468
+ videomailNinjaFormPlugin: this.options.versions?.videomailNinjaFormPlugin
4469
+ }
4470
+ };
4471
+ await superagent(FormMethod.POST, url).query(queryParams).set("Timezone-Id", this.timezoneId).withCredentials().send(fullVideomailErrorData).timeout(this.options.timeouts.connection);
4438
4472
  }
4439
4473
  async post(videomail) {
4440
4474
  const newVideomail = this.applyDefaultValues(videomail);
@@ -7513,9 +7547,6 @@ class Replay extends util_Despot {
7513
7547
  replayParentElement.appendChild(this.replayElement);
7514
7548
  }
7515
7549
  }
7516
- isStandalone() {
7517
- return "HTMLDivElement" === this.visuals.constructor.name;
7518
- }
7519
7550
  copyAttributes(newVideomail) {
7520
7551
  let attributeContainer;
7521
7552
  Object.keys(newVideomail).forEach((attribute)=>{
@@ -7601,10 +7632,10 @@ class Replay extends util_Despot {
7601
7632
  this.replayElement.setAttribute("autobuffer", "true");
7602
7633
  this.replayElement.setAttribute("playsinline", "true");
7603
7634
  this.replayElement.setAttribute("webkit-playsinline", "webkit-playsinline");
7604
- this.replayElement.setAttribute("controls", "controls");
7605
7635
  this.replayElement.setAttribute("preload", "auto");
7606
7636
  if (!this.built) {
7607
- if (!this.isStandalone()) this.on("PREVIEW", (params)=>{
7637
+ this.on("PREVIEW", (params)=>{
7638
+ this.replayElement?.setAttribute("controls", "controls");
7608
7639
  this.show(params?.width, params?.height, params?.hasAudio);
7609
7640
  });
7610
7641
  this.replayElement.addEventListener("touchstart", (e)=>{
@@ -7721,8 +7752,11 @@ class Replay extends util_Despot {
7721
7752
  });
7722
7753
  }
7723
7754
  hide() {
7724
- if (this.isStandalone()) this.visuals.hide();
7725
- else if (this.replayElement) {
7755
+ if (this.replayElement) {
7756
+ this.replayElement.pause();
7757
+ this.replayElement.removeAttribute("controls");
7758
+ this.replayElement.src = "";
7759
+ this.replayElement.load();
7726
7760
  html_hideElement(this.replayElement);
7727
7761
  html_hideElement(this.replayElement.parentElement);
7728
7762
  }
@@ -8674,4 +8708,4 @@ const Reactions = {
8674
8708
  label: "Sad"
8675
8709
  }
8676
8710
  };
8677
- export { Reactions, VideoType, VideomailClient };
8711
+ export { Reactions, VideoType, VideomailClient, util_getCapacitorDeviceMetadata as getCapacitorDeviceMetadata };
@@ -0,0 +1,10 @@
1
+ import type { BatteryInfo, DeviceInfo, GetLanguageCodeResult, LanguageTag } from "@capacitor/device";
2
+ import type { ErrorObject } from "serialize-error";
3
+ interface CapacitorDeviceMetadata {
4
+ battery?: BatteryInfo;
5
+ errors?: ErrorObject[];
6
+ info?: DeviceInfo;
7
+ languageCode?: GetLanguageCodeResult;
8
+ languageTag?: LanguageTag;
9
+ }
10
+ export type { CapacitorDeviceMetadata };
@@ -1,5 +1,6 @@
1
1
  import { ErrorObject } from "serialize-error";
2
2
  import type { IBrowser, ICPU, IDevice, IEngine, IOS } from "ua-parser-js";
3
+ import { CapacitorDeviceMetadata } from "./device";
3
4
  export interface VideomailErrorData {
4
5
  cause?: any;
5
6
  promise?: any;
@@ -40,5 +41,6 @@ export interface FullVideomailErrorData extends VideomailErrorData {
40
41
  clientIp?: string | null | undefined;
41
42
  userAgent?: string | null | undefined;
42
43
  isBot?: boolean | undefined;
44
+ capacitorDevice: CapacitorDeviceMetadata;
43
45
  }
44
46
  export {};
@@ -0,0 +1,3 @@
1
+ import { CapacitorDeviceMetadata } from "../types/device";
2
+ declare function getCapacitorDeviceMetadata(): Promise<CapacitorDeviceMetadata>;
3
+ export default getCapacitorDeviceMetadata;
@@ -10,7 +10,6 @@ declare class Replay extends Despot {
10
10
  private videomail?;
11
11
  constructor(visuals: Visuals, options: VideomailClientOptions);
12
12
  private buildElement;
13
- private isStandalone;
14
13
  private copyAttributes;
15
14
  private correctDimensions;
16
15
  setVideomail(newVideomail: Videomail, playerOnly?: boolean): void;