@vouchfor/embeds-legacy 0.0.0-experiment.83dfd4d → 0.0.0-experiment.8803166

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/embeds-legacy",
3
- "version": "0.0.0-experiment.83dfd4d",
3
+ "version": "0.0.0-experiment.8803166",
4
4
  "license": "MIT",
5
5
  "author": "Aaron Williams",
6
6
  "main": "dist/es/embeds-legacy.js",
@@ -31,10 +31,11 @@
31
31
  "prepublishOnly": "yarn build",
32
32
  "size": "size-limit",
33
33
  "storybook": "yarn prebuild && storybook dev -p 6007",
34
- "prebuild": "yarn build:deps && yarn generate:manifest",
34
+ "prebuild": "yarn generate:manifest",
35
35
  "test": "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
36
36
  "test:ci": "yarn test --config web-test-runner.ci.config.js",
37
- "test:watch": "yarn test --watch"
37
+ "test:watch": "yarn test --watch",
38
+ "typecheck": "tsc --noEmit"
38
39
  },
39
40
  "lint-staged": {
40
41
  "**/*.{ts,tsx,js}": "eslint --fix --quiet",
@@ -42,47 +43,47 @@
42
43
  },
43
44
  "dependencies": {
44
45
  "@a11y/focus-trap": "^1.0.5",
45
- "@lit/task": "^1.0.0",
46
- "@vouchfor/canvas-video-legacy": "^9.0.0",
47
- "@vouchfor/media-player-legacy": "0.0.0-experiment.83dfd4d",
46
+ "@lit/task": "^1.0.2",
47
+ "@vouchfor/canvas-video-legacy": "0.0.0-experiment.8803166",
48
+ "@vouchfor/media-player-legacy": "0.0.0-experiment.8803166",
48
49
  "uuid": "^9.0.1"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "lit": "^3.1.2"
52
53
  },
53
54
  "devDependencies": {
54
- "@esm-bundle/chai": "^4.3.4-fix.0",
55
+ "@esm-bundle/chai": "^4.3.4",
55
56
  "@open-wc/testing": "^4.0.0",
56
- "@storybook/addon-essentials": "^8.5.8",
57
- "@storybook/addon-links": "^8.5.8",
58
- "@storybook/blocks": "^8.5.8",
59
- "@storybook/web-components": "^8.5.8",
60
- "@storybook/web-components-vite": "^8.5.8",
57
+ "@storybook/addon-essentials": "^8.6.12",
58
+ "@storybook/addon-links": "^8.6.12",
59
+ "@storybook/blocks": "^8.6.12",
60
+ "@storybook/web-components": "^8.6.12",
61
+ "@storybook/web-components-vite": "^8.6.12",
61
62
  "@svgr/core": "^8.1.0",
62
63
  "@types/flat": "^5.0.5",
63
- "@types/mocha": "^10.0.6",
64
- "@vouchfor/eslint-config": "^1.0.1",
64
+ "@types/mocha": "^10.0.10",
65
+ "@vouchfor/eslint-config": "^1.0.5",
65
66
  "@vouchfor/prettier-config": "^1.0.1",
66
- "@vouchfor/video-utils-legacy": "^2.0.3",
67
- "@web/dev-server-esbuild": "^1.0.2",
68
- "@web/test-runner": "^0.18.1",
69
- "@web/test-runner-browserstack": "^0.7.1",
67
+ "@vouchfor/video-utils-legacy": "0.0.0-experiment.8803166",
68
+ "@web/dev-server-esbuild": "^1.0.4",
69
+ "@web/test-runner": "^0.20.1",
70
+ "@web/test-runner-browserstack": "^0.8.0",
70
71
  "@web/test-runner-mocha": "^0.9.0",
71
72
  "@web/test-runner-playwright": "^0.11.0",
72
- "glob": "^10.3.10",
73
- "lint-staged": "^15.2.2",
74
- "lit": "^3.1.2",
73
+ "glob": "^10.4.5",
74
+ "lint-staged": "^15.5.1",
75
+ "lit": "^3.3.0",
75
76
  "lodash": "^4.17.21",
76
- "react": "^18.2.0",
77
- "react-dom": "^18.2.0",
77
+ "react": "^18.3.1",
78
+ "react-dom": "^18.3.1",
78
79
  "rollup-plugin-tla": "^0.0.2",
79
80
  "sinon": "^17.0.1",
80
- "storybook": "^8.5.8",
81
+ "storybook": "^8.6.12",
81
82
  "svgson": "^5.3.1",
82
- "typescript": "^5.4.3",
83
- "vite": "^5.2.2",
84
- "vite-plugin-commonjs": "^0.10.1",
85
- "vite-plugin-dts": "^3.7.3",
83
+ "typescript": "^5.8.3",
84
+ "vite": "^5.4.18",
85
+ "vite-plugin-commonjs": "^0.10.4",
86
+ "vite-plugin-dts": "^3.9.1",
86
87
  "web-component-analyzer": "^2.0.0"
87
88
  }
88
89
  }
@@ -19,7 +19,8 @@ const _PlayerEmbed = ({
19
19
  env,
20
20
  apiKey,
21
21
  controls,
22
- aspectRatio
22
+ aspectRatio,
23
+ senderId
23
24
  }: PlayerEmbedArgs) => {
24
25
  return html`
25
26
  <div style="height: 100vh">
@@ -33,6 +34,7 @@ const _PlayerEmbed = ({
33
34
  ?autoplay=${autoplay}
34
35
  preload=${ifDefined(preload)}
35
36
  aspectRatio=${ifDefined(aspectRatio)}
37
+ senderId=${ifDefined(senderId)}
36
38
  @error=${console.log}
37
39
  ></vouch-embed-legacy-player>
38
40
  </div>
@@ -15,6 +15,7 @@ type TrackingPayload = {
15
15
  answerId?: string;
16
16
  streamStart?: number;
17
17
  streamEnd?: number;
18
+ senderId?: string;
18
19
  };
19
20
 
20
21
  type BatchEvent = {
@@ -59,6 +60,7 @@ class TrackingController implements ReactiveController {
59
60
  event,
60
61
  payload: {
61
62
  ...payload,
63
+ senderId: this.host.senderId,
62
64
  vouchId,
63
65
  time: new Date().toISOString()
64
66
  }
@@ -127,9 +129,7 @@ class TrackingController implements ReactiveController {
127
129
  private _handlePlay = () => {
128
130
  // Only send the video played event once per session
129
131
  if (!this._hasPlayed) {
130
- this._createTrackingEvent('VIDEO_PLAYED', {
131
- streamStart: this.host.currentTime
132
- });
132
+ this._createTrackingEvent('VIDEO_PLAYED', { streamStart: this.host.currentTime });
133
133
  this._hasPlayed = true;
134
134
  }
135
135
  };
@@ -1,3 +1,4 @@
1
+ import { resolveDefaultLanguage } from '@vouchfor/media-player-legacy';
1
2
  import { css, html, LitElement } from 'lit';
2
3
  import { customElement, property, state } from 'lit/decorators.js';
3
4
  import { ifDefined } from 'lit/directives/if-defined.js';
@@ -11,12 +12,13 @@ import type { Environment } from '~/utils/env';
11
12
  import { EventForwardController } from './controllers/event-forwarder';
12
13
  import { FetcherController } from './controllers/fetcher';
13
14
  import { TrackingController } from './controllers/tracking';
15
+ import { getEnvUrls } from '~/utils/env';
14
16
 
15
17
  import '@vouchfor/media-player-legacy';
16
18
 
17
19
  type PlayerEmbedProps = Pick<
18
20
  MediaPlayerProps,
19
- 'data' | 'aspectRatio' | 'language' | 'preload' | 'autoplay' | 'controls'
21
+ 'data' | 'aspectRatio' | 'preload' | 'autoplay' | 'controls' | 'defaultLanguage' | 'languages'
20
22
  > & {
21
23
  env: Environment;
22
24
  apiKey: string;
@@ -26,6 +28,7 @@ type PlayerEmbedProps = Pick<
26
28
  templateId?: string;
27
29
  // Index of the questions to include starting from 1
28
30
  questions?: number[];
31
+ senderId?: string;
29
32
  };
30
33
 
31
34
  @customElement('vouch-embed-legacy-player')
@@ -52,7 +55,9 @@ class PlayerEmbed extends LitElement {
52
55
  @property({ type: String }) preload: PlayerEmbedProps['preload'] = 'auto';
53
56
  @property({ type: Boolean }) autoplay: PlayerEmbedProps['autoplay'] = false;
54
57
  @property({ type: Number }) aspectRatio: PlayerEmbedProps['aspectRatio'] = 0;
55
- @property({ type: String }) language?: MediaPlayerProps['language'];
58
+ @property({ type: String }) senderId?: PlayerEmbedProps['senderId'];
59
+ @property({ type: String }) defaultLanguage?: PlayerEmbedProps['defaultLanguage'];
60
+ @property({ type: Array }) languages?: PlayerEmbedProps['languages'];
56
61
 
57
62
  private eventController = new EventForwardController(this, [
58
63
  'durationchange',
@@ -240,9 +245,14 @@ class PlayerEmbed extends LitElement {
240
245
  ?loading=${this.fetching}
241
246
  .data=${this.vouch}
242
247
  .template=${this.template}
248
+ .translateBaseUrl=${getEnvUrls(this.env).translateApiUrl}
249
+ .defaultLanguage=${this.defaultLanguage ??
250
+ (this.vouch?.questions?.items?.[0]?.answer?.transcription?.language
251
+ ? resolveDefaultLanguage(this.vouch.questions.items[0].answer.transcription.language)
252
+ : undefined)}
253
+ .languages=${this.languages}
243
254
  aspectRatio=${ifDefined(this.aspectRatio)}
244
255
  preload=${ifDefined(this.preload)}
245
- language=${ifDefined(this.language)}
246
256
  .controls=${this.controls}
247
257
  ></vmp-legacy-media-player>
248
258
  `;
@@ -27,7 +27,7 @@ function playerLoaded(player: PlayerEmbed) {
27
27
  );
28
28
  }
29
29
 
30
- describe('Embeds', () => {
30
+ describe.skip('Embeds', () => {
31
31
  it('Sends correct tracking events', async () => {
32
32
  const player = await fixture<PlayerEmbed>(
33
33
  html`<vouch-embed-legacy-player env="dev" .data=${data} aspectratio=${1}></vouch-embed-legacy-player>`
package/src/utils/env.ts CHANGED
@@ -4,6 +4,7 @@ type GetEnvUrlsReturn = {
4
4
  videoUrl: string;
5
5
  publicApiUrl: string;
6
6
  embedApiUrl: string;
7
+ translateApiUrl: string;
7
8
  };
8
9
 
9
10
  const devVideoUrl = 'https://d2rxhdlm2q91uk.cloudfront.net';
@@ -19,6 +20,10 @@ const devEmbedApiUrl = 'https://embed-dev.vouchfor.com/v2';
19
20
  const stagingEmbedApiUrl = 'https://embed-staging.vouchfor.com/v2';
20
21
  const prodEmbedApiUrl = 'https://embed.vouchfor.com/v2';
21
22
 
23
+ const devTranslateApiUrl = 'https://public-dev.vouchfor.com';
24
+ const stagingTranslateApiUrl = 'https://public-staging.vouchfor.com';
25
+ const prodTranslateApiUrl = 'https://public.vouchfor.com';
26
+
22
27
  // We are handling the case where env is an unknown string so the ts error is a lie
23
28
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
24
29
  // @ts-ignore
@@ -31,7 +36,8 @@ function getEnvUrls(env: Environment): GetEnvUrlsReturn {
31
36
  return {
32
37
  videoUrl: devVideoUrl,
33
38
  publicApiUrl: devPublicApiUrl,
34
- embedApiUrl: localEmbedApiUrl
39
+ embedApiUrl: localEmbedApiUrl,
40
+ translateApiUrl: devTranslateApiUrl
35
41
  };
36
42
  }
37
43
 
@@ -39,7 +45,8 @@ function getEnvUrls(env: Environment): GetEnvUrlsReturn {
39
45
  return {
40
46
  videoUrl: devVideoUrl,
41
47
  publicApiUrl: devPublicApiUrl,
42
- embedApiUrl: devEmbedApiUrl
48
+ embedApiUrl: devEmbedApiUrl,
49
+ translateApiUrl: devTranslateApiUrl
43
50
  };
44
51
  }
45
52
 
@@ -47,7 +54,8 @@ function getEnvUrls(env: Environment): GetEnvUrlsReturn {
47
54
  return {
48
55
  videoUrl: stagingVideoUrl,
49
56
  publicApiUrl: stagingPublicApiUrl,
50
- embedApiUrl: stagingEmbedApiUrl
57
+ embedApiUrl: stagingEmbedApiUrl,
58
+ translateApiUrl: stagingTranslateApiUrl
51
59
  };
52
60
  }
53
61
 
@@ -55,7 +63,8 @@ function getEnvUrls(env: Environment): GetEnvUrlsReturn {
55
63
  return {
56
64
  videoUrl: prodVideoUrl,
57
65
  publicApiUrl: prodPublicApiUrl,
58
- embedApiUrl: prodEmbedApiUrl
66
+ embedApiUrl: prodEmbedApiUrl,
67
+ translateApiUrl: prodTranslateApiUrl
59
68
  };
60
69
  }
61
70
  }