firebase-functions 6.6.0 → 7.0.0-rc.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.
- package/lib/_virtual/rolldown_runtime.js +34 -0
- package/lib/bin/firebase-functions.js +78 -103
- package/lib/common/app.js +35 -55
- package/lib/common/change.js +54 -75
- package/lib/common/config.js +41 -41
- package/lib/common/debug.js +23 -47
- package/lib/common/encoding.js +59 -82
- package/lib/common/onInit.js +26 -28
- package/lib/common/options.js +22 -42
- package/lib/common/params.d.ts +6 -6
- package/lib/common/params.js +0 -23
- package/lib/common/providers/database.js +270 -300
- package/lib/common/providers/firestore.js +66 -92
- package/lib/common/providers/https.d.ts +0 -1
- package/lib/common/providers/https.js +537 -539
- package/lib/common/providers/identity.js +393 -444
- package/lib/common/providers/tasks.js +64 -98
- package/lib/common/timezone.js +544 -542
- package/lib/common/trace.d.ts +0 -1
- package/lib/common/trace.js +63 -55
- package/lib/common/utilities/assertions.d.ts +11 -0
- package/lib/common/utilities/assertions.js +18 -0
- package/lib/common/utilities/encoder.js +20 -37
- package/lib/common/utilities/path-pattern.js +106 -132
- package/lib/common/utilities/path.js +28 -27
- package/lib/common/utilities/utils.js +23 -45
- package/lib/esm/_virtual/rolldown_runtime.mjs +16 -0
- package/lib/esm/bin/firebase-functions.mjs +91 -0
- package/lib/esm/common/app.mjs +39 -0
- package/lib/esm/common/change.mjs +57 -0
- package/lib/esm/common/config.mjs +45 -0
- package/lib/esm/common/debug.mjs +28 -0
- package/lib/esm/common/encoding.mjs +69 -0
- package/lib/esm/common/onInit.mjs +33 -0
- package/lib/esm/common/options.mjs +22 -0
- package/lib/esm/common/params.mjs +1 -0
- package/lib/esm/common/providers/database.mjs +269 -0
- package/lib/esm/common/providers/firestore.mjs +78 -0
- package/lib/esm/common/providers/https.mjs +573 -0
- package/lib/esm/common/providers/identity.mjs +428 -0
- package/lib/esm/common/providers/tasks.mjs +67 -0
- package/lib/esm/common/timezone.mjs +544 -0
- package/lib/esm/common/trace.mjs +73 -0
- package/lib/esm/common/utilities/assertions.mjs +17 -0
- package/lib/esm/common/utilities/encoder.mjs +21 -0
- package/lib/esm/common/utilities/path-pattern.mjs +116 -0
- package/lib/esm/common/utilities/path.mjs +35 -0
- package/lib/esm/common/utilities/utils.mjs +29 -0
- package/lib/esm/function-configuration.mjs +1 -0
- package/lib/esm/logger/common.mjs +23 -0
- package/lib/esm/logger/compat.mjs +25 -0
- package/lib/esm/logger/index.mjs +131 -0
- package/lib/esm/params/index.mjs +160 -0
- package/lib/esm/params/types.mjs +400 -0
- package/lib/esm/runtime/loader.mjs +132 -0
- package/lib/esm/runtime/manifest.mjs +134 -0
- package/lib/esm/types/global.d.mjs +1 -0
- package/lib/esm/v1/cloud-functions.mjs +206 -0
- package/lib/esm/v1/config.mjs +14 -0
- package/lib/esm/v1/function-builder.mjs +252 -0
- package/lib/esm/v1/function-configuration.mjs +72 -0
- package/lib/esm/v1/index.mjs +27 -0
- package/lib/esm/v1/providers/analytics.mjs +212 -0
- package/lib/esm/v1/providers/auth.mjs +156 -0
- package/lib/esm/v1/providers/database.mjs +243 -0
- package/lib/esm/v1/providers/firestore.mjs +131 -0
- package/lib/esm/v1/providers/https.mjs +82 -0
- package/lib/esm/v1/providers/pubsub.mjs +175 -0
- package/lib/esm/v1/providers/remoteConfig.mjs +64 -0
- package/lib/esm/v1/providers/storage.mjs +163 -0
- package/lib/esm/v1/providers/tasks.mjs +63 -0
- package/lib/esm/v1/providers/testLab.mjs +94 -0
- package/lib/esm/v2/core.mjs +4 -0
- package/lib/esm/v2/index.mjs +28 -0
- package/lib/esm/v2/options.mjs +102 -0
- package/lib/esm/v2/providers/alerts/alerts.mjs +85 -0
- package/lib/esm/v2/providers/alerts/appDistribution.mjs +75 -0
- package/lib/esm/v2/providers/alerts/billing.mjs +51 -0
- package/lib/esm/v2/providers/alerts/crashlytics.mjs +122 -0
- package/lib/esm/v2/providers/alerts/index.mjs +22 -0
- package/lib/esm/v2/providers/alerts/performance.mjs +66 -0
- package/lib/esm/v2/providers/database.mjs +197 -0
- package/lib/esm/v2/providers/dataconnect.mjs +130 -0
- package/lib/esm/v2/providers/eventarc.mjs +51 -0
- package/lib/esm/v2/providers/firestore.mjs +294 -0
- package/lib/esm/v2/providers/https.mjs +210 -0
- package/lib/esm/v2/providers/identity.mjs +103 -0
- package/lib/esm/v2/providers/pubsub.mjs +148 -0
- package/lib/esm/v2/providers/remoteConfig.mjs +52 -0
- package/lib/esm/v2/providers/scheduler.mjs +84 -0
- package/lib/esm/v2/providers/storage.mjs +155 -0
- package/lib/esm/v2/providers/tasks.mjs +65 -0
- package/lib/esm/v2/providers/testLab.mjs +53 -0
- package/lib/esm/v2/trace.mjs +20 -0
- package/lib/function-configuration.d.ts +0 -0
- package/lib/function-configuration.js +0 -0
- package/lib/logger/common.js +21 -41
- package/lib/logger/compat.js +18 -33
- package/lib/logger/index.js +119 -130
- package/lib/params/index.d.ts +4 -2
- package/lib/params/index.js +150 -144
- package/lib/params/types.js +389 -423
- package/lib/runtime/loader.js +114 -148
- package/lib/runtime/manifest.js +106 -126
- package/lib/types/global.d.js +0 -0
- package/lib/v1/cloud-functions.d.ts +2 -2
- package/lib/v1/cloud-functions.js +193 -241
- package/lib/v1/config.d.ts +4 -7
- package/lib/v1/config.js +13 -75
- package/lib/v1/function-builder.js +239 -368
- package/lib/v1/function-configuration.js +70 -63
- package/lib/v1/index.js +118 -73
- package/lib/v1/providers/analytics.js +188 -235
- package/lib/v1/providers/auth.d.ts +2 -1
- package/lib/v1/providers/auth.js +159 -164
- package/lib/v1/providers/database.js +237 -242
- package/lib/v1/providers/firestore.js +131 -130
- package/lib/v1/providers/https.d.ts +2 -1
- package/lib/v1/providers/https.js +79 -86
- package/lib/v1/providers/pubsub.js +175 -172
- package/lib/v1/providers/remoteConfig.js +64 -68
- package/lib/v1/providers/storage.js +161 -163
- package/lib/v1/providers/tasks.d.ts +1 -1
- package/lib/v1/providers/tasks.js +65 -80
- package/lib/v1/providers/testLab.js +94 -94
- package/lib/v2/core.d.ts +1 -1
- package/lib/v2/core.js +5 -32
- package/lib/v2/index.d.ts +6 -3
- package/lib/v2/index.js +123 -75
- package/lib/v2/options.js +88 -114
- package/lib/v2/providers/alerts/alerts.js +76 -95
- package/lib/v2/providers/alerts/appDistribution.js +73 -78
- package/lib/v2/providers/alerts/billing.js +49 -53
- package/lib/v2/providers/alerts/crashlytics.js +110 -102
- package/lib/v2/providers/alerts/index.js +56 -53
- package/lib/v2/providers/alerts/performance.js +64 -74
- package/lib/v2/providers/database.js +177 -180
- package/lib/v2/providers/dataconnect.d.ts +95 -0
- package/lib/v2/providers/dataconnect.js +137 -0
- package/lib/v2/providers/eventarc.js +55 -77
- package/lib/v2/providers/firestore.js +262 -260
- package/lib/v2/providers/https.d.ts +3 -2
- package/lib/v2/providers/https.js +210 -247
- package/lib/v2/providers/identity.d.ts +2 -1
- package/lib/v2/providers/identity.js +96 -105
- package/lib/v2/providers/pubsub.js +149 -167
- package/lib/v2/providers/remoteConfig.js +54 -63
- package/lib/v2/providers/scheduler.js +84 -96
- package/lib/v2/providers/storage.js +147 -162
- package/lib/v2/providers/tasks.d.ts +1 -1
- package/lib/v2/providers/tasks.js +68 -95
- package/lib/v2/providers/testLab.js +55 -64
- package/lib/v2/trace.js +18 -19
- package/package.json +290 -226
- package/protos/compiledFirestore.mjs +3512 -0
- package/protos/update.sh +28 -7
|
@@ -1,273 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
// SOFTWARE.
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.ExportBundleInfo = exports.UserPropertyValue = exports.UserDimensions = exports.AnalyticsEvent = exports.AnalyticsEventBuilder = exports._eventWithOptions = exports.event = exports.service = exports.provider = void 0;
|
|
25
|
-
const cloud_functions_1 = require("../cloud-functions");
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_v1_cloud_functions = require('../cloud-functions.js');
|
|
3
|
+
|
|
4
|
+
//#region src/v1/providers/analytics.ts
|
|
5
|
+
var analytics_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
6
|
+
AnalyticsEvent: () => AnalyticsEvent,
|
|
7
|
+
AnalyticsEventBuilder: () => AnalyticsEventBuilder,
|
|
8
|
+
ExportBundleInfo: () => ExportBundleInfo,
|
|
9
|
+
UserDimensions: () => UserDimensions,
|
|
10
|
+
UserPropertyValue: () => UserPropertyValue,
|
|
11
|
+
_eventWithOptions: () => _eventWithOptions,
|
|
12
|
+
event: () => event,
|
|
13
|
+
provider: () => provider,
|
|
14
|
+
service: () => service
|
|
15
|
+
});
|
|
26
16
|
/** @internal */
|
|
27
|
-
|
|
17
|
+
const provider = "google.analytics";
|
|
28
18
|
/** @internal */
|
|
29
|
-
|
|
19
|
+
const service = "app-measurement.com";
|
|
30
20
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
* Registers a function to handle analytics events.
|
|
22
|
+
*
|
|
23
|
+
* @param analyticsEventType Name of the analytics event type to which
|
|
24
|
+
* this Cloud Function is scoped.
|
|
25
|
+
*
|
|
26
|
+
* @returns Analytics event builder interface.
|
|
27
|
+
*/
|
|
38
28
|
function event(analyticsEventType) {
|
|
39
|
-
|
|
29
|
+
return _eventWithOptions(analyticsEventType, {});
|
|
40
30
|
}
|
|
41
|
-
exports.event = event;
|
|
42
31
|
/** @internal */
|
|
43
32
|
function _eventWithOptions(analyticsEventType, options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
return new AnalyticsEventBuilder(() => {
|
|
34
|
+
if (!process.env.GCLOUD_PROJECT) {
|
|
35
|
+
throw new Error("process.env.GCLOUD_PROJECT is not set.");
|
|
36
|
+
}
|
|
37
|
+
return "projects/" + process.env.GCLOUD_PROJECT + "/events/" + analyticsEventType;
|
|
38
|
+
}, options);
|
|
50
39
|
}
|
|
51
|
-
exports._eventWithOptions = _eventWithOptions;
|
|
52
40
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
exports.AnalyticsEventBuilder = AnalyticsEventBuilder;
|
|
41
|
+
* The Firebase Analytics event builder interface.
|
|
42
|
+
*
|
|
43
|
+
* Access via `functions.analytics.event()`.
|
|
44
|
+
*/
|
|
45
|
+
var AnalyticsEventBuilder = class {
|
|
46
|
+
/** @hidden */
|
|
47
|
+
constructor(triggerResource, options) {
|
|
48
|
+
this.triggerResource = triggerResource;
|
|
49
|
+
this.options = options;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Event handler that fires every time a Firebase Analytics event occurs.
|
|
53
|
+
*
|
|
54
|
+
* @param handler Event handler that fires every time a Firebase Analytics event
|
|
55
|
+
* occurs.
|
|
56
|
+
*
|
|
57
|
+
* @returns A function that you can export and deploy.
|
|
58
|
+
*/
|
|
59
|
+
onLog(handler) {
|
|
60
|
+
const dataConstructor = (raw) => {
|
|
61
|
+
return new AnalyticsEvent(raw.data);
|
|
62
|
+
};
|
|
63
|
+
return require_v1_cloud_functions.makeCloudFunction({
|
|
64
|
+
handler,
|
|
65
|
+
provider,
|
|
66
|
+
eventType: "event.log",
|
|
67
|
+
service,
|
|
68
|
+
legacyEventType: `providers/google.firebase.analytics/eventTypes/event.log`,
|
|
69
|
+
triggerResource: this.triggerResource,
|
|
70
|
+
dataConstructor,
|
|
71
|
+
options: this.options
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
88
75
|
/** Interface representing a Firebase Analytics event that was logged for a specific user. */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
exports.AnalyticsEvent = AnalyticsEvent;
|
|
76
|
+
var AnalyticsEvent = class {
|
|
77
|
+
/** @hidden */
|
|
78
|
+
constructor(wireFormat) {
|
|
79
|
+
this.params = {};
|
|
80
|
+
if (wireFormat.eventDim && wireFormat.eventDim.length > 0) {
|
|
81
|
+
const eventDim = wireFormat.eventDim[0];
|
|
82
|
+
copyField(eventDim, this, "name");
|
|
83
|
+
copyField(eventDim, this, "params", (p) => mapKeys(p, unwrapValue));
|
|
84
|
+
copyFieldTo(eventDim, this, "valueInUsd", "valueInUSD");
|
|
85
|
+
copyFieldTo(eventDim, this, "date", "reportingDate");
|
|
86
|
+
copyTimestampToString(eventDim, this, "timestampMicros", "logTime");
|
|
87
|
+
copyTimestampToString(eventDim, this, "previousTimestampMicros", "previousLogTime");
|
|
88
|
+
}
|
|
89
|
+
copyFieldTo(wireFormat, this, "userDim", "user", (dim) => new UserDimensions(dim));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
107
92
|
function isValidUserProperty(property) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
93
|
+
if (property == null || typeof property !== "object" || !("value" in property)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const { value } = property;
|
|
97
|
+
if (value == null) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === "object" && Object.keys(value).length === 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
119
104
|
}
|
|
120
105
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.UserDimensions = UserDimensions;
|
|
106
|
+
* Interface representing the user who triggered the events.
|
|
107
|
+
*/
|
|
108
|
+
var UserDimensions = class {
|
|
109
|
+
/** @hidden */
|
|
110
|
+
constructor(wireFormat) {
|
|
111
|
+
copyFields(wireFormat, this, [
|
|
112
|
+
"userId",
|
|
113
|
+
"deviceInfo",
|
|
114
|
+
"geoInfo",
|
|
115
|
+
"appInfo"
|
|
116
|
+
]);
|
|
117
|
+
copyTimestampToString(wireFormat, this, "firstOpenTimestampMicros", "firstOpenTime");
|
|
118
|
+
this.userProperties = {};
|
|
119
|
+
copyField(wireFormat, this, "userProperties", (r) => {
|
|
120
|
+
const entries = Object.entries(r).filter(([, v]) => isValidUserProperty(v)).map(([k, v]) => [k, new UserPropertyValue(v)]);
|
|
121
|
+
return Object.fromEntries(entries);
|
|
122
|
+
});
|
|
123
|
+
copyField(wireFormat, this, "bundleInfo", (r) => new ExportBundleInfo(r));
|
|
124
|
+
if (!this.userId && this.userProperties["user_id"]) {
|
|
125
|
+
this.userId = this.userProperties["user_id"].value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
147
129
|
/** Predefined or custom properties stored on the client side. */
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
exports.UserPropertyValue = UserPropertyValue;
|
|
130
|
+
var UserPropertyValue = class {
|
|
131
|
+
/** @hidden */
|
|
132
|
+
constructor(wireFormat) {
|
|
133
|
+
copyField(wireFormat, this, "value", unwrapValueAsString);
|
|
134
|
+
copyTimestampToString(wireFormat, this, "setTimestampUsec", "setTime");
|
|
135
|
+
}
|
|
136
|
+
};
|
|
156
137
|
/** Interface representing the bundle these events were uploaded to. */
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
exports.ExportBundleInfo = ExportBundleInfo;
|
|
138
|
+
var ExportBundleInfo = class {
|
|
139
|
+
/** @hidden */
|
|
140
|
+
constructor(wireFormat) {
|
|
141
|
+
copyField(wireFormat, this, "bundleSequenceId");
|
|
142
|
+
copyTimestampToMillis(wireFormat, this, "serverTimestampOffsetMicros", "serverTimestampOffset");
|
|
143
|
+
}
|
|
144
|
+
};
|
|
165
145
|
/** @hidden */
|
|
166
146
|
function copyFieldTo(from, to, fromField, toField, transform) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
147
|
+
if (typeof from[fromField] === "undefined") {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (transform) {
|
|
151
|
+
to[toField] = transform(from[fromField]);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
to[toField] = from[fromField];
|
|
175
155
|
}
|
|
176
156
|
/** @hidden */
|
|
177
|
-
function copyField(from, to, field, transform = (from) => from) {
|
|
178
|
-
|
|
157
|
+
function copyField(from, to, field, transform = (from$1) => from$1) {
|
|
158
|
+
copyFieldTo(from, to, field, field, transform);
|
|
179
159
|
}
|
|
180
160
|
/** @hidden */
|
|
181
161
|
function copyFields(from, to, fields) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
162
|
+
for (const field of fields) {
|
|
163
|
+
copyField(from, to, field);
|
|
164
|
+
}
|
|
185
165
|
}
|
|
186
166
|
function mapKeys(obj, transform) {
|
|
187
|
-
|
|
188
|
-
|
|
167
|
+
const entries = Object.entries(obj).map(([k, v]) => [k, transform(v)]);
|
|
168
|
+
return Object.fromEntries(entries);
|
|
189
169
|
}
|
|
190
|
-
// The incoming payload will have fields like:
|
|
191
|
-
// {
|
|
192
|
-
// 'myInt': {
|
|
193
|
-
// 'intValue': '123'
|
|
194
|
-
// },
|
|
195
|
-
// 'myDouble': {
|
|
196
|
-
// 'doubleValue': 1.0
|
|
197
|
-
// },
|
|
198
|
-
// 'myFloat': {
|
|
199
|
-
// 'floatValue': 1.1
|
|
200
|
-
// },
|
|
201
|
-
// 'myString': {
|
|
202
|
-
// 'stringValue': 'hi!'
|
|
203
|
-
// }
|
|
204
|
-
// }
|
|
205
|
-
//
|
|
206
|
-
// The following method will remove these four types of 'xValue' fields, flattening them
|
|
207
|
-
// to just their values, as a string:
|
|
208
|
-
// {
|
|
209
|
-
// 'myInt': '123',
|
|
210
|
-
// 'myDouble': '1.0',
|
|
211
|
-
// 'myFloat': '1.1',
|
|
212
|
-
// 'myString': 'hi!'
|
|
213
|
-
// }
|
|
214
|
-
//
|
|
215
|
-
// Note that while 'intValue' will have a quoted payload, 'doubleValue' and 'floatValue' will not. This
|
|
216
|
-
// is due to the encoding library, which renders int64 values as strings to avoid loss of precision. This
|
|
217
|
-
// method always returns a string, similarly to avoid loss of precision, unlike the less-conservative
|
|
218
|
-
// 'unwrapValue' method just below.
|
|
219
170
|
/** @hidden */
|
|
220
171
|
function unwrapValueAsString(wrapped) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
172
|
+
if (!wrapped || typeof wrapped !== "object") {
|
|
173
|
+
return "";
|
|
174
|
+
}
|
|
175
|
+
const keys = Object.keys(wrapped);
|
|
176
|
+
if (keys.length === 0) {
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
const key = keys[0];
|
|
180
|
+
const value = wrapped[key];
|
|
181
|
+
if (value === null || value === undefined) {
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
return value.toString();
|
|
234
185
|
}
|
|
235
|
-
// Ditto as the method above, but returning the values in the idiomatic JavaScript type (string for strings,
|
|
236
|
-
// number for numbers):
|
|
237
|
-
// {
|
|
238
|
-
// 'myInt': 123,
|
|
239
|
-
// 'myDouble': 1.0,
|
|
240
|
-
// 'myFloat': 1.1,
|
|
241
|
-
// 'myString': 'hi!'
|
|
242
|
-
// }
|
|
243
|
-
//
|
|
244
|
-
// The field names in the incoming xValue fields identify the type a value has, which for JavaScript's
|
|
245
|
-
// purposes can be divided into 'number' versus 'string'. This method will render all the numbers as
|
|
246
|
-
// JavaScript's 'number' type, since we prefer using idiomatic types. Note that this may lead to loss
|
|
247
|
-
// in precision for int64 fields, so use with care.
|
|
248
186
|
/** @hidden */
|
|
249
|
-
const xValueNumberFields = [
|
|
187
|
+
const xValueNumberFields = [
|
|
188
|
+
"intValue",
|
|
189
|
+
"floatValue",
|
|
190
|
+
"doubleValue"
|
|
191
|
+
];
|
|
250
192
|
/** @hidden */
|
|
251
193
|
function unwrapValue(wrapped) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
194
|
+
const key = Object.keys(wrapped)[0];
|
|
195
|
+
const value = unwrapValueAsString(wrapped);
|
|
196
|
+
return xValueNumberFields.includes(key) ? Number(value) : value;
|
|
255
197
|
}
|
|
256
|
-
// The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
|
|
257
|
-
// The JavaScript convention is to use numbers denoted in milliseconds. This method
|
|
258
|
-
// makes it easy to convert a field of one type into the other.
|
|
259
198
|
/** @hidden */
|
|
260
199
|
function copyTimestampToMillis(from, to, fromName, toName) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
200
|
+
if (from[fromName] !== undefined) {
|
|
201
|
+
to[toName] = Math.round(from[fromName] / 1e3);
|
|
202
|
+
}
|
|
264
203
|
}
|
|
265
|
-
// The JSON payload delivers timestamp fields as strings of timestamps denoted in microseconds.
|
|
266
|
-
// In our SDK, we'd like to present timestamp as ISO-format strings. This method makes it easy
|
|
267
|
-
// to convert a field of one type into the other.
|
|
268
204
|
/** @hidden */
|
|
269
205
|
function copyTimestampToString(from, to, fromName, toName) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
206
|
+
if (from[fromName] !== undefined) {
|
|
207
|
+
to[toName] = new Date(from[fromName] / 1e3).toISOString();
|
|
208
|
+
}
|
|
273
209
|
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
exports.AnalyticsEvent = AnalyticsEvent;
|
|
213
|
+
exports.AnalyticsEventBuilder = AnalyticsEventBuilder;
|
|
214
|
+
exports.ExportBundleInfo = ExportBundleInfo;
|
|
215
|
+
exports.UserDimensions = UserDimensions;
|
|
216
|
+
exports.UserPropertyValue = UserPropertyValue;
|
|
217
|
+
exports._eventWithOptions = _eventWithOptions;
|
|
218
|
+
Object.defineProperty(exports, 'analytics_exports', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return analytics_exports;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
exports.event = event;
|
|
225
|
+
exports.provider = provider;
|
|
226
|
+
exports.service = service;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthEventContext, AuthUserRecord, BeforeCreateResponse, BeforeEmailResponse, BeforeSignInResponse, BeforeSmsResponse, HttpsError, MaybeAsync, UserInfo, UserRecord, userRecordConstructor, UserRecordMetadata } from "../../common/providers/identity";
|
|
2
2
|
import { BlockingFunction, CloudFunction, EventContext } from "../cloud-functions";
|
|
3
|
-
export {
|
|
3
|
+
export { UserRecordMetadata, userRecordConstructor };
|
|
4
|
+
export type { UserRecord, UserInfo };
|
|
4
5
|
export { HttpsError };
|
|
5
6
|
/**
|
|
6
7
|
* Options for Auth blocking function.
|