@google-analytics/data 7.0.0 → 7.2.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.
@@ -493,6 +493,50 @@ export declare class AlphaAnalyticsDataClient {
493
493
  ]>;
494
494
  getReportTask(request: protos.google.analytics.data.v1alpha.IGetReportTaskRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1alpha.IReportTask, protos.google.analytics.data.v1alpha.IGetReportTaskRequest | null | undefined, {} | null | undefined>): void;
495
495
  getReportTask(request: protos.google.analytics.data.v1alpha.IGetReportTaskRequest, callback: Callback<protos.google.analytics.data.v1alpha.IReportTask, protos.google.analytics.data.v1alpha.IGetReportTaskRequest | null | undefined, {} | null | undefined>): void;
496
+ /**
497
+ * Provides a chat interface for interacting with Google Analytics data
498
+ * through the API.
499
+ *
500
+ * This product uses AI and may display inaccurate info. Your chat activity
501
+ * may be used to improve the product and your use is subject to Google's
502
+ * [Terms](https://policies.google.com/terms),
503
+ * [AI Use
504
+ * Policy](https://policies.google.com/terms/generative-ai/use-policy), and
505
+ * [Privacy Policy](https://policies.google.com/privacy).
506
+ * [Learn more about Chat AI
507
+ * Privacy](https://support.google.com/helpguide/answer/14185196).
508
+ *
509
+ * @param {Object} request
510
+ * The request object that will be sent.
511
+ * @param {string} request.property
512
+ * Required. The property to chat about.
513
+ * Format: properties/{property}
514
+ * @param {string} request.userQuery
515
+ * Required. The user's query.
516
+ * @param {string} [request.sessionId]
517
+ * Optional. Provide this session ID to continue an existing conversation
518
+ * and maintain context. If this field is empty or unset, a new chat
519
+ * session is created. Invalid session IDs will result in an error.
520
+ * @param {boolean} [request.returnPropertyQuota]
521
+ * Optional. If true, the response will include the current state of this
522
+ * Analytics Property's quota. Quota is returned in
523
+ * [PropertyChatQuota](#PropertyChatQuota).
524
+ * @param {object} [options]
525
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
526
+ * @returns {Promise} - The promise which resolves to an array.
527
+ * The first element of the array is an object representing {@link protos.google.analytics.data.v1alpha.ChatResponse|ChatResponse}.
528
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
529
+ * for more details and examples.
530
+ * @example <caption>include:samples/generated/v1alpha/alpha_analytics_data.chat.js</caption>
531
+ * region_tag:analyticsdata_v1alpha_generated_AlphaAnalyticsData_Chat_async
532
+ */
533
+ chat(request?: protos.google.analytics.data.v1alpha.IChatRequest, options?: CallOptions): Promise<[
534
+ protos.google.analytics.data.v1alpha.IChatResponse,
535
+ protos.google.analytics.data.v1alpha.IChatRequest | undefined,
536
+ {} | undefined
537
+ ]>;
538
+ chat(request: protos.google.analytics.data.v1alpha.IChatRequest, options: CallOptions, callback: Callback<protos.google.analytics.data.v1alpha.IChatResponse, protos.google.analytics.data.v1alpha.IChatRequest | null | undefined, {} | null | undefined>): void;
539
+ chat(request: protos.google.analytics.data.v1alpha.IChatRequest, callback: Callback<protos.google.analytics.data.v1alpha.IChatResponse, protos.google.analytics.data.v1alpha.IChatRequest | null | undefined, {} | null | undefined>): void;
496
540
  /**
497
541
  * Returns a customized report of your Google Analytics event data. Reports
498
542
  * contain statistics derived from data collected by the Google Analytics
@@ -253,11 +253,12 @@ class AlphaAnalyticsDataClient {
253
253
  'queryReportTask',
254
254
  'getReportTask',
255
255
  'listReportTasks',
256
+ 'chat',
256
257
  'runReport',
257
258
  'getMetadata',
258
259
  ];
259
260
  for (const methodName of alphaAnalyticsDataStubMethods) {
260
- const callPromise = this.alphaAnalyticsDataStub.then((stub) => (...args) => {
261
+ const callPromise = this.alphaAnalyticsDataStub.then(stub => (...args) => {
261
262
  if (this._terminated) {
262
263
  return Promise.reject('The client has already been closed.');
263
264
  }
@@ -323,6 +324,7 @@ class AlphaAnalyticsDataClient {
323
324
  static get scopes() {
324
325
  return [
325
326
  'https://www.googleapis.com/auth/analytics',
327
+ 'https://www.googleapis.com/auth/analytics.chatbot.read',
326
328
  'https://www.googleapis.com/auth/analytics.readonly',
327
329
  ];
328
330
  }
@@ -354,7 +356,7 @@ class AlphaAnalyticsDataClient {
354
356
  this._gaxModule.routingHeader.fromParams({
355
357
  property: request.property ?? '',
356
358
  });
357
- this.initialize().catch((err) => {
359
+ this.initialize().catch(err => {
358
360
  throw err;
359
361
  });
360
362
  this._log.info('runFunnelReport request %j', request);
@@ -397,7 +399,7 @@ class AlphaAnalyticsDataClient {
397
399
  this._gaxModule.routingHeader.fromParams({
398
400
  name: request.name ?? '',
399
401
  });
400
- this.initialize().catch((err) => {
402
+ this.initialize().catch(err => {
401
403
  throw err;
402
404
  });
403
405
  this._log.info('queryAudienceList request %j', request);
@@ -440,7 +442,7 @@ class AlphaAnalyticsDataClient {
440
442
  this._gaxModule.routingHeader.fromParams({
441
443
  name: request.name ?? '',
442
444
  });
443
- this.initialize().catch((err) => {
445
+ this.initialize().catch(err => {
444
446
  throw err;
445
447
  });
446
448
  this._log.info('getAudienceList request %j', request);
@@ -483,7 +485,7 @@ class AlphaAnalyticsDataClient {
483
485
  this._gaxModule.routingHeader.fromParams({
484
486
  parent: request.parent ?? '',
485
487
  });
486
- this.initialize().catch((err) => {
488
+ this.initialize().catch(err => {
487
489
  throw err;
488
490
  });
489
491
  this._log.info('createRecurringAudienceList request %j', request);
@@ -526,7 +528,7 @@ class AlphaAnalyticsDataClient {
526
528
  this._gaxModule.routingHeader.fromParams({
527
529
  name: request.name ?? '',
528
530
  });
529
- this.initialize().catch((err) => {
531
+ this.initialize().catch(err => {
530
532
  throw err;
531
533
  });
532
534
  this._log.info('getRecurringAudienceList request %j', request);
@@ -569,7 +571,7 @@ class AlphaAnalyticsDataClient {
569
571
  this._gaxModule.routingHeader.fromParams({
570
572
  name: request.name ?? '',
571
573
  });
572
- this.initialize().catch((err) => {
574
+ this.initialize().catch(err => {
573
575
  throw err;
574
576
  });
575
577
  this._log.info('getPropertyQuotasSnapshot request %j', request);
@@ -612,7 +614,7 @@ class AlphaAnalyticsDataClient {
612
614
  this._gaxModule.routingHeader.fromParams({
613
615
  name: request.name ?? '',
614
616
  });
615
- this.initialize().catch((err) => {
617
+ this.initialize().catch(err => {
616
618
  throw err;
617
619
  });
618
620
  this._log.info('queryReportTask request %j', request);
@@ -655,7 +657,7 @@ class AlphaAnalyticsDataClient {
655
657
  this._gaxModule.routingHeader.fromParams({
656
658
  name: request.name ?? '',
657
659
  });
658
- this.initialize().catch((err) => {
660
+ this.initialize().catch(err => {
659
661
  throw err;
660
662
  });
661
663
  this._log.info('getReportTask request %j', request);
@@ -681,6 +683,49 @@ class AlphaAnalyticsDataClient {
681
683
  throw error;
682
684
  });
683
685
  }
686
+ chat(request, optionsOrCallback, callback) {
687
+ request = request || {};
688
+ let options;
689
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
690
+ callback = optionsOrCallback;
691
+ options = {};
692
+ }
693
+ else {
694
+ options = optionsOrCallback;
695
+ }
696
+ options = options || {};
697
+ options.otherArgs = options.otherArgs || {};
698
+ options.otherArgs.headers = options.otherArgs.headers || {};
699
+ options.otherArgs.headers['x-goog-request-params'] =
700
+ this._gaxModule.routingHeader.fromParams({
701
+ property: request.property ?? '',
702
+ });
703
+ this.initialize().catch(err => {
704
+ throw err;
705
+ });
706
+ this._log.info('chat request %j', request);
707
+ const wrappedCallback = callback
708
+ ? (error, response, options, rawResponse) => {
709
+ this._log.info('chat response %j', response);
710
+ callback(error, response, options, rawResponse); // We verified callback above.
711
+ }
712
+ : undefined;
713
+ return this.innerApiCalls
714
+ .chat(request, options, wrappedCallback)
715
+ ?.then(([response, options, rawResponse]) => {
716
+ this._log.info('chat response %j', response);
717
+ return [response, options, rawResponse];
718
+ })
719
+ .catch((error) => {
720
+ if (error &&
721
+ 'statusDetails' in error &&
722
+ error.statusDetails instanceof Array) {
723
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
724
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
725
+ }
726
+ throw error;
727
+ });
728
+ }
684
729
  runReport(request, optionsOrCallback, callback) {
685
730
  request = request || {};
686
731
  let options;
@@ -698,7 +743,7 @@ class AlphaAnalyticsDataClient {
698
743
  this._gaxModule.routingHeader.fromParams({
699
744
  property: request.property ?? '',
700
745
  });
701
- this.initialize().catch((err) => {
746
+ this.initialize().catch(err => {
702
747
  throw err;
703
748
  });
704
749
  this._log.info('runReport request %j', request);
@@ -741,7 +786,7 @@ class AlphaAnalyticsDataClient {
741
786
  this._gaxModule.routingHeader.fromParams({
742
787
  name: request.name ?? '',
743
788
  });
744
- this.initialize().catch((err) => {
789
+ this.initialize().catch(err => {
745
790
  throw err;
746
791
  });
747
792
  this._log.info('getMetadata request %j', request);
@@ -784,7 +829,7 @@ class AlphaAnalyticsDataClient {
784
829
  this._gaxModule.routingHeader.fromParams({
785
830
  parent: request.parent ?? '',
786
831
  });
787
- this.initialize().catch((err) => {
832
+ this.initialize().catch(err => {
788
833
  throw err;
789
834
  });
790
835
  const wrappedCallback = callback
@@ -836,7 +881,7 @@ class AlphaAnalyticsDataClient {
836
881
  this._gaxModule.routingHeader.fromParams({
837
882
  parent: request.parent ?? '',
838
883
  });
839
- this.initialize().catch((err) => {
884
+ this.initialize().catch(err => {
840
885
  throw err;
841
886
  });
842
887
  const wrappedCallback = callback
@@ -888,7 +933,7 @@ class AlphaAnalyticsDataClient {
888
933
  this._gaxModule.routingHeader.fromParams({
889
934
  parent: request.parent ?? '',
890
935
  });
891
- this.initialize().catch((err) => {
936
+ this.initialize().catch(err => {
892
937
  throw err;
893
938
  });
894
939
  const wrappedCallback = callback
@@ -945,7 +990,7 @@ class AlphaAnalyticsDataClient {
945
990
  });
946
991
  const defaultCallSettings = this._defaults['listAudienceLists'];
947
992
  const callSettings = defaultCallSettings.merge(options);
948
- this.initialize().catch((err) => {
993
+ this.initialize().catch(err => {
949
994
  throw err;
950
995
  });
951
996
  this._log.info('listAudienceLists stream %j', request);
@@ -994,7 +1039,7 @@ class AlphaAnalyticsDataClient {
994
1039
  });
995
1040
  const defaultCallSettings = this._defaults['listAudienceLists'];
996
1041
  const callSettings = defaultCallSettings.merge(options);
997
- this.initialize().catch((err) => {
1042
+ this.initialize().catch(err => {
998
1043
  throw err;
999
1044
  });
1000
1045
  this._log.info('listAudienceLists iterate %j', request);
@@ -1017,7 +1062,7 @@ class AlphaAnalyticsDataClient {
1017
1062
  this._gaxModule.routingHeader.fromParams({
1018
1063
  parent: request.parent ?? '',
1019
1064
  });
1020
- this.initialize().catch((err) => {
1065
+ this.initialize().catch(err => {
1021
1066
  throw err;
1022
1067
  });
1023
1068
  const wrappedCallback = callback
@@ -1076,7 +1121,7 @@ class AlphaAnalyticsDataClient {
1076
1121
  });
1077
1122
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
1078
1123
  const callSettings = defaultCallSettings.merge(options);
1079
- this.initialize().catch((err) => {
1124
+ this.initialize().catch(err => {
1080
1125
  throw err;
1081
1126
  });
1082
1127
  this._log.info('listRecurringAudienceLists stream %j', request);
@@ -1127,7 +1172,7 @@ class AlphaAnalyticsDataClient {
1127
1172
  });
1128
1173
  const defaultCallSettings = this._defaults['listRecurringAudienceLists'];
1129
1174
  const callSettings = defaultCallSettings.merge(options);
1130
- this.initialize().catch((err) => {
1175
+ this.initialize().catch(err => {
1131
1176
  throw err;
1132
1177
  });
1133
1178
  this._log.info('listRecurringAudienceLists iterate %j', request);
@@ -1150,7 +1195,7 @@ class AlphaAnalyticsDataClient {
1150
1195
  this._gaxModule.routingHeader.fromParams({
1151
1196
  parent: request.parent ?? '',
1152
1197
  });
1153
- this.initialize().catch((err) => {
1198
+ this.initialize().catch(err => {
1154
1199
  throw err;
1155
1200
  });
1156
1201
  const wrappedCallback = callback
@@ -1201,7 +1246,7 @@ class AlphaAnalyticsDataClient {
1201
1246
  });
1202
1247
  const defaultCallSettings = this._defaults['listReportTasks'];
1203
1248
  const callSettings = defaultCallSettings.merge(options);
1204
- this.initialize().catch((err) => {
1249
+ this.initialize().catch(err => {
1205
1250
  throw err;
1206
1251
  });
1207
1252
  this._log.info('listReportTasks stream %j', request);
@@ -1244,7 +1289,7 @@ class AlphaAnalyticsDataClient {
1244
1289
  });
1245
1290
  const defaultCallSettings = this._defaults['listReportTasks'];
1246
1291
  const callSettings = defaultCallSettings.merge(options);
1247
- this.initialize().catch((err) => {
1292
+ this.initialize().catch(err => {
1248
1293
  throw err;
1249
1294
  });
1250
1295
  this._log.info('listReportTasks iterate %j', request);
@@ -1607,7 +1652,7 @@ class AlphaAnalyticsDataClient {
1607
1652
  */
1608
1653
  close() {
1609
1654
  if (this.alphaAnalyticsDataStub && !this._terminated) {
1610
- return this.alphaAnalyticsDataStub.then((stub) => {
1655
+ return this.alphaAnalyticsDataStub.then(stub => {
1611
1656
  this._log.info('ending gRPC channel');
1612
1657
  this._terminated = true;
1613
1658
  stub.close();
@@ -97,6 +97,11 @@
97
97
  "retry_codes_name": "unknown",
98
98
  "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c"
99
99
  },
100
+ "Chat": {
101
+ "timeout_millis": 60000,
102
+ "retry_codes_name": "unknown",
103
+ "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c"
104
+ },
100
105
  "RunReport": {
101
106
  "timeout_millis": 60000,
102
107
  "retry_codes_name": "unknown",
@@ -50,6 +50,11 @@
50
50
  "getReportTask"
51
51
  ]
52
52
  },
53
+ "Chat": {
54
+ "methods": [
55
+ "chat"
56
+ ]
57
+ },
53
58
  "RunReport": {
54
59
  "methods": [
55
60
  "runReport"
@@ -136,6 +141,11 @@
136
141
  "getReportTask"
137
142
  ]
138
143
  },
144
+ "Chat": {
145
+ "methods": [
146
+ "chat"
147
+ ]
148
+ },
139
149
  "RunReport": {
140
150
  "methods": [
141
151
  "runReport"
@@ -244,7 +244,7 @@ class BetaAnalyticsDataClient {
244
244
  'listAudienceExports',
245
245
  ];
246
246
  for (const methodName of betaAnalyticsDataStubMethods) {
247
- const callPromise = this.betaAnalyticsDataStub.then((stub) => (...args) => {
247
+ const callPromise = this.betaAnalyticsDataStub.then(stub => (...args) => {
248
248
  if (this._terminated) {
249
249
  return Promise.reject('The client has already been closed.');
250
250
  }
@@ -341,7 +341,7 @@ class BetaAnalyticsDataClient {
341
341
  this._gaxModule.routingHeader.fromParams({
342
342
  property: request.property ?? '',
343
343
  });
344
- this.initialize().catch((err) => {
344
+ this.initialize().catch(err => {
345
345
  throw err;
346
346
  });
347
347
  this._log.info('runReport request %j', request);
@@ -384,7 +384,7 @@ class BetaAnalyticsDataClient {
384
384
  this._gaxModule.routingHeader.fromParams({
385
385
  property: request.property ?? '',
386
386
  });
387
- this.initialize().catch((err) => {
387
+ this.initialize().catch(err => {
388
388
  throw err;
389
389
  });
390
390
  this._log.info('runPivotReport request %j', request);
@@ -427,7 +427,7 @@ class BetaAnalyticsDataClient {
427
427
  this._gaxModule.routingHeader.fromParams({
428
428
  property: request.property ?? '',
429
429
  });
430
- this.initialize().catch((err) => {
430
+ this.initialize().catch(err => {
431
431
  throw err;
432
432
  });
433
433
  this._log.info('batchRunReports request %j', request);
@@ -470,7 +470,7 @@ class BetaAnalyticsDataClient {
470
470
  this._gaxModule.routingHeader.fromParams({
471
471
  property: request.property ?? '',
472
472
  });
473
- this.initialize().catch((err) => {
473
+ this.initialize().catch(err => {
474
474
  throw err;
475
475
  });
476
476
  this._log.info('batchRunPivotReports request %j', request);
@@ -513,7 +513,7 @@ class BetaAnalyticsDataClient {
513
513
  this._gaxModule.routingHeader.fromParams({
514
514
  name: request.name ?? '',
515
515
  });
516
- this.initialize().catch((err) => {
516
+ this.initialize().catch(err => {
517
517
  throw err;
518
518
  });
519
519
  this._log.info('getMetadata request %j', request);
@@ -556,7 +556,7 @@ class BetaAnalyticsDataClient {
556
556
  this._gaxModule.routingHeader.fromParams({
557
557
  property: request.property ?? '',
558
558
  });
559
- this.initialize().catch((err) => {
559
+ this.initialize().catch(err => {
560
560
  throw err;
561
561
  });
562
562
  this._log.info('runRealtimeReport request %j', request);
@@ -599,7 +599,7 @@ class BetaAnalyticsDataClient {
599
599
  this._gaxModule.routingHeader.fromParams({
600
600
  property: request.property ?? '',
601
601
  });
602
- this.initialize().catch((err) => {
602
+ this.initialize().catch(err => {
603
603
  throw err;
604
604
  });
605
605
  this._log.info('checkCompatibility request %j', request);
@@ -642,7 +642,7 @@ class BetaAnalyticsDataClient {
642
642
  this._gaxModule.routingHeader.fromParams({
643
643
  name: request.name ?? '',
644
644
  });
645
- this.initialize().catch((err) => {
645
+ this.initialize().catch(err => {
646
646
  throw err;
647
647
  });
648
648
  this._log.info('queryAudienceExport request %j', request);
@@ -685,7 +685,7 @@ class BetaAnalyticsDataClient {
685
685
  this._gaxModule.routingHeader.fromParams({
686
686
  name: request.name ?? '',
687
687
  });
688
- this.initialize().catch((err) => {
688
+ this.initialize().catch(err => {
689
689
  throw err;
690
690
  });
691
691
  this._log.info('getAudienceExport request %j', request);
@@ -728,7 +728,7 @@ class BetaAnalyticsDataClient {
728
728
  this._gaxModule.routingHeader.fromParams({
729
729
  parent: request.parent ?? '',
730
730
  });
731
- this.initialize().catch((err) => {
731
+ this.initialize().catch(err => {
732
732
  throw err;
733
733
  });
734
734
  const wrappedCallback = callback
@@ -780,7 +780,7 @@ class BetaAnalyticsDataClient {
780
780
  this._gaxModule.routingHeader.fromParams({
781
781
  parent: request.parent ?? '',
782
782
  });
783
- this.initialize().catch((err) => {
783
+ this.initialize().catch(err => {
784
784
  throw err;
785
785
  });
786
786
  const wrappedCallback = callback
@@ -837,7 +837,7 @@ class BetaAnalyticsDataClient {
837
837
  });
838
838
  const defaultCallSettings = this._defaults['listAudienceExports'];
839
839
  const callSettings = defaultCallSettings.merge(options);
840
- this.initialize().catch((err) => {
840
+ this.initialize().catch(err => {
841
841
  throw err;
842
842
  });
843
843
  this._log.info('listAudienceExports stream %j', request);
@@ -886,7 +886,7 @@ class BetaAnalyticsDataClient {
886
886
  });
887
887
  const defaultCallSettings = this._defaults['listAudienceExports'];
888
888
  const callSettings = defaultCallSettings.merge(options);
889
- this.initialize().catch((err) => {
889
+ this.initialize().catch(err => {
890
890
  throw err;
891
891
  });
892
892
  this._log.info('listAudienceExports iterate %j', request);
@@ -1158,7 +1158,7 @@ class BetaAnalyticsDataClient {
1158
1158
  */
1159
1159
  close() {
1160
1160
  if (this.betaAnalyticsDataStub && !this._terminated) {
1161
- return this.betaAnalyticsDataStub.then((stub) => {
1161
+ return this.betaAnalyticsDataStub.then(stub => {
1162
1162
  this._log.info('ending gRPC channel');
1163
1163
  this._terminated = true;
1164
1164
  stub.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google-analytics/data",
3
- "version": "7.0.0",
3
+ "version": "7.2.0",
4
4
  "description": "Data client for Node.js",
5
5
  "repository": {
6
6
  "type": "git",