@sprig-technologies/sprig-browser 2.14.0 → 2.14.2

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.
@@ -1,4 +1,4 @@
1
- /* global navigator, MediaRecorder, UpChunk, File, Blob*/
1
+ /* global navigator, MediaRecorder, UpChunk, File, Blob, fetch*/
2
2
  /*
3
3
  recording api requirements
4
4
  - check for and request for permissions
@@ -6,6 +6,7 @@ recording api requirements
6
6
  - track start end times
7
7
  - show splash for permissions
8
8
  */
9
+ import 'whatwg-fetch';
9
10
  export const PERMISSION = {
10
11
  CAMERA: 'camera',
11
12
  MICROPHONE: 'microphone',
@@ -52,6 +53,41 @@ const recorder = {
52
53
  streams: [],
53
54
  recorders: [],
54
55
  startingTimeOnTask: undefined,
56
+ async uploadVideo(fileUrl) {
57
+ console.log('uploading task about to start for ${fileUrl}');
58
+ //doesn't necessarily stop when the next question also requires media
59
+ const body = {
60
+ surveyId: 5105,
61
+ updatedAt: new Date().toISOString(),
62
+ mediaType: 'video',
63
+ };
64
+ const url = await createUpload(body);
65
+ if (!url) return;
66
+
67
+ const blob = new Blob([atob(fileUrl)], {
68
+ type: 'video/webm',
69
+ });
70
+ const upload = UpChunk.createUpload({
71
+ // endpoint computed from backend separately and hacked together
72
+ endpoint: url,
73
+ file: new File([blob], `recording video ${Date.now()}`),
74
+ chunkSize: 5120, // Uploads the file in ~5mb chunks
75
+ });
76
+ upload.startTime = Date.now();
77
+
78
+ // subscribe to events
79
+ upload.on('error', (err) => {
80
+ console.log(`upload error ${err}`);
81
+ });
82
+
83
+ upload.on('progress', (progress) => {
84
+ console.log(progress);
85
+ });
86
+
87
+ upload.on('success', () => {
88
+ console.log('uploaded!');
89
+ });
90
+ },
55
91
  configure(eventEmitter) {
56
92
  eventEmitter.subscribe('permission', async (payload) => {
57
93
  const stream = await this.requestPermissions(payload.permissionDescriptors);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprig-technologies/sprig-browser",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "npm package for the sprig web sdk",
5
5
  "browser": "index.js",
6
6
  "scripts": {
@@ -42,6 +42,7 @@ export const CSS_CONSTANTS = {
42
42
  MOBILE_SUFFIX: '--mobile',
43
43
  QUESTION_HEADER_CLASS: 'ul-question',
44
44
  CAPTION_CLASS: 'ul-caption',
45
+ FADE_IN_CLASS: 'fade-in-transition',
45
46
  };
46
47
 
47
48
  export const EXPERIMENT_FLAGS = {
package/shared/network.js CHANGED
@@ -25,7 +25,7 @@ export function getHttpHeaders(Sprig = {}) {
25
25
  const headers = {
26
26
  'Content-Type': 'application/json',
27
27
  'userleap-platform': 'web',
28
- 'x-ul-sdk-version': '2.14.0', //version here doesn't matter. it is string-replaced when compiled
28
+ 'x-ul-sdk-version': '2.14.2', //version here doesn't matter. it is string-replaced when compiled
29
29
  };
30
30
  if (Sprig.envId) headers[HEADERS.ENVIRONMENT_ID] = Sprig.envId;
31
31
  if (Sprig.token) headers['Authorization'] = 'Bearer ' + Sprig.token;