@hopara/iframe 2.4.57 → 2.4.58

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.
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+ import {createRoot} from 'react-dom/client'
3
+ import { View } from './View'
4
+ import * as serviceWorkerRegistration from '@hopara/service-worker/src/Registration'
5
+ import { initRum } from '@hopara/rum'
6
+
7
+ initRum({
8
+ service: 'embedded',
9
+ sessionReplaySampleRate: 0,
10
+ // we need to set this to true to be able to record sessions in iframes
11
+ usePartitionedCrossSiteSessionCookie: true,
12
+ trackViewsManually: true
13
+ })
14
+
15
+ createRoot(
16
+ document.getElementById('root') as Element)
17
+ .render(
18
+ <View />)
19
+
20
+ serviceWorkerRegistration.register()
@@ -1,74 +0,0 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
- const pkg = require('../package.json')
4
-
5
- const appVersion = () => {
6
- if (!process.env.BUILD_NUMBER) return pkg.version
7
- return `${pkg.version}+${process.env.BUILD_NUMBER}`
8
- }
9
-
10
- const getGTMKey = () => {
11
- if (process.env.BUILD_ENV === 'production') return 'GTM-5HS5GGJQ'
12
- return 'GTM-PSBHVD56'
13
- }
14
-
15
- const gtagKey = () => {
16
- if (process.env.BUILD_ENV === 'production') return 'G-VFNH0BEP1Z'
17
- return 'G-0J2G78CGQY'
18
- }
19
-
20
- const resolvePath = (resourcePath) => {
21
- return path.resolve(__dirname, '..', resourcePath)
22
- }
23
-
24
- const readFile = (path) => new Promise((resolve, reject) => {
25
- fs.readFile(path, 'utf8', (err, data) => {
26
- if (err) return reject(err)
27
- return resolve(data)
28
- })
29
- })
30
-
31
- const saveFile = (path, data) => new Promise((resolve, reject) => {
32
- fs.writeFile(path, data, 'utf8', (err) => {
33
- if (err) return reject(err)
34
- return resolve()
35
- })
36
- })
37
-
38
- const replaceIn = (replaceCases, str) => {
39
- return replaceCases.reduce((str, c) => {
40
- return str.replace(new RegExp(c[0], 'g'), c[1])
41
- }, str)
42
- }
43
-
44
- module.exports.main = () => {
45
- const srcPath = resolvePath('./resources/index.html')
46
- const destPath = resolvePath('./public/index.html')
47
-
48
- const CONFIG = {
49
- gmtKey: process.env.GTM_KEY || getGTMKey(),
50
- gtagKey: process.env.GTAG_KEY || gtagKey(),
51
- appName: process.env.GTAG_APP_NAME || 'Kyrix',
52
- appVersion: appVersion(),
53
- }
54
-
55
- const replaceCases = [
56
- ['%VERSION%', appVersion()],
57
- ['%GTM_KEY%', CONFIG.gmtKey],
58
- ['%GTAG_KEY%', CONFIG.gtagKey],
59
- ['%GTAG_APP_NAME%', CONFIG.appName],
60
- ['%GTAG_APP_VERSION%', CONFIG.appVersion],
61
- ]
62
-
63
- readFile(srcPath)
64
- .then((fileString) => {
65
- const replacedFileString = replaceIn(replaceCases, fileString)
66
- return saveFile(destPath, replacedFileString)
67
- })
68
- .then(() => process.exit(0))
69
- .catch(() => process.exit(1))
70
- }
71
-
72
- // execute script
73
- // eslint-disable-next-line no-invalid-this
74
- this.main()